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
patrick-nicholson/spark
python/pyspark/statcounter.py
130
5115
# # 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. # # This file is ported from spark/util/StatCounter.scala import copy import math try: from numpy import maximum, minimum, sqrt except ImportError: maximum = max minimum = min sqrt = math.sqrt class StatCounter(object): def __init__(self, values=None): if values is None: values = list() self.n = 0 # Running count of our values self.mu = 0.0 # Running mean of our values self.m2 = 0.0 # Running variance numerator (sum of (x - mean)^2) self.maxValue = float("-inf") self.minValue = float("inf") for v in values: self.merge(v) # Add a value into this StatCounter, updating the internal statistics. def merge(self, value): delta = value - self.mu self.n += 1 self.mu += delta / self.n self.m2 += delta * (value - self.mu) self.maxValue = maximum(self.maxValue, value) self.minValue = minimum(self.minValue, value) return self # Merge another StatCounter into this one, adding up the internal statistics. def mergeStats(self, other): if not isinstance(other, StatCounter): raise Exception("Can only merge Statcounters!") if other is self: # reference equality holds self.merge(copy.deepcopy(other)) # Avoid overwriting fields in a weird order else: if self.n == 0: self.mu = other.mu self.m2 = other.m2 self.n = other.n self.maxValue = other.maxValue self.minValue = other.minValue elif other.n != 0: delta = other.mu - self.mu if other.n * 10 < self.n: self.mu = self.mu + (delta * other.n) / (self.n + other.n) elif self.n * 10 < other.n: self.mu = other.mu - (delta * self.n) / (self.n + other.n) else: self.mu = (self.mu * self.n + other.mu * other.n) / (self.n + other.n) self.maxValue = maximum(self.maxValue, other.maxValue) self.minValue = minimum(self.minValue, other.minValue) self.m2 += other.m2 + (delta * delta * self.n * other.n) / (self.n + other.n) self.n += other.n return self # Clone this StatCounter def copy(self): return copy.deepcopy(self) def count(self): return int(self.n) def mean(self): return self.mu def sum(self): return self.n * self.mu def min(self): return self.minValue def max(self): return self.maxValue # Return the variance of the values. def variance(self): if self.n == 0: return float('nan') else: return self.m2 / self.n # # Return the sample variance, which corrects for bias in estimating the variance by dividing # by N-1 instead of N. # def sampleVariance(self): if self.n <= 1: return float('nan') else: return self.m2 / (self.n - 1) # Return the standard deviation of the values. def stdev(self): return sqrt(self.variance()) # # Return the sample standard deviation of the values, which corrects for bias in estimating the # variance by dividing by N-1 instead of N. # def sampleStdev(self): return sqrt(self.sampleVariance()) def asDict(self, sample=False): """Returns the :class:`StatCounter` members as a ``dict``. >>> sc.parallelize([1., 2., 3., 4.]).stats().asDict() {'count': 4L, 'max': 4.0, 'mean': 2.5, 'min': 1.0, 'stdev': 1.2909944487358056, 'sum': 10.0, 'variance': 1.6666666666666667} """ return { 'count': self.count(), 'mean': self.mean(), 'sum': self.sum(), 'min': self.min(), 'max': self.max(), 'stdev': self.stdev() if sample else self.sampleStdev(), 'variance': self.variance() if sample else self.sampleVariance() } def __repr__(self): return ("(count: %s, mean: %s, stdev: %s, max: %s, min: %s)" % (self.count(), self.mean(), self.stdev(), self.max(), self.min()))
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 961, 570, 365, 299, 1376, 687, 15442, 15, 1974, 15, 11232, 11348, 14, 28708, 199, 199, 646, 1331, 199, 646, 3473, 199, 199, 893, 26, 272, 687, 2680, 492, 5696, 12, 7481, 12, 7452, 199, 2590, 3545, 26, 272, 5696, 275, 1390, 272, 7481, 275, 1748, 272, 7452, 275, 3473, 14, 5079, 421, 199, 533, 27673, 11348, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1338, 29, 403, 304, 267, 340, 1338, 365, 488, 26, 288, 1338, 275, 769, 342, 267, 291, 14, 78, 275, 378, 259, 327, 26848, 2338, 402, 4154, 1338, 267, 291, 14, 6553, 275, 378, 14, 16, 221, 327, 26848, 4615, 402, 4154, 1338, 267, 291, 14, 77, 18, 275, 378, 14, 16, 221, 327, 26848, 11773, 27640, 334, 1838, 402, 334, 88, 446, 4615, 18979, 18, 9, 267, 291, 14, 988, 1110, 275, 2069, 6096, 4904, 531, 267, 291, 14, 827, 1110, 275, 2069, 480, 4904, 531, 398, 367, 373, 315, 1338, 26, 288, 291, 14, 5628, 8, 86, 9, 339, 327, 2654, 282, 574, 1901, 642, 27673, 11348, 12, 12928, 314, 5007, 11076, 14, 272, 347, 5389, 8, 277, 12, 574, 304, 267, 5762, 275, 574, 446, 291, 14, 6553, 267, 291, 14, 78, 847, 413, 267, 291, 14, 6553, 847, 5762, 1182, 291, 14, 78, 267, 291, 14, 77, 18, 847, 5762, 627, 334, 585, 446, 291, 14, 6553, 9, 267, 291, 14, 988, 1110, 275, 5696, 8, 277, 14, 988, 1110, 12, 574, 9, 267, 291, 14, 827, 1110, 275, 7481, 8, 277, 14, 827, 1110, 12, 574, 9, 398, 372, 291, 339, 327, 14076, 4573, 27673, 11348, 1901, 642, 1373, 12, 7791, 1536, 314, 5007, 11076, 14, 272, 347, 5389, 8257, 8, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 27673, 11348, 304, 288, 746, 2186, 480, 6049, 1454, 5389, 27673, 16558, 9124, 398, 340, 1163, 365, 291, 26, 221, 327, 3659, 16612, 15164, 288, 291, 14, 5628, 8, 1574, 14, 8293, 8, 1848, 430, 221, 327, 19503, 32592, 1504, 315, 282, 22965, 1865, 267, 587, 26, 288, 340, 291, 14, 78, 508, 378, 26, 355, 291, 14, 6553, 275, 1163, 14, 6553, 355, 291, 14, 77, 18, 275, 1163, 14, 77, 18, 355, 291, 14, 78, 275, 1163, 14, 78, 355, 291, 14, 988, 1110, 275, 1163, 14, 988, 1110, 355, 291, 14, 827, 1110, 275, 1163, 14, 827, 1110, 953, 916, 1163, 14, 78, 1137, 378, 26, 355, 5762, 275, 1163, 14, 6553, 446, 291, 14, 6553, 355, 340, 1163, 14, 78, 627, 1616, 665, 291, 14, 78, 26, 490, 291, 14, 6553, 275, 291, 14, 6553, 435, 334, 3136, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 916, 291, 14, 78, 627, 1616, 665, 1163, 14, 78, 26, 490, 291, 14, 6553, 275, 1163, 14, 6553, 446, 334, 3136, 627, 291, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 587, 26, 490, 291, 14, 6553, 275, 334, 277, 14, 6553, 627, 291, 14, 78, 435, 1163, 14, 6553, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 2234, 291, 14, 988, 1110, 275, 5696, 8, 277, 14, 988, 1110, 12, 1163, 14, 988, 1110, 9, 355, 291, 14, 827, 1110, 275, 7481, 8, 277, 14, 827, 1110, 12, 1163, 14, 827, 1110, 9, 2234, 291, 14, 77, 18, 847, 1163, 14, 77, 18, 435, 334, 3136, 627, 5762, 627, 291, 14, 78, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 291, 14, 78, 847, 1163, 14, 78, 267, 372, 291, 339, 327, 8465, 368, 642, 27673, 11348, 272, 347, 1331, 8, 277, 304, 267, 372, 1331, 14, 8293, 8, 277, 9, 339, 347, 2338, 8, 277, 304, 267, 372, 1109, 8, 277, 14, 78, 9, 339, 347, 4615, 8, 277, 304, 267, 372, 291, 14, 6553, 339, 347, 3089, 8, 277, 304, 267, 372, 291, 14, 78, 627, 291, 14, 6553, 339, 347, 1748, 8, 277, 304, 267, 372, 291, 14, 827, 1110, 339, 347, 1390, 8, 277, 304, 267, 372, 291, 14, 988, 1110, 339, 327, 1432, 314, 11773, 402, 314, 1338, 14, 272, 347, 11773, 8, 277, 304, 267, 340, 291, 14, 78, 508, 378, 26, 288, 372, 2069, 360, 4304, 358, 267, 587, 26, 288, 372, 291, 14, 77, 18, 1182, 291, 14, 78, 339, 327, 272, 327, 1432, 314, 2690, 11773, 12, 1314, 3211, 83, 367, 10671, 315, 4347, 3969, 316, 314, 11773, 701, 487, 11604, 272, 327, 701, 653, 13, 17, 3140, 402, 653, 14, 272, 327, 272, 347, 2690, 31805, 8, 277, 304, 267, 340, 291, 14, 78, 2695, 413, 26, 288, 372, 2069, 360, 4304, 358, 267, 587, 26, 288, 372, 291, 14, 77, 18, 1182, 334, 277, 14, 78, 446, 413, 9, 339, 327, 1432, 314, 4465, 18458, 402, 314, 1338, 14, 272, 347, 410, 2374, 8, 277, 304, 267, 372, 7452, 8, 277, 14, 6221, 1012, 339, 327, 272, 327, 1432, 314, 2690, 4465, 18458, 402, 314, 1338, 12 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 961, 570, 365, 299, 1376, 687, 15442, 15, 1974, 15, 11232, 11348, 14, 28708, 199, 199, 646, 1331, 199, 646, 3473, 199, 199, 893, 26, 272, 687, 2680, 492, 5696, 12, 7481, 12, 7452, 199, 2590, 3545, 26, 272, 5696, 275, 1390, 272, 7481, 275, 1748, 272, 7452, 275, 3473, 14, 5079, 421, 199, 533, 27673, 11348, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1338, 29, 403, 304, 267, 340, 1338, 365, 488, 26, 288, 1338, 275, 769, 342, 267, 291, 14, 78, 275, 378, 259, 327, 26848, 2338, 402, 4154, 1338, 267, 291, 14, 6553, 275, 378, 14, 16, 221, 327, 26848, 4615, 402, 4154, 1338, 267, 291, 14, 77, 18, 275, 378, 14, 16, 221, 327, 26848, 11773, 27640, 334, 1838, 402, 334, 88, 446, 4615, 18979, 18, 9, 267, 291, 14, 988, 1110, 275, 2069, 6096, 4904, 531, 267, 291, 14, 827, 1110, 275, 2069, 480, 4904, 531, 398, 367, 373, 315, 1338, 26, 288, 291, 14, 5628, 8, 86, 9, 339, 327, 2654, 282, 574, 1901, 642, 27673, 11348, 12, 12928, 314, 5007, 11076, 14, 272, 347, 5389, 8, 277, 12, 574, 304, 267, 5762, 275, 574, 446, 291, 14, 6553, 267, 291, 14, 78, 847, 413, 267, 291, 14, 6553, 847, 5762, 1182, 291, 14, 78, 267, 291, 14, 77, 18, 847, 5762, 627, 334, 585, 446, 291, 14, 6553, 9, 267, 291, 14, 988, 1110, 275, 5696, 8, 277, 14, 988, 1110, 12, 574, 9, 267, 291, 14, 827, 1110, 275, 7481, 8, 277, 14, 827, 1110, 12, 574, 9, 398, 372, 291, 339, 327, 14076, 4573, 27673, 11348, 1901, 642, 1373, 12, 7791, 1536, 314, 5007, 11076, 14, 272, 347, 5389, 8257, 8, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 27673, 11348, 304, 288, 746, 2186, 480, 6049, 1454, 5389, 27673, 16558, 9124, 398, 340, 1163, 365, 291, 26, 221, 327, 3659, 16612, 15164, 288, 291, 14, 5628, 8, 1574, 14, 8293, 8, 1848, 430, 221, 327, 19503, 32592, 1504, 315, 282, 22965, 1865, 267, 587, 26, 288, 340, 291, 14, 78, 508, 378, 26, 355, 291, 14, 6553, 275, 1163, 14, 6553, 355, 291, 14, 77, 18, 275, 1163, 14, 77, 18, 355, 291, 14, 78, 275, 1163, 14, 78, 355, 291, 14, 988, 1110, 275, 1163, 14, 988, 1110, 355, 291, 14, 827, 1110, 275, 1163, 14, 827, 1110, 953, 916, 1163, 14, 78, 1137, 378, 26, 355, 5762, 275, 1163, 14, 6553, 446, 291, 14, 6553, 355, 340, 1163, 14, 78, 627, 1616, 665, 291, 14, 78, 26, 490, 291, 14, 6553, 275, 291, 14, 6553, 435, 334, 3136, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 916, 291, 14, 78, 627, 1616, 665, 1163, 14, 78, 26, 490, 291, 14, 6553, 275, 1163, 14, 6553, 446, 334, 3136, 627, 291, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 587, 26, 490, 291, 14, 6553, 275, 334, 277, 14, 6553, 627, 291, 14, 78, 435, 1163, 14, 6553, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 2234, 291, 14, 988, 1110, 275, 5696, 8, 277, 14, 988, 1110, 12, 1163, 14, 988, 1110, 9, 355, 291, 14, 827, 1110, 275, 7481, 8, 277, 14, 827, 1110, 12, 1163, 14, 827, 1110, 9, 2234, 291, 14, 77, 18, 847, 1163, 14, 77, 18, 435, 334, 3136, 627, 5762, 627, 291, 14, 78, 627, 1163, 14, 78, 9, 1182, 334, 277, 14, 78, 435, 1163, 14, 78, 9, 355, 291, 14, 78, 847, 1163, 14, 78, 267, 372, 291, 339, 327, 8465, 368, 642, 27673, 11348, 272, 347, 1331, 8, 277, 304, 267, 372, 1331, 14, 8293, 8, 277, 9, 339, 347, 2338, 8, 277, 304, 267, 372, 1109, 8, 277, 14, 78, 9, 339, 347, 4615, 8, 277, 304, 267, 372, 291, 14, 6553, 339, 347, 3089, 8, 277, 304, 267, 372, 291, 14, 78, 627, 291, 14, 6553, 339, 347, 1748, 8, 277, 304, 267, 372, 291, 14, 827, 1110, 339, 347, 1390, 8, 277, 304, 267, 372, 291, 14, 988, 1110, 339, 327, 1432, 314, 11773, 402, 314, 1338, 14, 272, 347, 11773, 8, 277, 304, 267, 340, 291, 14, 78, 508, 378, 26, 288, 372, 2069, 360, 4304, 358, 267, 587, 26, 288, 372, 291, 14, 77, 18, 1182, 291, 14, 78, 339, 327, 272, 327, 1432, 314, 2690, 11773, 12, 1314, 3211, 83, 367, 10671, 315, 4347, 3969, 316, 314, 11773, 701, 487, 11604, 272, 327, 701, 653, 13, 17, 3140, 402, 653, 14, 272, 327, 272, 347, 2690, 31805, 8, 277, 304, 267, 340, 291, 14, 78, 2695, 413, 26, 288, 372, 2069, 360, 4304, 358, 267, 587, 26, 288, 372, 291, 14, 77, 18, 1182, 334, 277, 14, 78, 446, 413, 9, 339, 327, 1432, 314, 4465, 18458, 402, 314, 1338, 14, 272, 347, 410, 2374, 8, 277, 304, 267, 372, 7452, 8, 277, 14, 6221, 1012, 339, 327, 272, 327, 1432, 314, 2690, 4465, 18458, 402, 314, 1338, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
suiyuan2009/tensorflow
tensorflow/python/kernel_tests/conv1d_test.py
97
2169
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for convolution related functionality in tensorflow.ops.nn.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops from tensorflow.python.ops import nn_ops from tensorflow.python.platform import test class Conv1DTest(test.TestCase): def testBasic(self): """Test that argument passing to conv2d is handled properly.""" x = constant_op.constant([1, 2, 3, 4], dtype=dtypes.float32) x = array_ops.expand_dims(x, 0) # Add batch dimension x = array_ops.expand_dims(x, 2) # And depth dimension filters = constant_op.constant([2, 1], dtype=dtypes.float32) filters = array_ops.expand_dims(filters, 1) # in_channels filters = array_ops.expand_dims(filters, 2) # out_channels # Filters is 2x1x1 for stride in [1, 2]: with self.test_session(): c = nn_ops.conv1d(x, filters, stride, padding="VALID") reduced = array_ops.squeeze(c) output = reduced.eval() if stride == 1: self.assertEqual(len(output), 3) self.assertAllClose(output, [2 * 1 + 1 * 2, 2 * 2 + 1 * 3, 2 * 3 + 1 * 4]) else: self.assertEqual(len(output), 2) self.assertAllClose(output, [2 * 1 + 1 * 2, 2 * 3 + 1 * 4]) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 17461, 4048, 9330, 315, 3228, 14, 1483, 14, 4411, 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, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 19140, 17, 36, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 6845, 8, 277, 304, 272, 408, 774, 626, 1423, 9476, 370, 8260, 18, 68, 365, 8860, 7684, 1041, 339, 671, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 12, 650, 12, 841, 467, 2152, 29, 5717, 14, 1609, 708, 9, 272, 671, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 88, 12, 378, 9, 221, 327, 2654, 3522, 6240, 272, 671, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 88, 12, 499, 9, 221, 327, 6061, 5818, 6240, 272, 4766, 275, 4413, 63, 411, 14, 4083, 779, 18, 12, 413, 467, 2152, 29, 5717, 14, 1609, 708, 9, 272, 4766, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 4273, 12, 413, 9, 221, 327, 315, 63, 6324, 272, 4766, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 4273, 12, 499, 9, 221, 327, 734, 63, 6324, 272, 327, 21240, 365, 499, 88, 17, 88, 17, 272, 367, 7345, 315, 359, 17, 12, 499, 2189, 489, 543, 291, 14, 396, 63, 1730, 837, 267, 286, 275, 11542, 63, 1483, 14, 5598, 17, 68, 8, 88, 12, 4766, 12, 7345, 12, 6273, 628, 5600, 531, 267, 14953, 275, 1625, 63, 1483, 14, 16597, 8, 67, 9, 267, 1072, 275, 14953, 14, 2579, 342, 267, 340, 7345, 508, 413, 26, 881, 291, 14, 629, 8, 552, 8, 1199, 395, 650, 9, 881, 291, 14, 7260, 8, 1199, 12, 2892, 359, 18, 627, 413, 435, 413, 627, 499, 12, 499, 627, 499, 435, 413, 627, 650, 12, 499, 627, 650, 435, 413, 627, 841, 566, 267, 587, 26, 881, 291, 14, 629, 8, 552, 8, 1199, 395, 499, 9, 881, 291, 14, 7260, 8, 1199, 12, 359, 18, 627, 413, 435, 413, 627, 499, 12, 499, 627, 650, 435, 413, 627, 841, 566, 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 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 17461, 4048, 9330, 315, 3228, 14, 1483, 14, 4411, 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, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 19140, 17, 36, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 6845, 8, 277, 304, 272, 408, 774, 626, 1423, 9476, 370, 8260, 18, 68, 365, 8860, 7684, 1041, 339, 671, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 12, 650, 12, 841, 467, 2152, 29, 5717, 14, 1609, 708, 9, 272, 671, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 88, 12, 378, 9, 221, 327, 2654, 3522, 6240, 272, 671, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 88, 12, 499, 9, 221, 327, 6061, 5818, 6240, 272, 4766, 275, 4413, 63, 411, 14, 4083, 779, 18, 12, 413, 467, 2152, 29, 5717, 14, 1609, 708, 9, 272, 4766, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 4273, 12, 413, 9, 221, 327, 315, 63, 6324, 272, 4766, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 4273, 12, 499, 9, 221, 327, 734, 63, 6324, 272, 327, 21240, 365, 499, 88, 17, 88, 17, 272, 367, 7345, 315, 359, 17, 12, 499, 2189, 489, 543, 291, 14, 396, 63, 1730, 837, 267, 286, 275, 11542, 63, 1483, 14, 5598, 17, 68, 8, 88, 12, 4766, 12, 7345, 12, 6273, 628, 5600, 531, 267, 14953, 275, 1625, 63, 1483, 14, 16597, 8, 67, 9, 267, 1072, 275, 14953, 14, 2579, 342, 267, 340, 7345, 508, 413, 26, 881, 291, 14, 629, 8, 552, 8, 1199, 395, 650, 9, 881, 291, 14, 7260, 8, 1199, 12, 2892, 359, 18, 627, 413, 435, 413, 627, 499, 12, 499, 627, 499, 435, 413, 627, 650, 12, 499, 627, 650, 435, 413, 627, 841, 566, 267, 587, 26, 881, 291, 14, 629, 8, 552, 8, 1199, 395, 499, 9, 881, 291, 14, 7260, 8, 1199, 12, 359, 18, 627, 413, 435, 413, 627, 499, 12, 499, 627, 650, 435, 413, 627, 841, 566, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
joelddiaz/openshift-tools
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_utils/test/test_load_and_handle_cert.py
78
2030
''' Unit tests for the load_and_handle_cert method ''' import datetime import os import sys import pytest MODULE_PATH = os.path.realpath(os.path.join(__file__, os.pardir, os.pardir, 'library')) sys.path.insert(1, MODULE_PATH) # pylint: disable=import-error,wrong-import-position,missing-docstring # pylint: disable=invalid-name,redefined-outer-name import openshift_cert_expiry # noqa: E402 # TODO: More testing on the results of the load_and_handle_cert function # could be implemented here as well, such as verifying subjects # match up. @pytest.fixture(params=['OpenSSLCertificate', 'FakeOpenSSLCertificate']) def loaded_cert(request, valid_cert): """ parameterized fixture to provide load_and_handle_cert results for both OpenSSL and FakeOpenSSL parsed certificates """ now = datetime.datetime.now() openshift_cert_expiry.HAS_OPENSSL = request.param == 'OpenSSLCertificate' # valid_cert['cert_file'] is a `py.path.LocalPath` object and # provides a read_text() method for reading the file contents. cert_string = valid_cert['cert_file'].read_text('utf8') (subject, expiry_date, time_remaining, serial) = openshift_cert_expiry.load_and_handle_cert(cert_string, now) return { 'now': now, 'subject': subject, 'expiry_date': expiry_date, 'time_remaining': time_remaining, 'serial': serial, } def test_serial(loaded_cert, valid_cert): """Params: * `loaded_cert` comes from the `loaded_cert` fixture in this file * `valid_cert` comes from the 'valid_cert' fixture in conftest.py """ valid_cert_serial = valid_cert['cert'].get_serial_number() assert loaded_cert['serial'] == valid_cert_serial def test_expiry(loaded_cert): """Params: * `loaded_cert` comes from the `loaded_cert` fixture in this file """ expiry_date = loaded_cert['expiry_date'] time_remaining = loaded_cert['time_remaining'] now = loaded_cert['now'] assert expiry_date == now + time_remaining
apache-2.0
[ 2344, 199, 12008, 2295, 367, 314, 2248, 63, 460, 63, 2479, 63, 4736, 1083, 199, 2344, 199, 646, 2197, 199, 646, 747, 199, 646, 984, 199, 199, 646, 4613, 199, 199, 10001, 63, 3243, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 747, 14, 21386, 12, 747, 14, 21386, 12, 283, 4342, 1333, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 30223, 63, 3243, 9, 199, 199, 3, 4287, 26, 3507, 29, 646, 13, 705, 12, 10603, 13, 646, 13, 3124, 12, 4752, 13, 12485, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 12, 27913, 13, 7837, 13, 354, 199, 646, 1551, 4723, 63, 4736, 63, 16844, 221, 327, 8151, 26, 662, 13314, 199, 199, 3, 3254, 26, 16917, 5343, 641, 314, 2058, 402, 314, 2248, 63, 460, 63, 2479, 63, 4736, 805, 199, 3, 4293, 506, 6366, 2348, 465, 5521, 12, 4066, 465, 31866, 32446, 199, 3, 1336, 1536, 14, 421, 199, 32, 4462, 14, 5997, 8, 1162, 2968, 22791, 11414, 297, 283, 8249, 22791, 11414, 1105, 199, 318, 6511, 63, 4736, 8, 1069, 12, 1686, 63, 4736, 304, 272, 408, 29526, 10949, 370, 5647, 2248, 63, 460, 63, 2479, 63, 4736, 2058, 267, 367, 3865, 14296, 436, 7777, 22791, 4565, 14512, 272, 408, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 342, 339, 1551, 4723, 63, 4736, 63, 16844, 14, 13533, 63, 9935, 5413, 275, 1056, 14, 635, 508, 283, 22791, 11414, 7, 339, 327, 1686, 63, 4736, 459, 4736, 63, 493, 418, 365, 282, 658, 647, 14, 515, 14, 26453, 64, 909, 436, 272, 327, 6571, 282, 1586, 63, 505, 342, 1083, 367, 7664, 314, 570, 4072, 14, 272, 6250, 63, 875, 275, 1686, 63, 4736, 459, 4736, 63, 493, 2278, 739, 63, 505, 360, 1624, 24, 358, 339, 334, 5875, 12, 1362, 23402, 63, 602, 12, 1362, 900, 63, 11266, 12, 1362, 3012, 9, 275, 1551, 4723, 63, 4736, 63, 16844, 14, 912, 63, 460, 63, 2479, 63, 4736, 8, 4736, 63, 875, 12, 3063, 9, 339, 372, 469, 267, 283, 2131, 356, 3063, 12, 267, 283, 5875, 356, 5420, 12, 267, 283, 16844, 63, 602, 356, 23402, 63, 602, 12, 267, 283, 521, 63, 11266, 356, 900, 63, 11266, 12, 267, 283, 2171, 356, 3012, 12, 272, 789, 421, 199, 318, 511, 63, 2171, 8, 4591, 63, 4736, 12, 1686, 63, 4736, 304, 272, 408, 6007, 26, 339, 627, 658, 4591, 63, 4736, 64, 12477, 687, 314, 658, 4591, 63, 4736, 64, 10949, 315, 642, 570, 272, 627, 658, 1078, 63, 4736, 64, 12477, 687, 314, 283, 1078, 63, 4736, 7, 10949, 315, 3743, 396, 14, 647, 272, 408, 272, 1686, 63, 4736, 63, 2171, 275, 1686, 63, 4736, 459, 4736, 2278, 362, 63, 2171, 63, 1955, 342, 272, 702, 6511, 63, 4736, 459, 2171, 418, 508, 1686, 63, 4736, 63, 2171, 421, 199, 318, 511, 63, 16844, 8, 4591, 63, 4736, 304, 272, 408, 6007, 26, 339, 627, 658, 4591, 63, 4736, 64, 12477, 687, 314, 658, 4591, 63, 4736, 64, 10949, 315, 642, 570, 272, 408, 272, 23402, 63, 602, 275, 6511, 63, 4736, 459, 16844, 63, 602, 418, 272, 900, 63, 11266, 275, 6511, 63, 4736, 459, 521, 63, 11266, 418, 272, 3063, 275, 6511, 63, 4736, 459, 2131, 418, 272, 702, 23402, 63, 602, 508, 3063, 435, 900, 63, 11266, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 12008, 2295, 367, 314, 2248, 63, 460, 63, 2479, 63, 4736, 1083, 199, 2344, 199, 646, 2197, 199, 646, 747, 199, 646, 984, 199, 199, 646, 4613, 199, 199, 10001, 63, 3243, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 747, 14, 21386, 12, 747, 14, 21386, 12, 283, 4342, 1333, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 30223, 63, 3243, 9, 199, 199, 3, 4287, 26, 3507, 29, 646, 13, 705, 12, 10603, 13, 646, 13, 3124, 12, 4752, 13, 12485, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 12, 27913, 13, 7837, 13, 354, 199, 646, 1551, 4723, 63, 4736, 63, 16844, 221, 327, 8151, 26, 662, 13314, 199, 199, 3, 3254, 26, 16917, 5343, 641, 314, 2058, 402, 314, 2248, 63, 460, 63, 2479, 63, 4736, 805, 199, 3, 4293, 506, 6366, 2348, 465, 5521, 12, 4066, 465, 31866, 32446, 199, 3, 1336, 1536, 14, 421, 199, 32, 4462, 14, 5997, 8, 1162, 2968, 22791, 11414, 297, 283, 8249, 22791, 11414, 1105, 199, 318, 6511, 63, 4736, 8, 1069, 12, 1686, 63, 4736, 304, 272, 408, 29526, 10949, 370, 5647, 2248, 63, 460, 63, 2479, 63, 4736, 2058, 267, 367, 3865, 14296, 436, 7777, 22791, 4565, 14512, 272, 408, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 342, 339, 1551, 4723, 63, 4736, 63, 16844, 14, 13533, 63, 9935, 5413, 275, 1056, 14, 635, 508, 283, 22791, 11414, 7, 339, 327, 1686, 63, 4736, 459, 4736, 63, 493, 418, 365, 282, 658, 647, 14, 515, 14, 26453, 64, 909, 436, 272, 327, 6571, 282, 1586, 63, 505, 342, 1083, 367, 7664, 314, 570, 4072, 14, 272, 6250, 63, 875, 275, 1686, 63, 4736, 459, 4736, 63, 493, 2278, 739, 63, 505, 360, 1624, 24, 358, 339, 334, 5875, 12, 1362, 23402, 63, 602, 12, 1362, 900, 63, 11266, 12, 1362, 3012, 9, 275, 1551, 4723, 63, 4736, 63, 16844, 14, 912, 63, 460, 63, 2479, 63, 4736, 8, 4736, 63, 875, 12, 3063, 9, 339, 372, 469, 267, 283, 2131, 356, 3063, 12, 267, 283, 5875, 356, 5420, 12, 267, 283, 16844, 63, 602, 356, 23402, 63, 602, 12, 267, 283, 521, 63, 11266, 356, 900, 63, 11266, 12, 267, 283, 2171, 356, 3012, 12, 272, 789, 421, 199, 318, 511, 63, 2171, 8, 4591, 63, 4736, 12, 1686, 63, 4736, 304, 272, 408, 6007, 26, 339, 627, 658, 4591, 63, 4736, 64, 12477, 687, 314, 658, 4591, 63, 4736, 64, 10949, 315, 642, 570, 272, 627, 658, 1078, 63, 4736, 64, 12477, 687, 314, 283, 1078, 63, 4736, 7, 10949, 315, 3743, 396, 14, 647, 272, 408, 272, 1686, 63, 4736, 63, 2171, 275, 1686, 63, 4736, 459, 4736, 2278, 362, 63, 2171, 63, 1955, 342, 272, 702, 6511, 63, 4736, 459, 2171, 418, 508, 1686, 63, 4736, 63, 2171, 421, 199, 318, 511, 63, 16844, 8, 4591, 63, 4736, 304, 272, 408, 6007, 26, 339, 627, 658, 4591, 63, 4736, 64, 12477, 687, 314, 658, 4591, 63, 4736, 64, 10949, 315, 642, 570, 272, 408, 272, 23402, 63, 602, 275, 6511, 63, 4736, 459, 16844, 63, 602, 418, 272, 900, 63, 11266, 275, 6511, 63, 4736, 459, 521, 63, 11266, 418, 272, 3063, 275, 6511, 63, 4736, 459, 2131, 418, 272, 702, 23402, 63, 602, 508, 3063, 435, 900, 63, 11266, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
WhireCrow/openwrt-mt7620
staging_dir/target-mipsel_r2_uClibc-0.9.33.2/usr/lib/python2.7/encodings/__init__.py
406
5698
""" Standard "encodings" Package Standard Python encoding modules are stored in this package directory. Codec modules must have names corresponding to normalized encoding names as defined in the normalize_encoding() function below, e.g. 'utf-8' must be implemented by the module 'utf_8.py'. Each codec module must export the following interface: * getregentry() -> codecs.CodecInfo object The getregentry() API must a CodecInfo object with encoder, decoder, incrementalencoder, incrementaldecoder, streamwriter and streamreader atttributes which adhere to the Python Codec Interface Standard. In addition, a module may optionally also define the following APIs which are then used by the package's codec search function: * getaliases() -> sequence of encoding name strings to use as aliases Alias names returned by getaliases() must be normalized encoding names as defined by normalize_encoding(). Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" import codecs from encodings import aliases import __builtin__ _cache = {} _unknown = '--unknown--' _import_tail = ['*'] _norm_encoding_map = (' . ' '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' ' ' ' ' ' ') _aliases = aliases.aliases class CodecRegistryError(LookupError, SystemError): pass def normalize_encoding(encoding): """ Normalize an encoding name. Normalization works as follows: all non-alphanumeric characters except the dot used for Python package names are collapsed and replaced with a single underscore, e.g. ' -;#' becomes '_'. Leading and trailing underscores are removed. Note that encoding names should be ASCII only; if they do use non-ASCII characters, these must be Latin-1 compatible. """ # Make sure we have an 8-bit string, because .translate() works # differently for Unicode strings. if hasattr(__builtin__, "unicode") and isinstance(encoding, unicode): # Note that .encode('latin-1') does *not* use the codec # registry, so this call doesn't recurse. (See unicodeobject.c # PyUnicode_AsEncodedString() for details) encoding = encoding.encode('latin-1') return '_'.join(encoding.translate(_norm_encoding_map).split()) def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import scheme, i.e. first # try in the encodings package, then at top-level. # norm_encoding = normalize_encoding(encoding) aliased_encoding = _aliases.get(norm_encoding) or \ _aliases.get(norm_encoding.replace('.', '_')) if aliased_encoding is not None: modnames = [aliased_encoding, norm_encoding] else: modnames = [norm_encoding] for modname in modnames: if not modname or '.' in modname: continue try: # Import is absolute to prevent the possibly malicious import of a # module with side-effects that is not in the 'encodings' package. mod = __import__('encodings.' + modname, fromlist=_import_tail, level=0) except ImportError: pass else: break else: mod = None try: getregentry = mod.getregentry except AttributeError: # Not a codec module mod = None if mod is None: # Cache misses _cache[encoding] = None return None # Now ask the module for the registry entry entry = getregentry() if not isinstance(entry, codecs.CodecInfo): if not 4 <= len(entry) <= 7: raise CodecRegistryError,\ 'module "%s" (%s) failed to register' % \ (mod.__name__, mod.__file__) if not hasattr(entry[0], '__call__') or \ not hasattr(entry[1], '__call__') or \ (entry[2] is not None and not hasattr(entry[2], '__call__')) or \ (entry[3] is not None and not hasattr(entry[3], '__call__')) or \ (len(entry) > 4 and entry[4] is not None and not hasattr(entry[4], '__call__')) or \ (len(entry) > 5 and entry[5] is not None and not hasattr(entry[5], '__call__')): raise CodecRegistryError,\ 'incompatible codecs in module "%s" (%s)' % \ (mod.__name__, mod.__file__) if len(entry)<7 or entry[6] is None: entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],) entry = codecs.CodecInfo(*entry) # Cache the codec registry entry _cache[encoding] = entry # Register its aliases (without overwriting previously registered # aliases) try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: if alias not in _aliases: _aliases[alias] = modname # Return the registry entry return entry # Register the search_function in the Python codec registry codecs.register(search_function)
gpl-2.0
[ 624, 9739, 298, 21138, 2, 15665, 339, 9739, 2018, 2644, 4621, 787, 5489, 315, 642, 2559, 272, 2082, 14, 339, 13732, 4621, 1471, 1172, 1561, 5226, 370, 9657, 2644, 272, 1561, 465, 3247, 315, 314, 7666, 63, 2991, 342, 805, 5084, 12, 325, 14, 71, 14, 272, 283, 1624, 13, 24, 7, 1471, 506, 6366, 701, 314, 859, 283, 1624, 63, 24, 14, 647, 1370, 339, 7048, 9076, 859, 1471, 4843, 314, 2569, 3217, 26, 339, 627, 26116, 342, 1035, 6010, 14, 26375, 909, 272, 710, 26116, 342, 3261, 1471, 282, 13732, 2354, 909, 543, 10295, 12, 10334, 12, 272, 26329, 12, 26317, 12, 26112, 436, 26101, 272, 15115, 1605, 1314, 1503, 1681, 370, 314, 2018, 13732, 14816, 9739, 14, 339, 1010, 10234, 12, 282, 859, 1443, 14190, 2597, 5627, 314, 2569, 272, 15913, 1314, 787, 2066, 1202, 701, 314, 2559, 1159, 9076, 2754, 805, 26, 339, 627, 664, 8602, 342, 1035, 3414, 402, 2644, 536, 3326, 370, 675, 465, 5481, 339, 24777, 1561, 2138, 701, 664, 8602, 342, 1471, 506, 9657, 2644, 272, 1561, 465, 3247, 701, 7666, 63, 2991, 1252, 199, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 8, 67, 9, 1898, 445, 46, 6129, 12, 2900, 5924, 5702, 14, 4825, 3408, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 504, 14134, 492, 5481, 199, 646, 636, 5351, 363, 199, 199, 63, 1637, 275, 1052, 199, 63, 5187, 275, 2850, 5187, 306, 7, 199, 63, 646, 63, 1521, 275, 788, 10, 418, 199, 63, 4791, 63, 2991, 63, 1130, 275, 661, 2476, 4519, 1275, 283, 1993, 283, 11371, 755, 17281, 5638, 39, 11183, 26490, 26018, 258, 283, 1993, 283, 13022, 318, 3561, 7879, 20701, 21832, 9326, 283, 1993, 283, 2476, 4483, 283, 1993, 283, 2476, 4483, 283, 1993, 283, 4483, 5320, 199, 63, 8602, 275, 5481, 14, 8602, 199, 199, 533, 13732, 10899, 547, 8, 32060, 12, 6187, 547, 304, 272, 986, 199, 199, 318, 7666, 63, 2991, 8, 2991, 304, 339, 408, 21017, 376, 2644, 536, 14, 398, 11514, 2072, 5419, 465, 11924, 26, 1006, 2222, 13, 31119, 267, 4110, 871, 314, 6308, 1202, 367, 2018, 2559, 1561, 787, 267, 31219, 436, 8717, 543, 282, 2849, 18888, 12, 325, 14, 71, 14, 283, 221, 446, 27, 19367, 267, 15410, 2513, 1370, 7005, 5384, 436, 8520, 23998, 787, 4829, 14, 398, 3390, 626, 2644, 1561, 1077, 506, 10485, 1454, 27, 340, 2985, 886, 675, 267, 2222, 13, 12292, 4110, 12, 3520, 1471, 506, 23864, 13, 17, 9025, 14, 339, 408, 272, 327, 4155, 3238, 781, 1172, 376, 1695, 13, 2075, 1059, 12, 2952, 1275, 5275, 342, 5419, 272, 327, 23142, 367, 6140, 3326, 14, 272, 340, 2688, 3460, 5351, 3108, 298, 2975, 531, 436, 1228, 8, 2991, 12, 2649, 304, 267, 327, 3390, 626, 1275, 2143, 360, 10378, 13, 17, 358, 1630, 627, 1397, 10, 675, 314, 9076, 267, 327, 7086, 12, 880, 642, 1240, 3181, 1133, 18011, 14, 334, 9295, 2649, 785, 14, 67, 267, 327, 1611, 7087, 63, 2822, 32149, 1558, 342, 367, 2436, 9, 267, 2644, 275, 2644, 14, 2143, 360, 10378, 13, 17, 358, 272, 372, 2513, 1370, 904, 8, 2991, 14, 5275, 1547, 4791, 63, 2991, 63, 1130, 680, 1294, 1012, 199, 199, 318, 2754, 63, 1593, 8, 2991, 304, 339, 327, 11977, 4237, 272, 2397, 275, 485, 1637, 14, 362, 8, 2991, 12, 485, 5187, 9, 272, 340, 2397, 365, 440, 485, 5187, 26, 267, 372, 2397, 339, 327, 3161, 314, 859, 26, 272, 327, 272, 327, 7758, 862, 370, 2342, 376, 5162, 367, 314, 9657, 2644, 272, 327, 536, 436, 4237, 314, 859, 1808, 314, 26642, 536, 12, 2066, 862, 370, 272, 327, 4237, 314, 859, 1808, 314, 4465, 492, 5687, 12, 284, 14, 69, 14, 1642, 272, 327, 862, 315, 314, 14134, 2559, 12, 2066, 737, 2746, 13, 1896, 14, 272, 327, 272, 6316, 63, 2991, 275, 7666, 63, 2991, 8, 2991, 9, 272, 26642, 63, 2991, 275, 485, 8602, 14, 362, 8, 4791, 63, 2991, 9, 503, 971, 2432, 485, 8602, 14, 362, 8, 4791, 63, 2991, 14, 1814, 14078, 2513, 1333, 272, 340, 26642, 63, 2991, 365, 440, 488, 26, 267, 3413, 1247, 275, 359, 26930, 63, 2991, 12, 490, 6316, 63, 2991, 61, 272, 587, 26, 267, 3413, 1247, 275, 359, 4791, 63, 2991, 61, 272, 367, 13526, 315, 3413, 1247, 26, 267, 340, 440, 13526, 503, 7815, 315, 13526, 26, 288, 1980, 267, 862, 26, 288, 327, 3161, 365, 3679, 370, 7981, 314, 12570, 333, 17999, 17326, 492, 402, 282, 288, 327, 859, 543, 5366, 13, 27626, 626, 365, 440, 315, 314, 283, 21138, 7, 2559, 14, 288, 3413, 275, 636, 646, 19734, 21138, 3530, 435, 13526, 12, 25321, 3699, 646, 63, 1521, 12, 2490, 2166, 29, 16, 9, 267, 871, 3545, 26, 288, 986, 267, 587, 26, 288, 2059, 272, 587, 26, 267, 3413, 275, 488, 339, 862, 26, 267, 26116, 275, 3413, 14, 362, 1135, 2373, 272, 871, 4281, 26, 267, 327, 2832, 282, 9076, 859, 267, 3413, 275, 488, 339, 340, 3413, 365, 488, 26, 267, 327, 11977, 3201, 874, 267, 485, 1637, 59, 2991, 61, 275, 488, 267, 372, 488, 339, 327, 7356, 7198, 314, 859, 367, 314, 7086, 2397, 272, 2397, 275, 26116, 342, 272, 340, 440, 1228, 8, 2373, 12, 6010, 14, 26375, 304, 267, 340, 440, 841, 2695, 822, 8, 2373, 9, 2695, 1520, 26, 288, 746, 13732, 10899, 547, 4202, 326, 283, 578, 2071, 83, 2, 4366, 83, 9, 3405, 370, 2274, 7, 450, 971, 2116, 334, 1494, 855, 354, 3108, 3413, 855, 493, 3368, 267, 340, 440, 2688, 8, 2373, 59, 16, 467, 2560, 1250, 13766, 503, 971, 1779, 440, 2688, 8, 2373, 59, 17, 467, 2560, 1250, 13766, 503, 971, 1779, 334, 2373, 59, 18, 61, 365, 440, 488, 436, 440, 2688, 8, 2373, 59, 18, 467, 2560, 1250, 363, 1333, 503, 971, 1779, 334, 2373, 59, 19, 61, 365, 440, 488, 436, 440, 2688, 8, 2373, 59, 19, 467, 2560, 1250, 363, 1333, 503, 971, 1779, 334, 552, 8, 2373, 9, 690, 841, 436, 2397, 59, 20, 61, 365, 440, 488, 436, 440, 2688 ]
[ 9739, 298, 21138, 2, 15665, 339, 9739, 2018, 2644, 4621, 787, 5489, 315, 642, 2559, 272, 2082, 14, 339, 13732, 4621, 1471, 1172, 1561, 5226, 370, 9657, 2644, 272, 1561, 465, 3247, 315, 314, 7666, 63, 2991, 342, 805, 5084, 12, 325, 14, 71, 14, 272, 283, 1624, 13, 24, 7, 1471, 506, 6366, 701, 314, 859, 283, 1624, 63, 24, 14, 647, 1370, 339, 7048, 9076, 859, 1471, 4843, 314, 2569, 3217, 26, 339, 627, 26116, 342, 1035, 6010, 14, 26375, 909, 272, 710, 26116, 342, 3261, 1471, 282, 13732, 2354, 909, 543, 10295, 12, 10334, 12, 272, 26329, 12, 26317, 12, 26112, 436, 26101, 272, 15115, 1605, 1314, 1503, 1681, 370, 314, 2018, 13732, 14816, 9739, 14, 339, 1010, 10234, 12, 282, 859, 1443, 14190, 2597, 5627, 314, 2569, 272, 15913, 1314, 787, 2066, 1202, 701, 314, 2559, 1159, 9076, 2754, 805, 26, 339, 627, 664, 8602, 342, 1035, 3414, 402, 2644, 536, 3326, 370, 675, 465, 5481, 339, 24777, 1561, 2138, 701, 664, 8602, 342, 1471, 506, 9657, 2644, 272, 1561, 465, 3247, 701, 7666, 63, 2991, 1252, 199, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 8, 67, 9, 1898, 445, 46, 6129, 12, 2900, 5924, 5702, 14, 4825, 3408, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 504, 14134, 492, 5481, 199, 646, 636, 5351, 363, 199, 199, 63, 1637, 275, 1052, 199, 63, 5187, 275, 2850, 5187, 306, 7, 199, 63, 646, 63, 1521, 275, 788, 10, 418, 199, 63, 4791, 63, 2991, 63, 1130, 275, 661, 2476, 4519, 1275, 283, 1993, 283, 11371, 755, 17281, 5638, 39, 11183, 26490, 26018, 258, 283, 1993, 283, 13022, 318, 3561, 7879, 20701, 21832, 9326, 283, 1993, 283, 2476, 4483, 283, 1993, 283, 2476, 4483, 283, 1993, 283, 4483, 5320, 199, 63, 8602, 275, 5481, 14, 8602, 199, 199, 533, 13732, 10899, 547, 8, 32060, 12, 6187, 547, 304, 272, 986, 199, 199, 318, 7666, 63, 2991, 8, 2991, 304, 339, 408, 21017, 376, 2644, 536, 14, 398, 11514, 2072, 5419, 465, 11924, 26, 1006, 2222, 13, 31119, 267, 4110, 871, 314, 6308, 1202, 367, 2018, 2559, 1561, 787, 267, 31219, 436, 8717, 543, 282, 2849, 18888, 12, 325, 14, 71, 14, 283, 221, 446, 27, 19367, 267, 15410, 2513, 1370, 7005, 5384, 436, 8520, 23998, 787, 4829, 14, 398, 3390, 626, 2644, 1561, 1077, 506, 10485, 1454, 27, 340, 2985, 886, 675, 267, 2222, 13, 12292, 4110, 12, 3520, 1471, 506, 23864, 13, 17, 9025, 14, 339, 408, 272, 327, 4155, 3238, 781, 1172, 376, 1695, 13, 2075, 1059, 12, 2952, 1275, 5275, 342, 5419, 272, 327, 23142, 367, 6140, 3326, 14, 272, 340, 2688, 3460, 5351, 3108, 298, 2975, 531, 436, 1228, 8, 2991, 12, 2649, 304, 267, 327, 3390, 626, 1275, 2143, 360, 10378, 13, 17, 358, 1630, 627, 1397, 10, 675, 314, 9076, 267, 327, 7086, 12, 880, 642, 1240, 3181, 1133, 18011, 14, 334, 9295, 2649, 785, 14, 67, 267, 327, 1611, 7087, 63, 2822, 32149, 1558, 342, 367, 2436, 9, 267, 2644, 275, 2644, 14, 2143, 360, 10378, 13, 17, 358, 272, 372, 2513, 1370, 904, 8, 2991, 14, 5275, 1547, 4791, 63, 2991, 63, 1130, 680, 1294, 1012, 199, 199, 318, 2754, 63, 1593, 8, 2991, 304, 339, 327, 11977, 4237, 272, 2397, 275, 485, 1637, 14, 362, 8, 2991, 12, 485, 5187, 9, 272, 340, 2397, 365, 440, 485, 5187, 26, 267, 372, 2397, 339, 327, 3161, 314, 859, 26, 272, 327, 272, 327, 7758, 862, 370, 2342, 376, 5162, 367, 314, 9657, 2644, 272, 327, 536, 436, 4237, 314, 859, 1808, 314, 26642, 536, 12, 2066, 862, 370, 272, 327, 4237, 314, 859, 1808, 314, 4465, 492, 5687, 12, 284, 14, 69, 14, 1642, 272, 327, 862, 315, 314, 14134, 2559, 12, 2066, 737, 2746, 13, 1896, 14, 272, 327, 272, 6316, 63, 2991, 275, 7666, 63, 2991, 8, 2991, 9, 272, 26642, 63, 2991, 275, 485, 8602, 14, 362, 8, 4791, 63, 2991, 9, 503, 971, 2432, 485, 8602, 14, 362, 8, 4791, 63, 2991, 14, 1814, 14078, 2513, 1333, 272, 340, 26642, 63, 2991, 365, 440, 488, 26, 267, 3413, 1247, 275, 359, 26930, 63, 2991, 12, 490, 6316, 63, 2991, 61, 272, 587, 26, 267, 3413, 1247, 275, 359, 4791, 63, 2991, 61, 272, 367, 13526, 315, 3413, 1247, 26, 267, 340, 440, 13526, 503, 7815, 315, 13526, 26, 288, 1980, 267, 862, 26, 288, 327, 3161, 365, 3679, 370, 7981, 314, 12570, 333, 17999, 17326, 492, 402, 282, 288, 327, 859, 543, 5366, 13, 27626, 626, 365, 440, 315, 314, 283, 21138, 7, 2559, 14, 288, 3413, 275, 636, 646, 19734, 21138, 3530, 435, 13526, 12, 25321, 3699, 646, 63, 1521, 12, 2490, 2166, 29, 16, 9, 267, 871, 3545, 26, 288, 986, 267, 587, 26, 288, 2059, 272, 587, 26, 267, 3413, 275, 488, 339, 862, 26, 267, 26116, 275, 3413, 14, 362, 1135, 2373, 272, 871, 4281, 26, 267, 327, 2832, 282, 9076, 859, 267, 3413, 275, 488, 339, 340, 3413, 365, 488, 26, 267, 327, 11977, 3201, 874, 267, 485, 1637, 59, 2991, 61, 275, 488, 267, 372, 488, 339, 327, 7356, 7198, 314, 859, 367, 314, 7086, 2397, 272, 2397, 275, 26116, 342, 272, 340, 440, 1228, 8, 2373, 12, 6010, 14, 26375, 304, 267, 340, 440, 841, 2695, 822, 8, 2373, 9, 2695, 1520, 26, 288, 746, 13732, 10899, 547, 4202, 326, 283, 578, 2071, 83, 2, 4366, 83, 9, 3405, 370, 2274, 7, 450, 971, 2116, 334, 1494, 855, 354, 3108, 3413, 855, 493, 3368, 267, 340, 440, 2688, 8, 2373, 59, 16, 467, 2560, 1250, 13766, 503, 971, 1779, 440, 2688, 8, 2373, 59, 17, 467, 2560, 1250, 13766, 503, 971, 1779, 334, 2373, 59, 18, 61, 365, 440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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 ]
brunolimawd/talk-nodebots-roll-out
node_modules/node-sass/node_modules/node-gyp/gyp/tools/pretty_gyp.py
2618
4756
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Pretty-prints the contents of a GYP file.""" import sys import re # Regex to remove comments when we're counting braces. COMMENT_RE = re.compile(r'\s*#.*') # Regex to remove quoted strings when we're counting braces. # It takes into account quoted quotes, and makes sure that the quotes match. # NOTE: It does not handle quotes that span more than one line, or # cases where an escaped quote is preceeded by an escaped backslash. QUOTE_RE_STR = r'(?P<q>[\'"])(.*?)(?<![^\\][\\])(?P=q)' QUOTE_RE = re.compile(QUOTE_RE_STR) def comment_replace(matchobj): return matchobj.group(1) + matchobj.group(2) + '#' * len(matchobj.group(3)) def mask_comments(input): """Mask the quoted strings so we skip braces inside quoted strings.""" search_re = re.compile(r'(.*?)(#)(.*)') return [search_re.sub(comment_replace, line) for line in input] def quote_replace(matchobj): return "%s%s%s%s" % (matchobj.group(1), matchobj.group(2), 'x'*len(matchobj.group(3)), matchobj.group(2)) def mask_quotes(input): """Mask the quoted strings so we skip braces inside quoted strings.""" search_re = re.compile(r'(.*?)' + QUOTE_RE_STR) return [search_re.sub(quote_replace, line) for line in input] def do_split(input, masked_input, search_re): output = [] mask_output = [] for (line, masked_line) in zip(input, masked_input): m = search_re.match(masked_line) while m: split = len(m.group(1)) line = line[:split] + r'\n' + line[split:] masked_line = masked_line[:split] + r'\n' + masked_line[split:] m = search_re.match(masked_line) output.extend(line.split(r'\n')) mask_output.extend(masked_line.split(r'\n')) return (output, mask_output) def split_double_braces(input): """Masks out the quotes and comments, and then splits appropriate lines (lines that matche the double_*_brace re's above) before indenting them below. These are used to split lines which have multiple braces on them, so that the indentation looks prettier when all laid out (e.g. closing braces make a nice diagonal line). """ double_open_brace_re = re.compile(r'(.*?[\[\{\(,])(\s*)([\[\{\(])') double_close_brace_re = re.compile(r'(.*?[\]\}\)],?)(\s*)([\]\}\)])') masked_input = mask_quotes(input) masked_input = mask_comments(masked_input) (output, mask_output) = do_split(input, masked_input, double_open_brace_re) (output, mask_output) = do_split(output, mask_output, double_close_brace_re) return output def count_braces(line): """keeps track of the number of braces on a given line and returns the result. It starts at zero and subtracts for closed braces, and adds for open braces. """ open_braces = ['[', '(', '{'] close_braces = [']', ')', '}'] closing_prefix_re = re.compile(r'(.*?[^\s\]\}\)]+.*?)([\]\}\)],?)\s*$') cnt = 0 stripline = COMMENT_RE.sub(r'', line) stripline = QUOTE_RE.sub(r"''", stripline) for char in stripline: for brace in open_braces: if char == brace: cnt += 1 for brace in close_braces: if char == brace: cnt -= 1 after = False if cnt > 0: after = True # This catches the special case of a closing brace having something # other than just whitespace ahead of it -- we don't want to # unindent that until after this line is printed so it stays with # the previous indentation level. if cnt < 0 and closing_prefix_re.match(stripline): after = True return (cnt, after) def prettyprint_input(lines): """Does the main work of indenting the input based on the brace counts.""" indent = 0 basic_offset = 2 last_line = "" for line in lines: if COMMENT_RE.match(line): print line else: line = line.strip('\r\n\t ') # Otherwise doesn't strip \r on Unix. if len(line) > 0: (brace_diff, after) = count_braces(line) if brace_diff != 0: if after: print " " * (basic_offset * indent) + line indent += brace_diff else: indent += brace_diff print " " * (basic_offset * indent) + line else: print " " * (basic_offset * indent) + line else: print "" last_line = line def main(): if len(sys.argv) > 1: data = open(sys.argv[1]).read().splitlines() else: data = sys.stdin.read().splitlines() # Split up the double braces. lines = split_double_braces(data) # Indent and print the output. prettyprint_input(lines) return 0 if __name__ == '__main__': sys.exit(main())
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 27153, 13, 29593, 314, 4072, 402, 282, 25686, 570, 1041, 199, 199, 646, 984, 199, 646, 295, 421, 199, 3, 12939, 370, 2813, 6786, 1380, 781, 3984, 23190, 27158, 14, 199, 10973, 63, 907, 275, 295, 14, 2014, 8, 82, 1154, 83, 10, 3, 24915, 199, 199, 3, 12939, 370, 2813, 10999, 3326, 1380, 781, 3984, 23190, 27158, 14, 199, 3, 2779, 6181, 1901, 2933, 10999, 9344, 12, 436, 7704, 3238, 626, 314, 9344, 1336, 14, 199, 3, 6944, 26, 2779, 1630, 440, 2429, 9344, 626, 13598, 1655, 2419, 1373, 1004, 12, 503, 199, 3, 5560, 2382, 376, 11077, 6313, 365, 9222, 6133, 701, 376, 11077, 13831, 14, 199, 18495, 63, 907, 63, 3027, 275, 519, 10120, 48, 28, 81, 9514, 3985, 3135, 17140, 18168, 11230, 4735, 1103, 1527, 1103, 566, 2229, 48, 29, 81, 3171, 199, 18495, 63, 907, 275, 295, 14, 2014, 8, 18495, 63, 907, 63, 3027, 9, 421, 199, 318, 3721, 63, 1814, 8, 1431, 1113, 304, 523, 372, 1336, 1113, 14, 923, 8, 17, 9, 435, 1336, 1113, 14, 923, 8, 18, 9, 435, 19619, 627, 822, 8, 1431, 1113, 14, 923, 8, 19, 430, 421, 199, 318, 3656, 63, 6223, 8, 1210, 304, 523, 408, 5144, 314, 10999, 3326, 880, 781, 3372, 27158, 6272, 10999, 3326, 1041, 523, 2754, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 5130, 3, 5130, 2795, 5942, 523, 372, 359, 1733, 63, 264, 14, 954, 8, 3349, 63, 1814, 12, 1004, 9, 367, 1004, 315, 1324, 61, 421, 199, 318, 6313, 63, 1814, 8, 1431, 1113, 304, 523, 372, 2071, 83, 5, 83, 5, 83, 5, 83, 2, 450, 334, 1431, 1113, 14, 923, 8, 17, 395, 2432, 1336, 1113, 14, 923, 8, 18, 395, 2432, 283, 88, 16804, 552, 8, 1431, 1113, 14, 923, 8, 19, 1826, 2432, 1336, 1113, 14, 923, 8, 18, 430, 421, 199, 318, 3656, 63, 14005, 8, 1210, 304, 523, 408, 5144, 314, 10999, 3326, 880, 781, 3372, 27158, 6272, 10999, 3326, 1041, 523, 2754, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 3171, 435, 7813, 9407, 63, 907, 63, 3027, 9, 523, 372, 359, 1733, 63, 264, 14, 954, 8, 3513, 63, 1814, 12, 1004, 9, 367, 1004, 315, 1324, 61, 421, 199, 318, 886, 63, 1294, 8, 1210, 12, 9742, 63, 1210, 12, 2754, 63, 264, 304, 523, 1072, 275, 942, 523, 3656, 63, 1199, 275, 942, 523, 367, 334, 604, 12, 9742, 63, 604, 9, 315, 3482, 8, 1210, 12, 9742, 63, 1210, 304, 272, 333, 275, 2754, 63, 264, 14, 1431, 8, 11018, 63, 604, 9, 272, 1830, 333, 26, 489, 3715, 275, 822, 8, 77, 14, 923, 8, 17, 430, 489, 1004, 275, 1004, 1491, 1294, 61, 435, 519, 1154, 78, 7, 435, 1004, 59, 1294, 2938, 489, 9742, 63, 604, 275, 9742, 63, 604, 1491, 1294, 61, 435, 519, 1154, 78, 7, 435, 9742, 63, 604, 59, 1294, 2938, 489, 333, 275, 2754, 63, 264, 14, 1431, 8, 11018, 63, 604, 9, 272, 1072, 14, 2880, 8, 604, 14, 1294, 8, 82, 1154, 78, 1333, 272, 3656, 63, 1199, 14, 2880, 8, 11018, 63, 604, 14, 1294, 8, 82, 1154, 78, 1333, 523, 372, 334, 1199, 12, 3656, 63, 1199, 9, 421, 199, 318, 3715, 63, 3157, 63, 7828, 823, 8, 1210, 304, 523, 408, 5144, 83, 734, 314, 9344, 436, 6786, 12, 436, 2066, 19115, 5827, 523, 2385, 334, 1278, 626, 2530, 595, 314, 4270, 15192, 63, 22359, 295, 1159, 3432, 9, 2544, 523, 4363, 316, 3062, 5084, 14, 819, 5723, 787, 1202, 370, 3715, 2385, 1314, 1172, 3663, 27158, 641, 3062, 12, 880, 523, 626, 314, 14311, 10734, 876, 84, 13949, 1380, 1006, 1127, 344, 734, 334, 69, 14, 71, 14, 11261, 523, 27158, 1852, 282, 14213, 16788, 1004, 680, 523, 408, 523, 4270, 63, 1490, 63, 22359, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 7023, 7023, 12911, 8, 30453, 2961, 83, 13278, 16510, 7023, 12911, 8, 566, 358, 523, 4270, 63, 1600, 63, 22359, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 7023, 7272, 4988, 4360, 31, 10127, 83, 13278, 16510, 7272, 4988, 3948, 358, 819, 9742, 63, 1210, 275, 3656, 63, 14005, 8, 1210, 9, 523, 9742, 63, 1210, 275, 3656, 63, 6223, 8, 11018, 63, 1210, 9, 819, 334, 1199, 12, 3656, 63, 1199, 9, 275, 886, 63, 1294, 8, 1210, 12, 9742, 63, 1210, 12, 4270, 63, 1490, 63, 22359, 63, 264, 9, 523, 334, 1199, 12, 3656, 63, 1199, 9, 275, 886, 63, 1294, 8, 1199, 12, 3656, 63, 1199, 12, 4270, 63, 1600, 63, 22359, 63, 264, 9, 819, 372, 1072, 421, 199, 318, 2338, 63, 7828, 823, 8, 604, 304, 523, 408, 415, 8277, 4426, 402, 314, 1329, 402, 27158, 641, 282, 1627, 1004, 436, 2529, 314, 754, 14, 819, 2779, 9174, 737, 4697, 436, 1007, 1239, 3021, 367, 6876, 27158, 12, 436, 9584, 367, 1551, 27158, 14, 523, 408, 523, 1551, 63, 7828, 823, 275, 788, 59, 297, 283, 5102, 5041, 418, 523, 4002, 63, 7828, 823, 275, 359, 418, 297, 283, 3196, 28544, 418, 523, 11261, 63, 1861, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 16045, 83, 60, 7272, 4988, 1874, 11, 6697, 9, 16510, 7272, 4988, 4360, 31, 2862, 83, 10, 9988, 523, 12703, 275, 378, 523, 6202, 604, 275, 25071, 63, 907, 14, 954, 8, 82, 6448, 1004, 9, 523, 6202, 604, 275, 7813, 9407, 63, 907, 14, 954, 8, 82, 2, 891, 401, 6202, 604, 9, 523, 367, 1495, 315, 6202, 604, 26, 272, 367, 23549, 315, 1551, 63, 7828, 823, 26, 489, 340, 1495, 508, 23549, 26, 267, 12703, 847, 413, 272, 367, 23549, 315, 4002, 63, 7828, 823, 26, 489, 340, 1495, 508, 23549, 26, 267, 12703, 4862, 413, 819, 2410, 275, 756, 523, 340, 12703, 690, 378, 26, 272, 2410, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 27153, 13, 29593, 314, 4072, 402, 282, 25686, 570, 1041, 199, 199, 646, 984, 199, 646, 295, 421, 199, 3, 12939, 370, 2813, 6786, 1380, 781, 3984, 23190, 27158, 14, 199, 10973, 63, 907, 275, 295, 14, 2014, 8, 82, 1154, 83, 10, 3, 24915, 199, 199, 3, 12939, 370, 2813, 10999, 3326, 1380, 781, 3984, 23190, 27158, 14, 199, 3, 2779, 6181, 1901, 2933, 10999, 9344, 12, 436, 7704, 3238, 626, 314, 9344, 1336, 14, 199, 3, 6944, 26, 2779, 1630, 440, 2429, 9344, 626, 13598, 1655, 2419, 1373, 1004, 12, 503, 199, 3, 5560, 2382, 376, 11077, 6313, 365, 9222, 6133, 701, 376, 11077, 13831, 14, 199, 18495, 63, 907, 63, 3027, 275, 519, 10120, 48, 28, 81, 9514, 3985, 3135, 17140, 18168, 11230, 4735, 1103, 1527, 1103, 566, 2229, 48, 29, 81, 3171, 199, 18495, 63, 907, 275, 295, 14, 2014, 8, 18495, 63, 907, 63, 3027, 9, 421, 199, 318, 3721, 63, 1814, 8, 1431, 1113, 304, 523, 372, 1336, 1113, 14, 923, 8, 17, 9, 435, 1336, 1113, 14, 923, 8, 18, 9, 435, 19619, 627, 822, 8, 1431, 1113, 14, 923, 8, 19, 430, 421, 199, 318, 3656, 63, 6223, 8, 1210, 304, 523, 408, 5144, 314, 10999, 3326, 880, 781, 3372, 27158, 6272, 10999, 3326, 1041, 523, 2754, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 5130, 3, 5130, 2795, 5942, 523, 372, 359, 1733, 63, 264, 14, 954, 8, 3349, 63, 1814, 12, 1004, 9, 367, 1004, 315, 1324, 61, 421, 199, 318, 6313, 63, 1814, 8, 1431, 1113, 304, 523, 372, 2071, 83, 5, 83, 5, 83, 5, 83, 2, 450, 334, 1431, 1113, 14, 923, 8, 17, 395, 2432, 1336, 1113, 14, 923, 8, 18, 395, 2432, 283, 88, 16804, 552, 8, 1431, 1113, 14, 923, 8, 19, 1826, 2432, 1336, 1113, 14, 923, 8, 18, 430, 421, 199, 318, 3656, 63, 14005, 8, 1210, 304, 523, 408, 5144, 314, 10999, 3326, 880, 781, 3372, 27158, 6272, 10999, 3326, 1041, 523, 2754, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 3171, 435, 7813, 9407, 63, 907, 63, 3027, 9, 523, 372, 359, 1733, 63, 264, 14, 954, 8, 3513, 63, 1814, 12, 1004, 9, 367, 1004, 315, 1324, 61, 421, 199, 318, 886, 63, 1294, 8, 1210, 12, 9742, 63, 1210, 12, 2754, 63, 264, 304, 523, 1072, 275, 942, 523, 3656, 63, 1199, 275, 942, 523, 367, 334, 604, 12, 9742, 63, 604, 9, 315, 3482, 8, 1210, 12, 9742, 63, 1210, 304, 272, 333, 275, 2754, 63, 264, 14, 1431, 8, 11018, 63, 604, 9, 272, 1830, 333, 26, 489, 3715, 275, 822, 8, 77, 14, 923, 8, 17, 430, 489, 1004, 275, 1004, 1491, 1294, 61, 435, 519, 1154, 78, 7, 435, 1004, 59, 1294, 2938, 489, 9742, 63, 604, 275, 9742, 63, 604, 1491, 1294, 61, 435, 519, 1154, 78, 7, 435, 9742, 63, 604, 59, 1294, 2938, 489, 333, 275, 2754, 63, 264, 14, 1431, 8, 11018, 63, 604, 9, 272, 1072, 14, 2880, 8, 604, 14, 1294, 8, 82, 1154, 78, 1333, 272, 3656, 63, 1199, 14, 2880, 8, 11018, 63, 604, 14, 1294, 8, 82, 1154, 78, 1333, 523, 372, 334, 1199, 12, 3656, 63, 1199, 9, 421, 199, 318, 3715, 63, 3157, 63, 7828, 823, 8, 1210, 304, 523, 408, 5144, 83, 734, 314, 9344, 436, 6786, 12, 436, 2066, 19115, 5827, 523, 2385, 334, 1278, 626, 2530, 595, 314, 4270, 15192, 63, 22359, 295, 1159, 3432, 9, 2544, 523, 4363, 316, 3062, 5084, 14, 819, 5723, 787, 1202, 370, 3715, 2385, 1314, 1172, 3663, 27158, 641, 3062, 12, 880, 523, 626, 314, 14311, 10734, 876, 84, 13949, 1380, 1006, 1127, 344, 734, 334, 69, 14, 71, 14, 11261, 523, 27158, 1852, 282, 14213, 16788, 1004, 680, 523, 408, 523, 4270, 63, 1490, 63, 22359, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 7023, 7023, 12911, 8, 30453, 2961, 83, 13278, 16510, 7023, 12911, 8, 566, 358, 523, 4270, 63, 1600, 63, 22359, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 7023, 7272, 4988, 4360, 31, 10127, 83, 13278, 16510, 7272, 4988, 3948, 358, 819, 9742, 63, 1210, 275, 3656, 63, 14005, 8, 1210, 9, 523, 9742, 63, 1210, 275, 3656, 63, 6223, 8, 11018, 63, 1210, 9, 819, 334, 1199, 12, 3656, 63, 1199, 9, 275, 886, 63, 1294, 8, 1210, 12, 9742, 63, 1210, 12, 4270, 63, 1490, 63, 22359, 63, 264, 9, 523, 334, 1199, 12, 3656, 63, 1199, 9, 275, 886, 63, 1294, 8, 1199, 12, 3656, 63, 1199, 12, 4270, 63, 1600, 63, 22359, 63, 264, 9, 819, 372, 1072, 421, 199, 318, 2338, 63, 7828, 823, 8, 604, 304, 523, 408, 415, 8277, 4426, 402, 314, 1329, 402, 27158, 641, 282, 1627, 1004, 436, 2529, 314, 754, 14, 819, 2779, 9174, 737, 4697, 436, 1007, 1239, 3021, 367, 6876, 27158, 12, 436, 9584, 367, 1551, 27158, 14, 523, 408, 523, 1551, 63, 7828, 823, 275, 788, 59, 297, 283, 5102, 5041, 418, 523, 4002, 63, 7828, 823, 275, 359, 418, 297, 283, 3196, 28544, 418, 523, 11261, 63, 1861, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 6697, 16045, 83, 60, 7272, 4988, 1874, 11, 6697, 9, 16510, 7272, 4988, 4360, 31, 2862, 83, 10, 9988, 523, 12703, 275, 378, 523, 6202, 604, 275, 25071, 63, 907, 14, 954, 8, 82, 6448, 1004, 9, 523, 6202, 604, 275, 7813, 9407, 63, 907, 14, 954, 8, 82, 2, 891, 401, 6202, 604, 9, 523, 367, 1495, 315, 6202, 604, 26, 272, 367, 23549, 315, 1551, 63, 7828, 823, 26, 489, 340, 1495, 508, 23549, 26, 267, 12703, 847, 413, 272, 367, 23549, 315, 4002, 63, 7828, 823, 26, 489, 340, 1495, 508, 23549, 26, 267, 12703, 4862, 413, 819, 2410, 275, 756, 523, 340, 12703, 690, 378, 26, 272, 2410, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
frossigneux/blazar
climate/api/root.py
2
1499
# Copyright (c) 2014 Bull. # # 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 json import pecan from climate.api.v2 import controllers class RootController(object): v2 = controllers.V2Controller() def _append_versions_from_controller(self, versions, controller, path): for version in getattr(controller, 'versions', None): version['links'] = [{ "href": "{0}/{1}".format(pecan.request.host_url, path), "rel": "self"}] versions.append(version) @pecan.expose(content_type='application/json') def index(self): pecan.response.status_code = 300 pecan.response.content_type = 'application/json' versions = {"versions": []} self._append_versions_from_controller(versions['versions'], self.v2, 'v2') return json.dumps(versions) @pecan.expose(content_type='application/json') def versions(self): return self.index()
apache-2.0
[ 3, 1898, 334, 67, 9, 6927, 699, 979, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2022, 199, 646, 299, 825, 290, 199, 199, 504, 286, 31583, 14, 1246, 14, 86, 18, 492, 27325, 421, 199, 533, 12826, 7506, 8, 785, 304, 339, 373, 18, 275, 27325, 14, 54, 18, 7506, 342, 339, 347, 485, 740, 63, 6234, 63, 504, 63, 5538, 8, 277, 12, 5459, 12, 7614, 12, 931, 304, 267, 367, 1015, 315, 2519, 8, 5538, 12, 283, 6234, 297, 488, 304, 288, 1015, 459, 4614, 418, 275, 8910, 355, 298, 6399, 582, 5310, 16, 16152, 17, 5469, 908, 8, 733, 290, 14, 1069, 14, 1102, 63, 633, 12, 931, 395, 355, 298, 3369, 582, 298, 277, 3570, 61, 288, 5459, 14, 740, 8, 1023, 9, 339, 768, 733, 290, 14, 20586, 8, 1317, 63, 466, 534, 3578, 15, 1001, 358, 272, 347, 1478, 8, 277, 304, 267, 299, 825, 290, 14, 1310, 14, 1205, 63, 600, 275, 9601, 267, 299, 825, 290, 14, 1310, 14, 1317, 63, 466, 275, 283, 3578, 15, 1001, 7, 267, 5459, 275, 2420, 6234, 582, 23455, 267, 291, 423, 740, 63, 6234, 63, 504, 63, 5538, 8, 6234, 459, 6234, 995, 6343, 291, 14, 86, 18, 12, 283, 86, 18, 358, 267, 372, 2022, 14, 4180, 8, 6234, 9, 339, 768, 733, 290, 14, 20586, 8, 1317, 63, 466, 534, 3578, 15, 1001, 358, 272, 347, 5459, 8, 277, 304, 267, 372, 291, 14, 1080, 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 ]
[ 1898, 334, 67, 9, 6927, 699, 979, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2022, 199, 646, 299, 825, 290, 199, 199, 504, 286, 31583, 14, 1246, 14, 86, 18, 492, 27325, 421, 199, 533, 12826, 7506, 8, 785, 304, 339, 373, 18, 275, 27325, 14, 54, 18, 7506, 342, 339, 347, 485, 740, 63, 6234, 63, 504, 63, 5538, 8, 277, 12, 5459, 12, 7614, 12, 931, 304, 267, 367, 1015, 315, 2519, 8, 5538, 12, 283, 6234, 297, 488, 304, 288, 1015, 459, 4614, 418, 275, 8910, 355, 298, 6399, 582, 5310, 16, 16152, 17, 5469, 908, 8, 733, 290, 14, 1069, 14, 1102, 63, 633, 12, 931, 395, 355, 298, 3369, 582, 298, 277, 3570, 61, 288, 5459, 14, 740, 8, 1023, 9, 339, 768, 733, 290, 14, 20586, 8, 1317, 63, 466, 534, 3578, 15, 1001, 358, 272, 347, 1478, 8, 277, 304, 267, 299, 825, 290, 14, 1310, 14, 1205, 63, 600, 275, 9601, 267, 299, 825, 290, 14, 1310, 14, 1317, 63, 466, 275, 283, 3578, 15, 1001, 7, 267, 5459, 275, 2420, 6234, 582, 23455, 267, 291, 423, 740, 63, 6234, 63, 504, 63, 5538, 8, 6234, 459, 6234, 995, 6343, 291, 14, 86, 18, 12, 283, 86, 18, 358, 267, 372, 2022, 14, 4180, 8, 6234, 9, 339, 768, 733, 290, 14, 20586, 8, 1317, 63, 466, 534, 3578, 15, 1001, 358, 272, 347, 5459, 8, 277, 304, 267, 372, 291, 14, 1080, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
brchiu/tensorflow
tensorflow/python/debug/cli/command_parser.py
79
17451
# 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. # ============================================================================== """Command parsing module for TensorFlow Debugger (tfdbg).""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import ast import re import sys _BRACKETS_PATTERN = re.compile(r"\[[^\]]*\]") _QUOTES_PATTERN = re.compile(r"(\"[^\"]*\"|\'[^\']*\')") _WHITESPACE_PATTERN = re.compile(r"\s+") _NUMBER_PATTERN = re.compile(r"[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?") class Interval(object): """Represents an interval between a start and end value.""" def __init__(self, start, start_included, end, end_included): self.start = start self.start_included = start_included self.end = end self.end_included = end_included def contains(self, value): if value < self.start or value == self.start and not self.start_included: return False if value > self.end or value == self.end and not self.end_included: return False return True def __eq__(self, other): return (self.start == other.start and self.start_included == other.start_included and self.end == other.end and self.end_included == other.end_included) def parse_command(command): """Parse command string into a list of arguments. - Disregards whitespace inside double quotes and brackets. - Strips paired leading and trailing double quotes in arguments. - Splits the command at whitespace. Nested double quotes and brackets are not handled. Args: command: (str) Input command. Returns: (list of str) List of arguments. """ command = command.strip() if not command: return [] brackets_intervals = [f.span() for f in _BRACKETS_PATTERN.finditer(command)] quotes_intervals = [f.span() for f in _QUOTES_PATTERN.finditer(command)] whitespaces_intervals = [ f.span() for f in _WHITESPACE_PATTERN.finditer(command) ] if not whitespaces_intervals: return [command] arguments = [] idx0 = 0 for start, end in whitespaces_intervals + [(len(command), None)]: # Skip whitespace stretches enclosed in brackets or double quotes. if not any(interval[0] < start < interval[1] for interval in brackets_intervals + quotes_intervals): argument = command[idx0:start] # Strip leading and trailing double quote if they are paired. if (argument.startswith("\"") and argument.endswith("\"") or argument.startswith("'") and argument.endswith("'")): argument = argument[1:-1] arguments.append(argument) idx0 = end return arguments def extract_output_file_path(args): """Extract output file path from command arguments. Args: args: (list of str) command arguments. Returns: (list of str) Command arguments with the output file path part stripped. (str or None) Output file path (if any). Raises: SyntaxError: If there is no file path after the last ">" character. """ if args and args[-1].endswith(">"): raise SyntaxError("Redirect file path is empty") elif args and args[-1].startswith(">"): try: _parse_interval(args[-1]) if len(args) > 1 and args[-2].startswith("-"): output_file_path = None else: output_file_path = args[-1][1:] args = args[:-1] except ValueError: output_file_path = args[-1][1:] args = args[:-1] elif len(args) > 1 and args[-2] == ">": output_file_path = args[-1] args = args[:-2] elif args and args[-1].count(">") == 1: gt_index = args[-1].index(">") if gt_index > 0 and args[-1][gt_index - 1] == "=": output_file_path = None else: output_file_path = args[-1][gt_index + 1:] args[-1] = args[-1][:gt_index] elif len(args) > 1 and args[-2].endswith(">"): output_file_path = args[-1] args = args[:-1] args[-1] = args[-1][:-1] else: output_file_path = None return args, output_file_path def parse_tensor_name_with_slicing(in_str): """Parse tensor name, potentially suffixed by slicing string. Args: in_str: (str) Input name of the tensor, potentially followed by a slicing string. E.g.: Without slicing string: "hidden/weights/Variable:0", with slicing string: "hidden/weights/Variable:0[1, :]" Returns: (str) name of the tensor (str) slicing string, if any. If no slicing string is present, return "". """ if in_str.count("[") == 1 and in_str.endswith("]"): tensor_name = in_str[:in_str.index("[")] tensor_slicing = in_str[in_str.index("["):] else: tensor_name = in_str tensor_slicing = "" return tensor_name, tensor_slicing def validate_slicing_string(slicing_string): """Validate a slicing string. Check if the input string contains only brackets, digits, commas and colons that are valid characters in numpy-style array slicing. Args: slicing_string: (str) Input slicing string to be validated. Returns: (bool) True if and only if the slicing string is valid. """ return bool(re.search(r"^\[(\d|,|\s|:)+\]$", slicing_string)) def _parse_slices(slicing_string): """Construct a tuple of slices from the slicing string. The string must be a valid slicing string. Args: slicing_string: (str) Input slicing string to be parsed. Returns: tuple(slice1, slice2, ...) Raises: ValueError: If tensor_slicing is not a valid numpy ndarray slicing str. """ parsed = [] for slice_string in slicing_string[1:-1].split(","): indices = slice_string.split(":") if len(indices) == 1: parsed.append(int(indices[0].strip())) elif 2 <= len(indices) <= 3: parsed.append( slice(*[ int(index.strip()) if index.strip() else None for index in indices ])) else: raise ValueError("Invalid tensor-slicing string.") return tuple(parsed) def parse_indices(indices_string): """Parse a string representing indices. For example, if the input is "[1, 2, 3]", the return value will be a list of indices: [1, 2, 3] Args: indices_string: (str) a string representing indices. Can optionally be surrounded by a pair of brackets. Returns: (list of int): Parsed indices. """ # Strip whitespace. indices_string = re.sub(r"\s+", "", indices_string) # Strip any brackets at the two ends. if indices_string.startswith("[") and indices_string.endswith("]"): indices_string = indices_string[1:-1] return [int(element) for element in indices_string.split(",")] def parse_ranges(range_string): """Parse a string representing numerical range(s). Args: range_string: (str) A string representing a numerical range or a list of them. For example: "[-1.0,1.0]", "[-inf, 0]", "[[-inf, -1.0], [1.0, inf]]" Returns: (list of list of float) A list of numerical ranges parsed from the input string. Raises: ValueError: If the input doesn't represent a range or a list of ranges. """ range_string = range_string.strip() if not range_string: return [] if "inf" in range_string: range_string = re.sub(r"inf", repr(sys.float_info.max), range_string) ranges = ast.literal_eval(range_string) if isinstance(ranges, list) and not isinstance(ranges[0], list): ranges = [ranges] # Verify that ranges is a list of list of numbers. for item in ranges: if len(item) != 2: raise ValueError("Incorrect number of elements in range") elif not isinstance(item[0], (int, float)): raise ValueError("Incorrect type in the 1st element of range: %s" % type(item[0])) elif not isinstance(item[1], (int, float)): raise ValueError("Incorrect type in the 2nd element of range: %s" % type(item[0])) return ranges def parse_memory_interval(interval_str): """Convert a human-readable memory interval to a tuple of start and end value. Args: interval_str: (`str`) A human-readable str representing an interval (e.g., "[10kB, 20kB]", "<100M", ">100G"). Only the units "kB", "MB", "GB" are supported. The "B character at the end of the input `str` may be omitted. Returns: `Interval` object where start and end are in bytes. Raises: ValueError: if the input is not valid. """ str_interval = _parse_interval(interval_str) interval_start = 0 interval_end = float("inf") if str_interval.start: interval_start = parse_readable_size_str(str_interval.start) if str_interval.end: interval_end = parse_readable_size_str(str_interval.end) if interval_start > interval_end: raise ValueError( "Invalid interval %s. Start of interval must be less than or equal " "to end of interval." % interval_str) return Interval(interval_start, str_interval.start_included, interval_end, str_interval.end_included) def parse_time_interval(interval_str): """Convert a human-readable time interval to a tuple of start and end value. Args: interval_str: (`str`) A human-readable str representing an interval (e.g., "[10us, 20us]", "<100s", ">100ms"). Supported time suffixes are us, ms, s. Returns: `Interval` object where start and end are in microseconds. Raises: ValueError: if the input is not valid. """ str_interval = _parse_interval(interval_str) interval_start = 0 interval_end = float("inf") if str_interval.start: interval_start = parse_readable_time_str(str_interval.start) if str_interval.end: interval_end = parse_readable_time_str(str_interval.end) if interval_start > interval_end: raise ValueError( "Invalid interval %s. Start must be before end of interval." % interval_str) return Interval(interval_start, str_interval.start_included, interval_end, str_interval.end_included) def _parse_interval(interval_str): """Convert a human-readable interval to a tuple of start and end value. Args: interval_str: (`str`) A human-readable str representing an interval (e.g., "[1M, 2M]", "<100k", ">100ms"). The items following the ">", "<", ">=" and "<=" signs have to start with a number (e.g., 3.0, -2, .98). The same requirement applies to the items in the parentheses or brackets. Returns: Interval object where start or end can be None if the range is specified as "<N" or ">N" respectively. Raises: ValueError: if the input is not valid. """ interval_str = interval_str.strip() if interval_str.startswith("<="): if _NUMBER_PATTERN.match(interval_str[2:].strip()): return Interval(start=None, start_included=False, end=interval_str[2:].strip(), end_included=True) else: raise ValueError("Invalid value string after <= in '%s'" % interval_str) if interval_str.startswith("<"): if _NUMBER_PATTERN.match(interval_str[1:].strip()): return Interval(start=None, start_included=False, end=interval_str[1:].strip(), end_included=False) else: raise ValueError("Invalid value string after < in '%s'" % interval_str) if interval_str.startswith(">="): if _NUMBER_PATTERN.match(interval_str[2:].strip()): return Interval(start=interval_str[2:].strip(), start_included=True, end=None, end_included=False) else: raise ValueError("Invalid value string after >= in '%s'" % interval_str) if interval_str.startswith(">"): if _NUMBER_PATTERN.match(interval_str[1:].strip()): return Interval(start=interval_str[1:].strip(), start_included=False, end=None, end_included=False) else: raise ValueError("Invalid value string after > in '%s'" % interval_str) if (not interval_str.startswith(("[", "(")) or not interval_str.endswith(("]", ")"))): raise ValueError( "Invalid interval format: %s. Valid formats are: [min, max], " "(min, max), <max, >min" % interval_str) interval = interval_str[1:-1].split(",") if len(interval) != 2: raise ValueError( "Incorrect interval format: %s. Interval should specify two values: " "[min, max] or (min, max)." % interval_str) start_item = interval[0].strip() if not _NUMBER_PATTERN.match(start_item): raise ValueError("Invalid first item in interval: '%s'" % start_item) end_item = interval[1].strip() if not _NUMBER_PATTERN.match(end_item): raise ValueError("Invalid second item in interval: '%s'" % end_item) return Interval(start=start_item, start_included=(interval_str[0] == "["), end=end_item, end_included=(interval_str[-1] == "]")) def parse_readable_size_str(size_str): """Convert a human-readable str representation to number of bytes. Only the units "kB", "MB", "GB" are supported. The "B character at the end of the input `str` may be omitted. Args: size_str: (`str`) A human-readable str representing a number of bytes (e.g., "0", "1023", "1.1kB", "24 MB", "23GB", "100 G". Returns: (`int`) The parsed number of bytes. Raises: ValueError: on failure to parse the input `size_str`. """ size_str = size_str.strip() if size_str.endswith("B"): size_str = size_str[:-1] if size_str.isdigit(): return int(size_str) elif size_str.endswith("k"): return int(float(size_str[:-1]) * 1024) elif size_str.endswith("M"): return int(float(size_str[:-1]) * 1048576) elif size_str.endswith("G"): return int(float(size_str[:-1]) * 1073741824) else: raise ValueError("Failed to parsed human-readable byte size str: \"%s\"" % size_str) def parse_readable_time_str(time_str): """Parses a time string in the format N, Nus, Nms, Ns. Args: time_str: (`str`) string consisting of an integer time value optionally followed by 'us', 'ms', or 's' suffix. If suffix is not specified, value is assumed to be in microseconds. (e.g. 100us, 8ms, 5s, 100). Returns: Microseconds value. """ def parse_positive_float(value_str): value = float(value_str) if value < 0: raise ValueError( "Invalid time %s. Time value must be positive." % value_str) return value time_str = time_str.strip() if time_str.endswith("us"): return int(parse_positive_float(time_str[:-2])) elif time_str.endswith("ms"): return int(parse_positive_float(time_str[:-2]) * 1e3) elif time_str.endswith("s"): return int(parse_positive_float(time_str[:-1]) * 1e6) return int(parse_positive_float(time_str)) def evaluate_tensor_slice(tensor, tensor_slicing): """Call eval on the slicing of a tensor, with validation. Args: tensor: (numpy ndarray) The tensor value. tensor_slicing: (str or None) Slicing of the tensor, e.g., "[:, 1]". If None, no slicing will be performed on the tensor. Returns: (numpy ndarray) The sliced tensor. Raises: ValueError: If tensor_slicing is not a valid numpy ndarray slicing str. """ _ = tensor if not validate_slicing_string(tensor_slicing): raise ValueError("Invalid tensor-slicing string.") return tensor[_parse_slices(tensor_slicing)] def get_print_tensor_argparser(description): """Get an ArgumentParser for a command that prints tensor values. Examples of such commands include print_tensor and print_feed. Args: description: Description of the ArgumentParser. Returns: An instance of argparse.ArgumentParser. """ ap = argparse.ArgumentParser( description=description, usage=argparse.SUPPRESS) ap.add_argument( "tensor_name", type=str, help="Name of the tensor, followed by any slicing indices, " "e.g., hidden1/Wx_plus_b/MatMul:0, " "hidden1/Wx_plus_b/MatMul:0[1, :]") ap.add_argument( "-n", "--number", dest="number", type=int, default=-1, help="0-based dump number for the specified tensor. " "Required for tensor with multiple dumps.") ap.add_argument( "-r", "--ranges", dest="ranges", type=str, default="", help="Numerical ranges to highlight tensor elements in. " "Examples: -r 0,1e-8, -r [-0.1,0.1], " "-r \"[[-inf, -0.1], [0.1, inf]]\"") ap.add_argument( "-a", "--all", dest="print_all", action="store_true", help="Print the tensor in its entirety, i.e., do not use ellipses.") ap.add_argument( "-s", "--numeric_summary", action="store_true", help="Include summary for non-empty tensors of numeric (int*, float*, " "complex*) and Boolean types.") ap.add_argument( "-w", "--write_path", type=str, default="", help="Path of the numpy file to write the tensor data to, using " "numpy.save().") return ap
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3110, 6057, 859, 367, 9134, 14245, 836, 334, 3249, 16310, 10477, 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, 7534, 199, 646, 6073, 199, 646, 295, 199, 646, 984, 421, 199, 63, 25950, 51, 63, 10764, 275, 295, 14, 2014, 8, 82, 3212, 59, 16045, 2677, 7590, 12523, 199, 63, 18654, 654, 63, 10764, 275, 295, 14, 2014, 8, 82, 2, 2961, 2, 16045, 937, 10, 4451, 6113, 29538, 418, 7590, 26530, 199, 63, 20620, 63, 10764, 275, 295, 14, 2014, 8, 82, 3212, 83, 21425, 199, 199, 63, 9190, 63, 10764, 275, 295, 14, 2014, 8, 82, 2, 27371, 11843, 2961, 68, 20900, 3134, 68, 10, 5547, 6113, 3134, 68, 8771, 779, 20565, 1527, 6793, 22426, 68, 19544, 531, 421, 199, 533, 18766, 8, 785, 304, 523, 408, 18089, 376, 6252, 3382, 282, 1343, 436, 1284, 574, 1041, 819, 347, 636, 826, 721, 277, 12, 1343, 12, 1343, 63, 12409, 12, 1284, 12, 1284, 63, 12409, 304, 272, 291, 14, 928, 275, 1343, 272, 291, 14, 928, 63, 12409, 275, 1343, 63, 12409, 272, 291, 14, 500, 275, 1284, 272, 291, 14, 500, 63, 12409, 275, 1284, 63, 12409, 819, 347, 3509, 8, 277, 12, 574, 304, 272, 340, 574, 665, 291, 14, 928, 503, 574, 508, 291, 14, 928, 436, 440, 291, 14, 928, 63, 12409, 26, 489, 372, 756, 272, 340, 574, 690, 291, 14, 500, 503, 574, 508, 291, 14, 500, 436, 440, 291, 14, 500, 63, 12409, 26, 489, 372, 756, 272, 372, 715, 819, 347, 636, 4077, 721, 277, 12, 1163, 304, 272, 372, 334, 277, 14, 928, 508, 1163, 14, 928, 436, 288, 291, 14, 928, 63, 12409, 508, 1163, 14, 928, 63, 12409, 436, 288, 291, 14, 500, 508, 1163, 14, 500, 436, 288, 291, 14, 500, 63, 12409, 508, 1163, 14, 500, 63, 12409, 9, 421, 199, 318, 2198, 63, 1531, 8, 1531, 304, 523, 408, 4003, 1414, 1059, 1901, 282, 769, 402, 2368, 14, 819, 446, 5289, 1135, 5596, 8139, 6272, 4270, 9344, 436, 21873, 14, 523, 446, 31309, 1190, 30177, 9186, 436, 8520, 4270, 9344, 315, 2368, 14, 523, 446, 11740, 83, 314, 1414, 737, 8139, 14, 819, 23137, 4270, 9344, 436, 21873, 787, 440, 8860, 14, 819, 3033, 26, 272, 1414, 26, 334, 495, 9, 6924, 1414, 14, 819, 1803, 26, 272, 334, 513, 402, 620, 9, 3820, 402, 2368, 14, 523, 408, 819, 1414, 275, 1414, 14, 1913, 342, 523, 340, 440, 1414, 26, 272, 372, 942, 819, 21873, 63, 18574, 275, 359, 70, 14, 3751, 342, 367, 289, 315, 485, 25950, 51, 63, 10764, 14, 19373, 8, 1531, 1874, 523, 9344, 63, 18574, 275, 359, 70, 14, 3751, 342, 367, 289, 315, 485, 18654, 654, 63, 10764, 14, 19373, 8, 1531, 1874, 523, 704, 31926, 63, 18574, 275, 359, 489, 289, 14, 3751, 342, 367, 289, 315, 485, 20620, 63, 10764, 14, 19373, 8, 1531, 9, 523, 1622, 819, 340, 440, 704, 31926, 63, 18574, 26, 272, 372, 359, 1531, 61, 819, 2368, 275, 942, 523, 4280, 16, 275, 378, 523, 367, 1343, 12, 1284, 315, 704, 31926, 63, 18574, 435, 3842, 552, 8, 1531, 395, 488, 19532, 272, 327, 8232, 8139, 410, 3292, 12253, 27828, 315, 21873, 503, 4270, 9344, 14, 339, 340, 440, 1263, 8, 4284, 59, 16, 61, 665, 1343, 665, 6252, 59, 17, 61, 2049, 367, 6252, 315, 21873, 63, 18574, 435, 9344, 63, 18574, 304, 489, 1423, 275, 1414, 59, 2996, 16, 26, 928, 61, 2541, 327, 19828, 9186, 436, 8520, 4270, 6313, 340, 2985, 787, 30177, 14, 489, 340, 334, 2094, 14, 2460, 4582, 7230, 436, 1423, 14, 4130, 4582, 7230, 503, 881, 1423, 14, 2460, 480, 9859, 436, 1423, 14, 4130, 480, 9859, 304, 267, 1423, 275, 1423, 59, 17, 6809, 17, 61, 489, 2368, 14, 740, 8, 2094, 9, 489, 4280, 16, 275, 1284, 819, 372, 2368, 421, 199, 318, 5536, 63, 1199, 63, 493, 63, 515, 8, 589, 304, 523, 408, 12147, 1072, 570, 931, 687, 1414, 2368, 14, 819, 3033, 26, 272, 1249, 26, 334, 513, 402, 620, 9, 1414, 2368, 14, 819, 1803, 26, 272, 334, 513, 402, 620, 9, 5817, 2368, 543, 314, 1072, 570, 931, 1777, 14489, 14, 272, 334, 495, 503, 488, 9, 7242, 570, 931, 334, 692, 1263, 680, 819, 6218, 26, 272, 12053, 26, 982, 2337, 365, 949, 570, 931, 2410, 314, 2061, 28192, 4528, 14, 523, 408, 819, 340, 1249, 436, 1249, 1988, 17, 1055, 4130, 19651, 2349, 272, 746, 12053, 480, 7071, 570, 931, 365, 2701, 531, 523, 916, 1249, 436, 1249, 1988, 17, 1055, 2460, 19651, 2349, 272, 862, 26, 489, 485, 1122, 63, 4284, 8, 589, 1988, 17, 566, 489, 340, 822, 8, 589, 9, 690, 413, 436, 1249, 1988, 18, 1055, 2460, 6096, 2349, 267, 1072, 63, 493, 63, 515, 275, 488, 489, 587, 26, 267, 1072, 63, 493, 63, 515, 275, 1249, 1988, 17, 1527, 17, 2938, 267, 1249, 275, 1249, 4439, 17, 61, 272, 871, 1722, 26, 489, 1072, 63, 493, 63, 515, 275, 1249, 1988, 17, 1527, 17, 2938, 489, 1249, 275, 1249, 4439, 17, 61, 523, 916, 822, 8, 589, 9, 690, 413, 436, 1249, 1988, 18, 61 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3110, 6057, 859, 367, 9134, 14245, 836, 334, 3249, 16310, 10477, 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, 7534, 199, 646, 6073, 199, 646, 295, 199, 646, 984, 421, 199, 63, 25950, 51, 63, 10764, 275, 295, 14, 2014, 8, 82, 3212, 59, 16045, 2677, 7590, 12523, 199, 63, 18654, 654, 63, 10764, 275, 295, 14, 2014, 8, 82, 2, 2961, 2, 16045, 937, 10, 4451, 6113, 29538, 418, 7590, 26530, 199, 63, 20620, 63, 10764, 275, 295, 14, 2014, 8, 82, 3212, 83, 21425, 199, 199, 63, 9190, 63, 10764, 275, 295, 14, 2014, 8, 82, 2, 27371, 11843, 2961, 68, 20900, 3134, 68, 10, 5547, 6113, 3134, 68, 8771, 779, 20565, 1527, 6793, 22426, 68, 19544, 531, 421, 199, 533, 18766, 8, 785, 304, 523, 408, 18089, 376, 6252, 3382, 282, 1343, 436, 1284, 574, 1041, 819, 347, 636, 826, 721, 277, 12, 1343, 12, 1343, 63, 12409, 12, 1284, 12, 1284, 63, 12409, 304, 272, 291, 14, 928, 275, 1343, 272, 291, 14, 928, 63, 12409, 275, 1343, 63, 12409, 272, 291, 14, 500, 275, 1284, 272, 291, 14, 500, 63, 12409, 275, 1284, 63, 12409, 819, 347, 3509, 8, 277, 12, 574, 304, 272, 340, 574, 665, 291, 14, 928, 503, 574, 508, 291, 14, 928, 436, 440, 291, 14, 928, 63, 12409, 26, 489, 372, 756, 272, 340, 574, 690, 291, 14, 500, 503, 574, 508, 291, 14, 500, 436, 440, 291, 14, 500, 63, 12409, 26, 489, 372, 756, 272, 372, 715, 819, 347, 636, 4077, 721, 277, 12, 1163, 304, 272, 372, 334, 277, 14, 928, 508, 1163, 14, 928, 436, 288, 291, 14, 928, 63, 12409, 508, 1163, 14, 928, 63, 12409, 436, 288, 291, 14, 500, 508, 1163, 14, 500, 436, 288, 291, 14, 500, 63, 12409, 508, 1163, 14, 500, 63, 12409, 9, 421, 199, 318, 2198, 63, 1531, 8, 1531, 304, 523, 408, 4003, 1414, 1059, 1901, 282, 769, 402, 2368, 14, 819, 446, 5289, 1135, 5596, 8139, 6272, 4270, 9344, 436, 21873, 14, 523, 446, 31309, 1190, 30177, 9186, 436, 8520, 4270, 9344, 315, 2368, 14, 523, 446, 11740, 83, 314, 1414, 737, 8139, 14, 819, 23137, 4270, 9344, 436, 21873, 787, 440, 8860, 14, 819, 3033, 26, 272, 1414, 26, 334, 495, 9, 6924, 1414, 14, 819, 1803, 26, 272, 334, 513, 402, 620, 9, 3820, 402, 2368, 14, 523, 408, 819, 1414, 275, 1414, 14, 1913, 342, 523, 340, 440, 1414, 26, 272, 372, 942, 819, 21873, 63, 18574, 275, 359, 70, 14, 3751, 342, 367, 289, 315, 485, 25950, 51, 63, 10764, 14, 19373, 8, 1531, 1874, 523, 9344, 63, 18574, 275, 359, 70, 14, 3751, 342, 367, 289, 315, 485, 18654, 654, 63, 10764, 14, 19373, 8, 1531, 1874, 523, 704, 31926, 63, 18574, 275, 359, 489, 289, 14, 3751, 342, 367, 289, 315, 485, 20620, 63, 10764, 14, 19373, 8, 1531, 9, 523, 1622, 819, 340, 440, 704, 31926, 63, 18574, 26, 272, 372, 359, 1531, 61, 819, 2368, 275, 942, 523, 4280, 16, 275, 378, 523, 367, 1343, 12, 1284, 315, 704, 31926, 63, 18574, 435, 3842, 552, 8, 1531, 395, 488, 19532, 272, 327, 8232, 8139, 410, 3292, 12253, 27828, 315, 21873, 503, 4270, 9344, 14, 339, 340, 440, 1263, 8, 4284, 59, 16, 61, 665, 1343, 665, 6252, 59, 17, 61, 2049, 367, 6252, 315, 21873, 63, 18574, 435, 9344, 63, 18574, 304, 489, 1423, 275, 1414, 59, 2996, 16, 26, 928, 61, 2541, 327, 19828, 9186, 436, 8520, 4270, 6313, 340, 2985, 787, 30177, 14, 489, 340, 334, 2094, 14, 2460, 4582, 7230, 436, 1423, 14, 4130, 4582, 7230, 503, 881, 1423, 14, 2460, 480, 9859, 436, 1423, 14, 4130, 480, 9859, 304, 267, 1423, 275, 1423, 59, 17, 6809, 17, 61, 489, 2368, 14, 740, 8, 2094, 9, 489, 4280, 16, 275, 1284, 819, 372, 2368, 421, 199, 318, 5536, 63, 1199, 63, 493, 63, 515, 8, 589, 304, 523, 408, 12147, 1072, 570, 931, 687, 1414, 2368, 14, 819, 3033, 26, 272, 1249, 26, 334, 513, 402, 620, 9, 1414, 2368, 14, 819, 1803, 26, 272, 334, 513, 402, 620, 9, 5817, 2368, 543, 314, 1072, 570, 931, 1777, 14489, 14, 272, 334, 495, 503, 488, 9, 7242, 570, 931, 334, 692, 1263, 680, 819, 6218, 26, 272, 12053, 26, 982, 2337, 365, 949, 570, 931, 2410, 314, 2061, 28192, 4528, 14, 523, 408, 819, 340, 1249, 436, 1249, 1988, 17, 1055, 4130, 19651, 2349, 272, 746, 12053, 480, 7071, 570, 931, 365, 2701, 531, 523, 916, 1249, 436, 1249, 1988, 17, 1055, 2460, 19651, 2349, 272, 862, 26, 489, 485, 1122, 63, 4284, 8, 589, 1988, 17, 566, 489, 340, 822, 8, 589, 9, 690, 413, 436, 1249, 1988, 18, 1055, 2460, 6096, 2349, 267, 1072, 63, 493, 63, 515, 275, 488, 489, 587, 26, 267, 1072, 63, 493, 63, 515, 275, 1249, 1988, 17, 1527, 17, 2938, 267, 1249, 275, 1249, 4439, 17, 61, 272, 871, 1722, 26, 489, 1072, 63, 493, 63, 515, 275, 1249, 1988, 17, 1527, 17, 2938, 489, 1249, 275, 1249, 4439, 17, 61, 523, 916, 822, 8, 589, 9, 690, 413, 436, 1249, 1988, 18, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hybrideagle/django
django/contrib/gis/geos/prototypes/io.py
309
9480
import threading from ctypes import POINTER, Structure, byref, c_char, c_char_p, c_int, c_size_t from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import ( check_geom, check_sized_string, check_string, ) from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.utils import six from django.utils.encoding import force_bytes # ### The WKB/WKT Reader/Writer structures and pointers ### class WKTReader_st(Structure): pass class WKTWriter_st(Structure): pass class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st) # WKTReader routines wkt_reader_create = GEOSFuncFactory('GEOSWKTReader_create', restype=WKT_READ_PTR) wkt_reader_destroy = GEOSFuncFactory('GEOSWKTReader_destroy', argtypes=[WKT_READ_PTR]) wkt_reader_read = GEOSFuncFactory( 'GEOSWKTReader_read', argtypes=[WKT_READ_PTR, c_char_p], restype=GEOM_PTR, errcheck=check_geom ) # WKTWriter routines wkt_writer_create = GEOSFuncFactory('GEOSWKTWriter_create', restype=WKT_WRITE_PTR) wkt_writer_destroy = GEOSFuncFactory('GEOSWKTWriter_destroy', argtypes=[WKT_WRITE_PTR]) wkt_writer_write = GEOSFuncFactory( 'GEOSWKTWriter_write', argtypes=[WKT_WRITE_PTR, GEOM_PTR], restype=geos_char_p, errcheck=check_string ) class WKTOutputDim(GEOSFuncFactory): def get_func(self, *args, **kwargs): try: return super(WKTOutputDim, self).get_func(*args, **kwargs) except AttributeError: # GEOSWKTWriter_get/setOutputDimension has been introduced in GEOS 3.3.0 # Always return 2 if not available return { 'GEOSWKTWriter_getOutputDimension': lambda ptr: 2, 'GEOSWKTWriter_setOutputDimension': lambda ptr, dim: None, }.get(self.func_name) wkt_writer_get_outdim = WKTOutputDim( 'GEOSWKTWriter_getOutputDimension', argtypes=[WKT_WRITE_PTR], restype=c_int ) wkt_writer_set_outdim = WKTOutputDim( 'GEOSWKTWriter_setOutputDimension', argtypes=[WKT_WRITE_PTR, c_int] ) # WKBReader routines wkb_reader_create = GEOSFuncFactory('GEOSWKBReader_create', restype=WKB_READ_PTR) wkb_reader_destroy = GEOSFuncFactory('GEOSWKBReader_destroy', argtypes=[WKB_READ_PTR]) class WKBReadFunc(GEOSFuncFactory): # Although the function definitions take `const unsigned char *` # as their parameter, we use c_char_p here so the function may # take Python strings directly as parameters. Inside Python there # is not a difference between signed and unsigned characters, so # it is not a problem. argtypes = [WKB_READ_PTR, c_char_p, c_size_t] restype = GEOM_PTR errcheck = staticmethod(check_geom) wkb_reader_read = WKBReadFunc('GEOSWKBReader_read') wkb_reader_read_hex = WKBReadFunc('GEOSWKBReader_readHEX') # WKBWriter routines wkb_writer_create = GEOSFuncFactory('GEOSWKBWriter_create', restype=WKB_WRITE_PTR) wkb_writer_destroy = GEOSFuncFactory('GEOSWKBWriter_destroy', argtypes=[WKB_WRITE_PTR]) # WKB Writing prototypes. class WKBWriteFunc(GEOSFuncFactory): argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)] restype = c_uchar_p errcheck = staticmethod(check_sized_string) wkb_writer_write = WKBWriteFunc('GEOSWKBWriter_write') wkb_writer_write_hex = WKBWriteFunc('GEOSWKBWriter_writeHEX') # WKBWriter property getter/setter prototypes. class WKBWriterGet(GEOSFuncFactory): argtypes = [WKB_WRITE_PTR] restype = c_int class WKBWriterSet(GEOSFuncFactory): argtypes = [WKB_WRITE_PTR, c_int] wkb_writer_get_byteorder = WKBWriterGet('GEOSWKBWriter_getByteOrder') wkb_writer_set_byteorder = WKBWriterSet('GEOSWKBWriter_setByteOrder') wkb_writer_get_outdim = WKBWriterGet('GEOSWKBWriter_getOutputDimension') wkb_writer_set_outdim = WKBWriterSet('GEOSWKBWriter_setOutputDimension') wkb_writer_get_include_srid = WKBWriterGet('GEOSWKBWriter_getIncludeSRID', restype=c_char) wkb_writer_set_include_srid = WKBWriterSet('GEOSWKBWriter_setIncludeSRID', argtypes=[WKB_WRITE_PTR, c_char]) # ### Base I/O Class ### class IOBase(GEOSBase): "Base class for GEOS I/O objects." def __init__(self): # Getting the pointer with the constructor. self.ptr = self._constructor() # Loading the real destructor function at this point as doing it in # __del__ is too late (import error). self._destructor.func = self._destructor.get_func( *self._destructor.args, **self._destructor.kwargs ) def __del__(self): # Cleaning up with the appropriate destructor. if self._ptr: self._destructor(self._ptr) # ### Base WKB/WKT Reading and Writing objects ### # Non-public WKB/WKT reader classes for internal use because # their `read` methods return _pointers_ instead of GEOSGeometry # objects. class _WKTReader(IOBase): _constructor = wkt_reader_create _destructor = wkt_reader_destroy ptr_type = WKT_READ_PTR def read(self, wkt): if not isinstance(wkt, (bytes, six.string_types)): raise TypeError return wkt_reader_read(self.ptr, force_bytes(wkt)) class _WKBReader(IOBase): _constructor = wkb_reader_create _destructor = wkb_reader_destroy ptr_type = WKB_READ_PTR def read(self, wkb): "Returns a _pointer_ to C GEOS Geometry object from the given WKB." if isinstance(wkb, six.memoryview): wkb_s = bytes(wkb) return wkb_reader_read(self.ptr, wkb_s, len(wkb_s)) elif isinstance(wkb, (bytes, six.string_types)): return wkb_reader_read_hex(self.ptr, wkb, len(wkb)) else: raise TypeError # ### WKB/WKT Writer Classes ### class WKTWriter(IOBase): _constructor = wkt_writer_create _destructor = wkt_writer_destroy ptr_type = WKT_WRITE_PTR def write(self, geom): "Returns the WKT representation of the given geometry." return wkt_writer_write(self.ptr, geom.ptr) @property def outdim(self): return wkt_writer_get_outdim(self.ptr) @outdim.setter def outdim(self, new_dim): if new_dim not in (2, 3): raise ValueError('WKT output dimension must be 2 or 3') wkt_writer_set_outdim(self.ptr, new_dim) class WKBWriter(IOBase): _constructor = wkb_writer_create _destructor = wkb_writer_destroy ptr_type = WKB_WRITE_PTR def write(self, geom): "Returns the WKB representation of the given geometry." return six.memoryview(wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t()))) def write_hex(self, geom): "Returns the HEXEWKB representation of the given geometry." return wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t())) # ### WKBWriter Properties ### # Property for getting/setting the byteorder. def _get_byteorder(self): return wkb_writer_get_byteorder(self.ptr) def _set_byteorder(self, order): if order not in (0, 1): raise ValueError('Byte order parameter must be 0 (Big Endian) or 1 (Little Endian).') wkb_writer_set_byteorder(self.ptr, order) byteorder = property(_get_byteorder, _set_byteorder) # Property for getting/setting the output dimension. def _get_outdim(self): return wkb_writer_get_outdim(self.ptr) def _set_outdim(self, new_dim): if new_dim not in (2, 3): raise ValueError('WKB output dimension must be 2 or 3') wkb_writer_set_outdim(self.ptr, new_dim) outdim = property(_get_outdim, _set_outdim) # Property for getting/setting the include srid flag. def _get_include_srid(self): return bool(ord(wkb_writer_get_include_srid(self.ptr))) def _set_include_srid(self, include): if include: flag = b'\x01' else: flag = b'\x00' wkb_writer_set_include_srid(self.ptr, flag) srid = property(_get_include_srid, _set_include_srid) # `ThreadLocalIO` object holds instances of the WKT and WKB reader/writer # objects that are local to the thread. The `GEOSGeometry` internals # access these instances by calling the module-level functions, defined # below. class ThreadLocalIO(threading.local): wkt_r = None wkt_w = None wkb_r = None wkb_w = None ewkb_w = None thread_context = ThreadLocalIO() # These module-level routines return the I/O object that is local to the # thread. If the I/O object does not exist yet it will be initialized. def wkt_r(): if not thread_context.wkt_r: thread_context.wkt_r = _WKTReader() return thread_context.wkt_r def wkt_w(dim=2): if not thread_context.wkt_w: thread_context.wkt_w = WKTWriter() thread_context.wkt_w.outdim = dim return thread_context.wkt_w def wkb_r(): if not thread_context.wkb_r: thread_context.wkb_r = _WKBReader() return thread_context.wkb_r def wkb_w(dim=2): if not thread_context.wkb_w: thread_context.wkb_w = WKBWriter() thread_context.wkb_w.outdim = dim return thread_context.wkb_w def ewkb_w(dim=2): if not thread_context.ewkb_w: thread_context.ewkb_w = WKBWriter() thread_context.ewkb_w.srid = True thread_context.ewkb_w.outdim = dim return thread_context.ewkb_w
bsd-3-clause
[ 646, 5796, 199, 504, 5577, 492, 6569, 12, 21730, 12, 15968, 12, 286, 63, 1560, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 442, 12, 286, 63, 890, 63, 84, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 1095, 492, 11920, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 12, 11920, 7465, 2927, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 21205, 492, 334, 272, 1104, 63, 6481, 12, 1104, 63, 15308, 63, 875, 12, 1104, 63, 875, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 6481, 492, 286, 63, 85, 1560, 63, 80, 12, 30259, 63, 1560, 63, 80, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 421, 199, 3, 6754, 710, 644, 12780, 15, 55, 12362, 23099, 15, 6261, 13955, 436, 21116, 6754, 199, 533, 22561, 5929, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 22561, 6261, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 644, 12780, 5929, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 644, 12780, 6261, 63, 270, 8, 10766, 304, 272, 986, 199, 199, 55, 12362, 63, 5670, 63, 14528, 275, 6569, 8, 55, 12362, 5929, 63, 270, 9, 199, 55, 12362, 63, 10387, 63, 14528, 275, 6569, 8, 55, 12362, 6261, 63, 270, 9, 199, 28328, 63, 5670, 63, 14528, 275, 6569, 8, 28328, 5929, 63, 270, 9, 199, 28328, 63, 10387, 63, 14528, 275, 6569, 8, 28328, 5929, 63, 270, 9, 199, 199, 3, 22561, 5929, 14975, 199, 11412, 63, 5503, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 5929, 63, 981, 297, 4618, 514, 29, 55, 12362, 63, 5670, 63, 14528, 9, 199, 11412, 63, 5503, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 5929, 63, 7237, 297, 29669, 1524, 55, 12362, 63, 5670, 63, 14528, 566, 199, 199, 11412, 63, 5503, 63, 739, 275, 11920, 7465, 2927, 8, 272, 283, 14151, 55, 12362, 5929, 63, 739, 297, 29669, 1524, 55, 12362, 63, 5670, 63, 14528, 12, 286, 63, 1560, 63, 80, 467, 4618, 514, 29, 31080, 63, 14528, 12, 2329, 1074, 29, 1074, 63, 6481, 199, 9, 199, 3, 22561, 6261, 14975, 199, 11412, 63, 5491, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 6261, 63, 981, 297, 4618, 514, 29, 55, 12362, 63, 10387, 63, 14528, 9, 199, 11412, 63, 5491, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 6261, 63, 7237, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 566, 199, 199, 11412, 63, 5491, 63, 952, 275, 11920, 7465, 2927, 8, 272, 283, 14151, 55, 12362, 6261, 63, 952, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 12, 8991, 7474, 63, 14528, 467, 4618, 514, 29, 12151, 63, 1560, 63, 80, 12, 2329, 1074, 29, 1074, 63, 875, 199, 9, 421, 199, 533, 22561, 2959, 19156, 8, 31887, 2927, 304, 272, 347, 664, 63, 1532, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 1613, 8, 55, 12362, 2959, 19156, 12, 291, 680, 362, 63, 1532, 2031, 589, 12, 1011, 958, 9, 267, 871, 4281, 26, 288, 327, 11920, 55, 12362, 6261, 63, 362, 15, 409, 2959, 17905, 965, 2757, 21399, 315, 11920, 650, 14, 19, 14, 16, 288, 327, 16763, 372, 499, 340, 440, 2808, 288, 372, 469, 355, 283, 14151, 55, 12362, 6261, 63, 362, 2959, 17905, 356, 2400, 12448, 26, 499, 12, 355, 283, 14151, 55, 12362, 6261, 63, 409, 2959, 17905, 356, 2400, 12448, 12, 8134, 26, 488, 12, 288, 789, 14, 362, 8, 277, 14, 1532, 63, 354, 9, 199, 199, 11412, 63, 5491, 63, 362, 63, 548, 3572, 275, 22561, 2959, 19156, 8, 272, 283, 14151, 55, 12362, 6261, 63, 362, 2959, 17905, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 467, 4618, 514, 29, 67, 63, 442, 199, 9, 199, 11412, 63, 5491, 63, 409, 63, 548, 3572, 275, 22561, 2959, 19156, 8, 272, 283, 14151, 55, 12362, 6261, 63, 409, 2959, 17905, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 12, 286, 63, 442, 61, 199, 9, 199, 199, 3, 644, 12780, 5929, 14975, 199, 18914, 63, 5503, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 28328, 5929, 63, 981, 297, 4618, 514, 29, 28328, 63, 5670, 63, 14528, 9, 199, 18914, 63, 5503, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 28328, 5929, 63, 7237, 297, 29669, 1524, 28328, 63, 5670, 63, 14528, 566, 421, 199, 533, 644, 12780, 3284, 7465, 8, 31887, 2927, 304, 272, 327, 4580, 15401, 314, 805, 10269, 5452, 658, 1297, 7381, 1495, 627, 64, 272, 327, 465, 3932, 2725, 12, 781, 675, 286, 63, 1560, 63, 80, 2348, 880, 314, 805, 1443, 272, 327, 5452, 2018, 3326, 5370, 465, 2633, 14, 221, 1010, 2441, 2018, 2337, 272, 327, 365, 440, 282, 8865, 3382, 10514, 436, 7381, 4110, 12, 880, 272, 327, 652, 365, 440, 282, 5160, 14, 272, 29669, 275, 359, 28328, 63, 5670, 63, 14528, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 890, 63, 84, 61, 272, 4618, 514, 275, 8991, 7474, 63, 14528, 272, 2329, 1074, 275, 12822, 8, 1074, 63, 6481, 9, 421, 199, 18914, 63, 5503, 63, 739, 275, 644, 12780, 3284, 7465, 360, 14151, 28328, 5929, 63, 739, 358, 199, 18914, 63, 5503, 63, 739, 63, 4097, 275, 644, 12780, 3284, 7465, 360, 14151, 28328, 5929, 63, 739, 21377, 358, 199, 199, 3, 644, 12780, 6261, 14975, 199, 18914, 63, 5491, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 28328, 6261, 63, 981, 297, 4618, 514, 29, 28328, 63, 10387, 63, 14528, 9, 199, 18914, 63, 5491, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 28328, 6261, 63, 7237, 297, 29669, 1524, 28328, 63, 10387, 63, 14528, 566, 421, 199, 3, 644, 12780, 12859, 1337, 19393, 83, 14, 199, 533, 644, 12780, 3534, 7465, 8, 31887, 2927, 304, 272, 29669, 275, 359, 28328, 63, 10387, 63, 14528, 12, 8991, 7474, 63, 14528, 12, 6569, 8, 67, 63, 890, 63, 84 ]
[ 5796, 199, 504, 5577, 492, 6569, 12, 21730, 12, 15968, 12, 286, 63, 1560, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 442, 12, 286, 63, 890, 63, 84, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 1095, 492, 11920, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 12, 11920, 7465, 2927, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 21205, 492, 334, 272, 1104, 63, 6481, 12, 1104, 63, 15308, 63, 875, 12, 1104, 63, 875, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 6481, 492, 286, 63, 85, 1560, 63, 80, 12, 30259, 63, 1560, 63, 80, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 421, 199, 3, 6754, 710, 644, 12780, 15, 55, 12362, 23099, 15, 6261, 13955, 436, 21116, 6754, 199, 533, 22561, 5929, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 22561, 6261, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 644, 12780, 5929, 63, 270, 8, 10766, 304, 272, 986, 421, 199, 533, 644, 12780, 6261, 63, 270, 8, 10766, 304, 272, 986, 199, 199, 55, 12362, 63, 5670, 63, 14528, 275, 6569, 8, 55, 12362, 5929, 63, 270, 9, 199, 55, 12362, 63, 10387, 63, 14528, 275, 6569, 8, 55, 12362, 6261, 63, 270, 9, 199, 28328, 63, 5670, 63, 14528, 275, 6569, 8, 28328, 5929, 63, 270, 9, 199, 28328, 63, 10387, 63, 14528, 275, 6569, 8, 28328, 5929, 63, 270, 9, 199, 199, 3, 22561, 5929, 14975, 199, 11412, 63, 5503, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 5929, 63, 981, 297, 4618, 514, 29, 55, 12362, 63, 5670, 63, 14528, 9, 199, 11412, 63, 5503, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 5929, 63, 7237, 297, 29669, 1524, 55, 12362, 63, 5670, 63, 14528, 566, 199, 199, 11412, 63, 5503, 63, 739, 275, 11920, 7465, 2927, 8, 272, 283, 14151, 55, 12362, 5929, 63, 739, 297, 29669, 1524, 55, 12362, 63, 5670, 63, 14528, 12, 286, 63, 1560, 63, 80, 467, 4618, 514, 29, 31080, 63, 14528, 12, 2329, 1074, 29, 1074, 63, 6481, 199, 9, 199, 3, 22561, 6261, 14975, 199, 11412, 63, 5491, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 6261, 63, 981, 297, 4618, 514, 29, 55, 12362, 63, 10387, 63, 14528, 9, 199, 11412, 63, 5491, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 55, 12362, 6261, 63, 7237, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 566, 199, 199, 11412, 63, 5491, 63, 952, 275, 11920, 7465, 2927, 8, 272, 283, 14151, 55, 12362, 6261, 63, 952, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 12, 8991, 7474, 63, 14528, 467, 4618, 514, 29, 12151, 63, 1560, 63, 80, 12, 2329, 1074, 29, 1074, 63, 875, 199, 9, 421, 199, 533, 22561, 2959, 19156, 8, 31887, 2927, 304, 272, 347, 664, 63, 1532, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 1613, 8, 55, 12362, 2959, 19156, 12, 291, 680, 362, 63, 1532, 2031, 589, 12, 1011, 958, 9, 267, 871, 4281, 26, 288, 327, 11920, 55, 12362, 6261, 63, 362, 15, 409, 2959, 17905, 965, 2757, 21399, 315, 11920, 650, 14, 19, 14, 16, 288, 327, 16763, 372, 499, 340, 440, 2808, 288, 372, 469, 355, 283, 14151, 55, 12362, 6261, 63, 362, 2959, 17905, 356, 2400, 12448, 26, 499, 12, 355, 283, 14151, 55, 12362, 6261, 63, 409, 2959, 17905, 356, 2400, 12448, 12, 8134, 26, 488, 12, 288, 789, 14, 362, 8, 277, 14, 1532, 63, 354, 9, 199, 199, 11412, 63, 5491, 63, 362, 63, 548, 3572, 275, 22561, 2959, 19156, 8, 272, 283, 14151, 55, 12362, 6261, 63, 362, 2959, 17905, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 467, 4618, 514, 29, 67, 63, 442, 199, 9, 199, 11412, 63, 5491, 63, 409, 63, 548, 3572, 275, 22561, 2959, 19156, 8, 272, 283, 14151, 55, 12362, 6261, 63, 409, 2959, 17905, 297, 29669, 1524, 55, 12362, 63, 10387, 63, 14528, 12, 286, 63, 442, 61, 199, 9, 199, 199, 3, 644, 12780, 5929, 14975, 199, 18914, 63, 5503, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 28328, 5929, 63, 981, 297, 4618, 514, 29, 28328, 63, 5670, 63, 14528, 9, 199, 18914, 63, 5503, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 28328, 5929, 63, 7237, 297, 29669, 1524, 28328, 63, 5670, 63, 14528, 566, 421, 199, 533, 644, 12780, 3284, 7465, 8, 31887, 2927, 304, 272, 327, 4580, 15401, 314, 805, 10269, 5452, 658, 1297, 7381, 1495, 627, 64, 272, 327, 465, 3932, 2725, 12, 781, 675, 286, 63, 1560, 63, 80, 2348, 880, 314, 805, 1443, 272, 327, 5452, 2018, 3326, 5370, 465, 2633, 14, 221, 1010, 2441, 2018, 2337, 272, 327, 365, 440, 282, 8865, 3382, 10514, 436, 7381, 4110, 12, 880, 272, 327, 652, 365, 440, 282, 5160, 14, 272, 29669, 275, 359, 28328, 63, 5670, 63, 14528, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 890, 63, 84, 61, 272, 4618, 514, 275, 8991, 7474, 63, 14528, 272, 2329, 1074, 275, 12822, 8, 1074, 63, 6481, 9, 421, 199, 18914, 63, 5503, 63, 739, 275, 644, 12780, 3284, 7465, 360, 14151, 28328, 5929, 63, 739, 358, 199, 18914, 63, 5503, 63, 739, 63, 4097, 275, 644, 12780, 3284, 7465, 360, 14151, 28328, 5929, 63, 739, 21377, 358, 199, 199, 3, 644, 12780, 6261, 14975, 199, 18914, 63, 5491, 63, 981, 275, 11920, 7465, 2927, 360, 14151, 28328, 6261, 63, 981, 297, 4618, 514, 29, 28328, 63, 10387, 63, 14528, 9, 199, 18914, 63, 5491, 63, 7237, 275, 11920, 7465, 2927, 360, 14151, 28328, 6261, 63, 7237, 297, 29669, 1524, 28328, 63, 10387, 63, 14528, 566, 421, 199, 3, 644, 12780, 12859, 1337, 19393, 83, 14, 199, 533, 644, 12780, 3534, 7465, 8, 31887, 2927, 304, 272, 29669, 275, 359, 28328, 63, 10387, 63, 14528, 12, 8991, 7474, 63, 14528, 12, 6569, 8, 67, 63, 890, 63, 84, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lynndotconfig/server-tools
base_optional_quick_create/model.py
41
2507
# -*- coding: utf-8 -*- ############################################################################## # # Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.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 orm, fields from openerp import SUPERUSER_ID from openerp.tools.translate import _ class ir_model(orm.Model): _inherit = 'ir.model' _columns = { 'avoid_quick_create': fields.boolean('Avoid quick create'), } def _wrap_name_create(self, old_create, model): def wrapper(cr, uid, name, context=None): raise orm.except_orm( _('Error'), _("Can't create quickly. Opening create form")) return wrapper def _register_hook(self, cr, ids=None): if ids is None: ids = self.search(cr, SUPERUSER_ID, []) for model in self.browse(cr, SUPERUSER_ID, ids): if model.avoid_quick_create: model_name = model.model model_obj = self.pool.get(model_name) if model_obj and not hasattr(model_obj, 'check_quick_create'): model_obj.name_create = self._wrap_name_create( model_obj.name_create, model_name) model_obj.check_quick_create = True return True def create(self, cr, uid, vals, context=None): res_id = super(ir_model, self).create(cr, uid, vals, context=context) self._register_hook(cr, [res_id]) return res_id def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] res = super(ir_model, self).write(cr, uid, ids, vals, context=context) self._register_hook(cr, ids) return res
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6171, 21582, 441, 23813, 5611, 308, 643, 76, 8642, 1014, 921, 1544, 14, 643, 441, 6856, 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, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 8190, 63, 1238, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1238, 7, 339, 485, 3406, 275, 469, 267, 283, 27403, 63, 13239, 63, 981, 356, 1504, 14, 4871, 360, 33, 1647, 12530, 1218, 659, 267, 789, 339, 347, 485, 3823, 63, 354, 63, 981, 8, 277, 12, 2269, 63, 981, 12, 1402, 304, 267, 347, 4975, 8, 1556, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 288, 746, 9813, 14, 2590, 63, 1025, 8, 355, 4018, 547, 659, 355, 3824, 6049, 1133, 1218, 23661, 14, 3232, 316, 1218, 1824, 2237, 267, 372, 4975, 339, 347, 485, 2683, 63, 3664, 8, 277, 12, 2467, 12, 2762, 29, 403, 304, 267, 340, 2762, 365, 488, 26, 288, 2762, 275, 291, 14, 1733, 8, 1556, 12, 12824, 63, 998, 12, 3073, 267, 367, 1402, 315, 291, 14, 4570, 8, 1556, 12, 12824, 63, 998, 12, 2762, 304, 288, 340, 1402, 14, 27403, 63, 13239, 63, 981, 26, 355, 1402, 63, 354, 275, 1402, 14, 1238, 355, 1402, 63, 1113, 275, 291, 14, 2293, 14, 362, 8, 1238, 63, 354, 9, 355, 340, 1402, 63, 1113, 436, 440, 2688, 8, 1238, 63, 1113, 12, 283, 1074, 63, 13239, 63, 981, 735, 490, 1402, 63, 1113, 14, 354, 63, 981, 275, 291, 423, 3823, 63, 354, 63, 981, 8, 717, 1402, 63, 1113, 14, 354, 63, 981, 12, 1402, 63, 354, 9, 490, 1402, 63, 1113, 14, 1074, 63, 13239, 63, 981, 275, 715, 267, 372, 715, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 522, 63, 344, 275, 1613, 8, 723, 63, 1238, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 267, 291, 423, 2683, 63, 3664, 8, 1556, 12, 359, 470, 63, 344, 566, 267, 372, 522, 63, 344, 339, 347, 2218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 403, 304, 267, 340, 1228, 8, 1580, 12, 334, 442, 12, 1846, 2298, 288, 2762, 275, 359, 1580, 61, 267, 522, 275, 1613, 8, 723, 63, 1238, 12, 291, 680, 952, 8, 1556, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 1100, 9, 267, 291, 423, 2683, 63, 3664, 8, 1556, 12, 2762, 9, 267, 372, 522, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6171, 21582, 441, 23813, 5611, 308, 643, 76, 8642, 1014, 921, 1544, 14, 643, 441, 6856, 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, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 8190, 63, 1238, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1238, 7, 339, 485, 3406, 275, 469, 267, 283, 27403, 63, 13239, 63, 981, 356, 1504, 14, 4871, 360, 33, 1647, 12530, 1218, 659, 267, 789, 339, 347, 485, 3823, 63, 354, 63, 981, 8, 277, 12, 2269, 63, 981, 12, 1402, 304, 267, 347, 4975, 8, 1556, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 288, 746, 9813, 14, 2590, 63, 1025, 8, 355, 4018, 547, 659, 355, 3824, 6049, 1133, 1218, 23661, 14, 3232, 316, 1218, 1824, 2237, 267, 372, 4975, 339, 347, 485, 2683, 63, 3664, 8, 277, 12, 2467, 12, 2762, 29, 403, 304, 267, 340, 2762, 365, 488, 26, 288, 2762, 275, 291, 14, 1733, 8, 1556, 12, 12824, 63, 998, 12, 3073, 267, 367, 1402, 315, 291, 14, 4570, 8, 1556, 12, 12824, 63, 998, 12, 2762, 304, 288, 340, 1402, 14, 27403, 63, 13239, 63, 981, 26, 355, 1402, 63, 354, 275, 1402, 14, 1238, 355, 1402, 63, 1113, 275, 291, 14, 2293, 14, 362, 8, 1238, 63, 354, 9, 355, 340, 1402, 63, 1113, 436, 440, 2688, 8, 1238, 63, 1113, 12, 283, 1074, 63, 13239, 63, 981, 735, 490, 1402, 63, 1113, 14, 354, 63, 981, 275, 291, 423, 3823, 63, 354, 63, 981, 8, 717, 1402, 63, 1113, 14, 354, 63, 981, 12, 1402, 63, 354, 9, 490, 1402, 63, 1113, 14, 1074, 63, 13239, 63, 981, 275, 715, 267, 372, 715, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 522, 63, 344, 275, 1613, 8, 723, 63, 1238, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 267, 291, 423, 2683, 63, 3664, 8, 1556, 12, 359, 470, 63, 344, 566, 267, 372, 522, 63, 344, 339, 347, 2218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 403, 304, 267, 340, 1228, 8, 1580, 12, 334, 442, 12, 1846, 2298, 288, 2762, 275, 359, 1580, 61, 267, 522, 275, 1613, 8, 723, 63, 1238, 12, 291, 680, 952, 8, 1556, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 1100, 9, 267, 291, 423, 2683, 63, 3664, 8, 1556, 12, 2762, 9, 267, 372, 522, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
niklasberglund/freesprints
source/freesprints/__init__.py
1
9191
import pygame, sys import pygame.font from pygame.locals import * import logging import fs_menu import helpers as helpers import plugins import os.path import race import hardware import defaults import logging from rainbow_logging_handler import RainbowLoggingHandler DISPLAY_RESOLUTION = (1024, 768) # platform-specific imports if helpers.is_running_on_rpi():# running on Raspberry Pi import RPi.GPIO import os print "ON RASPBERRY PI" #os.environ['SDL_VIDEODRIVER']="fbcon" #os.environ["SDL_FBDEV"] = "/dev/fb1" print "SET DRIVER" else: # running on computer import FakeRPi.GPIO class Application(object): instance = None state = None # application state constants STATE_MAINMENU = 0 STATE_INGAME = 1 # member variables window_surface = None menu_surface = None menu = None state = STATE_MAINMENU plugin_loader = None roller_controller = None race_options = None race_object = None selected_plugin_index = 0 # 0 by default. this should ideally be restored from stored settings def __init__(self): print "Application.__init__" pygame.font.init() menu_options_dict = { "font_path": "fonts/Cave-Story.ttf", "font_size": 42, "color_background": (0, 0, 0), "color_text": (255, 255, 255), "color_text_highlight": (100, 20, 45) } menu_structure = [ { "title": "New race", "callback": self.start_race, "submenu": [ { "title": "Start", "callback": self.start_race }, { "title": "Race visualizer", "callback": None, "submenu_populator_callback": self.populate_visualizers, "identifier": "race_visualizer_selection" }, { "title": "Number of rollers", "input": { "type": "int", "verifier": None, "value": "2" }, "callback": self.start_race }, { "title": "Roller diameter(mm)", "input": { "type": "int", "verifier": None, "value": "200" } } ] }, { "title": "Options", "callback": self.show_options }, { "title": "Exit", "callback": self.exit } ] #self.window_surface = pygame.display.set_mode((500, 400), pygame.FULLSCREEN, 32) pygame.display.init() self.window_surface = pygame.display.set_mode(defaults.RESOLUTION, 0, 32) menu_options = fs_menu.MenuOptions(menu_options_dict) self.menu = fs_menu.Menu(self.window_surface, menu_structure, menu_options) self.roller_controller = hardware.RollerController() def load_plugins(self): self.plugin_loader = plugins.PluginLoader() def start_race(self): print "start game" self.state = self.STATE_INGAME race_options = race.Options() race_participants = ([ race.Participant("Niklas", 7, Color("red")), race.Participant("Some loser", 11, Color("blue")) ]) self.race_object = race.Race(race_options, race_participants) plugins = self.plugin_loader.getAvailablePlugins() self.race_object.start() plugins[self.selected_plugin_index].start(self.race_object) def show_options(self): print "show options" def populate_visualizers(self): print "populate_visualizers" submenu = [] pluginIndex = 0 for plugin in self.plugin_loader.getAvailablePlugins(): submenu.append({ "title": plugin.name, "callback": self.select_plugin, "tag": pluginIndex }) pluginIndex = pluginIndex + 1 return submenu def select_plugin(self, plugin_index): print "selected plugin with index " + str(plugin_index) self.selected_plugin_index = plugin_index def exit(self): pygame.quit() sys.exit() def hide(self): pass def get_window_surface(self): return self.window_surface def game_loop(self): # run the game loop while True: for event in pygame.event.get(): if event.type == pygame.locals.QUIT: self.exit() elif event.type == pygame.locals.KEYUP: if self.state == self.STATE_MAINMENU: self.menu.registerKeypress(event.key) elif event.key == pygame.locals.K_ESCAPE: self.exit() def start(self): # set up pygame pygame.init() pygame.font.init() if helpers.is_running_on_rpi(): disp_no = os.getenv("DISPLAY") if disp_no: print "I'm running under X display = {0}".format(disp_no) # Check which frame buffer drivers are available # Start with fbcon since directfb hangs with composite output drivers = ['fbcon', 'directfb', 'svgalib'] found = False for driver in drivers: # Make sure that SDL_VIDEODRIVER is set if not os.getenv('SDL_VIDEODRIVER'): os.putenv('SDL_VIDEODRIVER', driver) try: pygame.display.init() except pygame.error: print 'Driver: {0} failed.'.format(driver) continue found = True break if not found: raise Exception('No suitable video driver found!') size = (pygame.display.Info().current_w, pygame.display.Info().current_h) print "Framebuffer size: %d x %d" % (size[0], size[1]) #self.window_surface = pygame.display.set_mode(size, pygame.FULLSCREEN) # set up the window pygame.display.set_caption('Freesprints') # set up the colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) # set up fonts #availableFonts = pygame.font.get_fonts() font_path = "./fonts/Cave-Story.ttf" #basicFont = pygame.font.SysFont(None, 30) basicFont = pygame.font.Font(font_path, 48) # set up the text #text = basicFont.render('asdasd', True, WHITE, BLUE) #textRect = text.get_rect() #textRect.centerx = self.window_surface.get_rect().centerx #textRect.centery = self.window_surface.get_rect().centery # draw the white background onto the surface self.window_surface.fill(BLACK) # draw a green polygon onto the surface #pygame.draw.polygon(self.window_surface, GREEN, ((146, 0), (291, 106), (236, 277), (56, 277), (0, 106))) # draw some blue lines onto the surface #pygame.draw.line(self.window_surface, BLUE, (60, 60), (120, 60), 4) #pygame.draw.line(self.window_surface, BLUE, (120, 60), (60, 120)) #pygame.draw.line(self.window_surface, BLUE, (60, 120), (120, 120), 4) # draw a blue circle onto the surface #pygame.draw.circle(self.window_surface, BLUE, (300, 50), 20, 0) # draw a red ellipse onto the surface #pygame.draw.ellipse(self.window_surface, RED, (450, 160, 40, 80), 1) # menu background background = pygame.image.load('images/menu_background.png').convert() backgroundRect = background.get_rect() backgroundRect.x = 0 backgroundRect.y = 0 self.window_surface.blit(background, backgroundRect) # draw the window onto the screen pygame.display.update() self.menu.render() self.game_loop() app = None logger = None def get_app(): global app if app == None: app = Application() return app def get_logger(): global logger if logger == None: logger = logging.getLogger('freesprints') logger.setLevel(logging.DEBUG) formatter = logging.Formatter("[%(asctime)s] %(name)s %(funcName)s():%(lineno)d\t%(message)s") # same as default # setup colored logging handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True)) handler.setFormatter(formatter) logger.addHandler(handler) return logger def init(): global app print "start" app = get_app() app.load_plugins() app.start()
mit
[ 646, 9193, 12, 984, 199, 646, 9193, 14, 4246, 199, 504, 9193, 14, 9350, 492, 627, 199, 646, 2050, 199, 646, 7449, 63, 4470, 199, 646, 10897, 465, 10897, 199, 646, 8963, 199, 646, 747, 14, 515, 199, 646, 21209, 199, 646, 14991, 199, 646, 4243, 199, 646, 2050, 199, 504, 660, 262, 22856, 63, 4806, 63, 2232, 492, 820, 1581, 22856, 14054, 2461, 199, 199, 20993, 63, 3830, 2228, 27129, 275, 334, 7727, 12, 32404, 9, 199, 199, 3, 4298, 13, 6100, 8925, 199, 692, 10897, 14, 374, 63, 5720, 63, 265, 63, 82, 1038, 837, 3, 3879, 641, 820, 20222, 605, 651, 19835, 272, 492, 820, 10542, 14, 21071, 272, 492, 747, 272, 870, 298, 615, 820, 1179, 13167, 2666, 57, 16678, 2, 272, 327, 736, 14, 2314, 459, 14029, 63, 20142, 23401, 418, 628, 4675, 388, 2, 272, 327, 736, 14, 2314, 905, 14029, 63, 8223, 13260, 937, 275, 3286, 2374, 15, 4675, 17, 2, 272, 870, 298, 3597, 577, 6129, 2111, 2, 199, 2836, 26, 327, 3879, 641, 24189, 272, 492, 7777, 50, 10542, 14, 21071, 421, 199, 533, 13515, 8, 785, 304, 272, 1256, 275, 488, 272, 1174, 275, 488, 2286, 327, 4223, 1174, 5262, 272, 11377, 63, 5848, 18223, 275, 378, 272, 11377, 63, 1206, 1991, 275, 413, 339, 327, 3653, 2860, 272, 4353, 63, 10992, 275, 488, 272, 6269, 63, 10992, 275, 488, 272, 6269, 275, 488, 272, 1174, 275, 11377, 63, 5848, 18223, 272, 3589, 63, 3422, 275, 488, 272, 20182, 1435, 63, 5538, 275, 488, 272, 21209, 63, 1419, 275, 488, 272, 21209, 63, 785, 275, 488, 272, 4895, 63, 2718, 63, 1080, 275, 378, 327, 378, 701, 849, 14, 642, 1077, 9979, 1183, 506, 14429, 687, 5489, 2202, 339, 347, 636, 826, 721, 277, 304, 267, 870, 298, 5039, 855, 826, 16526, 398, 9193, 14, 4246, 14, 826, 342, 398, 6269, 63, 1419, 63, 807, 275, 469, 288, 298, 4246, 63, 515, 582, 298, 19864, 15, 35, 811, 13, 25120, 14, 32264, 401, 288, 298, 4246, 63, 890, 582, 5685, 12, 288, 298, 2326, 63, 7451, 582, 334, 16, 12, 378, 12, 378, 395, 288, 298, 2326, 63, 505, 582, 334, 2299, 12, 5450, 12, 5450, 395, 288, 298, 2326, 63, 505, 63, 14337, 582, 334, 1960, 12, 3388, 12, 10416, 9, 267, 789, 398, 6269, 63, 6976, 275, 359, 288, 469, 355, 298, 1213, 582, 298, 4665, 21209, 401, 355, 298, 3058, 582, 291, 14, 928, 63, 5986, 12, 355, 298, 954, 4470, 582, 359, 490, 469, 717, 298, 1213, 582, 298, 3162, 401, 717, 298, 3058, 582, 291, 14, 928, 63, 5986, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 1537, 301, 13104, 1793, 401, 717, 298, 3058, 582, 488, 12, 717, 298, 954, 4470, 63, 1935, 6109, 63, 3058, 582, 291, 14, 13817, 63, 16948, 6315, 12, 717, 298, 5364, 582, 298, 5986, 63, 16948, 1793, 63, 5592, 2, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 3259, 402, 20182, 29099, 401, 717, 298, 1210, 582, 469, 1169, 298, 466, 582, 298, 442, 401, 1169, 298, 21227, 582, 488, 12, 1169, 298, 585, 582, 298, 18, 2, 717, 1660, 717, 298, 3058, 582, 291, 14, 928, 63, 5986, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 50, 393, 1435, 487, 1787, 8, 596, 4186, 717, 298, 1210, 582, 469, 1169, 298, 466, 582, 298, 442, 401, 1169, 298, 21227, 582, 488, 12, 1169, 298, 585, 582, 298, 1840, 2, 717, 789, 490, 789, 355, 1622, 288, 1660, 288, 469, 355, 298, 1213, 582, 298, 4558, 401, 355, 298, 3058, 582, 291, 14, 2384, 63, 1419, 288, 1660, 288, 469, 355, 298, 1213, 582, 298, 6699, 401, 355, 298, 3058, 582, 291, 14, 2224, 288, 789, 267, 1622, 267, 327, 277, 14, 3806, 63, 10992, 275, 9193, 14, 2918, 14, 409, 63, 632, 1332, 5783, 12, 8290, 395, 9193, 14, 14742, 25070, 12, 4337, 9, 267, 9193, 14, 2918, 14, 826, 342, 267, 291, 14, 3806, 63, 10992, 275, 9193, 14, 2918, 14, 409, 63, 632, 8, 4322, 14, 3830, 2228, 27129, 12, 378, 12, 4337, 9, 398, 6269, 63, 1419, 275, 7449, 63, 4470, 14, 5977, 4558, 8, 4470, 63, 1419, 63, 807, 9, 267, 291, 14, 4470, 275, 7449, 63, 4470, 14, 5977, 8, 277, 14, 3806, 63, 10992, 12, 6269, 63, 6976, 12, 6269, 63, 1419, 9, 2728, 291, 14, 8459, 1435, 63, 5538, 275, 14991, 14, 50, 393, 1435, 7506, 342, 339, 347, 2248, 63, 5265, 8, 277, 304, 267, 291, 14, 2718, 63, 3422, 275, 8963, 14, 5061, 5455, 342, 339, 347, 1343, 63, 5986, 8, 277, 304, 267, 870, 298, 928, 9219, 2, 267, 291, 14, 929, 275, 291, 14, 6689, 63, 1206, 1991, 2728, 21209, 63, 1419, 275, 21209, 14, 4558, 342, 267, 21209, 63, 31790, 275, 7287, 288, 21209, 14, 1262, 16448, 480, 46, 3258, 12536, 401, 1520, 12, 11581, 480, 581, 8150, 288, 21209, 14, 1262, 16448, 480, 7700, 560, 332, 401, 4119, 12, 11581, 480, 6304, 2237, 267, 4794, 2728, 291, 14, 5986, 63, 785, 275, 21209, 14, 1537, 301, 8, 5986, 63, 1419, 12, 21209, 63, 31790, 9, 2728, 8963, 275, 291, 14, 2718, 63, 3422, 14, 362, 11464, 19330, 342, 2728, 291, 14, 5986, 63, 785, 14, 928, 342, 267, 8963, 59, 277, 14, 5511, 63, 2718, 63, 1080, 1055, 928, 8, 277, 14, 5986, 63, 785, 9, 339, 347, 2498, 63, 1419, 8, 277, 304, 267, 870, 298, 2384, 1511, 2, 339, 347, 13904, 63, 16948, 6315, 8, 277, 304, 267, 870, 298, 13817, 63, 16948, 6315, 2, 2728, 1007, 4470, 275, 942, 267, 3589, 2681, 275, 378, 2728, 367, 3589, 315, 291, 14, 2718, 63, 3422, 14, 362, 11464, 19330, 837, 288, 1007, 4470, 14, 740, 2561, 355, 298, 1213, 582, 3589, 14, 354, 12, 355, 298, 3058, 582, 291, 14, 2416, 63, 2718, 12, 355, 298, 1450, 582, 3589, 2681, 288, 3828, 7846, 3589, 2681, 275, 3589, 2681, 435, 413, 2728, 372, 1007, 4470, 339, 347, 3504, 63, 2718, 8, 277, 12, 3589, 63, 1080, 304, 267, 870, 298, 5511, 3589, 543, 1478, 298, 435, 620, 8, 2718, 63, 1080, 9, 267, 291, 14 ]
[ 9193, 12, 984, 199, 646, 9193, 14, 4246, 199, 504, 9193, 14, 9350, 492, 627, 199, 646, 2050, 199, 646, 7449, 63, 4470, 199, 646, 10897, 465, 10897, 199, 646, 8963, 199, 646, 747, 14, 515, 199, 646, 21209, 199, 646, 14991, 199, 646, 4243, 199, 646, 2050, 199, 504, 660, 262, 22856, 63, 4806, 63, 2232, 492, 820, 1581, 22856, 14054, 2461, 199, 199, 20993, 63, 3830, 2228, 27129, 275, 334, 7727, 12, 32404, 9, 199, 199, 3, 4298, 13, 6100, 8925, 199, 692, 10897, 14, 374, 63, 5720, 63, 265, 63, 82, 1038, 837, 3, 3879, 641, 820, 20222, 605, 651, 19835, 272, 492, 820, 10542, 14, 21071, 272, 492, 747, 272, 870, 298, 615, 820, 1179, 13167, 2666, 57, 16678, 2, 272, 327, 736, 14, 2314, 459, 14029, 63, 20142, 23401, 418, 628, 4675, 388, 2, 272, 327, 736, 14, 2314, 905, 14029, 63, 8223, 13260, 937, 275, 3286, 2374, 15, 4675, 17, 2, 272, 870, 298, 3597, 577, 6129, 2111, 2, 199, 2836, 26, 327, 3879, 641, 24189, 272, 492, 7777, 50, 10542, 14, 21071, 421, 199, 533, 13515, 8, 785, 304, 272, 1256, 275, 488, 272, 1174, 275, 488, 2286, 327, 4223, 1174, 5262, 272, 11377, 63, 5848, 18223, 275, 378, 272, 11377, 63, 1206, 1991, 275, 413, 339, 327, 3653, 2860, 272, 4353, 63, 10992, 275, 488, 272, 6269, 63, 10992, 275, 488, 272, 6269, 275, 488, 272, 1174, 275, 11377, 63, 5848, 18223, 272, 3589, 63, 3422, 275, 488, 272, 20182, 1435, 63, 5538, 275, 488, 272, 21209, 63, 1419, 275, 488, 272, 21209, 63, 785, 275, 488, 272, 4895, 63, 2718, 63, 1080, 275, 378, 327, 378, 701, 849, 14, 642, 1077, 9979, 1183, 506, 14429, 687, 5489, 2202, 339, 347, 636, 826, 721, 277, 304, 267, 870, 298, 5039, 855, 826, 16526, 398, 9193, 14, 4246, 14, 826, 342, 398, 6269, 63, 1419, 63, 807, 275, 469, 288, 298, 4246, 63, 515, 582, 298, 19864, 15, 35, 811, 13, 25120, 14, 32264, 401, 288, 298, 4246, 63, 890, 582, 5685, 12, 288, 298, 2326, 63, 7451, 582, 334, 16, 12, 378, 12, 378, 395, 288, 298, 2326, 63, 505, 582, 334, 2299, 12, 5450, 12, 5450, 395, 288, 298, 2326, 63, 505, 63, 14337, 582, 334, 1960, 12, 3388, 12, 10416, 9, 267, 789, 398, 6269, 63, 6976, 275, 359, 288, 469, 355, 298, 1213, 582, 298, 4665, 21209, 401, 355, 298, 3058, 582, 291, 14, 928, 63, 5986, 12, 355, 298, 954, 4470, 582, 359, 490, 469, 717, 298, 1213, 582, 298, 3162, 401, 717, 298, 3058, 582, 291, 14, 928, 63, 5986, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 1537, 301, 13104, 1793, 401, 717, 298, 3058, 582, 488, 12, 717, 298, 954, 4470, 63, 1935, 6109, 63, 3058, 582, 291, 14, 13817, 63, 16948, 6315, 12, 717, 298, 5364, 582, 298, 5986, 63, 16948, 1793, 63, 5592, 2, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 3259, 402, 20182, 29099, 401, 717, 298, 1210, 582, 469, 1169, 298, 466, 582, 298, 442, 401, 1169, 298, 21227, 582, 488, 12, 1169, 298, 585, 582, 298, 18, 2, 717, 1660, 717, 298, 3058, 582, 291, 14, 928, 63, 5986, 490, 1660, 490, 469, 717, 298, 1213, 582, 298, 50, 393, 1435, 487, 1787, 8, 596, 4186, 717, 298, 1210, 582, 469, 1169, 298, 466, 582, 298, 442, 401, 1169, 298, 21227, 582, 488, 12, 1169, 298, 585, 582, 298, 1840, 2, 717, 789, 490, 789, 355, 1622, 288, 1660, 288, 469, 355, 298, 1213, 582, 298, 4558, 401, 355, 298, 3058, 582, 291, 14, 2384, 63, 1419, 288, 1660, 288, 469, 355, 298, 1213, 582, 298, 6699, 401, 355, 298, 3058, 582, 291, 14, 2224, 288, 789, 267, 1622, 267, 327, 277, 14, 3806, 63, 10992, 275, 9193, 14, 2918, 14, 409, 63, 632, 1332, 5783, 12, 8290, 395, 9193, 14, 14742, 25070, 12, 4337, 9, 267, 9193, 14, 2918, 14, 826, 342, 267, 291, 14, 3806, 63, 10992, 275, 9193, 14, 2918, 14, 409, 63, 632, 8, 4322, 14, 3830, 2228, 27129, 12, 378, 12, 4337, 9, 398, 6269, 63, 1419, 275, 7449, 63, 4470, 14, 5977, 4558, 8, 4470, 63, 1419, 63, 807, 9, 267, 291, 14, 4470, 275, 7449, 63, 4470, 14, 5977, 8, 277, 14, 3806, 63, 10992, 12, 6269, 63, 6976, 12, 6269, 63, 1419, 9, 2728, 291, 14, 8459, 1435, 63, 5538, 275, 14991, 14, 50, 393, 1435, 7506, 342, 339, 347, 2248, 63, 5265, 8, 277, 304, 267, 291, 14, 2718, 63, 3422, 275, 8963, 14, 5061, 5455, 342, 339, 347, 1343, 63, 5986, 8, 277, 304, 267, 870, 298, 928, 9219, 2, 267, 291, 14, 929, 275, 291, 14, 6689, 63, 1206, 1991, 2728, 21209, 63, 1419, 275, 21209, 14, 4558, 342, 267, 21209, 63, 31790, 275, 7287, 288, 21209, 14, 1262, 16448, 480, 46, 3258, 12536, 401, 1520, 12, 11581, 480, 581, 8150, 288, 21209, 14, 1262, 16448, 480, 7700, 560, 332, 401, 4119, 12, 11581, 480, 6304, 2237, 267, 4794, 2728, 291, 14, 5986, 63, 785, 275, 21209, 14, 1537, 301, 8, 5986, 63, 1419, 12, 21209, 63, 31790, 9, 2728, 8963, 275, 291, 14, 2718, 63, 3422, 14, 362, 11464, 19330, 342, 2728, 291, 14, 5986, 63, 785, 14, 928, 342, 267, 8963, 59, 277, 14, 5511, 63, 2718, 63, 1080, 1055, 928, 8, 277, 14, 5986, 63, 785, 9, 339, 347, 2498, 63, 1419, 8, 277, 304, 267, 870, 298, 2384, 1511, 2, 339, 347, 13904, 63, 16948, 6315, 8, 277, 304, 267, 870, 298, 13817, 63, 16948, 6315, 2, 2728, 1007, 4470, 275, 942, 267, 3589, 2681, 275, 378, 2728, 367, 3589, 315, 291, 14, 2718, 63, 3422, 14, 362, 11464, 19330, 837, 288, 1007, 4470, 14, 740, 2561, 355, 298, 1213, 582, 3589, 14, 354, 12, 355, 298, 3058, 582, 291, 14, 2416, 63, 2718, 12, 355, 298, 1450, 582, 3589, 2681, 288, 3828, 7846, 3589, 2681, 275, 3589, 2681, 435, 413, 2728, 372, 1007, 4470, 339, 347, 3504, 63, 2718, 8, 277, 12, 3589, 63, 1080, 304, 267, 870, 298, 5511, 3589, 543, 1478, 298, 435, 620, 8, 2718, 63, 1080, 9, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kingvuplus/PE-gui
e2reactor.py
29
5262
# enigma2 reactor: based on pollreactor, which is # Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. """ Maintainer: U{Felix Domke<mailto:tmbinc@elitedvb.net>} """ # System imports import select, errno, sys # Twisted imports from twisted.python import log, failure from twisted.internet import main, posixbase, error #from twisted.internet.pollreactor import PollReactor, poller from enigma import getApplication # globals reads = {} writes = {} selectables = {} POLL_DISCONNECTED = (select.POLLHUP | select.POLLERR | select.POLLNVAL) class E2SharedPoll: def __init__(self): self.dict = { } self.eApp = getApplication() def register(self, fd, eventmask = select.POLLIN | select.POLLERR | select.POLLOUT): self.dict[fd] = eventmask def unregister(self, fd): del self.dict[fd] def poll(self, timeout = None): try: r = self.eApp.poll(timeout, self.dict) except KeyboardInterrupt: return None return r poller = E2SharedPoll() class PollReactor(posixbase.PosixReactorBase): """A reactor that uses poll(2).""" def _updateRegistration(self, fd): """Register/unregister an fd with the poller.""" try: poller.unregister(fd) except KeyError: pass mask = 0 if reads.has_key(fd): mask = mask | select.POLLIN if writes.has_key(fd): mask = mask | select.POLLOUT if mask != 0: poller.register(fd, mask) else: if selectables.has_key(fd): del selectables[fd] poller.eApp.interruptPoll() def _dictRemove(self, selectable, mdict): try: # the easy way fd = selectable.fileno() # make sure the fd is actually real. In some situations we can get # -1 here. mdict[fd] except: # the hard way: necessary because fileno() may disappear at any # moment, thanks to python's underlying sockets impl for fd, fdes in selectables.items(): if selectable is fdes: break else: # Hmm, maybe not the right course of action? This method can't # fail, because it happens inside error detection... return if mdict.has_key(fd): del mdict[fd] self._updateRegistration(fd) def addReader(self, reader): """Add a FileDescriptor for notification of data available to read. """ fd = reader.fileno() if not reads.has_key(fd): selectables[fd] = reader reads[fd] = 1 self._updateRegistration(fd) def addWriter(self, writer, writes=writes, selectables=selectables): """Add a FileDescriptor for notification of data available to write. """ fd = writer.fileno() if not writes.has_key(fd): selectables[fd] = writer writes[fd] = 1 self._updateRegistration(fd) def removeReader(self, reader, reads=reads): """Remove a Selectable for notification of data available to read. """ return self._dictRemove(reader, reads) def removeWriter(self, writer, writes=writes): """Remove a Selectable for notification of data available to write. """ return self._dictRemove(writer, writes) def removeAll(self, reads=reads, writes=writes, selectables=selectables): """Remove all selectables, and return a list of them.""" if self.waker is not None: self.removeReader(self.waker) result = selectables.values() fds = selectables.keys() reads.clear() writes.clear() selectables.clear() for fd in fds: poller.unregister(fd) if self.waker is not None: self.addReader(self.waker) return result def doPoll(self, timeout, reads=reads, writes=writes, selectables=selectables, select=select, log=log, POLLIN=select.POLLIN, POLLOUT=select.POLLOUT): """Poll the poller for new events.""" if timeout is not None: timeout = int(timeout * 1000) # convert seconds to milliseconds try: l = poller.poll(timeout) if l is None: if self.running: self.stop() l = [ ] except select.error, e: if e[0] == errno.EINTR: return else: raise _drdw = self._doReadOrWrite for fd, event in l: try: selectable = selectables[fd] except KeyError: # Handles the infrequent case where one selectable's # handler disconnects another. continue log.callWithLogger(selectable, _drdw, selectable, fd, event, POLLIN, POLLOUT, log) doIteration = doPoll def _doReadOrWrite(self, selectable, fd, event, POLLIN, POLLOUT, log, faildict={ error.ConnectionDone: failure.Failure(error.ConnectionDone()), error.ConnectionLost: failure.Failure(error.ConnectionLost()) }): why = None inRead = False if event & POLL_DISCONNECTED and not (event & POLLIN): why = main.CONNECTION_LOST else: try: if event & POLLIN: why = selectable.doRead() inRead = True if not why and event & POLLOUT: why = selectable.doWrite() inRead = False if not selectable.fileno() == fd: why = error.ConnectionFdescWentAway('Filedescriptor went away') inRead = False except: log.deferr() why = sys.exc_info()[1] if why: self._disconnectSelectable(selectable, why, inRead) def callLater(self, *args, **kwargs): poller.eApp.interruptPoll() return posixbase.PosixReactorBase.callLater(self, *args, **kwargs) def install(): """Install the poll() reactor.""" p = PollReactor() main.installReactor(p) __all__ = ["PollReactor", "install"]
gpl-2.0
[ 3, 655, 27021, 18, 9655, 26, 4079, 641, 11271, 13544, 12, 1314, 365, 199, 3, 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 11903, 8368, 281, 26, 738, 91, 3456, 20528, 577, 676, 415, 28, 26206, 26, 84, 887, 6559, 32, 18865, 471, 18708, 14, 846, 23307, 199, 624, 199, 199, 3, 6187, 8925, 199, 646, 3504, 12, 7554, 12, 984, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 199, 504, 7390, 14, 4901, 492, 2446, 12, 10694, 1095, 12, 1125, 199, 3, 504, 7390, 14, 4901, 14, 6843, 13544, 492, 25306, 15860, 12, 28073, 199, 199, 504, 655, 27021, 492, 664, 5039, 199, 199, 3, 7992, 199, 15656, 275, 1052, 199, 16334, 275, 1052, 199, 2416, 5921, 275, 1052, 199, 199, 16428, 63, 6178, 14657, 1149, 275, 334, 2416, 14, 16428, 40, 2160, 1204, 3504, 14, 16428, 2666, 1204, 3504, 14, 16428, 46, 3204, 9, 199, 199, 533, 662, 18, 12197, 24022, 26, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 807, 275, 469, 789, 507, 198, 277, 14, 69, 2640, 275, 664, 5039, 342, 421, 198, 318, 2274, 8, 277, 12, 6111, 12, 1566, 2629, 275, 3504, 14, 16428, 568, 1204, 3504, 14, 16428, 2666, 1204, 3504, 14, 32713, 1484, 934, 304, 507, 198, 277, 14, 807, 59, 2592, 61, 275, 1566, 2629, 8299, 198, 318, 24369, 8, 277, 12, 6111, 304, 507, 198, 2264, 291, 14, 807, 59, 2592, 61, 8299, 198, 318, 11271, 8, 277, 12, 2653, 275, 488, 304, 507, 198, 893, 26, 686, 198, 82, 275, 291, 14, 69, 2640, 14, 6843, 8, 2593, 12, 291, 14, 807, 9, 507, 198, 2590, 13483, 26, 686, 198, 1107, 488, 507, 198, 1107, 519, 199, 199, 26746, 275, 662, 18, 12197, 24022, 342, 199, 199, 533, 25306, 15860, 8, 9228, 1095, 14, 1575, 4174, 15860, 1563, 304, 199, 198, 624, 33, 9655, 626, 4440, 11271, 8, 18, 10477, 421, 198, 318, 485, 873, 11757, 8, 277, 12, 6111, 304, 507, 198, 624, 7099, 15, 18408, 376, 6111, 543, 314, 28073, 1041, 507, 198, 893, 26, 686, 198, 26746, 14, 18408, 8, 2592, 9, 507, 198, 2590, 4067, 26, 686, 198, 1529, 2742, 198, 2629, 275, 378, 507, 198, 692, 11597, 14, 1989, 63, 498, 8, 2592, 304, 3656, 275, 3656, 1204, 3504, 14, 16428, 568, 507, 198, 692, 14511, 14, 1989, 63, 498, 8, 2592, 304, 3656, 275, 3656, 1204, 3504, 14, 32713, 1484, 934, 507, 198, 692, 3656, 1137, 378, 26, 686, 198, 26746, 14, 2683, 8, 2592, 12, 3656, 9, 507, 198, 2836, 26, 686, 198, 692, 3504, 5921, 14, 1989, 63, 498, 8, 2592, 304, 2150, 3504, 5921, 59, 2592, 61, 686, 9068, 198, 26746, 14, 69, 2640, 14, 20172, 24022, 342, 421, 198, 318, 485, 807, 5587, 8, 277, 12, 23378, 12, 333, 807, 304, 507, 198, 893, 26, 686, 198, 3, 314, 8837, 4340, 686, 198, 2592, 275, 23378, 14, 9843, 342, 686, 198, 3, 1852, 3238, 314, 6111, 365, 5965, 3363, 14, 221, 1010, 2005, 24325, 781, 883, 664, 686, 198, 3, 446, 17, 2348, 14, 686, 198, 77, 807, 59, 2592, 61, 507, 198, 2590, 26, 686, 198, 3, 314, 7508, 4340, 26, 5784, 2952, 25255, 342, 1443, 2153, 27307, 737, 1263, 686, 198, 3, 12427, 12, 2419, 6080, 370, 2366, 1159, 8793, 18772, 11512, 686, 198, 509, 6111, 12, 289, 3424, 315, 3504, 5921, 14, 1744, 837, 1585, 198, 692, 23378, 365, 289, 3424, 26, 1871, 198, 4785, 686, 198, 2836, 26, 1585, 198, 3, 869, 596, 12, 11703, 440, 314, 2451, 2518, 402, 1595, 31, 221, 961, 1083, 883, 1133, 1585, 198, 3, 2449, 12, 2952, 652, 10986, 6272, 1125, 15212, 1396, 1585, 198, 1107, 507, 198, 692, 333, 807, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2264, 333, 807, 59, 2592, 61, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 1050, 5929, 8, 277, 12, 7002, 304, 507, 198, 624, 1123, 282, 3814, 4311, 367, 6955, 402, 666, 2808, 370, 1586, 14, 507, 198, 624, 507, 198, 2592, 275, 7002, 14, 9843, 342, 507, 198, 692, 440, 11597, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2416, 5921, 59, 2592, 61, 275, 7002, 686, 198, 15656, 59, 2592, 61, 275, 221, 413, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 1050, 6261, 8, 277, 12, 7060, 12, 14511, 29, 16334, 12, 3504, 5921, 29, 2416, 5921, 304, 507, 198, 624, 1123, 282, 3814, 4311, 367, 6955, 402, 666, 2808, 370, 2218, 14, 507, 198, 624, 507, 198, 2592, 275, 7060, 14, 9843, 342, 507, 198, 692, 440, 14511, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2416, 5921, 59, 2592, 61, 275, 7060, 686, 198, 16334, 59, 2592, 61, 275, 221, 413, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 2813, 5929, 8, 277, 12, 7002, 12, 11597, 29, 15656, 304, 507, 198, 624, 5587, 282, 9496, 461, 367, 6955, 402, 666, 2808, 370, 1586, 14, 507, 198, 624, 507, 198, 1107, 291, 423, 807, 5587, 8, 5503, 12, 11597, 9, 421, 198, 318, 2813, 6261, 8, 277, 12, 7060, 12, 14511, 29, 16334, 304, 507, 198, 624, 5587, 282, 9496, 461, 367, 6955, 402, 666, 2808, 370, 2218, 14, 507, 198, 624, 507, 198, 1107, 291, 423, 807, 5587, 8, 5491, 12, 14511, 9, 421, 198, 318, 2813, 2422, 8, 277, 12, 11597, 29, 15656, 12, 14511, 29, 16334, 12, 3504, 5921, 29, 2416, 5921, 304, 507, 198, 624, 5587, 1006, 3504, 5921, 12, 436, 372, 282, 769, 402, 3062, 1041, 507, 198, 692, 291, 14, 758, 2570, 365, 440, 488, 26, 686, 198, 277, 14, 2168, 5929, 8, 277, 14, 758, 2570, 9, 507, 198, 1099, 275, 3504, 5921, 14, 1459, 342, 507, 198, 14240, 275, 3504, 5921, 14, 1612, 342, 507, 198, 15656, 14, 3584, 342, 507, 198, 16334, 14, 3584, 342, 507, 198, 2416, 5921, 14, 3584, 342, 507, 198, 509, 6111, 315, 289, 795, 26, 686, 198, 26746, 14, 18408, 8, 2592, 9, 1585, 507 ]
[ 655, 27021, 18, 9655, 26, 4079, 641, 11271, 13544, 12, 1314, 365, 199, 3, 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 11903, 8368, 281, 26, 738, 91, 3456, 20528, 577, 676, 415, 28, 26206, 26, 84, 887, 6559, 32, 18865, 471, 18708, 14, 846, 23307, 199, 624, 199, 199, 3, 6187, 8925, 199, 646, 3504, 12, 7554, 12, 984, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 199, 504, 7390, 14, 4901, 492, 2446, 12, 10694, 1095, 12, 1125, 199, 3, 504, 7390, 14, 4901, 14, 6843, 13544, 492, 25306, 15860, 12, 28073, 199, 199, 504, 655, 27021, 492, 664, 5039, 199, 199, 3, 7992, 199, 15656, 275, 1052, 199, 16334, 275, 1052, 199, 2416, 5921, 275, 1052, 199, 199, 16428, 63, 6178, 14657, 1149, 275, 334, 2416, 14, 16428, 40, 2160, 1204, 3504, 14, 16428, 2666, 1204, 3504, 14, 16428, 46, 3204, 9, 199, 199, 533, 662, 18, 12197, 24022, 26, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 807, 275, 469, 789, 507, 198, 277, 14, 69, 2640, 275, 664, 5039, 342, 421, 198, 318, 2274, 8, 277, 12, 6111, 12, 1566, 2629, 275, 3504, 14, 16428, 568, 1204, 3504, 14, 16428, 2666, 1204, 3504, 14, 32713, 1484, 934, 304, 507, 198, 277, 14, 807, 59, 2592, 61, 275, 1566, 2629, 8299, 198, 318, 24369, 8, 277, 12, 6111, 304, 507, 198, 2264, 291, 14, 807, 59, 2592, 61, 8299, 198, 318, 11271, 8, 277, 12, 2653, 275, 488, 304, 507, 198, 893, 26, 686, 198, 82, 275, 291, 14, 69, 2640, 14, 6843, 8, 2593, 12, 291, 14, 807, 9, 507, 198, 2590, 13483, 26, 686, 198, 1107, 488, 507, 198, 1107, 519, 199, 199, 26746, 275, 662, 18, 12197, 24022, 342, 199, 199, 533, 25306, 15860, 8, 9228, 1095, 14, 1575, 4174, 15860, 1563, 304, 199, 198, 624, 33, 9655, 626, 4440, 11271, 8, 18, 10477, 421, 198, 318, 485, 873, 11757, 8, 277, 12, 6111, 304, 507, 198, 624, 7099, 15, 18408, 376, 6111, 543, 314, 28073, 1041, 507, 198, 893, 26, 686, 198, 26746, 14, 18408, 8, 2592, 9, 507, 198, 2590, 4067, 26, 686, 198, 1529, 2742, 198, 2629, 275, 378, 507, 198, 692, 11597, 14, 1989, 63, 498, 8, 2592, 304, 3656, 275, 3656, 1204, 3504, 14, 16428, 568, 507, 198, 692, 14511, 14, 1989, 63, 498, 8, 2592, 304, 3656, 275, 3656, 1204, 3504, 14, 32713, 1484, 934, 507, 198, 692, 3656, 1137, 378, 26, 686, 198, 26746, 14, 2683, 8, 2592, 12, 3656, 9, 507, 198, 2836, 26, 686, 198, 692, 3504, 5921, 14, 1989, 63, 498, 8, 2592, 304, 2150, 3504, 5921, 59, 2592, 61, 686, 9068, 198, 26746, 14, 69, 2640, 14, 20172, 24022, 342, 421, 198, 318, 485, 807, 5587, 8, 277, 12, 23378, 12, 333, 807, 304, 507, 198, 893, 26, 686, 198, 3, 314, 8837, 4340, 686, 198, 2592, 275, 23378, 14, 9843, 342, 686, 198, 3, 1852, 3238, 314, 6111, 365, 5965, 3363, 14, 221, 1010, 2005, 24325, 781, 883, 664, 686, 198, 3, 446, 17, 2348, 14, 686, 198, 77, 807, 59, 2592, 61, 507, 198, 2590, 26, 686, 198, 3, 314, 7508, 4340, 26, 5784, 2952, 25255, 342, 1443, 2153, 27307, 737, 1263, 686, 198, 3, 12427, 12, 2419, 6080, 370, 2366, 1159, 8793, 18772, 11512, 686, 198, 509, 6111, 12, 289, 3424, 315, 3504, 5921, 14, 1744, 837, 1585, 198, 692, 23378, 365, 289, 3424, 26, 1871, 198, 4785, 686, 198, 2836, 26, 1585, 198, 3, 869, 596, 12, 11703, 440, 314, 2451, 2518, 402, 1595, 31, 221, 961, 1083, 883, 1133, 1585, 198, 3, 2449, 12, 2952, 652, 10986, 6272, 1125, 15212, 1396, 1585, 198, 1107, 507, 198, 692, 333, 807, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2264, 333, 807, 59, 2592, 61, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 1050, 5929, 8, 277, 12, 7002, 304, 507, 198, 624, 1123, 282, 3814, 4311, 367, 6955, 402, 666, 2808, 370, 1586, 14, 507, 198, 624, 507, 198, 2592, 275, 7002, 14, 9843, 342, 507, 198, 692, 440, 11597, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2416, 5921, 59, 2592, 61, 275, 7002, 686, 198, 15656, 59, 2592, 61, 275, 221, 413, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 1050, 6261, 8, 277, 12, 7060, 12, 14511, 29, 16334, 12, 3504, 5921, 29, 2416, 5921, 304, 507, 198, 624, 1123, 282, 3814, 4311, 367, 6955, 402, 666, 2808, 370, 2218, 14, 507, 198, 624, 507, 198, 2592, 275, 7060, 14, 9843, 342, 507, 198, 692, 440, 14511, 14, 1989, 63, 498, 8, 2592, 304, 686, 198, 2416, 5921, 59, 2592, 61, 275, 7060, 686, 198, 16334, 59, 2592, 61, 275, 221, 413, 686, 198, 277, 423, 873, 11757, 8, 2592, 9, 421, 198, 318, 2813, 5929, 8, 277, 12, 7002, 12, 11597, 29, 15656, 304, 507, 198, 624, 5587, 282, 9496, 461, 367, 6955, 402, 666, 2808, 370, 1586, 14, 507, 198, 624, 507, 198, 1107, 291, 423, 807, 5587, 8, 5503, 12, 11597, 9, 421, 198, 318, 2813, 6261, 8, 277, 12, 7060, 12, 14511, 29, 16334, 304, 507, 198, 624, 5587, 282, 9496, 461, 367, 6955, 402, 666, 2808, 370, 2218, 14, 507, 198, 624, 507, 198, 1107, 291, 423, 807, 5587, 8, 5491, 12, 14511, 9, 421, 198, 318, 2813, 2422, 8, 277, 12, 11597, 29, 15656, 12, 14511, 29, 16334, 12, 3504, 5921, 29, 2416, 5921, 304, 507, 198, 624, 5587, 1006, 3504, 5921, 12, 436, 372, 282, 769, 402, 3062, 1041, 507, 198, 692, 291, 14, 758, 2570, 365, 440, 488, 26, 686, 198, 277, 14, 2168, 5929, 8, 277, 14, 758, 2570, 9, 507, 198, 1099, 275, 3504, 5921, 14, 1459, 342, 507, 198, 14240, 275, 3504, 5921, 14, 1612, 342, 507, 198, 15656, 14, 3584, 342, 507, 198, 16334, 14, 3584, 342, 507, 198, 2416, 5921, 14, 3584, 342, 507, 198, 509, 6111, 315, 289, 795, 26, 686, 198, 26746, 14, 18408, 8, 2592, 9, 1585, 507, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pburdet/hyperspy
hyperspy/_signals/eds.py
1
21939
# -*- coding: utf-8 -*- # Copyright 2007-2011 The HyperSpy developers # # This file is part of HyperSpy. # # HyperSpy 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. # # HyperSpy 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 HyperSpy. If not, see <http://www.gnu.org/licenses/>. from __future__ import division import numpy as np from hyperspy import utils from hyperspy._signals.spectrum import Spectrum from hyperspy.misc.elements import elements as elements_db from hyperspy.misc.eds import utils as utils_eds from hyperspy.misc.utils import isiterable class EDSSpectrum(Spectrum): _signal_type = "EDS" def __init__(self, *args, **kwards): Spectrum.__init__(self, *args, **kwards) if self.metadata.Signal.signal_type == 'EDS': print('The microscope type is not set. Use ' 'set_signal_type(\'EDS_TEM\') or set_signal_type(\'EDS_SEM\')') self.metadata.Signal.binned = True def _get_line_energy(self, Xray_line, FWHM_MnKa=None): """ Get the line energy and the energy resolution of a Xray line. The return values are in the same units than the signal axis Parameters ---------- Xray_line : strings Valid element X-ray lines e.g. Fe_Kb. FWHM_MnKa: {None, float, 'auto'} The energy resolution of the detector in eV if 'auto', used the one in 'self.metadata.Acquisition_instrument.SEM.Detector.EDS.energy_resolution_MnKa' Returns ------ float: the line energy, if FWHM_MnKa is None (float,float): the line energy and the energy resolution, if FWHM_MnKa is not None """ units_name = self.axes_manager.signal_axes[0].units if FWHM_MnKa == 'auto': if self.metadata.Signal.signal_type == 'EDS_SEM': FWHM_MnKa = self.metadata.Acquisition_instrument.SEM.Detector.EDS.energy_resolution_MnKa elif self.metadata.Signal.signal_type == 'EDS_TEM': FWHM_MnKa = self.metadata.Acquisition_instrument.TEM.Detector.EDS.energy_resolution_MnKa else: raise NotImplementedError( "This method only works for EDS_TEM or EDS_SEM signals. " "You can use `set_signal_type(\"EDS_TEM\")` or" "`set_signal_type(\"EDS_SEM\")` to convert to one of these" "signal types.") line_energy = utils_eds._get_energy_xray_line(Xray_line) if units_name == 'eV': line_energy *= 1000 if FWHM_MnKa is not None: line_FWHM = utils_eds.get_FWHM_at_Energy(FWHM_MnKa, line_energy / 1000) * 1000 elif units_name == 'keV': if FWHM_MnKa is not None: line_FWHM = utils_eds.get_FWHM_at_Energy(FWHM_MnKa, line_energy) else: raise ValueError( "%s is not a valid units for the energy axis. " "Only `eV` and `keV` are supported. " "If `s` is the variable containing this EDS spectrum:\n " ">>> s.axes_manager.signal_axes[0].units = \'keV\' \n" % (units_name)) if FWHM_MnKa is None: return line_energy else: return line_energy, line_FWHM def _get_beam_energy(self): """ Get the beam energy. The return value is in the same units than the signal axis """ if "Acquisition_instrument.SEM.beam_energy" in self.metadata: beam_energy = self.metadata.Acquisition_instrument.SEM.beam_energy elif "Acquisition_instrument.TEM.beam_energy" in self.metadata: beam_energy = self.metadata.Acquisition_instrument.TEM.beam_energy else: raise AttributeError( "To use this method the beam energy `Acquisition_instrument.TEM.beam_energy` " "or `Acquisition_instrument.SEM.beam_energy` must be defined in " "`metadata`.") units_name = self.axes_manager.signal_axes[0].units if units_name == 'eV': beam_energy = beam_energy * 1000 return beam_energy def sum(self, axis): """Sum the data over the given axis. Parameters ---------- axis : {int, string} The axis can be specified using the index of the axis in `axes_manager` or the axis name. Returns ------- s : Signal See also -------- sum_in_mask, mean Examples -------- >>> import numpy as np >>> s = Signal(np.random.random((64,64,1024))) >>> s.data.shape (64,64,1024) >>> s.sum(-1).data.shape (64,64) # If we just want to plot the result of the operation s.sum(-1, True).plot() """ # modify time spend per spectrum if "Acquisition_instrument.SEM" in self.metadata: mp = self.metadata.Acquisition_instrument.SEM else: mp = self.metadata.Acquisition_instrument.TEM if mp.has_item('Detector.EDS.live_time'): mp.Detector.EDS.live_time = mp.Detector.EDS.live_time * \ self.axes_manager.shape[axis] return super(EDSSpectrum, self).sum(axis) def rebin(self, new_shape): """Rebins the data to the new shape Parameters ---------- new_shape: tuple of ints The new shape must be a divisor of the original shape """ new_shape_in_array = [] for axis in self.axes_manager._axes: new_shape_in_array.append( new_shape[axis.index_in_axes_manager]) factors = (np.array(self.data.shape) / np.array(new_shape_in_array)) s = super(EDSSpectrum, self).rebin(new_shape) # modify time per spectrum if "Acquisition_instrument.SEM.Detector.EDS.live_time" in s.metadata: for factor in factors: s.metadata.Acquisition_instrument.SEM.Detector.EDS.live_time *= factor if "Acquisition_instrument.TEM.Detector.EDS.live_time" in s.metadata: for factor in factors: s.metadata.Acquisition_instrument.TEM.Detector.EDS.live_time *= factor return s def set_elements(self, elements): """Erase all elements and set them. Parameters ---------- elements : list of strings A list of chemical element symbols. See also -------- add_elements, set_line, add_lines. Examples -------- >>> s = signals.EDSSEMSpectrum(np.arange(1024)) >>> s.set_elements(['Ni', 'O'],['Ka','Ka']) Adding Ni_Ka Line Adding O_Ka Line >>> s.mapped_paramters.Acquisition_instrument.SEM.beam_energy = 10 >>> s.set_elements(['Ni', 'O']) Adding Ni_La Line Adding O_Ka Line """ # Erase previous elements and X-ray lines if "Sample.elements" in self.metadata: del self.metadata.Sample.elements self.add_elements(elements) def add_elements(self, elements): """Add elements and the corresponding X-ray lines. The list of elements is stored in `metadata.Sample.elements` Parameters ---------- elements : list of strings The symbol of the elements. See also -------- set_elements, add_lines, set_lines. """ if not isiterable(elements) or isinstance(elements, basestring): raise ValueError( "Input must be in the form of a list. For example, " "if `s` is the variable containing this EDS spectrum:\n " ">>> s.add_elements(('C',))\n" "See the docstring for more information.") if "Sample.elements" in self.metadata: elements_ = set(self.metadata.Sample.elements) else: elements_ = set() for element in elements: if element in elements_db: elements_.add(element) else: raise ValueError( "%s is not a valid chemical element symbol." % element) if not hasattr(self.metadata, 'Sample'): self.metadata.add_node('Sample') self.metadata.Sample.elements = sorted(list(elements_)) def set_lines(self, lines, only_one=True, only_lines=("Ka", "La", "Ma")): """Erase all Xrays lines and set them. See add_lines for details. Parameters ---------- lines : list of strings A list of valid element X-ray lines to add e.g. Fe_Kb. Additionally, if `metadata.Sample.elements` is defined, add the lines of those elements that where not given in this list. only_one: bool If False, add all the lines of each element in `metadata.Sample.elements` that has not line defined in lines. If True (default), only add the line at the highest energy above an overvoltage of 2 (< beam energy / 2). only_lines : {None, list of strings} If not None, only the given lines will be added. See also -------- add_lines, add_elements, set_elements.. """ if "Sample.xray_lines" in self.metadata: del self.metadata.Sample.xray_lines self.add_lines(lines=lines, only_one=only_one, only_lines=only_lines) def add_lines(self, lines=(), only_one=True, only_lines=("Ka", "La", "Ma")): """Add X-rays lines to the internal list. Although most functions do not require an internal list of X-ray lines because they can be calculated from the internal list of elements, ocassionally it might be useful to customize the X-ray lines to be use by all functions by default using this method. The list of X-ray lines is stored in `metadata.Sample.xray_lines` Parameters ---------- lines : list of strings A list of valid element X-ray lines to add e.g. Fe_Kb. Additionally, if `metadata.Sample.elements` is defined, add the lines of those elements that where not given in this list. If the list is empty (default), and `metadata.Sample.elements` is defined, add the lines of all those elements. only_one: bool If False, add all the lines of each element in `metadata.Sample.elements` that has not line defined in lines. If True (default), only add the line at the highest energy above an overvoltage of 2 (< beam energy / 2). only_lines : {None, list of strings} If not None, only the given lines will be added. See also -------- set_lines, add_elements, set_elements. """ if "Sample.xray_lines" in self.metadata: xray_lines = set(self.metadata.Sample.xray_lines) else: xray_lines = set() # Define the elements which Xray lines has been customized # So that we don't attempt to add new lines automatically elements = set() for line in xray_lines: elements.add(line.split("_")[0]) end_energy = self.axes_manager.signal_axes[0].high_value for line in lines: try: element, subshell = line.split("_") except ValueError: raise ValueError( "Invalid line symbol. " "Please provide a valid line symbol e.g. Fe_Ka") if element in elements_db: elements.add(element) if subshell in elements_db[element]['Atomic_properties']['Xray_lines']: lines_len = len(xray_lines) xray_lines.add(line) if lines_len != len(xray_lines): print("%s line added," % line) else: print("%s line already in." % line) if (self._get_line_energy(element + '_' + subshell) > end_energy): print("Warning: %s %s is above the data energy range." % (element, subshell)) else: raise ValueError( "%s is not a valid line of %s." % (line, element)) else: raise ValueError( "%s is not a valid symbol of an element." % element) if "Sample.elements" in self.metadata: extra_elements = (set(self.metadata.Sample.elements) - elements) if extra_elements: new_lines = self._get_lines_from_elements( extra_elements, only_one=only_one, only_lines=only_lines) if new_lines: self.add_lines(list(new_lines) + list(lines)) self.add_elements(elements) if not hasattr(self.metadata, 'Sample'): self.metadata.add_node('Sample') if "Sample.xray_lines" in self.metadata: xray_lines = xray_lines.union( self.metadata.Sample.xray_lines) self.metadata.Sample.xray_lines = sorted(list(xray_lines)) def _get_lines_from_elements(self, elements, only_one=False, only_lines=("Ka", "La", "Ma")): """Returns the X-ray lines of the given elements in spectral range of the data. Parameters ---------- elements : list of strings A list containing the symbol of the chemical elements. only_one : bool If False, add all the lines of each element in the data spectral range. If True only add the line at the highest energy above an overvoltage of 2 (< beam energy / 2). only_lines : {None, list of strings} If not None, only the given lines will be returned. Returns ------- """ beam_energy = self._get_beam_energy() end_energy = self.axes_manager.signal_axes[0].high_value if beam_energy < end_energy: end_energy = beam_energy lines = [] for element in elements: # Possible line (existing and excited by electron) element_lines = [] for subshell in elements_db[element]['Atomic_properties']['Xray_lines'].keys(): if only_lines and subshell not in only_lines: continue if (self._get_line_energy(element + '_' + subshell) < end_energy): element_lines.append(element + "_" + subshell) if only_one and element_lines: # Choose the best line select_this = -1 for i, line in enumerate(element_lines): if (self._get_line_energy(line) < beam_energy / 2): select_this = i break element_lines = [element_lines[select_this], ] if not element_lines: print(("There is not X-ray line for element %s " % element) + "in the data spectral range") else: lines.extend(element_lines) return lines def get_lines_intensity(self, xray_lines=None, plot_result=False, integration_window_factor=2., only_one=True, only_lines=("Ka", "La", "Ma"), **kwargs): """Return the intensity map of selected Xray lines. The intensities, the number of X-ray counts, are computed by suming the spectrum over the different X-ray lines. The sum window width is calculated from the energy resolution of the detector defined as defined in `self.metadata.Acquisition_instrument.SEM.Detector.EDS.energy_resolution_MnKa` or `self.metadata.Acquisition_instrument.SEM.Detector.EDS.energy_resolution_MnKa`. Parameters ---------- xray_lines: {None, "best", list of string} If None, if `mapped.parameters.Sample.elements.xray_lines` contains a list of lines use those. If `mapped.parameters.Sample.elements.xray_lines` is undefined or empty but `mapped.parameters.Sample.elements` is defined, use the same syntax as `add_line` to select a subset of lines for the operation. Alternatively, provide an iterable containing a list of valid X-ray lines symbols. plot_result : bool If True, plot the calculated line intensities. If the current object is a single spectrum it prints the result instead. integration_window_factor: Float The integration window is centered at the center of the X-ray line and its width is defined by this factor (2 by default) times the calculated FWHM of the line. only_one : bool If False, use all the lines of each element in the data spectral range. If True use only the line at the highest energy above an overvoltage of 2 (< beam energy / 2). only_lines : {None, list of strings} If not None, use only the given lines. kwargs The extra keyword arguments for plotting. See `utils.plot.plot_signals` Returns ------- intensities : list A list containing the intensities as Signal subclasses. Examples -------- >>> specImg.get_lines_intensity(["C_Ka", "Ta_Ma"]) See also -------- set_elements, add_elements. """ if xray_lines is None: if 'Sample.xray_lines' in self.metadata: xray_lines = self.metadata.Sample.xray_lines elif 'Sample.elements' in self.metadata: xray_lines = self._get_lines_from_elements( self.metadata.Sample.elements, only_one=only_one, only_lines=only_lines) else: raise ValueError( "Not X-ray line, set them with `add_elements`") intensities = [] # test 1D Spectrum (0D problem) #signal_to_index = self.axes_manager.navigation_dimension - 2 for Xray_line in xray_lines: line_energy, line_FWHM = self._get_line_energy(Xray_line, FWHM_MnKa='auto') det = integration_window_factor * line_FWHM / 2. img = self[..., line_energy - det:line_energy + det ].integrate1D(-1) img.metadata.General.title = ( 'Intensity of %s at %.2f %s from %s' % (Xray_line, line_energy, self.axes_manager.signal_axes[0].units, self.metadata.General.title)) if img.axes_manager.navigation_dimension >= 2: img = img.as_image([0, 1]) elif img.axes_manager.navigation_dimension == 1: img.axes_manager.set_signal_dimension(1) if plot_result and img.axes_manager.signal_dimension == 0: print("%s at %s %s : Intensity = %.2f" % (Xray_line, line_energy, self.axes_manager.signal_axes[0].units, img.data)) intensities.append(img) if plot_result and img.axes_manager.signal_dimension != 0: utils.plot.plot_signals(intensities, **kwargs) return intensities def get_take_off_angle(self): """Calculate the take-off-angle (TOA). TOA is the angle with which the X-rays leave the surface towards the detector. Parameters are read in 'SEM.tilt_stage', 'Acquisition_instrument.SEM.Detector.EDS.azimuth_angle' and 'SEM.Detector.EDS.elevation_angle' in 'metadata'. Returns ------- take_off_angle: float (Degree) See also -------- utils.eds.take_off_angle Notes ----- Defined by M. Schaffer et al., Ultramicroscopy 107(8), pp 587-597 (2007) """ if self.metadata.Signal.signal_type == 'EDS_SEM': mp = self.metadata.Acquisition_instrument.SEM elif self.metadata.Signal.signal_type == 'EDS_TEM': mp = self.metadata.Acquisition_instrument.TEM tilt_stage = mp.tilt_stage azimuth_angle = mp.Detector.EDS.azimuth_angle elevation_angle = mp.Detector.EDS.elevation_angle TOA = utils.eds.take_off_angle(tilt_stage, azimuth_angle, elevation_angle) return TOA
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 10219, 13, 8128, 710, 21344, 51, 647, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 221, 21344, 51, 647, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 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, 221, 21344, 51, 647, 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, 221, 21344, 51, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 10342, 15252, 492, 3778, 199, 504, 10342, 15252, 423, 10458, 14, 18142, 492, 428, 9120, 199, 504, 10342, 15252, 14, 9923, 14, 5527, 492, 4008, 465, 4008, 63, 697, 199, 504, 10342, 15252, 14, 9923, 14, 5923, 492, 3778, 465, 3778, 63, 5923, 199, 504, 10342, 15252, 14, 9923, 14, 1208, 492, 284, 2124, 6842, 421, 199, 533, 662, 36, 2300, 9120, 8, 16684, 304, 272, 485, 4653, 63, 466, 275, 298, 1149, 51, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 5596, 304, 267, 428, 9120, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 5596, 9, 267, 340, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 356, 288, 870, 360, 1918, 9967, 2645, 730, 365, 440, 663, 14, 3645, 283, 2116, 283, 409, 63, 4653, 63, 466, 30338, 1149, 51, 63, 22057, 60, 358, 503, 663, 63, 4653, 63, 466, 30338, 1149, 51, 63, 899, 45, 60, 358, 358, 267, 291, 14, 2343, 14, 11274, 14, 1393, 7439, 275, 715, 339, 347, 485, 362, 63, 604, 63, 8443, 8, 277, 12, 1323, 803, 63, 604, 12, 481, 9792, 45, 63, 45, 78, 26133, 29, 403, 304, 267, 408, 267, 2372, 314, 1004, 12304, 436, 314, 12304, 12401, 402, 282, 1323, 803, 1004, 14, 398, 710, 372, 1338, 787, 315, 314, 2011, 6204, 2419, 314, 4673, 3114, 398, 3897, 267, 4143, 398, 1323, 803, 63, 604, 520, 3326, 288, 4821, 1819, 1323, 13, 803, 2385, 325, 14, 71, 14, 7949, 63, 43, 66, 14, 398, 481, 9792, 45, 63, 45, 78, 26133, 26, 469, 403, 12, 2069, 12, 283, 2495, 936, 288, 710, 12304, 12401, 402, 314, 17842, 315, 325, 54, 288, 340, 283, 2495, 297, 1202, 314, 1373, 315, 288, 283, 277, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 899, 45, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 7, 398, 1803, 267, 21397, 398, 2069, 26, 314, 1004, 12304, 12, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 488, 267, 334, 1609, 12, 1609, 304, 314, 1004, 12304, 436, 314, 12304, 12401, 12, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 267, 408, 398, 6204, 63, 354, 275, 291, 14, 6402, 63, 2609, 14, 4653, 63, 6402, 59, 16, 1055, 5260, 398, 340, 481, 9792, 45, 63, 45, 78, 26133, 508, 283, 2495, 356, 288, 340, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 63, 899, 45, 356, 355, 481, 9792, 45, 63, 45, 78, 26133, 275, 291, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 899, 45, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 288, 916, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 63, 22057, 356, 355, 481, 9792, 45, 63, 45, 78, 26133, 275, 291, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 288, 587, 26, 355, 746, 4279, 8, 490, 298, 2765, 1083, 1454, 5419, 367, 662, 3177, 63, 22057, 503, 662, 3177, 63, 899, 45, 10166, 14, 298, 490, 298, 5556, 883, 675, 658, 409, 63, 4653, 63, 466, 2961, 2, 1149, 51, 63, 22057, 60, 531, 64, 503, 2, 490, 24505, 409, 63, 4653, 63, 466, 2961, 2, 1149, 51, 63, 899, 45, 60, 531, 64, 370, 3957, 370, 1373, 402, 3520, 2, 490, 298, 4653, 2943, 2685, 267, 1004, 63, 8443, 275, 3778, 63, 5923, 423, 362, 63, 8443, 63, 88, 803, 63, 604, 8, 56, 803, 63, 604, 9, 267, 340, 6204, 63, 354, 508, 283, 27786, 356, 288, 1004, 63, 8443, 9000, 5198, 288, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 26, 355, 1004, 63, 38, 9792, 45, 275, 3778, 63, 5923, 14, 362, 63, 38, 9792, 45, 63, 292, 63, 9900, 8, 38, 9792, 45, 63, 45, 78, 26133, 12, 12740, 1004, 63, 8443, 1182, 5198, 9, 627, 5198, 267, 916, 6204, 63, 354, 508, 283, 27482, 356, 288, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 26, 355, 1004, 63, 38, 9792, 45, 275, 3778, 63, 5923, 14, 362, 63, 38, 9792, 45, 63, 292, 63, 9900, 8, 38, 9792, 45, 63, 45, 78, 26133, 12, 12740, 1004, 63, 8443, 9, 267, 587, 26, 288, 746, 1722, 8, 355, 2071, 83, 365, 440, 282, 1686, 6204, 367, 314, 12304, 3114, 14, 298, 355, 298, 5903, 658, 27786, 64, 436, 658, 27482, 64, 787, 3748, 14, 298, 355, 298, 3917, 658, 83, 64, 365, 314, 1750, 3035, 642, 662, 3177, 20645, 3427, 78, 298, 355, 298, 6071, 308, 14, 6402, 63, 2609, 14, 4653, 63, 6402, 59, 16, 1055, 5260, 275, 8891, 27482, 3985, 971, 78, 2, 355, 450, 334, 5260, 63, 354, 430, 267, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 488, 26, 288 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 10219, 13, 8128, 710, 21344, 51, 647, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 221, 21344, 51, 647, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 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, 221, 21344, 51, 647, 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, 221, 21344, 51, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 10342, 15252, 492, 3778, 199, 504, 10342, 15252, 423, 10458, 14, 18142, 492, 428, 9120, 199, 504, 10342, 15252, 14, 9923, 14, 5527, 492, 4008, 465, 4008, 63, 697, 199, 504, 10342, 15252, 14, 9923, 14, 5923, 492, 3778, 465, 3778, 63, 5923, 199, 504, 10342, 15252, 14, 9923, 14, 1208, 492, 284, 2124, 6842, 421, 199, 533, 662, 36, 2300, 9120, 8, 16684, 304, 272, 485, 4653, 63, 466, 275, 298, 1149, 51, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 5596, 304, 267, 428, 9120, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 5596, 9, 267, 340, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 356, 288, 870, 360, 1918, 9967, 2645, 730, 365, 440, 663, 14, 3645, 283, 2116, 283, 409, 63, 4653, 63, 466, 30338, 1149, 51, 63, 22057, 60, 358, 503, 663, 63, 4653, 63, 466, 30338, 1149, 51, 63, 899, 45, 60, 358, 358, 267, 291, 14, 2343, 14, 11274, 14, 1393, 7439, 275, 715, 339, 347, 485, 362, 63, 604, 63, 8443, 8, 277, 12, 1323, 803, 63, 604, 12, 481, 9792, 45, 63, 45, 78, 26133, 29, 403, 304, 267, 408, 267, 2372, 314, 1004, 12304, 436, 314, 12304, 12401, 402, 282, 1323, 803, 1004, 14, 398, 710, 372, 1338, 787, 315, 314, 2011, 6204, 2419, 314, 4673, 3114, 398, 3897, 267, 4143, 398, 1323, 803, 63, 604, 520, 3326, 288, 4821, 1819, 1323, 13, 803, 2385, 325, 14, 71, 14, 7949, 63, 43, 66, 14, 398, 481, 9792, 45, 63, 45, 78, 26133, 26, 469, 403, 12, 2069, 12, 283, 2495, 936, 288, 710, 12304, 12401, 402, 314, 17842, 315, 325, 54, 288, 340, 283, 2495, 297, 1202, 314, 1373, 315, 288, 283, 277, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 899, 45, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 7, 398, 1803, 267, 21397, 398, 2069, 26, 314, 1004, 12304, 12, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 488, 267, 334, 1609, 12, 1609, 304, 314, 1004, 12304, 436, 314, 12304, 12401, 12, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 267, 408, 398, 6204, 63, 354, 275, 291, 14, 6402, 63, 2609, 14, 4653, 63, 6402, 59, 16, 1055, 5260, 398, 340, 481, 9792, 45, 63, 45, 78, 26133, 508, 283, 2495, 356, 288, 340, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 63, 899, 45, 356, 355, 481, 9792, 45, 63, 45, 78, 26133, 275, 291, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 899, 45, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 288, 916, 291, 14, 2343, 14, 11274, 14, 4653, 63, 466, 508, 283, 1149, 51, 63, 22057, 356, 355, 481, 9792, 45, 63, 45, 78, 26133, 275, 291, 14, 2343, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 24402, 14, 1149, 51, 14, 8443, 63, 12588, 63, 45, 78, 26133, 288, 587, 26, 355, 746, 4279, 8, 490, 298, 2765, 1083, 1454, 5419, 367, 662, 3177, 63, 22057, 503, 662, 3177, 63, 899, 45, 10166, 14, 298, 490, 298, 5556, 883, 675, 658, 409, 63, 4653, 63, 466, 2961, 2, 1149, 51, 63, 22057, 60, 531, 64, 503, 2, 490, 24505, 409, 63, 4653, 63, 466, 2961, 2, 1149, 51, 63, 899, 45, 60, 531, 64, 370, 3957, 370, 1373, 402, 3520, 2, 490, 298, 4653, 2943, 2685, 267, 1004, 63, 8443, 275, 3778, 63, 5923, 423, 362, 63, 8443, 63, 88, 803, 63, 604, 8, 56, 803, 63, 604, 9, 267, 340, 6204, 63, 354, 508, 283, 27786, 356, 288, 1004, 63, 8443, 9000, 5198, 288, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 26, 355, 1004, 63, 38, 9792, 45, 275, 3778, 63, 5923, 14, 362, 63, 38, 9792, 45, 63, 292, 63, 9900, 8, 38, 9792, 45, 63, 45, 78, 26133, 12, 12740, 1004, 63, 8443, 1182, 5198, 9, 627, 5198, 267, 916, 6204, 63, 354, 508, 283, 27482, 356, 288, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 440, 488, 26, 355, 1004, 63, 38, 9792, 45, 275, 3778, 63, 5923, 14, 362, 63, 38, 9792, 45, 63, 292, 63, 9900, 8, 38, 9792, 45, 63, 45, 78, 26133, 12, 12740, 1004, 63, 8443, 9, 267, 587, 26, 288, 746, 1722, 8, 355, 2071, 83, 365, 440, 282, 1686, 6204, 367, 314, 12304, 3114, 14, 298, 355, 298, 5903, 658, 27786, 64, 436, 658, 27482, 64, 787, 3748, 14, 298, 355, 298, 3917, 658, 83, 64, 365, 314, 1750, 3035, 642, 662, 3177, 20645, 3427, 78, 298, 355, 298, 6071, 308, 14, 6402, 63, 2609, 14, 4653, 63, 6402, 59, 16, 1055, 5260, 275, 8891, 27482, 3985, 971, 78, 2, 355, 450, 334, 5260, 63, 354, 430, 267, 340, 481, 9792, 45, 63, 45, 78, 26133, 365, 488, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
matrix65536/kosmosfs
src/python/kfscp/kfscp.py
11
8528
# # $Id$ # # Copyright 2006 Kosmix Corp. # # Author: Blake Lewis (Kosmix Corp.) # # This file is part of Kosmos File System (KFS). # # 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. # # # Python module that parses a KFS checkpoint file into a set of # dictionaries to allow easy examination and consistency checking. # import re def strip_dots(path): """Strip '.' and '..' components from path""" if (path == "/"): return path out = [] for p in path[1:].split('/'): if p == "..": if len(out) != 0: del out[-1] else: out.append(p) elif p != ".": out.append(p) return "/" + "/".join(out) def add_to_path(current, new): """Combine current and new into one path""" if len(new) == 0: path = current elif new[0] == "/": path = new elif current == "/": path = "/" + new else: path = current + "/" + new return strip_dots(path) class cp: """Read a KFS checkpoint file and convert it into Python structures The cp file is converted into a set of dictionaries that can be inspected. The main one, 'byfid', is indexed by file ID and collects all the information for each file; 'byname' maps the tuple (parent diretory file id, name) to a file id, and 'bychunk' maps chunk ids to the file id of their owners. As an aid to navigate, 'cd' and 'ls' commands are provided. Also, the 'check' command runs consistency checks. """ def __init__(self, cpfile): self.read(cpfile) def reset(self): self.byfid = { } self.byname = { } self.bychunk = { } self.cpdescr = { } self.cwd = "/" def read(self, cpfile): """Read cp from file and generate Python representation""" self.reset() try: cp = open(cpfile, "r") except IOError: print "can't open", cpfile return line = 0 for entry in cp: line += 1 if len(entry) == 1: # just the newline continue parts = entry.rstrip().split('/') parser_name = parts[0] + "_parse" valid = hasattr(self, parser_name) if valid: parser = getattr(self, parser_name) valid = callable(parser) and parser(parts) if not valid: print "invalid entry, line %d: %s" % \ (line, entry) def validate(self, parts, re_list): m = [re.match(re_list[i] + "$", parts[i + 1]) \ for i in range(len(re_list))] return bool(min(m)) def checkpoint_parse(self, parts): ok = self.validate(parts, ["\d+"]) if ok: self.cpdescr["number"] = int(parts[1]) return ok def version_parse(self, parts): ok = self.validate(parts, ["\d+"]) if ok: self.cpdescr["version"] = int(parts[1]) return ok def fid_parse(self, parts): ok = self.validate(parts, ["\d+"]) if ok: self.cpdescr["next_fid"] = int(parts[1]) return ok def chunkId_parse(self, parts): ok = self.validate(parts, ["\d+"]) if ok: self.cpdescr["next_chunkId"] = int(parts[1]) return ok def time_parse(self, parts): tpat = "[A-Z][a-z]{2} [A-Z][a-z]{2}\s+\d+ \d+:\d+:\d+ \d+" ok = self.validate(parts, [tpat]) if ok: self.cpdescr["saved_at"] = parts[1] return ok def log_parse(self, parts): self.cpdescr["log_file"] = "/".join(parts[1:]) return True def makefattr(self, parts): d = dict() d["type"] = parts[1] # dir | file d["chunkcount"] = int(parts[5]) d["mtime"] = (int(parts[7]), int(parts[8])) d["ctime"] = (int(parts[10]), int(parts[11])) d["crtime"] = (int(parts[13]), int(parts[14])) return d def fattr_parse(self, parts): pat = ["dir|file", "id", "\d+", "chunkcount", "\d+", "mtime", "\d+", "\d+", "ctime", "\d+", "\d+", "crtime", "\d+", "\d+"] ok = self.validate(parts, pat) if ok: fdict = self.makefattr(parts) my_id = int(parts[3]) if my_id not in self.byfid: self.byfid[my_id] = dict() self.byfid[my_id]["fattr"] = fdict return ok def dentry_parse(self, parts): pat = ["name", ".+", "id", "\d+", "parent", "\d+"] ok = self.validate(parts, pat) if ok: my_name = parts[2] my_id = int(parts[4]) parent = int(parts[6]) else: pat2 = ["name", "", "", "id", "\d+", "parent", "\d+"] ok = self.validate(parts, pat2) if ok: my_name = "/" my_id = int(parts[5]) parent = int(parts[7]) if ok: if my_id not in self.byfid: self.byfid[my_id] = dict() d = self.byfid[my_id] if parent not in self.byfid: self.byfid[parent] = dict() p = self.byfid[parent] if my_name == ".": if "dot" in d: print "Duplicate '.' entries" return False if my_id != parent: print "'.' not linked to self" return False d["dot"] = my_id elif my_name == "..": if "dotdot" in p: print "Duplicate '..' entries" return False p["dotdot"] = my_id else: if "name" in d: print "Duplicate directory entries" return False d["name"] = my_name d["parent"] = parent if "children" not in p: p["children"] = [] p["children"].append(my_id) self.byname[(parent, my_name)] = my_id return ok def chunkinfo_parse(self, parts): pat = ["fid", "\d+", "chunkid", "\d+", "offset", "\d+"] ok = self.validate(parts, pat) if ok: my_id = int(parts[2]) chunk_id = int(parts[4]) offset = int(parts[6]) if my_id not in self.byfid: self.byfid[my_id] = dict() d = self.byfid[my_id] if "chunklist" not in d: d["chunklist"] = dict() chlist = d["chunklist"] if offset in chlist: print "Duplicate chunkinfo for offset" return False chlist[offset] = chunk_id if chunk_id in self.bychunk: print "Duplicate chunkinfo for chunk_id" return False self.bychunk[chunk_id] = my_id return ok def check_missing_dentries(self): for id in self.byfid: if "name" not in self.byfid[id]: print "File %d has no directory entry" % id def check_missing_fattr(self): for id in self.byfid: if "fattr" not in self.byfid[id]: print "File %d has no attributes" % id def check_dot(self): for id in self.byfid: e = self.byfid[id] if "fattr" not in e: continue # already reported type = e["fattr"]["type"] if type == "dir" and "dot" not in e: print "Directory %d has no '.' link" % id if type != "dir" and "dot" in e: print "Plain file %d has a '.' link" % id def check_dotdot(self): for id in self.byfid: e = self.byfid[id] if "fattr" not in e: continue # already reported type = e["fattr"]["type"] if type == "dir" and "dotdot" not in e: print "Directory %d has no '..' link" % id if type != "dir" and "dotdot" in e: print "Plain file %d has a '..' link" % id if "dotdot" not in e: continue if "parent" not in e: continue # already reported link = e["dotdot"] parent = e["parent"] if link != parent: print "Directory %d has invalid '..' link" % id def check(self): """Run consistency checks""" self.check_missing_dentries() self.check_missing_fattr() self.check_dot() self.check_dotdot() def lookup(self, path): """Convert path into file id""" target = add_to_path(self.cwd, path) id = 2 # start at root if target == "/": return id for p in target[1:].split('/'): if id not in self.byfid: return -1 if (id, p) not in self.byname: return -1 id = self.byname[(id, p)] return id def cd(self, path): """Change current directory""" id = self.lookup(path) if id < 0: print "%s: No such file or directory" % path elif self.byfid[id]["fattr"]["type"] != "dir": print "%s: Not a directory" % path else: self.cwd = add_to_path(self.cwd, path) def name(self, id): return self.byfid[id]["name"] def name_and_type(self, id): e = self.byfid[id] return (e["name"], e["fattr"]["type"]) def ls(self, path = "", flags = ""): """List file or directory""" id = self.lookup(path) if id < 0: print "%s: No such file or directory" % path return None e = self.byfid[id] if e["fattr"]["type"] == "file": return [ path ] if "children" in e: kids = e["children"] else: kids = [] if flags == "F": formatter = self.name_and_type else: formatter = self.name return [formatter(k) for k in kids]
apache-2.0
[ 3, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1898, 8315, 1804, 736, 13979, 22304, 14, 199, 3, 199, 3, 6529, 26, 699, 416, 415, 491, 546, 374, 334, 43, 736, 13979, 22304, 4959, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1804, 736, 16908, 3814, 6187, 334, 43, 7079, 680, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 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, 199, 3, 2478, 14, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 199, 3, 3443, 436, 4204, 1334, 314, 844, 14, 199, 3, 199, 3, 199, 3, 2018, 859, 626, 19953, 282, 1804, 7079, 9997, 570, 1901, 282, 663, 402, 199, 3, 11196, 370, 2040, 8837, 15735, 3155, 436, 17754, 7907, 14, 199, 3, 199, 646, 295, 199, 199, 318, 6202, 63, 25310, 8, 515, 304, 199, 198, 624, 21332, 7815, 436, 11541, 7, 7323, 687, 931, 624, 199, 198, 692, 334, 515, 508, 3286, 2349, 507, 198, 1107, 931, 421, 198, 548, 275, 942, 199, 198, 509, 299, 315, 931, 59, 17, 11455, 1294, 18265, 507, 198, 692, 299, 508, 21777, 582, 686, 198, 692, 822, 8, 548, 9, 1137, 378, 26, 1585, 198, 2264, 734, 1988, 17, 61, 686, 198, 2836, 26, 1585, 198, 548, 14, 740, 8, 80, 9, 507, 198, 4164, 299, 1137, 3680, 582, 686, 198, 548, 14, 740, 8, 80, 9, 421, 198, 1107, 10609, 435, 3286, 1674, 904, 8, 548, 9, 199, 199, 318, 1050, 63, 475, 63, 515, 8, 1818, 12, 892, 304, 199, 198, 624, 23163, 1453, 436, 892, 1901, 1373, 931, 624, 199, 198, 692, 822, 8, 1222, 9, 508, 378, 26, 507, 198, 515, 275, 1453, 199, 198, 4164, 892, 59, 16, 61, 508, 30681, 507, 198, 515, 275, 892, 199, 198, 4164, 1453, 508, 30681, 507, 198, 515, 275, 10609, 435, 892, 199, 198, 2836, 26, 507, 198, 515, 275, 1453, 435, 10609, 435, 892, 199, 198, 1107, 6202, 63, 25310, 8, 515, 9, 199, 199, 533, 7667, 26, 199, 198, 624, 3284, 282, 1804, 7079, 9997, 570, 436, 3957, 652, 1901, 2018, 13955, 421, 198, 1918, 7667, 570, 365, 6702, 1901, 282, 663, 402, 11196, 626, 883, 506, 199, 198, 3617, 1043, 14, 221, 710, 2446, 1373, 12, 283, 991, 9430, 297, 365, 15235, 701, 570, 2870, 436, 199, 198, 7112, 83, 1006, 314, 2556, 367, 1924, 570, 27, 283, 24810, 7, 9033, 314, 199, 198, 2960, 334, 1708, 487, 3292, 1089, 570, 1305, 12, 536, 9, 370, 282, 570, 1305, 12, 436, 283, 991, 4604, 7, 199, 198, 8919, 3728, 2762, 370, 314, 570, 1305, 402, 3932, 31867, 14, 421, 198, 2822, 376, 23939, 370, 20850, 12, 283, 2866, 7, 436, 283, 478, 7, 3718, 787, 2741, 14, 199, 198, 31892, 12, 314, 283, 1074, 7, 1414, 7858, 17754, 5920, 14, 199, 198, 624, 8299, 198, 318, 636, 826, 721, 277, 12, 7667, 493, 304, 507, 198, 277, 14, 739, 8, 1850, 493, 9, 421, 198, 318, 5305, 8, 277, 304, 507, 198, 277, 14, 991, 9430, 275, 469, 789, 507, 198, 277, 14, 24810, 275, 469, 789, 507, 198, 277, 14, 991, 4604, 275, 469, 789, 507, 198, 277, 14, 1850, 12113, 275, 469, 789, 507, 198, 277, 14, 6525, 275, 10609, 421, 198, 318, 1586, 8, 277, 12, 7667, 493, 304, 507, 198, 624, 3284, 7667, 687, 570, 436, 3550, 2018, 6025, 624, 507, 198, 277, 14, 3958, 342, 507, 198, 893, 26, 686, 198, 1850, 275, 1551, 8, 1850, 493, 12, 298, 82, 531, 507, 198, 2590, 5925, 26, 686, 198, 1361, 298, 2425, 1133, 1551, 401, 7667, 493, 686, 198, 1107, 2742, 198, 604, 275, 378, 507, 198, 509, 2397, 315, 7667, 26, 686, 198, 604, 847, 413, 686, 198, 692, 822, 8, 2373, 9, 508, 413, 26, 198, 3, 2951, 314, 8057, 1585, 198, 6958, 686, 198, 4181, 275, 2397, 14, 6735, 1252, 1294, 7825, 686, 198, 2087, 63, 354, 275, 4184, 59, 16, 61, 435, 2668, 1122, 2, 686, 198, 1078, 275, 2688, 8, 277, 12, 1798, 63, 354, 9, 686, 198, 692, 1686, 26, 1585, 198, 2087, 275, 2519, 8, 277, 12, 1798, 63, 354, 9, 1585, 198, 1078, 275, 4550, 8, 2087, 9, 436, 1798, 8, 4181, 9, 686, 198, 692, 440, 1686, 26, 1585, 198, 1361, 298, 3197, 2397, 12, 1004, 450, 68, 26, 450, 83, 2, 450, 971, 4671, 198, 8, 604, 12, 2397, 9, 421, 198, 318, 4107, 8, 277, 12, 4184, 12, 295, 63, 513, 304, 507, 198, 77, 275, 359, 264, 14, 1431, 8, 264, 63, 513, 59, 73, 61, 435, 7880, 401, 4184, 59, 73, 435, 413, 566, 971, 1585, 198, 509, 284, 315, 1425, 8, 552, 8, 264, 63, 513, 10524, 507, 198, 1107, 2155, 8, 827, 8, 77, 430, 421, 198, 318, 9997, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 1955, 937, 275, 1109, 8, 4181, 59, 17, 566, 507, 198, 1107, 4112, 421, 198, 318, 1015, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 1023, 937, 275, 1109, 8, 4181, 59, 17, 566, 507, 198, 1107, 4112, 421, 198, 318, 8289, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 2184, 63, 9430 ]
[ 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1898, 8315, 1804, 736, 13979, 22304, 14, 199, 3, 199, 3, 6529, 26, 699, 416, 415, 491, 546, 374, 334, 43, 736, 13979, 22304, 4959, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1804, 736, 16908, 3814, 6187, 334, 43, 7079, 680, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 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, 199, 3, 2478, 14, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 199, 3, 3443, 436, 4204, 1334, 314, 844, 14, 199, 3, 199, 3, 199, 3, 2018, 859, 626, 19953, 282, 1804, 7079, 9997, 570, 1901, 282, 663, 402, 199, 3, 11196, 370, 2040, 8837, 15735, 3155, 436, 17754, 7907, 14, 199, 3, 199, 646, 295, 199, 199, 318, 6202, 63, 25310, 8, 515, 304, 199, 198, 624, 21332, 7815, 436, 11541, 7, 7323, 687, 931, 624, 199, 198, 692, 334, 515, 508, 3286, 2349, 507, 198, 1107, 931, 421, 198, 548, 275, 942, 199, 198, 509, 299, 315, 931, 59, 17, 11455, 1294, 18265, 507, 198, 692, 299, 508, 21777, 582, 686, 198, 692, 822, 8, 548, 9, 1137, 378, 26, 1585, 198, 2264, 734, 1988, 17, 61, 686, 198, 2836, 26, 1585, 198, 548, 14, 740, 8, 80, 9, 507, 198, 4164, 299, 1137, 3680, 582, 686, 198, 548, 14, 740, 8, 80, 9, 421, 198, 1107, 10609, 435, 3286, 1674, 904, 8, 548, 9, 199, 199, 318, 1050, 63, 475, 63, 515, 8, 1818, 12, 892, 304, 199, 198, 624, 23163, 1453, 436, 892, 1901, 1373, 931, 624, 199, 198, 692, 822, 8, 1222, 9, 508, 378, 26, 507, 198, 515, 275, 1453, 199, 198, 4164, 892, 59, 16, 61, 508, 30681, 507, 198, 515, 275, 892, 199, 198, 4164, 1453, 508, 30681, 507, 198, 515, 275, 10609, 435, 892, 199, 198, 2836, 26, 507, 198, 515, 275, 1453, 435, 10609, 435, 892, 199, 198, 1107, 6202, 63, 25310, 8, 515, 9, 199, 199, 533, 7667, 26, 199, 198, 624, 3284, 282, 1804, 7079, 9997, 570, 436, 3957, 652, 1901, 2018, 13955, 421, 198, 1918, 7667, 570, 365, 6702, 1901, 282, 663, 402, 11196, 626, 883, 506, 199, 198, 3617, 1043, 14, 221, 710, 2446, 1373, 12, 283, 991, 9430, 297, 365, 15235, 701, 570, 2870, 436, 199, 198, 7112, 83, 1006, 314, 2556, 367, 1924, 570, 27, 283, 24810, 7, 9033, 314, 199, 198, 2960, 334, 1708, 487, 3292, 1089, 570, 1305, 12, 536, 9, 370, 282, 570, 1305, 12, 436, 283, 991, 4604, 7, 199, 198, 8919, 3728, 2762, 370, 314, 570, 1305, 402, 3932, 31867, 14, 421, 198, 2822, 376, 23939, 370, 20850, 12, 283, 2866, 7, 436, 283, 478, 7, 3718, 787, 2741, 14, 199, 198, 31892, 12, 314, 283, 1074, 7, 1414, 7858, 17754, 5920, 14, 199, 198, 624, 8299, 198, 318, 636, 826, 721, 277, 12, 7667, 493, 304, 507, 198, 277, 14, 739, 8, 1850, 493, 9, 421, 198, 318, 5305, 8, 277, 304, 507, 198, 277, 14, 991, 9430, 275, 469, 789, 507, 198, 277, 14, 24810, 275, 469, 789, 507, 198, 277, 14, 991, 4604, 275, 469, 789, 507, 198, 277, 14, 1850, 12113, 275, 469, 789, 507, 198, 277, 14, 6525, 275, 10609, 421, 198, 318, 1586, 8, 277, 12, 7667, 493, 304, 507, 198, 624, 3284, 7667, 687, 570, 436, 3550, 2018, 6025, 624, 507, 198, 277, 14, 3958, 342, 507, 198, 893, 26, 686, 198, 1850, 275, 1551, 8, 1850, 493, 12, 298, 82, 531, 507, 198, 2590, 5925, 26, 686, 198, 1361, 298, 2425, 1133, 1551, 401, 7667, 493, 686, 198, 1107, 2742, 198, 604, 275, 378, 507, 198, 509, 2397, 315, 7667, 26, 686, 198, 604, 847, 413, 686, 198, 692, 822, 8, 2373, 9, 508, 413, 26, 198, 3, 2951, 314, 8057, 1585, 198, 6958, 686, 198, 4181, 275, 2397, 14, 6735, 1252, 1294, 7825, 686, 198, 2087, 63, 354, 275, 4184, 59, 16, 61, 435, 2668, 1122, 2, 686, 198, 1078, 275, 2688, 8, 277, 12, 1798, 63, 354, 9, 686, 198, 692, 1686, 26, 1585, 198, 2087, 275, 2519, 8, 277, 12, 1798, 63, 354, 9, 1585, 198, 1078, 275, 4550, 8, 2087, 9, 436, 1798, 8, 4181, 9, 686, 198, 692, 440, 1686, 26, 1585, 198, 1361, 298, 3197, 2397, 12, 1004, 450, 68, 26, 450, 83, 2, 450, 971, 4671, 198, 8, 604, 12, 2397, 9, 421, 198, 318, 4107, 8, 277, 12, 4184, 12, 295, 63, 513, 304, 507, 198, 77, 275, 359, 264, 14, 1431, 8, 264, 63, 513, 59, 73, 61, 435, 7880, 401, 4184, 59, 73, 435, 413, 566, 971, 1585, 198, 509, 284, 315, 1425, 8, 552, 8, 264, 63, 513, 10524, 507, 198, 1107, 2155, 8, 827, 8, 77, 430, 421, 198, 318, 9997, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 1955, 937, 275, 1109, 8, 4181, 59, 17, 566, 507, 198, 1107, 4112, 421, 198, 318, 1015, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 1023, 937, 275, 1109, 8, 4181, 59, 17, 566, 507, 198, 1107, 4112, 421, 198, 318, 8289, 63, 1122, 8, 277, 12, 4184, 304, 507, 198, 745, 275, 291, 14, 3502, 8, 4181, 12, 2097, 60, 68, 11, 3135, 507, 198, 692, 4112, 26, 686, 198, 277, 14, 1850, 12113, 905, 2184, 63, 9430, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gurneyalex/OpenUpgrade
addons/project/tests/__init__.py
121
1126
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2013-TODAY OpenERP S.A. <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 . import test_project_flow checks = [ test_project_flow, ] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 1275, 492, 511, 63, 1715, 63, 1659, 199, 199, 8625, 275, 359, 272, 511, 63, 1715, 63, 1659, 12, 199, 61, 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, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 1275, 492, 511, 63, 1715, 63, 1659, 199, 199, 8625, 275, 359, 272, 511, 63, 1715, 63, 1659, 12, 199, 61, 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, 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, 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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 ]
dansomething/vim-snippets
pythonx/vimsnippets.py
41
2928
"""Helper methods used in UltiSnips snippets.""" import string, vim def complete(tab, opts): """ get options that start with tab :param tab: query string :param opts: list that needs to be completed :return: a string that start with tab """ msg = "({0})" if tab: opts = [m[len(tab):] for m in opts if m.startswith(tab)] if len(opts) == 1: return opts[0] if not len(opts): msg = "{0}" return msg.format("|".join(opts)) def _parse_comments(s): """ Parses vim's comments option to extract comment format """ i = iter(s.split(",")) rv = [] try: while True: # get the flags and text of a comment part flags, text = next(i).split(':', 1) if len(flags) == 0: rv.append((text, text, text, "")) # parse 3-part comment, but ignore those with O flag elif 's' in flags and 'O' not in flags: ctriple = ["TRIPLE"] indent = "" if flags[-1] in string.digits: indent = " " * int(flags[-1]) ctriple.append(text) flags, text = next(i).split(':', 1) assert flags[0] == 'm' ctriple.append(text) flags, text = next(i).split(':', 1) assert flags[0] == 'e' ctriple.append(text) ctriple.append(indent) rv.append(ctriple) elif 'b' in flags: if len(text) == 1: rv.insert(0, ("SINGLE_CHAR", text, text, text, "")) except StopIteration: return rv def get_comment_format(): """ Returns a 4-element tuple (first_line, middle_lines, end_line, indent) representing the comment format for the current file. It first looks at the 'commentstring', if that ends with %s, it uses that. Otherwise it parses '&comments' and prefers single character comment markers if there are any. """ commentstring = vim.eval("&commentstring") if commentstring.endswith("%s"): c = commentstring[:-2] return (c, c, c, "") comments = _parse_comments(vim.eval("&comments")) for c in comments: if c[0] == "SINGLE_CHAR": return c[1:] return comments[0][1:] def make_box(twidth, bwidth=None): b, m, e, i = (s.strip() for s in get_comment_format()) bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2 sline = b + m + bwidth_inner * m[0] + 2 * m[0] nspaces = (bwidth_inner - twidth) // 2 mlines = i + m + " " + " " * nspaces mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e return sline, mlines, mlinee, eline def foldmarker(): "Return a tuple of (open fold marker, close fold marker)" return vim.eval("&foldmarker").split(",")
mit
[ 624, 4433, 3102, 1202, 315, 738, 21934, 20821, 6142, 19484, 1041, 199, 199, 646, 1059, 12, 6695, 199, 199, 318, 4890, 8, 2902, 12, 3999, 304, 272, 408, 272, 664, 1511, 626, 1343, 543, 5174, 339, 520, 635, 5174, 26, 1827, 1059, 272, 520, 635, 3999, 26, 769, 626, 4839, 370, 506, 9709, 339, 520, 1107, 26, 282, 1059, 626, 1343, 543, 5174, 272, 408, 272, 1499, 275, 298, 2561, 16, 1552, 2, 272, 340, 5174, 26, 267, 3999, 275, 359, 77, 59, 552, 8, 2902, 15405, 367, 333, 315, 3999, 340, 333, 14, 2460, 8, 2902, 1874, 272, 340, 822, 8, 3291, 9, 508, 413, 26, 267, 372, 3999, 59, 16, 61, 339, 340, 440, 822, 8, 3291, 304, 267, 1499, 275, 5310, 16, 7063, 272, 372, 1499, 14, 908, 25795, 1674, 904, 8, 3291, 430, 199, 199, 318, 485, 1122, 63, 6223, 8, 83, 304, 272, 408, 29968, 6695, 1159, 6786, 945, 370, 5536, 3721, 1475, 408, 272, 284, 275, 2740, 8, 83, 14, 1294, 11854, 2237, 339, 4336, 275, 942, 272, 862, 26, 267, 1830, 715, 26, 288, 327, 664, 314, 3285, 436, 1318, 402, 282, 3721, 1777, 288, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 953, 340, 822, 8, 2469, 9, 508, 378, 26, 355, 4336, 14, 740, 1332, 505, 12, 1318, 12, 1318, 12, 25491, 288, 327, 2198, 650, 13, 2064, 3721, 12, 1325, 3686, 5204, 543, 593, 3305, 288, 916, 283, 83, 7, 315, 3285, 436, 283, 47, 7, 440, 315, 3285, 26, 355, 286, 19956, 275, 2097, 1766, 1772, 906, 937, 355, 4363, 275, 3087, 2234, 340, 3285, 1988, 17, 61, 315, 1059, 14, 7022, 26, 490, 4363, 275, 298, 298, 627, 1109, 8, 2469, 1988, 17, 566, 355, 286, 19956, 14, 740, 8, 505, 9, 2234, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 355, 702, 3285, 59, 16, 61, 508, 283, 77, 7, 355, 286, 19956, 14, 740, 8, 505, 9, 2234, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 355, 702, 3285, 59, 16, 61, 508, 283, 69, 7, 355, 286, 19956, 14, 740, 8, 505, 9, 355, 286, 19956, 14, 740, 8, 3724, 9, 2234, 4336, 14, 740, 8, 319, 322, 11045, 9, 288, 916, 283, 66, 7, 315, 3285, 26, 355, 340, 822, 8, 505, 9, 508, 413, 26, 490, 4336, 14, 3176, 8, 16, 12, 1689, 16425, 63, 5901, 401, 1318, 12, 1318, 12, 1318, 12, 25491, 272, 871, 10852, 26, 267, 372, 4336, 199, 199, 318, 664, 63, 3349, 63, 908, 837, 272, 408, 1803, 282, 841, 13, 2108, 2008, 334, 2246, 63, 604, 12, 12180, 63, 1278, 12, 1284, 63, 604, 12, 4363, 9, 272, 6144, 314, 3721, 1475, 367, 314, 1453, 570, 14, 339, 2779, 1642, 10734, 737, 314, 283, 3349, 875, 297, 340, 626, 11187, 543, 450, 83, 12, 652, 4440, 626, 14, 272, 6630, 652, 19953, 7673, 6223, 7, 436, 20491, 1192, 2849, 4528, 3721, 272, 14327, 340, 2337, 787, 1263, 14, 272, 408, 272, 3721, 875, 275, 6695, 14, 2579, 22077, 3349, 875, 531, 272, 340, 3721, 875, 14, 4130, 3647, 83, 2349, 267, 286, 275, 3721, 875, 4439, 18, 61, 267, 372, 334, 67, 12, 286, 12, 286, 12, 6899, 272, 6786, 275, 485, 1122, 63, 6223, 8, 16361, 14, 2579, 22077, 6223, 2237, 272, 367, 286, 315, 6786, 26, 267, 340, 286, 59, 16, 61, 508, 298, 16425, 63, 5901, 582, 288, 372, 286, 59, 17, 2938, 272, 372, 6786, 59, 16, 1527, 17, 2938, 421, 199, 318, 1852, 63, 1977, 8, 84, 2063, 12, 330, 2063, 29, 403, 304, 272, 330, 12, 333, 12, 325, 12, 284, 275, 334, 83, 14, 1913, 342, 367, 308, 315, 664, 63, 3349, 63, 908, 1012, 272, 330, 2063, 63, 5216, 275, 330, 2063, 446, 650, 446, 1390, 8, 552, 8, 66, 395, 822, 8, 73, 435, 325, 430, 340, 330, 2063, 587, 307, 2063, 435, 499, 272, 308, 604, 275, 330, 435, 333, 435, 330, 2063, 63, 5216, 627, 333, 59, 16, 61, 435, 499, 627, 333, 59, 16, 61, 272, 700, 4285, 275, 334, 66, 2063, 63, 5216, 446, 307, 2063, 9, 5001, 499, 272, 333, 1278, 275, 284, 435, 333, 435, 298, 298, 435, 298, 298, 627, 700, 4285, 272, 333, 604, 69, 275, 298, 298, 435, 298, 298, 5830, 66, 2063, 63, 5216, 446, 307, 2063, 446, 700, 4285, 9, 435, 333, 272, 325, 604, 275, 284, 435, 333, 435, 330, 2063, 63, 5216, 627, 333, 59, 16, 61, 435, 499, 627, 333, 59, 16, 61, 435, 325, 272, 372, 308, 604, 12, 333, 1278, 12, 333, 604, 69, 12, 325, 604, 199, 199, 318, 20675, 4211, 837, 272, 298, 1767, 282, 2008, 402, 334, 1490, 20675, 3608, 12, 4002, 20675, 3608, 2924, 272, 372, 6695, 14, 2579, 22077, 14011, 4211, 3471, 1294, 20324, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4433, 3102, 1202, 315, 738, 21934, 20821, 6142, 19484, 1041, 199, 199, 646, 1059, 12, 6695, 199, 199, 318, 4890, 8, 2902, 12, 3999, 304, 272, 408, 272, 664, 1511, 626, 1343, 543, 5174, 339, 520, 635, 5174, 26, 1827, 1059, 272, 520, 635, 3999, 26, 769, 626, 4839, 370, 506, 9709, 339, 520, 1107, 26, 282, 1059, 626, 1343, 543, 5174, 272, 408, 272, 1499, 275, 298, 2561, 16, 1552, 2, 272, 340, 5174, 26, 267, 3999, 275, 359, 77, 59, 552, 8, 2902, 15405, 367, 333, 315, 3999, 340, 333, 14, 2460, 8, 2902, 1874, 272, 340, 822, 8, 3291, 9, 508, 413, 26, 267, 372, 3999, 59, 16, 61, 339, 340, 440, 822, 8, 3291, 304, 267, 1499, 275, 5310, 16, 7063, 272, 372, 1499, 14, 908, 25795, 1674, 904, 8, 3291, 430, 199, 199, 318, 485, 1122, 63, 6223, 8, 83, 304, 272, 408, 29968, 6695, 1159, 6786, 945, 370, 5536, 3721, 1475, 408, 272, 284, 275, 2740, 8, 83, 14, 1294, 11854, 2237, 339, 4336, 275, 942, 272, 862, 26, 267, 1830, 715, 26, 288, 327, 664, 314, 3285, 436, 1318, 402, 282, 3721, 1777, 288, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 953, 340, 822, 8, 2469, 9, 508, 378, 26, 355, 4336, 14, 740, 1332, 505, 12, 1318, 12, 1318, 12, 25491, 288, 327, 2198, 650, 13, 2064, 3721, 12, 1325, 3686, 5204, 543, 593, 3305, 288, 916, 283, 83, 7, 315, 3285, 436, 283, 47, 7, 440, 315, 3285, 26, 355, 286, 19956, 275, 2097, 1766, 1772, 906, 937, 355, 4363, 275, 3087, 2234, 340, 3285, 1988, 17, 61, 315, 1059, 14, 7022, 26, 490, 4363, 275, 298, 298, 627, 1109, 8, 2469, 1988, 17, 566, 355, 286, 19956, 14, 740, 8, 505, 9, 2234, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 355, 702, 3285, 59, 16, 61, 508, 283, 77, 7, 355, 286, 19956, 14, 740, 8, 505, 9, 2234, 3285, 12, 1318, 275, 2163, 8, 73, 680, 1294, 16451, 413, 9, 355, 702, 3285, 59, 16, 61, 508, 283, 69, 7, 355, 286, 19956, 14, 740, 8, 505, 9, 355, 286, 19956, 14, 740, 8, 3724, 9, 2234, 4336, 14, 740, 8, 319, 322, 11045, 9, 288, 916, 283, 66, 7, 315, 3285, 26, 355, 340, 822, 8, 505, 9, 508, 413, 26, 490, 4336, 14, 3176, 8, 16, 12, 1689, 16425, 63, 5901, 401, 1318, 12, 1318, 12, 1318, 12, 25491, 272, 871, 10852, 26, 267, 372, 4336, 199, 199, 318, 664, 63, 3349, 63, 908, 837, 272, 408, 1803, 282, 841, 13, 2108, 2008, 334, 2246, 63, 604, 12, 12180, 63, 1278, 12, 1284, 63, 604, 12, 4363, 9, 272, 6144, 314, 3721, 1475, 367, 314, 1453, 570, 14, 339, 2779, 1642, 10734, 737, 314, 283, 3349, 875, 297, 340, 626, 11187, 543, 450, 83, 12, 652, 4440, 626, 14, 272, 6630, 652, 19953, 7673, 6223, 7, 436, 20491, 1192, 2849, 4528, 3721, 272, 14327, 340, 2337, 787, 1263, 14, 272, 408, 272, 3721, 875, 275, 6695, 14, 2579, 22077, 3349, 875, 531, 272, 340, 3721, 875, 14, 4130, 3647, 83, 2349, 267, 286, 275, 3721, 875, 4439, 18, 61, 267, 372, 334, 67, 12, 286, 12, 286, 12, 6899, 272, 6786, 275, 485, 1122, 63, 6223, 8, 16361, 14, 2579, 22077, 6223, 2237, 272, 367, 286, 315, 6786, 26, 267, 340, 286, 59, 16, 61, 508, 298, 16425, 63, 5901, 582, 288, 372, 286, 59, 17, 2938, 272, 372, 6786, 59, 16, 1527, 17, 2938, 421, 199, 318, 1852, 63, 1977, 8, 84, 2063, 12, 330, 2063, 29, 403, 304, 272, 330, 12, 333, 12, 325, 12, 284, 275, 334, 83, 14, 1913, 342, 367, 308, 315, 664, 63, 3349, 63, 908, 1012, 272, 330, 2063, 63, 5216, 275, 330, 2063, 446, 650, 446, 1390, 8, 552, 8, 66, 395, 822, 8, 73, 435, 325, 430, 340, 330, 2063, 587, 307, 2063, 435, 499, 272, 308, 604, 275, 330, 435, 333, 435, 330, 2063, 63, 5216, 627, 333, 59, 16, 61, 435, 499, 627, 333, 59, 16, 61, 272, 700, 4285, 275, 334, 66, 2063, 63, 5216, 446, 307, 2063, 9, 5001, 499, 272, 333, 1278, 275, 284, 435, 333, 435, 298, 298, 435, 298, 298, 627, 700, 4285, 272, 333, 604, 69, 275, 298, 298, 435, 298, 298, 5830, 66, 2063, 63, 5216, 446, 307, 2063, 446, 700, 4285, 9, 435, 333, 272, 325, 604, 275, 284, 435, 333, 435, 330, 2063, 63, 5216, 627, 333, 59, 16, 61, 435, 499, 627, 333, 59, 16, 61, 435, 325, 272, 372, 308, 604, 12, 333, 1278, 12, 333, 604, 69, 12, 325, 604, 199, 199, 318, 20675, 4211, 837, 272, 298, 1767, 282, 2008, 402, 334, 1490, 20675, 3608, 12, 4002, 20675, 3608, 2924, 272, 372, 6695, 14, 2579, 22077, 14011, 4211, 3471, 1294, 20324, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
ajm-asiaa/test
carta/scriptedClient/tests/test_image.py
6
1942
import os import time import Image import carta.cartavis as cartavis import pyautogui import ImageUtil def test_saveImage(cartavisInstance, cleanSlate): """ Test that an image can be saved from the GUI. """ cartavisInstance.setImageLayout() i = cartavisInstance.getImageViews() filename = '/tmp/saveImage.png' imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png') assert imageWindow != None i[0].loadFile(os.getcwd() + '/data/mexinputtest.fits') _saveImage(imageWindow) # Verify that the output image is of the desired size given the save # parameters. image = Image.open(filename) # The default size of the saved image is 400x500, but the aspect # ratio mode is Keep, so the output size should be 400x400. assert image.size == (400,400) os.remove(filename) # This next save is a regression test for issue #101. zoomLevel = 0.2 i[0].setZoomLevel(zoomLevel) _saveImage(imageWindow) image = Image.open(filename) assert image.size == (400*zoomLevel, 400*zoomLevel) def _saveImage(imageWindow): """ Brings up the save image dialog, presses the Save button, and then closes the dialog. Parameters ---------- imageWindow: The image window which has already been located. """ pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1]) pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('return') saveButton = ImageUtil.locateCenterOnScreen( 'test_images/saveImageButton.png') assert saveButton != None pyautogui.click( x=saveButton[0], y=saveButton[1] ) closeButton = ImageUtil.locateCenterOnScreen('test_images/closeButton.png') assert closeButton != None pyautogui.click( x=closeButton[0], y=closeButton[1] )
gpl-2.0
[ 646, 747, 221, 199, 646, 900, 199, 646, 6047, 199, 646, 9590, 502, 14, 7007, 502, 5068, 465, 9590, 502, 5068, 199, 646, 1134, 6898, 974, 1907, 199, 646, 6047, 9562, 199, 199, 318, 511, 63, 2117, 3491, 8, 7007, 502, 5068, 3244, 12, 3633, 51, 750, 304, 272, 408, 272, 1379, 626, 376, 1834, 883, 506, 6290, 687, 314, 17160, 14, 272, 408, 272, 9590, 502, 5068, 3244, 14, 409, 3491, 4798, 342, 272, 284, 275, 9590, 502, 5068, 3244, 14, 362, 3491, 21180, 342, 272, 1788, 275, 1994, 2791, 15, 2117, 3491, 14, 4524, 7, 272, 1834, 4301, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 360, 396, 63, 4782, 15, 1569, 4301, 14, 4524, 358, 272, 702, 1834, 4301, 1137, 488, 272, 284, 59, 16, 1055, 912, 1173, 8, 736, 14, 9458, 342, 435, 1994, 576, 15, 278, 88, 1210, 396, 14, 14948, 358, 272, 485, 2117, 3491, 8, 1569, 4301, 9, 272, 327, 7635, 626, 314, 1072, 1834, 365, 402, 314, 6387, 1568, 1627, 314, 3354, 272, 327, 2633, 14, 272, 1834, 275, 6047, 14, 1490, 8, 1501, 9, 272, 327, 710, 849, 1568, 402, 314, 6290, 1834, 365, 8290, 88, 5783, 12, 1325, 314, 17435, 272, 327, 10463, 818, 365, 14797, 12, 880, 314, 1072, 1568, 1077, 506, 8290, 88, 5303, 14, 272, 702, 1834, 14, 890, 508, 334, 5303, 12, 5303, 9, 272, 747, 14, 2168, 8, 1501, 9, 272, 327, 961, 2163, 3354, 365, 282, 10864, 511, 367, 4976, 327, 4893, 14, 272, 16935, 4670, 275, 378, 14, 18, 5591, 284, 59, 16, 1055, 409, 26798, 4670, 8, 10598, 4670, 9, 272, 485, 2117, 3491, 8, 1569, 4301, 9, 272, 1834, 275, 6047, 14, 1490, 8, 1501, 9, 272, 702, 1834, 14, 890, 508, 334, 5303, 10, 10598, 4670, 12, 8290, 10, 10598, 4670, 9, 199, 199, 318, 485, 2117, 3491, 8, 1569, 4301, 304, 272, 408, 272, 699, 25182, 1536, 314, 3354, 1834, 9592, 12, 299, 4357, 314, 11063, 5528, 12, 436, 2066, 272, 27811, 314, 9592, 14, 339, 3897, 272, 4143, 272, 1834, 4301, 26, 267, 710, 1834, 4353, 1314, 965, 2575, 2757, 16180, 14, 272, 408, 272, 1134, 6898, 974, 1907, 14, 1019, 12040, 8, 88, 29, 1569, 4301, 59, 16, 467, 612, 29, 1569, 4301, 59, 17, 566, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 1107, 358, 272, 3354, 4259, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 8, 490, 283, 396, 63, 4782, 15, 2117, 3491, 4259, 14, 4524, 358, 272, 702, 3354, 4259, 1137, 488, 272, 1134, 6898, 974, 1907, 14, 4891, 8, 671, 29, 2117, 4259, 59, 16, 467, 612, 29, 2117, 4259, 59, 17, 61, 776, 272, 4002, 4259, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 360, 396, 63, 4782, 15, 1600, 4259, 14, 4524, 358, 272, 702, 4002, 4259, 1137, 488, 272, 1134, 6898, 974, 1907, 14, 4891, 8, 671, 29, 1600, 4259, 59, 16, 467, 612, 29, 1600, 4259, 59, 17, 61, 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 ]
[ 747, 221, 199, 646, 900, 199, 646, 6047, 199, 646, 9590, 502, 14, 7007, 502, 5068, 465, 9590, 502, 5068, 199, 646, 1134, 6898, 974, 1907, 199, 646, 6047, 9562, 199, 199, 318, 511, 63, 2117, 3491, 8, 7007, 502, 5068, 3244, 12, 3633, 51, 750, 304, 272, 408, 272, 1379, 626, 376, 1834, 883, 506, 6290, 687, 314, 17160, 14, 272, 408, 272, 9590, 502, 5068, 3244, 14, 409, 3491, 4798, 342, 272, 284, 275, 9590, 502, 5068, 3244, 14, 362, 3491, 21180, 342, 272, 1788, 275, 1994, 2791, 15, 2117, 3491, 14, 4524, 7, 272, 1834, 4301, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 360, 396, 63, 4782, 15, 1569, 4301, 14, 4524, 358, 272, 702, 1834, 4301, 1137, 488, 272, 284, 59, 16, 1055, 912, 1173, 8, 736, 14, 9458, 342, 435, 1994, 576, 15, 278, 88, 1210, 396, 14, 14948, 358, 272, 485, 2117, 3491, 8, 1569, 4301, 9, 272, 327, 7635, 626, 314, 1072, 1834, 365, 402, 314, 6387, 1568, 1627, 314, 3354, 272, 327, 2633, 14, 272, 1834, 275, 6047, 14, 1490, 8, 1501, 9, 272, 327, 710, 849, 1568, 402, 314, 6290, 1834, 365, 8290, 88, 5783, 12, 1325, 314, 17435, 272, 327, 10463, 818, 365, 14797, 12, 880, 314, 1072, 1568, 1077, 506, 8290, 88, 5303, 14, 272, 702, 1834, 14, 890, 508, 334, 5303, 12, 5303, 9, 272, 747, 14, 2168, 8, 1501, 9, 272, 327, 961, 2163, 3354, 365, 282, 10864, 511, 367, 4976, 327, 4893, 14, 272, 16935, 4670, 275, 378, 14, 18, 5591, 284, 59, 16, 1055, 409, 26798, 4670, 8, 10598, 4670, 9, 272, 485, 2117, 3491, 8, 1569, 4301, 9, 272, 1834, 275, 6047, 14, 1490, 8, 1501, 9, 272, 702, 1834, 14, 890, 508, 334, 5303, 10, 10598, 4670, 12, 8290, 10, 10598, 4670, 9, 199, 199, 318, 485, 2117, 3491, 8, 1569, 4301, 304, 272, 408, 272, 699, 25182, 1536, 314, 3354, 1834, 9592, 12, 299, 4357, 314, 11063, 5528, 12, 436, 2066, 272, 27811, 314, 9592, 14, 339, 3897, 272, 4143, 272, 1834, 4301, 26, 267, 710, 1834, 4353, 1314, 965, 2575, 2757, 16180, 14, 272, 408, 272, 1134, 6898, 974, 1907, 14, 1019, 12040, 8, 88, 29, 1569, 4301, 59, 16, 467, 612, 29, 1569, 4301, 59, 17, 566, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 2110, 358, 272, 1134, 6898, 974, 1907, 14, 2915, 360, 1107, 358, 272, 3354, 4259, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 8, 490, 283, 396, 63, 4782, 15, 2117, 3491, 4259, 14, 4524, 358, 272, 702, 3354, 4259, 1137, 488, 272, 1134, 6898, 974, 1907, 14, 4891, 8, 671, 29, 2117, 4259, 59, 16, 467, 612, 29, 2117, 4259, 59, 17, 61, 776, 272, 4002, 4259, 275, 6047, 9562, 14, 6280, 13551, 3314, 9616, 360, 396, 63, 4782, 15, 1600, 4259, 14, 4524, 358, 272, 702, 4002, 4259, 1137, 488, 272, 1134, 6898, 974, 1907, 14, 4891, 8, 671, 29, 1600, 4259, 59, 16, 467, 612, 29, 1600, 4259, 59, 17, 61, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hujiajie/chromium-crosswalk
third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py
13
3176
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import flakytests from webkitpy.common.checkout.scm.scm_mock import MockSCM from webkitpy.layout_tests.layout_package import bot_test_expectations from webkitpy.tool.commands.commandtest import CommandsTest from webkitpy.tool.mocktool import MockTool, MockOptions from webkitpy.layout_tests.port import builders class FakeBotTestExpectations(object): def expectation_lines(self, only_ignore_very_flaky=False): return [] class FakeBotTestExpectationsFactory(object): FAILURE_MAP = {"A": "AUDIO", "C": "CRASH", "F": "TEXT", "I": "IMAGE", "O": "MISSING", "N": "NO DATA", "P": "PASS", "T": "TIMEOUT", "Y": "NOTRUN", "X": "SKIP", "Z": "IMAGE+TEXT", "K": "LEAK"} def _expectations_from_test_data(self, builder, test_data): test_data[bot_test_expectations.ResultsJSON.FAILURE_MAP_KEY] = self.FAILURE_MAP json_dict = { builder: test_data, } results = bot_test_expectations.ResultsJSON(builder, json_dict) return bot_test_expectations.BotTestExpectations(results, builders._exact_matches[builder]["specifiers"]) def expectations_for_builder(self, builder): if builder == 'foo-builder': return self._expectations_from_test_data(builder, { 'tests': { 'pass.html': {'results': [[2, 'FFFP']], 'expected': 'PASS'}, } }) if builder == 'bar-builder': return self._expectations_from_test_data(builder, { 'tests': { 'pass.html': {'results': [[2, 'TTTP']], 'expected': 'PASS'}, } }) return FakeBotTestExpectations() class FlakyTestsTest(CommandsTest): def test_merge_lines(self): command = flakytests.FlakyTests() factory = FakeBotTestExpectationsFactory() old_builders = builders._exact_matches builders._exact_matches = { "foo-builder": {"port_name": "dummy-port", "specifiers": ['Linux', 'Release']}, "bar-builder": {"port_name": "dummy-port", "specifiers": ['Mac', 'Debug']}, } try: lines = command._collect_expectation_lines(['foo-builder', 'bar-builder'], factory) self.assertEqual(len(lines), 1) self.assertEqual(lines[0].expectations, ['TEXT', 'TIMEOUT', 'PASS']) self.assertEqual(lines[0].specifiers, ['Mac', 'Linux']) finally: builders._exact_matches = old_builders def test_integration(self): command = flakytests.FlakyTests() tool = MockTool() command.expectations_factory = FakeBotTestExpectationsFactory options = MockOptions(upload=True) expected_stdout = flakytests.FlakyTests.OUTPUT % ( flakytests.FlakyTests.HEADER, '', flakytests.FlakyTests.FLAKINESS_DASHBOARD_URL % '') + '\n' self.assert_execute_outputs(command, options=options, tool=tool, expected_stdout=expected_stdout)
bsd-3-clause
[ 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 17566, 10562, 2219, 199, 199, 504, 18007, 14, 2330, 14, 12891, 14, 17143, 14, 17143, 63, 1805, 492, 4420, 5153, 45, 199, 504, 18007, 14, 4209, 63, 2219, 14, 4209, 63, 2491, 492, 5888, 63, 396, 63, 15752, 199, 504, 18007, 14, 3557, 14, 4405, 14, 1531, 396, 492, 5817, 26935, 199, 504, 18007, 14, 3557, 14, 1805, 3557, 492, 4420, 5157, 12, 4420, 4558, 199, 504, 18007, 14, 4209, 63, 2219, 14, 719, 492, 27378, 199, 199, 533, 7777, 14026, 774, 31323, 8, 785, 304, 272, 347, 17513, 63, 1278, 8, 277, 12, 1454, 63, 4247, 63, 2588, 63, 14163, 10562, 29, 797, 304, 267, 372, 942, 421, 199, 533, 7777, 14026, 774, 31323, 2927, 8, 785, 304, 272, 10341, 3942, 63, 5443, 275, 2420, 33, 582, 298, 27743, 401, 298, 35, 582, 298, 2944, 8100, 401, 298, 38, 582, 298, 3876, 401, 298, 41, 582, 298, 9438, 401, 298, 47, 582, 298, 18701, 401, 673, 298, 46, 582, 298, 2826, 7126, 401, 298, 48, 582, 298, 6909, 401, 298, 52, 582, 298, 8899, 401, 298, 57, 582, 298, 4609, 9390, 401, 298, 56, 582, 298, 13525, 401, 673, 298, 58, 582, 298, 9438, 11, 3876, 401, 298, 43, 582, 298, 906, 7872, 3570, 339, 347, 485, 15752, 63, 504, 63, 396, 63, 576, 8, 277, 12, 6545, 12, 511, 63, 576, 304, 267, 511, 63, 576, 59, 3018, 63, 396, 63, 15752, 14, 6579, 6243, 14, 13989, 63, 5443, 63, 3078, 61, 275, 291, 14, 13989, 63, 5443, 267, 2022, 63, 807, 275, 469, 288, 6545, 26, 511, 63, 576, 12, 267, 789, 267, 2058, 275, 5888, 63, 396, 63, 15752, 14, 6579, 6243, 8, 5649, 12, 2022, 63, 807, 9, 267, 372, 5888, 63, 396, 63, 15752, 14, 14026, 774, 31323, 8, 2604, 12, 27378, 423, 7327, 63, 6742, 59, 5649, 7541, 31659, 3135, 339, 347, 21851, 63, 509, 63, 5649, 8, 277, 12, 6545, 304, 267, 340, 6545, 508, 283, 1421, 13, 5649, 356, 288, 372, 291, 423, 15752, 63, 504, 63, 396, 63, 576, 8, 5649, 12, 469, 355, 283, 2219, 356, 469, 490, 283, 1529, 14, 1360, 356, 791, 2604, 356, 3474, 18, 12, 283, 1665, 17095, 2157, 283, 2062, 356, 283, 6909, 2267, 355, 789, 288, 3828, 398, 340, 6545, 508, 283, 1700, 13, 5649, 356, 288, 372, 291, 423, 15752, 63, 504, 63, 396, 63, 576, 8, 5649, 12, 469, 355, 283, 2219, 356, 469, 490, 283, 1529, 14, 1360, 356, 791, 2604, 356, 3474, 18, 12, 283, 1481, 6495, 2157, 283, 2062, 356, 283, 6909, 2267, 355, 789, 288, 3828, 398, 372, 7777, 14026, 774, 31323, 342, 421, 199, 533, 481, 416, 10562, 2925, 774, 8, 14680, 774, 304, 272, 347, 511, 63, 5628, 63, 1278, 8, 277, 304, 267, 1414, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 342, 267, 6434, 275, 7777, 14026, 774, 31323, 2927, 342, 398, 2269, 63, 20968, 275, 27378, 423, 7327, 63, 6742, 267, 27378, 423, 7327, 63, 6742, 275, 469, 288, 298, 1421, 13, 5649, 582, 2420, 719, 63, 354, 582, 298, 5869, 13, 719, 401, 298, 31659, 582, 788, 14091, 297, 283, 9625, 14949, 288, 298, 1700, 13, 5649, 582, 2420, 719, 63, 354, 582, 298, 5869, 13, 719, 401, 298, 31659, 582, 788, 3399, 297, 283, 7084, 14949, 267, 789, 398, 862, 26, 288, 2385, 275, 1414, 423, 7112, 63, 20838, 63, 1278, 2941, 1421, 13, 5649, 297, 283, 1700, 13, 5649, 995, 6434, 9, 288, 291, 14, 629, 8, 552, 8, 1278, 395, 413, 9, 288, 291, 14, 629, 8, 1278, 59, 16, 1055, 15752, 12, 788, 3876, 297, 283, 8899, 297, 283, 6909, 1105, 288, 291, 14, 629, 8, 1278, 59, 16, 1055, 31659, 12, 788, 3399, 297, 283, 14091, 1105, 267, 3753, 26, 288, 27378, 423, 7327, 63, 6742, 275, 2269, 63, 20968, 2378, 347, 511, 63, 15092, 8, 277, 304, 267, 1414, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 342, 267, 4744, 275, 4420, 5157, 342, 267, 1414, 14, 15752, 63, 3702, 275, 7777, 14026, 774, 31323, 2927, 267, 1511, 275, 4420, 4558, 8, 5064, 29, 549, 9, 267, 1420, 63, 2703, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 8414, 450, 334, 288, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 7311, 12, 288, 3260, 288, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 3143, 7872, 9639, 63, 29019, 23368, 63, 2632, 450, 4074, 435, 1557, 78, 7, 398, 291, 14, 479, 63, 2526, 63, 4467, 8, 1531, 12, 1511, 29, 1419, 12, 4744, 29, 3557, 12, 1420, 63, 2703, 29, 2062, 63, 2703, 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 ]
[ 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 17566, 10562, 2219, 199, 199, 504, 18007, 14, 2330, 14, 12891, 14, 17143, 14, 17143, 63, 1805, 492, 4420, 5153, 45, 199, 504, 18007, 14, 4209, 63, 2219, 14, 4209, 63, 2491, 492, 5888, 63, 396, 63, 15752, 199, 504, 18007, 14, 3557, 14, 4405, 14, 1531, 396, 492, 5817, 26935, 199, 504, 18007, 14, 3557, 14, 1805, 3557, 492, 4420, 5157, 12, 4420, 4558, 199, 504, 18007, 14, 4209, 63, 2219, 14, 719, 492, 27378, 199, 199, 533, 7777, 14026, 774, 31323, 8, 785, 304, 272, 347, 17513, 63, 1278, 8, 277, 12, 1454, 63, 4247, 63, 2588, 63, 14163, 10562, 29, 797, 304, 267, 372, 942, 421, 199, 533, 7777, 14026, 774, 31323, 2927, 8, 785, 304, 272, 10341, 3942, 63, 5443, 275, 2420, 33, 582, 298, 27743, 401, 298, 35, 582, 298, 2944, 8100, 401, 298, 38, 582, 298, 3876, 401, 298, 41, 582, 298, 9438, 401, 298, 47, 582, 298, 18701, 401, 673, 298, 46, 582, 298, 2826, 7126, 401, 298, 48, 582, 298, 6909, 401, 298, 52, 582, 298, 8899, 401, 298, 57, 582, 298, 4609, 9390, 401, 298, 56, 582, 298, 13525, 401, 673, 298, 58, 582, 298, 9438, 11, 3876, 401, 298, 43, 582, 298, 906, 7872, 3570, 339, 347, 485, 15752, 63, 504, 63, 396, 63, 576, 8, 277, 12, 6545, 12, 511, 63, 576, 304, 267, 511, 63, 576, 59, 3018, 63, 396, 63, 15752, 14, 6579, 6243, 14, 13989, 63, 5443, 63, 3078, 61, 275, 291, 14, 13989, 63, 5443, 267, 2022, 63, 807, 275, 469, 288, 6545, 26, 511, 63, 576, 12, 267, 789, 267, 2058, 275, 5888, 63, 396, 63, 15752, 14, 6579, 6243, 8, 5649, 12, 2022, 63, 807, 9, 267, 372, 5888, 63, 396, 63, 15752, 14, 14026, 774, 31323, 8, 2604, 12, 27378, 423, 7327, 63, 6742, 59, 5649, 7541, 31659, 3135, 339, 347, 21851, 63, 509, 63, 5649, 8, 277, 12, 6545, 304, 267, 340, 6545, 508, 283, 1421, 13, 5649, 356, 288, 372, 291, 423, 15752, 63, 504, 63, 396, 63, 576, 8, 5649, 12, 469, 355, 283, 2219, 356, 469, 490, 283, 1529, 14, 1360, 356, 791, 2604, 356, 3474, 18, 12, 283, 1665, 17095, 2157, 283, 2062, 356, 283, 6909, 2267, 355, 789, 288, 3828, 398, 340, 6545, 508, 283, 1700, 13, 5649, 356, 288, 372, 291, 423, 15752, 63, 504, 63, 396, 63, 576, 8, 5649, 12, 469, 355, 283, 2219, 356, 469, 490, 283, 1529, 14, 1360, 356, 791, 2604, 356, 3474, 18, 12, 283, 1481, 6495, 2157, 283, 2062, 356, 283, 6909, 2267, 355, 789, 288, 3828, 398, 372, 7777, 14026, 774, 31323, 342, 421, 199, 533, 481, 416, 10562, 2925, 774, 8, 14680, 774, 304, 272, 347, 511, 63, 5628, 63, 1278, 8, 277, 304, 267, 1414, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 342, 267, 6434, 275, 7777, 14026, 774, 31323, 2927, 342, 398, 2269, 63, 20968, 275, 27378, 423, 7327, 63, 6742, 267, 27378, 423, 7327, 63, 6742, 275, 469, 288, 298, 1421, 13, 5649, 582, 2420, 719, 63, 354, 582, 298, 5869, 13, 719, 401, 298, 31659, 582, 788, 14091, 297, 283, 9625, 14949, 288, 298, 1700, 13, 5649, 582, 2420, 719, 63, 354, 582, 298, 5869, 13, 719, 401, 298, 31659, 582, 788, 3399, 297, 283, 7084, 14949, 267, 789, 398, 862, 26, 288, 2385, 275, 1414, 423, 7112, 63, 20838, 63, 1278, 2941, 1421, 13, 5649, 297, 283, 1700, 13, 5649, 995, 6434, 9, 288, 291, 14, 629, 8, 552, 8, 1278, 395, 413, 9, 288, 291, 14, 629, 8, 1278, 59, 16, 1055, 15752, 12, 788, 3876, 297, 283, 8899, 297, 283, 6909, 1105, 288, 291, 14, 629, 8, 1278, 59, 16, 1055, 31659, 12, 788, 3399, 297, 283, 14091, 1105, 267, 3753, 26, 288, 27378, 423, 7327, 63, 6742, 275, 2269, 63, 20968, 2378, 347, 511, 63, 15092, 8, 277, 304, 267, 1414, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 342, 267, 4744, 275, 4420, 5157, 342, 267, 1414, 14, 15752, 63, 3702, 275, 7777, 14026, 774, 31323, 2927, 267, 1511, 275, 4420, 4558, 8, 5064, 29, 549, 9, 267, 1420, 63, 2703, 275, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 8414, 450, 334, 288, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 7311, 12, 288, 3260, 288, 17566, 10562, 2219, 14, 38, 416, 10562, 2925, 14, 3143, 7872, 9639, 63, 29019, 23368, 63, 2632, 450, 4074, 435, 1557, 78, 7, 398, 291, 14, 479, 63, 2526, 63, 4467, 8, 1531, 12, 1511, 29, 1419, 12, 4744, 29, 3557, 12, 1420, 63, 2703, 29, 2062, 63, 2703, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jagguli/intellij-community
python/lib/Lib/site-packages/django/db/models/related.py
231
3157
from django.utils.encoding import smart_unicode from django.db.models.fields import BLANK_CHOICE_DASH class BoundRelatedObject(object): def __init__(self, related_object, field_mapping, original): self.relation = related_object self.field_mappings = field_mapping[related_object.name] def template_name(self): raise NotImplementedError def __repr__(self): return repr(self.__dict__) class RelatedObject(object): def __init__(self, parent_model, model, field): self.parent_model = parent_model self.model = model self.opts = model._meta self.field = field self.name = '%s:%s' % (self.opts.app_label, self.opts.module_name) self.var_name = self.opts.object_name.lower() def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_to_currently_related=False): """Returns choices with a default blank choices included, for use as SelectField choices for this field. Analogue of django.db.models.fields.Field.get_choices, provided initially for utilisation by RelatedFilterSpec. """ first_choice = include_blank and blank_choice or [] queryset = self.model._default_manager.all() if limit_to_currently_related: queryset = queryset.complex_filter( {'%s__isnull' % self.parent_model._meta.module_name: False}) lst = [(x._get_pk_val(), smart_unicode(x)) for x in queryset] return first_choice + lst def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): # Defer to the actual field definition for db prep return self.field.get_db_prep_lookup(lookup_type, value, connection=connection, prepared=prepared) def editable_fields(self): "Get the fields in this class that should be edited inline." return [f for f in self.opts.fields + self.opts.many_to_many if f.editable and f != self.field] def __repr__(self): return "<RelatedObject: %s related to %s>" % (self.name, self.field.name) def bind(self, field_mapping, original, bound_related_object_class=BoundRelatedObject): return bound_related_object_class(self, field_mapping, original) def get_accessor_name(self): # This method encapsulates the logic that decides what name to give an # accessor descriptor that retrieves related many-to-one or # many-to-many objects. It uses the lower-cased object_name + "_set", # but this can be overridden with the "related_name" option. if self.field.rel.multiple: # If this is a symmetrical m2m relation on self, there is no reverse accessor. if getattr(self.field.rel, 'symmetrical', False) and self.model == self.parent_model: return None return self.field.rel.related_name or (self.opts.object_name.lower() + '_set') else: return self.field.rel.related_name or (self.opts.object_name.lower()) def get_cache_name(self): return "_%s_cache" % self.get_accessor_name()
apache-2.0
[ 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 699, 10825, 43, 63, 22544, 63, 29019, 199, 199, 533, 21972, 13885, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4048, 63, 785, 12, 901, 63, 4745, 12, 3379, 304, 267, 291, 14, 5690, 275, 4048, 63, 785, 267, 291, 14, 698, 63, 14632, 275, 901, 63, 4745, 59, 2407, 63, 785, 14, 354, 61, 339, 347, 1978, 63, 354, 8, 277, 304, 267, 746, 4279, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 855, 807, 3368, 199, 199, 533, 20116, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 63, 1238, 12, 1402, 12, 901, 304, 267, 291, 14, 1708, 63, 1238, 275, 1676, 63, 1238, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 3291, 275, 1402, 423, 2024, 267, 291, 14, 698, 275, 901, 267, 291, 14, 354, 275, 1543, 83, 2689, 83, 7, 450, 334, 277, 14, 3291, 14, 571, 63, 1302, 12, 291, 14, 3291, 14, 578, 63, 354, 9, 267, 291, 14, 1391, 63, 354, 275, 291, 14, 3291, 14, 785, 63, 354, 14, 2325, 342, 339, 347, 664, 63, 4577, 8, 277, 12, 2387, 63, 2500, 29, 549, 12, 4596, 63, 5095, 29, 20438, 63, 22544, 63, 29019, 12, 490, 2304, 63, 475, 63, 19767, 63, 2407, 29, 797, 304, 267, 408, 3407, 3415, 543, 282, 849, 4596, 3415, 5120, 12, 367, 675, 267, 465, 9496, 792, 3415, 367, 642, 901, 14, 398, 1626, 2548, 310, 402, 1639, 14, 697, 14, 992, 14, 955, 14, 792, 14, 362, 63, 4577, 12, 2741, 267, 22801, 367, 7678, 14392, 425, 701, 20116, 4131, 5307, 14, 267, 408, 267, 1642, 63, 5095, 275, 2387, 63, 2500, 436, 4596, 63, 5095, 503, 942, 267, 7594, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 342, 267, 340, 2304, 63, 475, 63, 19767, 63, 2407, 26, 288, 7594, 275, 7594, 14, 5254, 63, 1541, 8, 355, 791, 5, 83, 363, 15114, 7, 450, 291, 14, 1708, 63, 1238, 423, 2024, 14, 578, 63, 354, 26, 756, 1552, 267, 9877, 275, 3842, 88, 423, 362, 63, 2051, 63, 637, 1062, 11179, 63, 2975, 8, 88, 430, 367, 671, 315, 7594, 61, 267, 372, 1642, 63, 5095, 435, 9877, 5493, 347, 664, 63, 697, 63, 10837, 63, 3892, 8, 277, 12, 4237, 63, 466, 12, 574, 12, 1950, 12, 16318, 29, 797, 304, 267, 327, 1487, 2412, 370, 314, 3503, 901, 5492, 367, 1592, 19986, 267, 372, 291, 14, 698, 14, 362, 63, 697, 63, 10837, 63, 3892, 8, 3892, 63, 466, 12, 574, 12, 717, 1950, 29, 2105, 12, 16318, 29, 19260, 9, 339, 347, 14783, 63, 955, 8, 277, 304, 267, 298, 1002, 314, 1504, 315, 642, 1021, 626, 1077, 506, 21062, 8308, 2122, 267, 372, 359, 70, 367, 289, 315, 291, 14, 3291, 14, 955, 435, 291, 14, 3291, 14, 3479, 63, 475, 63, 3479, 340, 289, 14, 10820, 436, 289, 1137, 291, 14, 698, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 13885, 1692, 26, 450, 83, 4048, 370, 450, 83, 4335, 450, 334, 277, 14, 354, 12, 291, 14, 698, 14, 354, 9, 339, 347, 5398, 8, 277, 12, 901, 63, 4745, 12, 3379, 12, 3914, 63, 2407, 63, 785, 63, 533, 29, 8934, 13885, 1692, 304, 267, 372, 3914, 63, 2407, 63, 785, 63, 533, 8, 277, 12, 901, 63, 4745, 12, 3379, 9, 339, 347, 664, 63, 14033, 63, 354, 8, 277, 304, 267, 327, 961, 1083, 22667, 15409, 314, 9661, 626, 12985, 3424, 4052, 536, 370, 8120, 376, 267, 327, 19474, 5872, 626, 9619, 2310, 4048, 5002, 13, 475, 13, 368, 503, 267, 327, 5002, 13, 475, 13, 3479, 2251, 14, 2779, 4440, 314, 5117, 13, 32738, 909, 63, 354, 435, 2668, 409, 401, 267, 327, 1325, 642, 883, 506, 10087, 543, 314, 298, 2407, 63, 354, 2, 945, 14, 267, 340, 291, 14, 698, 14, 3369, 14, 6048, 26, 288, 327, 982, 642, 365, 282, 30091, 333, 18, 77, 5850, 641, 291, 12, 2337, 365, 949, 3837, 19474, 14, 288, 340, 2519, 8, 277, 14, 698, 14, 3369, 12, 283, 10247, 297, 756, 9, 436, 291, 14, 1238, 508, 291, 14, 1708, 63, 1238, 26, 355, 372, 488, 288, 372, 291, 14, 698, 14, 3369, 14, 2407, 63, 354, 503, 334, 277, 14, 3291, 14, 785, 63, 354, 14, 2325, 342, 435, 2513, 409, 358, 267, 587, 26, 288, 372, 291, 14, 698, 14, 3369, 14, 2407, 63, 354, 503, 334, 277, 14, 3291, 14, 785, 63, 354, 14, 2325, 1012, 339, 347, 664, 63, 1637, 63, 354, 8, 277, 304, 267, 372, 2668, 5, 83, 63, 1637, 2, 450, 291, 14, 362, 63, 14033, 63, 354, 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 ]
[ 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 699, 10825, 43, 63, 22544, 63, 29019, 199, 199, 533, 21972, 13885, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4048, 63, 785, 12, 901, 63, 4745, 12, 3379, 304, 267, 291, 14, 5690, 275, 4048, 63, 785, 267, 291, 14, 698, 63, 14632, 275, 901, 63, 4745, 59, 2407, 63, 785, 14, 354, 61, 339, 347, 1978, 63, 354, 8, 277, 304, 267, 746, 4279, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 855, 807, 3368, 199, 199, 533, 20116, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 63, 1238, 12, 1402, 12, 901, 304, 267, 291, 14, 1708, 63, 1238, 275, 1676, 63, 1238, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 3291, 275, 1402, 423, 2024, 267, 291, 14, 698, 275, 901, 267, 291, 14, 354, 275, 1543, 83, 2689, 83, 7, 450, 334, 277, 14, 3291, 14, 571, 63, 1302, 12, 291, 14, 3291, 14, 578, 63, 354, 9, 267, 291, 14, 1391, 63, 354, 275, 291, 14, 3291, 14, 785, 63, 354, 14, 2325, 342, 339, 347, 664, 63, 4577, 8, 277, 12, 2387, 63, 2500, 29, 549, 12, 4596, 63, 5095, 29, 20438, 63, 22544, 63, 29019, 12, 490, 2304, 63, 475, 63, 19767, 63, 2407, 29, 797, 304, 267, 408, 3407, 3415, 543, 282, 849, 4596, 3415, 5120, 12, 367, 675, 267, 465, 9496, 792, 3415, 367, 642, 901, 14, 398, 1626, 2548, 310, 402, 1639, 14, 697, 14, 992, 14, 955, 14, 792, 14, 362, 63, 4577, 12, 2741, 267, 22801, 367, 7678, 14392, 425, 701, 20116, 4131, 5307, 14, 267, 408, 267, 1642, 63, 5095, 275, 2387, 63, 2500, 436, 4596, 63, 5095, 503, 942, 267, 7594, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 342, 267, 340, 2304, 63, 475, 63, 19767, 63, 2407, 26, 288, 7594, 275, 7594, 14, 5254, 63, 1541, 8, 355, 791, 5, 83, 363, 15114, 7, 450, 291, 14, 1708, 63, 1238, 423, 2024, 14, 578, 63, 354, 26, 756, 1552, 267, 9877, 275, 3842, 88, 423, 362, 63, 2051, 63, 637, 1062, 11179, 63, 2975, 8, 88, 430, 367, 671, 315, 7594, 61, 267, 372, 1642, 63, 5095, 435, 9877, 5493, 347, 664, 63, 697, 63, 10837, 63, 3892, 8, 277, 12, 4237, 63, 466, 12, 574, 12, 1950, 12, 16318, 29, 797, 304, 267, 327, 1487, 2412, 370, 314, 3503, 901, 5492, 367, 1592, 19986, 267, 372, 291, 14, 698, 14, 362, 63, 697, 63, 10837, 63, 3892, 8, 3892, 63, 466, 12, 574, 12, 717, 1950, 29, 2105, 12, 16318, 29, 19260, 9, 339, 347, 14783, 63, 955, 8, 277, 304, 267, 298, 1002, 314, 1504, 315, 642, 1021, 626, 1077, 506, 21062, 8308, 2122, 267, 372, 359, 70, 367, 289, 315, 291, 14, 3291, 14, 955, 435, 291, 14, 3291, 14, 3479, 63, 475, 63, 3479, 340, 289, 14, 10820, 436, 289, 1137, 291, 14, 698, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 13885, 1692, 26, 450, 83, 4048, 370, 450, 83, 4335, 450, 334, 277, 14, 354, 12, 291, 14, 698, 14, 354, 9, 339, 347, 5398, 8, 277, 12, 901, 63, 4745, 12, 3379, 12, 3914, 63, 2407, 63, 785, 63, 533, 29, 8934, 13885, 1692, 304, 267, 372, 3914, 63, 2407, 63, 785, 63, 533, 8, 277, 12, 901, 63, 4745, 12, 3379, 9, 339, 347, 664, 63, 14033, 63, 354, 8, 277, 304, 267, 327, 961, 1083, 22667, 15409, 314, 9661, 626, 12985, 3424, 4052, 536, 370, 8120, 376, 267, 327, 19474, 5872, 626, 9619, 2310, 4048, 5002, 13, 475, 13, 368, 503, 267, 327, 5002, 13, 475, 13, 3479, 2251, 14, 2779, 4440, 314, 5117, 13, 32738, 909, 63, 354, 435, 2668, 409, 401, 267, 327, 1325, 642, 883, 506, 10087, 543, 314, 298, 2407, 63, 354, 2, 945, 14, 267, 340, 291, 14, 698, 14, 3369, 14, 6048, 26, 288, 327, 982, 642, 365, 282, 30091, 333, 18, 77, 5850, 641, 291, 12, 2337, 365, 949, 3837, 19474, 14, 288, 340, 2519, 8, 277, 14, 698, 14, 3369, 12, 283, 10247, 297, 756, 9, 436, 291, 14, 1238, 508, 291, 14, 1708, 63, 1238, 26, 355, 372, 488, 288, 372, 291, 14, 698, 14, 3369, 14, 2407, 63, 354, 503, 334, 277, 14, 3291, 14, 785, 63, 354, 14, 2325, 342, 435, 2513, 409, 358, 267, 587, 26, 288, 372, 291, 14, 698, 14, 3369, 14, 2407, 63, 354, 503, 334, 277, 14, 3291, 14, 785, 63, 354, 14, 2325, 1012, 339, 347, 664, 63, 1637, 63, 354, 8, 277, 304, 267, 372, 2668, 5, 83, 63, 1637, 2, 450, 291, 14, 362, 63, 14033, 63, 354, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
stevedh/queryutils
queryutils/user.py
1
2181
from json import JSONEncoder class User(object): def __init__(self, name): self.name = name self.sessions = {} self.queries = [] class VerboseUserEncoder(JSONEncoder): def encode(self, obj): user_dict = {} user_dict['name'] = obj.name session_dict = {} for (session_id, session) in obj.sessions.iteritems(): session_dict[session_id] = SessionEncoder().default(session) query_list = [] for query in obj.queries: query_list.append(QueryEncoder().default(query)) user_dict['queries'] = query_list return user_dict def default(self, obj): if isinstance(obj, User): return self.encode(obj) return JSONEncoder.default(self, obj) class UserEncoder(JSONEncoder): def encode(self, obj): user_dict = {} user_dict['name'] = obj.name session_dict = {} for (session_id, session) in obj.sessions.iteritems(): session_dict['id'] = session_id query_list = [] for query in session.queries: query_dict = {} query_dict['delta'] = query.delta query_dict['time'] = query.time query_dict['text'] = query.text query_list.append(query_dict) session_dict['queries'] = query_list session_dict['user'] = obj.name try: autorecurring_query_list = [] for query in obj.autorecurring_queries: query_dict = {} query_dict['repeat_delta'] = query.repeat_delta query_dict['time'] = query.time query_dict['text'] = query.text autorecurring_query_list.append(query_dict) user_dict['autorecurring_queries'] = autorecurring_query_list except AttributeError: print "Not encoding autorecurring queries. No such attribute." user_dict['sessions'] = session_dict return user_dict def default(self, obj): if isinstance(obj, User): return self.encode(obj) return JSONEncoder.default(self, obj)
bsd-3-clause
[ 199, 504, 2022, 492, 4840, 6679, 199, 199, 533, 2876, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 11676, 275, 1052, 267, 291, 14, 10590, 275, 942, 199, 199, 533, 5444, 2220, 1899, 6679, 8, 23069, 304, 339, 347, 3752, 8, 277, 12, 1559, 304, 267, 922, 63, 807, 275, 1052, 267, 922, 63, 807, 459, 354, 418, 275, 1559, 14, 354, 267, 2351, 63, 807, 275, 1052, 267, 367, 334, 1730, 63, 344, 12, 2351, 9, 315, 1559, 14, 11676, 14, 4611, 837, 288, 2351, 63, 807, 59, 1730, 63, 344, 61, 275, 8596, 6679, 1252, 885, 8, 1730, 9, 267, 1827, 63, 513, 275, 942, 267, 367, 1827, 315, 1559, 14, 10590, 26, 288, 1827, 63, 513, 14, 740, 8, 3227, 6679, 1252, 885, 8, 1131, 430, 267, 922, 63, 807, 459, 10590, 418, 275, 1827, 63, 513, 267, 372, 922, 63, 807, 339, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2876, 304, 288, 372, 291, 14, 2143, 8, 1113, 9, 267, 372, 4840, 6679, 14, 885, 8, 277, 12, 1559, 9, 199, 199, 533, 2876, 6679, 8, 23069, 304, 339, 347, 3752, 8, 277, 12, 1559, 304, 267, 922, 63, 807, 275, 1052, 267, 922, 63, 807, 459, 354, 418, 275, 1559, 14, 354, 267, 2351, 63, 807, 275, 1052, 267, 367, 334, 1730, 63, 344, 12, 2351, 9, 315, 1559, 14, 11676, 14, 4611, 837, 288, 2351, 63, 807, 459, 344, 418, 275, 2351, 63, 344, 288, 1827, 63, 513, 275, 942, 288, 367, 1827, 315, 2351, 14, 10590, 26, 355, 1827, 63, 807, 275, 1052, 355, 1827, 63, 807, 459, 3136, 418, 275, 1827, 14, 3136, 355, 1827, 63, 807, 459, 521, 418, 275, 1827, 14, 521, 355, 1827, 63, 807, 459, 505, 418, 275, 1827, 14, 505, 355, 1827, 63, 513, 14, 740, 8, 1131, 63, 807, 9, 288, 2351, 63, 807, 459, 10590, 418, 275, 1827, 63, 513, 288, 2351, 63, 807, 459, 751, 418, 275, 1559, 14, 354, 267, 862, 26, 288, 28589, 895, 5985, 63, 1131, 63, 513, 275, 942, 288, 367, 1827, 315, 1559, 14, 27082, 895, 5985, 63, 10590, 26, 355, 1827, 63, 807, 275, 1052, 355, 1827, 63, 807, 459, 8755, 63, 3136, 418, 275, 1827, 14, 8755, 63, 3136, 355, 1827, 63, 807, 459, 521, 418, 275, 1827, 14, 521, 355, 1827, 63, 807, 459, 505, 418, 275, 1827, 14, 505, 355, 28589, 895, 5985, 63, 1131, 63, 513, 14, 740, 8, 1131, 63, 807, 9, 288, 922, 63, 807, 459, 27082, 895, 5985, 63, 10590, 418, 275, 28589, 895, 5985, 63, 1131, 63, 513, 267, 871, 4281, 26, 7205, 870, 298, 1763, 2644, 28589, 895, 5985, 9212, 14, 3091, 4066, 2225, 2122, 267, 922, 63, 807, 459, 11676, 418, 275, 2351, 63, 807, 267, 372, 922, 63, 807, 339, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2876, 304, 288, 372, 291, 14, 2143, 8, 1113, 9, 267, 372, 4840, 6679, 14, 885, 8, 277, 12, 1559, 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 ]
[ 504, 2022, 492, 4840, 6679, 199, 199, 533, 2876, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 11676, 275, 1052, 267, 291, 14, 10590, 275, 942, 199, 199, 533, 5444, 2220, 1899, 6679, 8, 23069, 304, 339, 347, 3752, 8, 277, 12, 1559, 304, 267, 922, 63, 807, 275, 1052, 267, 922, 63, 807, 459, 354, 418, 275, 1559, 14, 354, 267, 2351, 63, 807, 275, 1052, 267, 367, 334, 1730, 63, 344, 12, 2351, 9, 315, 1559, 14, 11676, 14, 4611, 837, 288, 2351, 63, 807, 59, 1730, 63, 344, 61, 275, 8596, 6679, 1252, 885, 8, 1730, 9, 267, 1827, 63, 513, 275, 942, 267, 367, 1827, 315, 1559, 14, 10590, 26, 288, 1827, 63, 513, 14, 740, 8, 3227, 6679, 1252, 885, 8, 1131, 430, 267, 922, 63, 807, 459, 10590, 418, 275, 1827, 63, 513, 267, 372, 922, 63, 807, 339, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2876, 304, 288, 372, 291, 14, 2143, 8, 1113, 9, 267, 372, 4840, 6679, 14, 885, 8, 277, 12, 1559, 9, 199, 199, 533, 2876, 6679, 8, 23069, 304, 339, 347, 3752, 8, 277, 12, 1559, 304, 267, 922, 63, 807, 275, 1052, 267, 922, 63, 807, 459, 354, 418, 275, 1559, 14, 354, 267, 2351, 63, 807, 275, 1052, 267, 367, 334, 1730, 63, 344, 12, 2351, 9, 315, 1559, 14, 11676, 14, 4611, 837, 288, 2351, 63, 807, 459, 344, 418, 275, 2351, 63, 344, 288, 1827, 63, 513, 275, 942, 288, 367, 1827, 315, 2351, 14, 10590, 26, 355, 1827, 63, 807, 275, 1052, 355, 1827, 63, 807, 459, 3136, 418, 275, 1827, 14, 3136, 355, 1827, 63, 807, 459, 521, 418, 275, 1827, 14, 521, 355, 1827, 63, 807, 459, 505, 418, 275, 1827, 14, 505, 355, 1827, 63, 513, 14, 740, 8, 1131, 63, 807, 9, 288, 2351, 63, 807, 459, 10590, 418, 275, 1827, 63, 513, 288, 2351, 63, 807, 459, 751, 418, 275, 1559, 14, 354, 267, 862, 26, 288, 28589, 895, 5985, 63, 1131, 63, 513, 275, 942, 288, 367, 1827, 315, 1559, 14, 27082, 895, 5985, 63, 10590, 26, 355, 1827, 63, 807, 275, 1052, 355, 1827, 63, 807, 459, 8755, 63, 3136, 418, 275, 1827, 14, 8755, 63, 3136, 355, 1827, 63, 807, 459, 521, 418, 275, 1827, 14, 521, 355, 1827, 63, 807, 459, 505, 418, 275, 1827, 14, 505, 355, 28589, 895, 5985, 63, 1131, 63, 513, 14, 740, 8, 1131, 63, 807, 9, 288, 922, 63, 807, 459, 27082, 895, 5985, 63, 10590, 418, 275, 28589, 895, 5985, 63, 1131, 63, 513, 267, 871, 4281, 26, 7205, 870, 298, 1763, 2644, 28589, 895, 5985, 9212, 14, 3091, 4066, 2225, 2122, 267, 922, 63, 807, 459, 11676, 418, 275, 2351, 63, 807, 267, 372, 922, 63, 807, 339, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2876, 304, 288, 372, 291, 14, 2143, 8, 1113, 9, 267, 372, 4840, 6679, 14, 885, 8, 277, 12, 1559, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
daavery/audacity
lib-src/lv2/lv2/waflib/Configure.py
181
9880
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file import os,shlex,sys,time from waflib import ConfigSet,Utils,Options,Logs,Context,Build,Errors try: from urllib import request except ImportError: from urllib import urlopen else: urlopen=request.urlopen BREAK='break' CONTINUE='continue' WAF_CONFIG_LOG='config.log' autoconfig=False conf_template='''# project %(app)s configured on %(now)s by # waf %(wafver)s (abi %(abi)s, python %(pyver)x on %(systype)s) # using %(args)s #''' def download_check(node): pass def download_tool(tool,force=False,ctx=None): for x in Utils.to_list(Context.remote_repo): for sub in Utils.to_list(Context.remote_locs): url='/'.join((x,sub,tool+'.py')) try: web=urlopen(url) try: if web.getcode()!=200: continue except AttributeError: pass except Exception: continue else: tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py'))) tmp.write(web.read(),'wb') Logs.warn('Downloaded %s from %s'%(tool,url)) download_check(tmp) try: module=Context.load_tool(tool) except Exception: Logs.warn('The tool %s from %s is unusable'%(tool,url)) try: tmp.delete() except Exception: pass continue return module raise Errors.WafError('Could not load the Waf tool') class ConfigurationContext(Context.Context): '''configures the project''' cmd='configure' error_handlers=[] def __init__(self,**kw): super(ConfigurationContext,self).__init__(**kw) self.environ=dict(os.environ) self.all_envs={} self.top_dir=None self.out_dir=None self.tools=[] self.hash=0 self.files=[] self.tool_cache=[] self.setenv('') def setenv(self,name,env=None): if name not in self.all_envs or env: if not env: env=ConfigSet.ConfigSet() self.prepare_env(env) else: env=env.derive() self.all_envs[name]=env self.variant=name def get_env(self): return self.all_envs[self.variant] def set_env(self,val): self.all_envs[self.variant]=val env=property(get_env,set_env) def init_dirs(self): top=self.top_dir if not top: top=Options.options.top if not top: top=getattr(Context.g_module,Context.TOP,None) if not top: top=self.path.abspath() top=os.path.abspath(top) self.srcnode=(os.path.isabs(top)and self.root or self.path).find_dir(top) assert(self.srcnode) out=self.out_dir if not out: out=Options.options.out if not out: out=getattr(Context.g_module,Context.OUT,None) if not out: out=Options.lockfile.replace('.lock-waf_%s_'%sys.platform,'').replace('.lock-waf','') self.bldnode=(os.path.isabs(out)and self.root or self.path).make_node(out) self.bldnode.mkdir() if not os.path.isdir(self.bldnode.abspath()): conf.fatal('Could not create the build directory %s'%self.bldnode.abspath()) def execute(self): self.init_dirs() self.cachedir=self.bldnode.make_node(Build.CACHE_DIR) self.cachedir.mkdir() path=os.path.join(self.bldnode.abspath(),WAF_CONFIG_LOG) self.logger=Logs.make_logger(path,'cfg') app=getattr(Context.g_module,'APPNAME','') if app: ver=getattr(Context.g_module,'VERSION','') if ver: app="%s (%s)"%(app,ver) now=time.ctime() pyver=sys.hexversion systype=sys.platform args=" ".join(sys.argv) wafver=Context.WAFVERSION abi=Context.ABI self.to_log(conf_template%vars()) self.msg('Setting top to',self.srcnode.abspath()) self.msg('Setting out to',self.bldnode.abspath()) if id(self.srcnode)==id(self.bldnode): Logs.warn('Setting top == out (remember to use "update_outputs")') elif id(self.path)!=id(self.srcnode): if self.srcnode.is_child_of(self.path): Logs.warn('Are you certain that you do not want to set top="." ?') super(ConfigurationContext,self).execute() self.store() Context.top_dir=self.srcnode.abspath() Context.out_dir=self.bldnode.abspath() env=ConfigSet.ConfigSet() env['argv']=sys.argv env['options']=Options.options.__dict__ env.run_dir=Context.run_dir env.top_dir=Context.top_dir env.out_dir=Context.out_dir env['hash']=self.hash env['files']=self.files env['environ']=dict(self.environ) if not self.env.NO_LOCK_IN_RUN: env.store(Context.run_dir+os.sep+Options.lockfile) if not self.env.NO_LOCK_IN_TOP: env.store(Context.top_dir+os.sep+Options.lockfile) if not self.env.NO_LOCK_IN_OUT: env.store(Context.out_dir+os.sep+Options.lockfile) def prepare_env(self,env): if not env.PREFIX: if Options.options.prefix or Utils.is_win32: env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix)) else: env.PREFIX='' if not env.BINDIR: env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env) if not env.LIBDIR: env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env) def store(self): n=self.cachedir.make_node('build.config.py') n.write('version = 0x%x\ntools = %r\n'%(Context.HEXVERSION,self.tools)) if not self.all_envs: self.fatal('nothing to store in the configuration context!') for key in self.all_envs: tmpenv=self.all_envs[key] tmpenv.store(os.path.join(self.cachedir.abspath(),key+Build.CACHE_SUFFIX)) def load(self,input,tooldir=None,funs=None,download=True): tools=Utils.to_list(input) if tooldir:tooldir=Utils.to_list(tooldir) for tool in tools: mag=(tool,id(self.env),funs) if mag in self.tool_cache: self.to_log('(tool %s is already loaded, skipping)'%tool) continue self.tool_cache.append(mag) module=None try: module=Context.load_tool(tool,tooldir) except ImportError ,e: if Options.options.download: module=download_tool(tool,ctx=self) if not module: self.fatal('Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s'%(tool,sys.path,e)) else: self.fatal('Could not load the Waf tool %r from %r (try the --download option?):\n%s'%(tool,sys.path,e)) except Exception ,e: self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs)) self.to_log(Utils.ex_stack()) raise if funs is not None: self.eval_rules(funs) else: func=getattr(module,'configure',None) if func: if type(func)is type(Utils.readf):func(self) else:self.eval_rules(func) self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs}) def post_recurse(self,node): super(ConfigurationContext,self).post_recurse(node) self.hash=Utils.h_list((self.hash,node.read('rb'))) self.files.append(node.abspath()) def eval_rules(self,rules): self.rules=Utils.to_list(rules) for x in self.rules: f=getattr(self,x) if not f:self.fatal("No such method '%s'."%x) try: f() except Exception ,e: ret=self.err_handler(x,e) if ret==BREAK: break elif ret==CONTINUE: continue else: raise def err_handler(self,fun,error): pass def conf(f): def fun(*k,**kw): mandatory=True if'mandatory'in kw: mandatory=kw['mandatory'] del kw['mandatory'] try: return f(*k,**kw) except Errors.ConfigurationError: if mandatory: raise setattr(ConfigurationContext,f.__name__,fun) setattr(Build.BuildContext,f.__name__,fun) return f @conf def add_os_flags(self,var,dest=None): try:self.env.append_value(dest or var,shlex.split(self.environ[var])) except KeyError:pass @conf def cmd_to_list(self,cmd): if isinstance(cmd,str)and cmd.find(' '): try: os.stat(cmd) except OSError: return shlex.split(cmd) else: return[cmd] return cmd @conf def check_waf_version(self,mini='1.6.99',maxi='1.8.0'): self.start_msg('Checking for waf version in %s-%s'%(str(mini),str(maxi))) ver=Context.HEXVERSION if Utils.num2ver(mini)>ver: self.fatal('waf version should be at least %r (%r found)'%(Utils.num2ver(mini),ver)) if Utils.num2ver(maxi)<ver: self.fatal('waf version should be at most %r (%r found)'%(Utils.num2ver(maxi),ver)) self.end_msg('ok') @conf def find_file(self,filename,path_list=[]): for n in Utils.to_list(filename): for d in Utils.to_list(path_list): p=os.path.join(d,n) if os.path.exists(p): return p self.fatal('Could not find %r'%filename) @conf def find_program(self,filename,**kw): exts=kw.get('exts',Utils.is_win32 and'.exe,.com,.bat,.cmd'or',.sh,.pl,.py') environ=kw.get('environ',os.environ) ret='' filename=Utils.to_list(filename) var=kw.get('var','') if not var: var=filename[0].upper() if self.env[var]: ret=self.env[var] elif var in environ: ret=environ[var] path_list=kw.get('path_list','') if not ret: if path_list: path_list=Utils.to_list(path_list) else: path_list=environ.get('PATH','').split(os.pathsep) if not isinstance(filename,list): filename=[filename] for a in exts.split(','): if ret: break for b in filename: if ret: break for c in path_list: if ret: break x=os.path.expanduser(os.path.join(c,b+a)) if os.path.isfile(x): ret=x if not ret and Utils.winreg: ret=Utils.get_registry_app_path(Utils.winreg.HKEY_CURRENT_USER,filename) if not ret and Utils.winreg: ret=Utils.get_registry_app_path(Utils.winreg.HKEY_LOCAL_MACHINE,filename) self.msg('Checking for program '+','.join(filename),ret or False) self.to_log('find program=%r paths=%r var=%r -> %r'%(filename,path_list,var,ret)) if not ret: self.fatal(kw.get('errmsg','')or'Could not find the program %s'%','.join(filename)) if var: self.env[var]=ret return ret @conf def find_perl_program(self,filename,path_list=[],var=None,environ=None,exts=''): try: app=self.find_program(filename,path_list=path_list,var=var,environ=environ,exts=exts) except Exception: self.find_program('perl',var='PERL') app=self.find_file(filename,os.environ['PATH'].split(os.pathsep)) if not app: raise if var: self.env[var]=Utils.to_list(self.env['PERL'])+[app] self.msg('Checking for %r'%filename,app)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 32507, 12, 1274, 12, 521, 199, 504, 31380, 492, 4094, 1084, 12, 7535, 12, 4558, 12, 16333, 12, 2998, 12, 3425, 12, 9298, 199, 893, 26, 199, 198, 504, 4011, 492, 1056, 199, 2590, 3545, 26, 199, 198, 504, 4011, 492, 18279, 199, 2836, 26, 199, 198, 10890, 29, 1069, 14, 10890, 199, 14731, 534, 4785, 7, 199, 26663, 4187, 534, 6958, 7, 199, 55, 5699, 63, 5569, 63, 4947, 534, 888, 14, 793, 7, 199, 2495, 888, 29, 797, 199, 2190, 63, 1160, 19938, 3, 2199, 2818, 571, 9, 83, 7526, 641, 2818, 2131, 9, 83, 701, 199, 3, 25782, 2818, 21500, 422, 9, 83, 334, 14677, 2818, 14677, 9, 83, 12, 2366, 2818, 29686, 9, 88, 641, 2818, 1786, 20615, 9, 83, 9, 199, 3, 1808, 2818, 589, 9, 83, 199, 3, 2344, 199, 318, 5235, 63, 1074, 8, 932, 304, 199, 198, 1529, 199, 318, 5235, 63, 3557, 8, 3557, 12, 3990, 29, 797, 12, 3799, 29, 403, 304, 199, 198, 509, 671, 315, 17397, 14, 475, 63, 513, 8, 2998, 14, 3846, 63, 3417, 304, 507, 198, 509, 1007, 315, 17397, 14, 475, 63, 513, 8, 2998, 14, 3846, 63, 15781, 304, 686, 198, 633, 8805, 1370, 904, 1332, 88, 12, 954, 12, 3557, 18098, 647, 1333, 686, 198, 893, 26, 1585, 198, 2520, 29, 10890, 8, 633, 9, 1585, 198, 893, 26, 1871, 198, 692, 3330, 14, 362, 600, 342, 1111, 1840, 26, 4671, 198, 6958, 1585, 198, 2590, 4281, 26, 1871, 198, 1529, 686, 198, 2590, 2186, 26, 1585, 198, 6958, 686, 198, 2836, 26, 1585, 198, 2791, 29, 3799, 14, 1231, 14, 1875, 63, 932, 8, 736, 14, 4127, 14, 904, 1332, 2998, 14, 21500, 63, 694, 2584, 21500, 773, 1673, 9975, 297, 3557, 18098, 647, 7058, 1585, 198, 2791, 14, 952, 8, 2520, 14, 739, 1062, 7, 6603, 358, 1585, 198, 16333, 14, 4050, 360, 3514, 4591, 450, 83, 687, 450, 83, 13328, 3557, 12, 633, 430, 1585, 198, 4249, 63, 1074, 8, 2791, 9, 1585, 198, 893, 26, 1871, 198, 578, 29, 2998, 14, 912, 63, 3557, 8, 3557, 9, 1585, 198, 2590, 2186, 26, 1871, 198, 16333, 14, 4050, 360, 1918, 4744, 450, 83, 687, 450, 83, 365, 625, 14418, 13328, 3557, 12, 633, 430, 1871, 198, 893, 26, 4671, 198, 2791, 14, 1807, 342, 1871, 198, 2590, 2186, 26, 4671, 198, 1529, 1871, 198, 6958, 1585, 198, 1107, 859, 199, 198, 3730, 20456, 14, 55, 2756, 547, 360, 6531, 440, 2248, 314, 644, 2756, 4744, 358, 199, 533, 11595, 2998, 8, 2998, 14, 2998, 304, 199, 198, 2344, 888, 1482, 314, 2199, 2344, 199, 198, 1760, 534, 6472, 7, 199, 198, 705, 63, 5586, 9811, 199, 198, 318, 636, 826, 721, 277, 12663, 829, 304, 507, 198, 4792, 8, 5688, 2998, 12, 277, 2843, 826, 14155, 829, 9, 507, 198, 277, 14, 2314, 29, 807, 8, 736, 14, 2314, 9, 507, 198, 277, 14, 452, 63, 27900, 7622, 507, 198, 277, 14, 2119, 63, 694, 29, 403, 507, 198, 277, 14, 548, 63, 694, 29, 403, 507, 198, 277, 14, 2537, 9811, 507, 198, 277, 14, 2227, 29, 16, 507, 198, 277, 14, 1725, 9811, 507, 198, 277, 14, 3557, 63, 1637, 9811, 507, 198, 277, 14, 261, 9072, 8355, 199, 198, 318, 542, 9072, 8, 277, 12, 354, 12, 1813, 29, 403, 304, 507, 198, 692, 536, 440, 315, 291, 14, 452, 63, 27900, 503, 2589, 26, 686, 198, 692, 440, 2589, 26, 1585, 198, 1813, 29, 2028, 1084, 14, 2028, 1084, 342, 1585, 198, 277, 14, 6726, 63, 1813, 8, 1813, 9, 686, 198, 2836, 26, 1585, 198, 1813, 29, 1813, 14, 271, 6053, 342, 686, 198, 277, 14, 452, 63, 27900, 59, 354, 10404, 1813, 507, 198, 277, 14, 8759, 29, 354, 199, 198, 318, 664, 63, 1813, 8, 277, 304, 507, 198, 1107, 291, 14, 452, 63, 27900, 59, 277, 14, 8759, 61, 199, 198, 318, 663, 63, 1813, 8, 277, 12, 637, 304, 507, 198, 277, 14, 452, 63, 27900, 59, 277, 14, 8759, 10404, 637, 199, 198, 1813, 29, 1829, 8, 362, 63, 1813, 12, 409, 63, 1813, 9, 199, 198, 318, 4205, 63, 3220, 8, 277, 304, 507, 198, 2119, 29, 277, 14, 2119, 63, 694, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 4558, 14, 1419, 14, 2119, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 5675, 8, 2998, 14, 71, 63, 578, 12, 2998, 14, 11422, 12, 403, 9, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 277, 14, 515, 14, 4832, 342, 507, 198, 2119, 29, 736, 14, 515, 14, 4832, 8, 2119, 9, 507, 198, 277, 14, 2164, 932, 2687, 736, 14, 515, 14, 17896, 8, 2119, 9, 460, 291, 14, 1231, 503, 291, 14, 515, 680, 1623, 63, 694, 8, 2119, 9, 507, 198, 479, 8, 277, 14, 2164, 932, 9, 507, 198, 548, 29, 277, 14, 548, 63, 694, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 4558, 14, 1419, 14, 548, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 5675, 8, 2998, 14, 71, 63, 578, 12, 2998, 14, 1877, 12, 403, 9, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 4558, 14, 26204, 14, 1814, 5175, 831, 13, 21500, 4970, 83, 63, 5956, 1274, 14, 3246, 2584, 1959, 1814, 5175, 831, 13, 21500, 20944, 507, 198, 277, 14, 14341, 932, 2687, 736, 14, 515, 14, 17896, 8, 548, 9, 460, 291, 14, 1231, 503, 291, 14, 515, 680, 1875, 63, 932, 8, 548, 9, 507, 198, 277, 14, 14341, 932, 14, 8215, 342, 507, 198, 692, 440, 747, 14, 515, 14, 6027, 8, 277, 14, 14341, 932, 14, 4832, 5109, 686, 198, 2190, 14, 16208, 360, 6531, 440, 1218, 314, 1900, 2082, 450, 83, 5956, 277, 14, 14341, 932, 14, 4832 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 32507, 12, 1274, 12, 521, 199, 504, 31380, 492, 4094, 1084, 12, 7535, 12, 4558, 12, 16333, 12, 2998, 12, 3425, 12, 9298, 199, 893, 26, 199, 198, 504, 4011, 492, 1056, 199, 2590, 3545, 26, 199, 198, 504, 4011, 492, 18279, 199, 2836, 26, 199, 198, 10890, 29, 1069, 14, 10890, 199, 14731, 534, 4785, 7, 199, 26663, 4187, 534, 6958, 7, 199, 55, 5699, 63, 5569, 63, 4947, 534, 888, 14, 793, 7, 199, 2495, 888, 29, 797, 199, 2190, 63, 1160, 19938, 3, 2199, 2818, 571, 9, 83, 7526, 641, 2818, 2131, 9, 83, 701, 199, 3, 25782, 2818, 21500, 422, 9, 83, 334, 14677, 2818, 14677, 9, 83, 12, 2366, 2818, 29686, 9, 88, 641, 2818, 1786, 20615, 9, 83, 9, 199, 3, 1808, 2818, 589, 9, 83, 199, 3, 2344, 199, 318, 5235, 63, 1074, 8, 932, 304, 199, 198, 1529, 199, 318, 5235, 63, 3557, 8, 3557, 12, 3990, 29, 797, 12, 3799, 29, 403, 304, 199, 198, 509, 671, 315, 17397, 14, 475, 63, 513, 8, 2998, 14, 3846, 63, 3417, 304, 507, 198, 509, 1007, 315, 17397, 14, 475, 63, 513, 8, 2998, 14, 3846, 63, 15781, 304, 686, 198, 633, 8805, 1370, 904, 1332, 88, 12, 954, 12, 3557, 18098, 647, 1333, 686, 198, 893, 26, 1585, 198, 2520, 29, 10890, 8, 633, 9, 1585, 198, 893, 26, 1871, 198, 692, 3330, 14, 362, 600, 342, 1111, 1840, 26, 4671, 198, 6958, 1585, 198, 2590, 4281, 26, 1871, 198, 1529, 686, 198, 2590, 2186, 26, 1585, 198, 6958, 686, 198, 2836, 26, 1585, 198, 2791, 29, 3799, 14, 1231, 14, 1875, 63, 932, 8, 736, 14, 4127, 14, 904, 1332, 2998, 14, 21500, 63, 694, 2584, 21500, 773, 1673, 9975, 297, 3557, 18098, 647, 7058, 1585, 198, 2791, 14, 952, 8, 2520, 14, 739, 1062, 7, 6603, 358, 1585, 198, 16333, 14, 4050, 360, 3514, 4591, 450, 83, 687, 450, 83, 13328, 3557, 12, 633, 430, 1585, 198, 4249, 63, 1074, 8, 2791, 9, 1585, 198, 893, 26, 1871, 198, 578, 29, 2998, 14, 912, 63, 3557, 8, 3557, 9, 1585, 198, 2590, 2186, 26, 1871, 198, 16333, 14, 4050, 360, 1918, 4744, 450, 83, 687, 450, 83, 365, 625, 14418, 13328, 3557, 12, 633, 430, 1871, 198, 893, 26, 4671, 198, 2791, 14, 1807, 342, 1871, 198, 2590, 2186, 26, 4671, 198, 1529, 1871, 198, 6958, 1585, 198, 1107, 859, 199, 198, 3730, 20456, 14, 55, 2756, 547, 360, 6531, 440, 2248, 314, 644, 2756, 4744, 358, 199, 533, 11595, 2998, 8, 2998, 14, 2998, 304, 199, 198, 2344, 888, 1482, 314, 2199, 2344, 199, 198, 1760, 534, 6472, 7, 199, 198, 705, 63, 5586, 9811, 199, 198, 318, 636, 826, 721, 277, 12663, 829, 304, 507, 198, 4792, 8, 5688, 2998, 12, 277, 2843, 826, 14155, 829, 9, 507, 198, 277, 14, 2314, 29, 807, 8, 736, 14, 2314, 9, 507, 198, 277, 14, 452, 63, 27900, 7622, 507, 198, 277, 14, 2119, 63, 694, 29, 403, 507, 198, 277, 14, 548, 63, 694, 29, 403, 507, 198, 277, 14, 2537, 9811, 507, 198, 277, 14, 2227, 29, 16, 507, 198, 277, 14, 1725, 9811, 507, 198, 277, 14, 3557, 63, 1637, 9811, 507, 198, 277, 14, 261, 9072, 8355, 199, 198, 318, 542, 9072, 8, 277, 12, 354, 12, 1813, 29, 403, 304, 507, 198, 692, 536, 440, 315, 291, 14, 452, 63, 27900, 503, 2589, 26, 686, 198, 692, 440, 2589, 26, 1585, 198, 1813, 29, 2028, 1084, 14, 2028, 1084, 342, 1585, 198, 277, 14, 6726, 63, 1813, 8, 1813, 9, 686, 198, 2836, 26, 1585, 198, 1813, 29, 1813, 14, 271, 6053, 342, 686, 198, 277, 14, 452, 63, 27900, 59, 354, 10404, 1813, 507, 198, 277, 14, 8759, 29, 354, 199, 198, 318, 664, 63, 1813, 8, 277, 304, 507, 198, 1107, 291, 14, 452, 63, 27900, 59, 277, 14, 8759, 61, 199, 198, 318, 663, 63, 1813, 8, 277, 12, 637, 304, 507, 198, 277, 14, 452, 63, 27900, 59, 277, 14, 8759, 10404, 637, 199, 198, 1813, 29, 1829, 8, 362, 63, 1813, 12, 409, 63, 1813, 9, 199, 198, 318, 4205, 63, 3220, 8, 277, 304, 507, 198, 2119, 29, 277, 14, 2119, 63, 694, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 4558, 14, 1419, 14, 2119, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 5675, 8, 2998, 14, 71, 63, 578, 12, 2998, 14, 11422, 12, 403, 9, 507, 198, 692, 440, 2746, 26, 686, 198, 2119, 29, 277, 14, 515, 14, 4832, 342, 507, 198, 2119, 29, 736, 14, 515, 14, 4832, 8, 2119, 9, 507, 198, 277, 14, 2164, 932, 2687, 736, 14, 515, 14, 17896, 8, 2119, 9, 460, 291, 14, 1231, 503, 291, 14, 515, 680, 1623, 63, 694, 8, 2119, 9, 507, 198, 479, 8, 277, 14, 2164, 932, 9, 507, 198, 548, 29, 277, 14, 548, 63, 694, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 4558, 14, 1419, 14, 548, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 5675, 8, 2998, 14, 71, 63, 578, 12, 2998, 14, 1877, 12, 403, 9, 507, 198, 692, 440, 734, 26, 686, 198, 548, 29, 4558, 14, 26204, 14, 1814, 5175, 831, 13, 21500, 4970, 83, 63, 5956, 1274, 14, 3246, 2584, 1959, 1814, 5175, 831, 13, 21500, 20944, 507, 198, 277, 14, 14341, 932, 2687, 736, 14, 515, 14, 17896, 8, 548, 9, 460, 291, 14, 1231, 503, 291, 14, 515, 680, 1875, 63, 932, 8, 548, 9, 507, 198, 277, 14, 14341, 932, 14, 8215, 342, 507, 198, 692, 440, 747, 14, 515, 14, 6027, 8, 277, 14, 14341, 932, 14, 4832, 5109, 686, 198, 2190, 14, 16208, 360, 6531, 440, 1218, 314, 1900, 2082, 450, 83, 5956, 277, 14, 14341, 932, 14, 4832, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Gagnon06/StrategyIA
RULEngine/Communication/protobuf/google/protobuf/internal/message_test.py
6
29543
#! /usr/bin/python # # Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # 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. """Tests python protocol buffers against the golden message. Note that the golden messages exercise every known field type, thus this test ends up exercising and verifying nearly all of the parsing and serialization code in the whole library. TODO(kenton): Merge with wire_format_test? It doesn't make a whole lot of sense to call this a test of the "message" module, which only declares an abstract interface. """ __author__ = 'gps@google.com (Gregory P. Smith)' import copy import math import operator import pickle import sys from google.apputils import basetest from google.protobuf import unittest_pb2 from google.protobuf.internal import api_implementation from google.protobuf.internal import test_util from google.protobuf import message # Python pre-2.6 does not have isinf() or isnan() functions, so we have # to provide our own. def isnan(val): # NaN is never equal to itself. return val != val def isinf(val): # Infinity times zero equals NaN. return not isnan(val) and isnan(val * 0) def IsPosInf(val): return isinf(val) and (val > 0) def IsNegInf(val): return isinf(val) and (val < 0) class MessageTest(basetest.TestCase): def testBadUtf8String(self): if api_implementation.Type() != 'python': self.skipTest("Skipping testBadUtf8String, currently only the python " "api implementation raises UnicodeDecodeError when a " "string field contains bad utf-8.") bad_utf8_data = test_util.GoldenFileData('bad_utf8_string') with self.assertRaises(UnicodeDecodeError) as context: unittest_pb2.TestAllTypes.FromString(bad_utf8_data) self.assertIn('field: protobuf_unittest.TestAllTypes.optional_string', str(context.exception)) def testGoldenMessage(self): golden_data = test_util.GoldenFileData( 'golden_message_oneof_implemented') golden_message = unittest_pb2.TestAllTypes() golden_message.ParseFromString(golden_data) test_util.ExpectAllFieldsSet(self, golden_message) self.assertEqual(golden_data, golden_message.SerializeToString()) golden_copy = copy.deepcopy(golden_message) self.assertEqual(golden_data, golden_copy.SerializeToString()) def testGoldenExtensions(self): golden_data = test_util.GoldenFileData('golden_message') golden_message = unittest_pb2.TestAllExtensions() golden_message.ParseFromString(golden_data) all_set = unittest_pb2.TestAllExtensions() test_util.SetAllExtensions(all_set) self.assertEqual(all_set, golden_message) self.assertEqual(golden_data, golden_message.SerializeToString()) golden_copy = copy.deepcopy(golden_message) self.assertEqual(golden_data, golden_copy.SerializeToString()) def testGoldenPackedMessage(self): golden_data = test_util.GoldenFileData('golden_packed_fields_message') golden_message = unittest_pb2.TestPackedTypes() golden_message.ParseFromString(golden_data) all_set = unittest_pb2.TestPackedTypes() test_util.SetAllPackedFields(all_set) self.assertEqual(all_set, golden_message) self.assertEqual(golden_data, all_set.SerializeToString()) golden_copy = copy.deepcopy(golden_message) self.assertEqual(golden_data, golden_copy.SerializeToString()) def testGoldenPackedExtensions(self): golden_data = test_util.GoldenFileData('golden_packed_fields_message') golden_message = unittest_pb2.TestPackedExtensions() golden_message.ParseFromString(golden_data) all_set = unittest_pb2.TestPackedExtensions() test_util.SetAllPackedExtensions(all_set) self.assertEqual(all_set, golden_message) self.assertEqual(golden_data, all_set.SerializeToString()) golden_copy = copy.deepcopy(golden_message) self.assertEqual(golden_data, golden_copy.SerializeToString()) def testPickleSupport(self): golden_data = test_util.GoldenFileData('golden_message') golden_message = unittest_pb2.TestAllTypes() golden_message.ParseFromString(golden_data) pickled_message = pickle.dumps(golden_message) unpickled_message = pickle.loads(pickled_message) self.assertEqual(unpickled_message, golden_message) def testPickleIncompleteProto(self): golden_message = unittest_pb2.TestRequired(a=1) pickled_message = pickle.dumps(golden_message) unpickled_message = pickle.loads(pickled_message) self.assertEqual(unpickled_message, golden_message) self.assertEqual(unpickled_message.a, 1) # This is still an incomplete proto - so serializing should fail self.assertRaises(message.EncodeError, unpickled_message.SerializeToString) def testPositiveInfinity(self): golden_data = (b'\x5D\x00\x00\x80\x7F' b'\x61\x00\x00\x00\x00\x00\x00\xF0\x7F' b'\xCD\x02\x00\x00\x80\x7F' b'\xD1\x02\x00\x00\x00\x00\x00\x00\xF0\x7F') golden_message = unittest_pb2.TestAllTypes() golden_message.ParseFromString(golden_data) self.assertTrue(IsPosInf(golden_message.optional_float)) self.assertTrue(IsPosInf(golden_message.optional_double)) self.assertTrue(IsPosInf(golden_message.repeated_float[0])) self.assertTrue(IsPosInf(golden_message.repeated_double[0])) self.assertEqual(golden_data, golden_message.SerializeToString()) def testNegativeInfinity(self): golden_data = (b'\x5D\x00\x00\x80\xFF' b'\x61\x00\x00\x00\x00\x00\x00\xF0\xFF' b'\xCD\x02\x00\x00\x80\xFF' b'\xD1\x02\x00\x00\x00\x00\x00\x00\xF0\xFF') golden_message = unittest_pb2.TestAllTypes() golden_message.ParseFromString(golden_data) self.assertTrue(IsNegInf(golden_message.optional_float)) self.assertTrue(IsNegInf(golden_message.optional_double)) self.assertTrue(IsNegInf(golden_message.repeated_float[0])) self.assertTrue(IsNegInf(golden_message.repeated_double[0])) self.assertEqual(golden_data, golden_message.SerializeToString()) def testNotANumber(self): golden_data = (b'\x5D\x00\x00\xC0\x7F' b'\x61\x00\x00\x00\x00\x00\x00\xF8\x7F' b'\xCD\x02\x00\x00\xC0\x7F' b'\xD1\x02\x00\x00\x00\x00\x00\x00\xF8\x7F') golden_message = unittest_pb2.TestAllTypes() golden_message.ParseFromString(golden_data) self.assertTrue(isnan(golden_message.optional_float)) self.assertTrue(isnan(golden_message.optional_double)) self.assertTrue(isnan(golden_message.repeated_float[0])) self.assertTrue(isnan(golden_message.repeated_double[0])) # The protocol buffer may serialize to any one of multiple different # representations of a NaN. Rather than verify a specific representation, # verify the serialized string can be converted into a correctly # behaving protocol buffer. serialized = golden_message.SerializeToString() message = unittest_pb2.TestAllTypes() message.ParseFromString(serialized) self.assertTrue(isnan(message.optional_float)) self.assertTrue(isnan(message.optional_double)) self.assertTrue(isnan(message.repeated_float[0])) self.assertTrue(isnan(message.repeated_double[0])) def testPositiveInfinityPacked(self): golden_data = (b'\xA2\x06\x04\x00\x00\x80\x7F' b'\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF0\x7F') golden_message = unittest_pb2.TestPackedTypes() golden_message.ParseFromString(golden_data) self.assertTrue(IsPosInf(golden_message.packed_float[0])) self.assertTrue(IsPosInf(golden_message.packed_double[0])) self.assertEqual(golden_data, golden_message.SerializeToString()) def testNegativeInfinityPacked(self): golden_data = (b'\xA2\x06\x04\x00\x00\x80\xFF' b'\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF0\xFF') golden_message = unittest_pb2.TestPackedTypes() golden_message.ParseFromString(golden_data) self.assertTrue(IsNegInf(golden_message.packed_float[0])) self.assertTrue(IsNegInf(golden_message.packed_double[0])) self.assertEqual(golden_data, golden_message.SerializeToString()) def testNotANumberPacked(self): golden_data = (b'\xA2\x06\x04\x00\x00\xC0\x7F' b'\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF8\x7F') golden_message = unittest_pb2.TestPackedTypes() golden_message.ParseFromString(golden_data) self.assertTrue(isnan(golden_message.packed_float[0])) self.assertTrue(isnan(golden_message.packed_double[0])) serialized = golden_message.SerializeToString() message = unittest_pb2.TestPackedTypes() message.ParseFromString(serialized) self.assertTrue(isnan(message.packed_float[0])) self.assertTrue(isnan(message.packed_double[0])) def testExtremeFloatValues(self): message = unittest_pb2.TestAllTypes() # Most positive exponent, no significand bits set. kMostPosExponentNoSigBits = math.pow(2, 127) message.optional_float = kMostPosExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == kMostPosExponentNoSigBits) # Most positive exponent, one significand bit set. kMostPosExponentOneSigBit = 1.5 * math.pow(2, 127) message.optional_float = kMostPosExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == kMostPosExponentOneSigBit) # Repeat last two cases with values of same magnitude, but negative. message.optional_float = -kMostPosExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == -kMostPosExponentNoSigBits) message.optional_float = -kMostPosExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == -kMostPosExponentOneSigBit) # Most negative exponent, no significand bits set. kMostNegExponentNoSigBits = math.pow(2, -127) message.optional_float = kMostNegExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == kMostNegExponentNoSigBits) # Most negative exponent, one significand bit set. kMostNegExponentOneSigBit = 1.5 * math.pow(2, -127) message.optional_float = kMostNegExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == kMostNegExponentOneSigBit) # Repeat last two cases with values of the same magnitude, but negative. message.optional_float = -kMostNegExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == -kMostNegExponentNoSigBits) message.optional_float = -kMostNegExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_float == -kMostNegExponentOneSigBit) def testExtremeDoubleValues(self): message = unittest_pb2.TestAllTypes() # Most positive exponent, no significand bits set. kMostPosExponentNoSigBits = math.pow(2, 1023) message.optional_double = kMostPosExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == kMostPosExponentNoSigBits) # Most positive exponent, one significand bit set. kMostPosExponentOneSigBit = 1.5 * math.pow(2, 1023) message.optional_double = kMostPosExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == kMostPosExponentOneSigBit) # Repeat last two cases with values of same magnitude, but negative. message.optional_double = -kMostPosExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == -kMostPosExponentNoSigBits) message.optional_double = -kMostPosExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == -kMostPosExponentOneSigBit) # Most negative exponent, no significand bits set. kMostNegExponentNoSigBits = math.pow(2, -1023) message.optional_double = kMostNegExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == kMostNegExponentNoSigBits) # Most negative exponent, one significand bit set. kMostNegExponentOneSigBit = 1.5 * math.pow(2, -1023) message.optional_double = kMostNegExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == kMostNegExponentOneSigBit) # Repeat last two cases with values of the same magnitude, but negative. message.optional_double = -kMostNegExponentNoSigBits message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == -kMostNegExponentNoSigBits) message.optional_double = -kMostNegExponentOneSigBit message.ParseFromString(message.SerializeToString()) self.assertTrue(message.optional_double == -kMostNegExponentOneSigBit) def testFloatPrinting(self): message = unittest_pb2.TestAllTypes() message.optional_float = 2.0 self.assertEqual(str(message), 'optional_float: 2.0\n') def testHighPrecisionFloatPrinting(self): message = unittest_pb2.TestAllTypes() message.optional_double = 0.12345678912345678 if sys.version_info.major >= 3: self.assertEqual(str(message), 'optional_double: 0.12345678912345678\n') else: self.assertEqual(str(message), 'optional_double: 0.123456789123\n') def testUnknownFieldPrinting(self): populated = unittest_pb2.TestAllTypes() test_util.SetAllNonLazyFields(populated) empty = unittest_pb2.TestEmptyMessage() empty.ParseFromString(populated.SerializeToString()) self.assertEqual(str(empty), '') def testSortingRepeatedScalarFieldsDefaultComparator(self): """Check some different types with the default comparator.""" message = unittest_pb2.TestAllTypes() # TODO(mattp): would testing more scalar types strengthen test? message.repeated_int32.append(1) message.repeated_int32.append(3) message.repeated_int32.append(2) message.repeated_int32.sort() self.assertEqual(message.repeated_int32[0], 1) self.assertEqual(message.repeated_int32[1], 2) self.assertEqual(message.repeated_int32[2], 3) message.repeated_float.append(1.1) message.repeated_float.append(1.3) message.repeated_float.append(1.2) message.repeated_float.sort() self.assertAlmostEqual(message.repeated_float[0], 1.1) self.assertAlmostEqual(message.repeated_float[1], 1.2) self.assertAlmostEqual(message.repeated_float[2], 1.3) message.repeated_string.append('a') message.repeated_string.append('c') message.repeated_string.append('b') message.repeated_string.sort() self.assertEqual(message.repeated_string[0], 'a') self.assertEqual(message.repeated_string[1], 'b') self.assertEqual(message.repeated_string[2], 'c') message.repeated_bytes.append(b'a') message.repeated_bytes.append(b'c') message.repeated_bytes.append(b'b') message.repeated_bytes.sort() self.assertEqual(message.repeated_bytes[0], b'a') self.assertEqual(message.repeated_bytes[1], b'b') self.assertEqual(message.repeated_bytes[2], b'c') def testSortingRepeatedScalarFieldsCustomComparator(self): """Check some different types with custom comparator.""" message = unittest_pb2.TestAllTypes() message.repeated_int32.append(-3) message.repeated_int32.append(-2) message.repeated_int32.append(-1) message.repeated_int32.sort(key=abs) self.assertEqual(message.repeated_int32[0], -1) self.assertEqual(message.repeated_int32[1], -2) self.assertEqual(message.repeated_int32[2], -3) message.repeated_string.append('aaa') message.repeated_string.append('bb') message.repeated_string.append('c') message.repeated_string.sort(key=len) self.assertEqual(message.repeated_string[0], 'c') self.assertEqual(message.repeated_string[1], 'bb') self.assertEqual(message.repeated_string[2], 'aaa') def testSortingRepeatedCompositeFieldsCustomComparator(self): """Check passing a custom comparator to sort a repeated composite field.""" message = unittest_pb2.TestAllTypes() message.repeated_nested_message.add().bb = 1 message.repeated_nested_message.add().bb = 3 message.repeated_nested_message.add().bb = 2 message.repeated_nested_message.add().bb = 6 message.repeated_nested_message.add().bb = 5 message.repeated_nested_message.add().bb = 4 message.repeated_nested_message.sort(key=operator.attrgetter('bb')) self.assertEqual(message.repeated_nested_message[0].bb, 1) self.assertEqual(message.repeated_nested_message[1].bb, 2) self.assertEqual(message.repeated_nested_message[2].bb, 3) self.assertEqual(message.repeated_nested_message[3].bb, 4) self.assertEqual(message.repeated_nested_message[4].bb, 5) self.assertEqual(message.repeated_nested_message[5].bb, 6) def testRepeatedCompositeFieldSortArguments(self): """Check sorting a repeated composite field using list.sort() arguments.""" message = unittest_pb2.TestAllTypes() get_bb = operator.attrgetter('bb') cmp_bb = lambda a, b: cmp(a.bb, b.bb) message.repeated_nested_message.add().bb = 1 message.repeated_nested_message.add().bb = 3 message.repeated_nested_message.add().bb = 2 message.repeated_nested_message.add().bb = 6 message.repeated_nested_message.add().bb = 5 message.repeated_nested_message.add().bb = 4 message.repeated_nested_message.sort(key=get_bb) self.assertEqual([k.bb for k in message.repeated_nested_message], [1, 2, 3, 4, 5, 6]) message.repeated_nested_message.sort(key=get_bb, reverse=True) self.assertEqual([k.bb for k in message.repeated_nested_message], [6, 5, 4, 3, 2, 1]) if sys.version_info.major >= 3: return # No cmp sorting in PY3. message.repeated_nested_message.sort(sort_function=cmp_bb) self.assertEqual([k.bb for k in message.repeated_nested_message], [1, 2, 3, 4, 5, 6]) message.repeated_nested_message.sort(cmp=cmp_bb, reverse=True) self.assertEqual([k.bb for k in message.repeated_nested_message], [6, 5, 4, 3, 2, 1]) def testRepeatedScalarFieldSortArguments(self): """Check sorting a scalar field using list.sort() arguments.""" message = unittest_pb2.TestAllTypes() message.repeated_int32.append(-3) message.repeated_int32.append(-2) message.repeated_int32.append(-1) message.repeated_int32.sort(key=abs) self.assertEqual(list(message.repeated_int32), [-1, -2, -3]) message.repeated_int32.sort(key=abs, reverse=True) self.assertEqual(list(message.repeated_int32), [-3, -2, -1]) if sys.version_info.major < 3: # No cmp sorting in PY3. abs_cmp = lambda a, b: cmp(abs(a), abs(b)) message.repeated_int32.sort(sort_function=abs_cmp) self.assertEqual(list(message.repeated_int32), [-1, -2, -3]) message.repeated_int32.sort(cmp=abs_cmp, reverse=True) self.assertEqual(list(message.repeated_int32), [-3, -2, -1]) message.repeated_string.append('aaa') message.repeated_string.append('bb') message.repeated_string.append('c') message.repeated_string.sort(key=len) self.assertEqual(list(message.repeated_string), ['c', 'bb', 'aaa']) message.repeated_string.sort(key=len, reverse=True) self.assertEqual(list(message.repeated_string), ['aaa', 'bb', 'c']) if sys.version_info.major < 3: # No cmp sorting in PY3. len_cmp = lambda a, b: cmp(len(a), len(b)) message.repeated_string.sort(sort_function=len_cmp) self.assertEqual(list(message.repeated_string), ['c', 'bb', 'aaa']) message.repeated_string.sort(cmp=len_cmp, reverse=True) self.assertEqual(list(message.repeated_string), ['aaa', 'bb', 'c']) def testRepeatedFieldsComparable(self): m1 = unittest_pb2.TestAllTypes() m2 = unittest_pb2.TestAllTypes() m1.repeated_int32.append(0) m1.repeated_int32.append(1) m1.repeated_int32.append(2) m2.repeated_int32.append(0) m2.repeated_int32.append(1) m2.repeated_int32.append(2) m1.repeated_nested_message.add().bb = 1 m1.repeated_nested_message.add().bb = 2 m1.repeated_nested_message.add().bb = 3 m2.repeated_nested_message.add().bb = 1 m2.repeated_nested_message.add().bb = 2 m2.repeated_nested_message.add().bb = 3 if sys.version_info.major >= 3: return # No cmp() in PY3. # These comparisons should not raise errors. _ = m1 < m2 _ = m1.repeated_nested_message < m2.repeated_nested_message # Make sure cmp always works. If it wasn't defined, these would be # id() comparisons and would all fail. self.assertEqual(cmp(m1, m2), 0) self.assertEqual(cmp(m1.repeated_int32, m2.repeated_int32), 0) self.assertEqual(cmp(m1.repeated_int32, [0, 1, 2]), 0) self.assertEqual(cmp(m1.repeated_nested_message, m2.repeated_nested_message), 0) with self.assertRaises(TypeError): # Can't compare repeated composite containers to lists. cmp(m1.repeated_nested_message, m2.repeated_nested_message[:]) # TODO(anuraag): Implement extensiondict comparison in C++ and then add test def testParsingMerge(self): """Check the merge behavior when a required or optional field appears multiple times in the input.""" messages = [ unittest_pb2.TestAllTypes(), unittest_pb2.TestAllTypes(), unittest_pb2.TestAllTypes() ] messages[0].optional_int32 = 1 messages[1].optional_int64 = 2 messages[2].optional_int32 = 3 messages[2].optional_string = 'hello' merged_message = unittest_pb2.TestAllTypes() merged_message.optional_int32 = 3 merged_message.optional_int64 = 2 merged_message.optional_string = 'hello' generator = unittest_pb2.TestParsingMerge.RepeatedFieldsGenerator() generator.field1.extend(messages) generator.field2.extend(messages) generator.field3.extend(messages) generator.ext1.extend(messages) generator.ext2.extend(messages) generator.group1.add().field1.MergeFrom(messages[0]) generator.group1.add().field1.MergeFrom(messages[1]) generator.group1.add().field1.MergeFrom(messages[2]) generator.group2.add().field1.MergeFrom(messages[0]) generator.group2.add().field1.MergeFrom(messages[1]) generator.group2.add().field1.MergeFrom(messages[2]) data = generator.SerializeToString() parsing_merge = unittest_pb2.TestParsingMerge() parsing_merge.ParseFromString(data) # Required and optional fields should be merged. self.assertEqual(parsing_merge.required_all_types, merged_message) self.assertEqual(parsing_merge.optional_all_types, merged_message) self.assertEqual(parsing_merge.optionalgroup.optional_group_all_types, merged_message) self.assertEqual(parsing_merge.Extensions[ unittest_pb2.TestParsingMerge.optional_ext], merged_message) # Repeated fields should not be merged. self.assertEqual(len(parsing_merge.repeated_all_types), 3) self.assertEqual(len(parsing_merge.repeatedgroup), 3) self.assertEqual(len(parsing_merge.Extensions[ unittest_pb2.TestParsingMerge.repeated_ext]), 3) def ensureNestedMessageExists(self, msg, attribute): """Make sure that a nested message object exists. As soon as a nested message attribute is accessed, it will be present in the _fields dict, without being marked as actually being set. """ getattr(msg, attribute) self.assertFalse(msg.HasField(attribute)) def testOneofGetCaseNonexistingField(self): m = unittest_pb2.TestAllTypes() self.assertRaises(ValueError, m.WhichOneof, 'no_such_oneof_field') def testOneofSemantics(self): m = unittest_pb2.TestAllTypes() self.assertIs(None, m.WhichOneof('oneof_field')) m.oneof_uint32 = 11 self.assertEqual('oneof_uint32', m.WhichOneof('oneof_field')) self.assertTrue(m.HasField('oneof_uint32')) m.oneof_string = 'foo' self.assertEqual('oneof_string', m.WhichOneof('oneof_field')) self.assertFalse(m.HasField('oneof_uint32')) self.assertTrue(m.HasField('oneof_string')) m.oneof_nested_message.bb = 11 self.assertEqual('oneof_nested_message', m.WhichOneof('oneof_field')) self.assertFalse(m.HasField('oneof_string')) self.assertTrue(m.HasField('oneof_nested_message')) m.oneof_bytes = b'bb' self.assertEqual('oneof_bytes', m.WhichOneof('oneof_field')) self.assertFalse(m.HasField('oneof_nested_message')) self.assertTrue(m.HasField('oneof_bytes')) def testOneofCompositeFieldReadAccess(self): m = unittest_pb2.TestAllTypes() m.oneof_uint32 = 11 self.ensureNestedMessageExists(m, 'oneof_nested_message') self.assertEqual('oneof_uint32', m.WhichOneof('oneof_field')) self.assertEqual(11, m.oneof_uint32) def testOneofHasField(self): m = unittest_pb2.TestAllTypes() self.assertFalse(m.HasField('oneof_field')) m.oneof_uint32 = 11 self.assertTrue(m.HasField('oneof_field')) m.oneof_bytes = b'bb' self.assertTrue(m.HasField('oneof_field')) m.ClearField('oneof_bytes') self.assertFalse(m.HasField('oneof_field')) def testOneofClearField(self): m = unittest_pb2.TestAllTypes() m.oneof_uint32 = 11 m.ClearField('oneof_field') self.assertFalse(m.HasField('oneof_field')) self.assertFalse(m.HasField('oneof_uint32')) self.assertIs(None, m.WhichOneof('oneof_field')) def testOneofClearSetField(self): m = unittest_pb2.TestAllTypes() m.oneof_uint32 = 11 m.ClearField('oneof_uint32') self.assertFalse(m.HasField('oneof_field')) self.assertFalse(m.HasField('oneof_uint32')) self.assertIs(None, m.WhichOneof('oneof_field')) def testOneofClearUnsetField(self): m = unittest_pb2.TestAllTypes() m.oneof_uint32 = 11 self.ensureNestedMessageExists(m, 'oneof_nested_message') m.ClearField('oneof_nested_message') self.assertEqual(11, m.oneof_uint32) self.assertTrue(m.HasField('oneof_field')) self.assertTrue(m.HasField('oneof_uint32')) self.assertEqual('oneof_uint32', m.WhichOneof('oneof_field')) def testOneofDeserialize(self): m = unittest_pb2.TestAllTypes() m.oneof_uint32 = 11 m2 = unittest_pb2.TestAllTypes() m2.ParseFromString(m.SerializeToString()) self.assertEqual('oneof_uint32', m2.WhichOneof('oneof_field')) def testSortEmptyRepeatedCompositeContainer(self): """Exercise a scenario that has led to segfaults in the past. """ m = unittest_pb2.TestAllTypes() m.repeated_nested_message.sort() def testHasFieldOnRepeatedField(self): """Using HasField on a repeated field should raise an exception. """ m = unittest_pb2.TestAllTypes() with self.assertRaises(ValueError) as _: m.HasField('repeated_int32') class ValidTypeNamesTest(basetest.TestCase): def assertImportFromName(self, msg, base_name): # Parse <type 'module.class_name'> to extra 'some.name' as a string. tp_name = str(type(msg)).split("'")[1] valid_names = ('Repeated%sContainer' % base_name, 'Repeated%sFieldContainer' % base_name) self.assertTrue(any(tp_name.endswith(v) for v in valid_names), '%r does end with any of %r' % (tp_name, valid_names)) parts = tp_name.split('.') class_name = parts[-1] module_name = '.'.join(parts[:-1]) __import__(module_name, fromlist=[class_name]) def testTypeNamesCanBeImported(self): # If import doesn't work, pickling won't work either. pb = unittest_pb2.TestAllTypes() self.assertImportFromName(pb.repeated_int32, 'Scalar') self.assertImportFromName(pb.repeated_nested_message, 'Composite') if __name__ == '__main__': basetest.main()
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3922, 13, 17389, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 2366, 4113, 19383, 6169, 314, 17631, 1245, 14, 199, 199, 7443, 626, 314, 17631, 3788, 26511, 4036, 6040, 901, 730, 12, 12850, 642, 199, 396, 11187, 1536, 444, 281, 67, 11136, 436, 31866, 17429, 590, 1006, 402, 314, 6057, 436, 199, 12161, 1233, 315, 314, 8852, 3555, 14, 199, 199, 11768, 8, 75, 484, 265, 304, 221, 14076, 543, 11799, 63, 908, 63, 396, 31, 221, 2779, 3181, 1133, 1852, 282, 8852, 13918, 402, 199, 16517, 370, 1240, 642, 282, 511, 402, 314, 298, 1188, 2, 859, 12, 1314, 1454, 477, 3995, 470, 376, 199, 6198, 3217, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 25556, 32, 3098, 14, 957, 334, 39, 1135, 1089, 510, 14, 25924, 3171, 199, 199, 646, 1331, 199, 646, 3473, 199, 646, 4182, 199, 646, 5927, 199, 646, 984, 199, 199, 504, 6233, 14, 571, 1208, 492, 1300, 396, 199, 504, 6233, 14, 7204, 492, 2882, 63, 3317, 18, 199, 504, 6233, 14, 7204, 14, 4672, 492, 2986, 63, 12236, 199, 504, 6233, 14, 7204, 14, 4672, 492, 511, 63, 1974, 199, 504, 6233, 14, 7204, 492, 1245, 199, 199, 3, 2018, 876, 13, 18, 14, 22, 1630, 440, 1172, 365, 4904, 342, 503, 365, 4304, 342, 3423, 12, 880, 781, 1172, 199, 3, 370, 5647, 4154, 5705, 14, 199, 318, 365, 4304, 8, 637, 304, 523, 327, 16046, 365, 7078, 4472, 370, 6337, 14, 523, 372, 1139, 1137, 1139, 199, 318, 365, 4904, 8, 637, 304, 523, 327, 1010, 9693, 5431, 4697, 18527, 16046, 14, 523, 372, 440, 365, 4304, 8, 637, 9, 436, 365, 4304, 8, 637, 627, 378, 9, 199, 318, 6596, 6981, 17354, 8, 637, 304, 523, 372, 365, 4904, 8, 637, 9, 436, 334, 637, 690, 378, 9, 199, 318, 6596, 27814, 17354, 8, 637, 304, 523, 372, 365, 4904, 8, 637, 9, 436, 334, 637, 665, 378, 9, 421, 199, 533, 6430, 774, 8, 1095, 396, 14, 1746, 304, 819, 347, 511, 5725, 11561, 24, 1558, 8, 277, 304, 272, 340, 2986, 63, 12236, 14, 804, 342, 1137, 283, 1548, 356, 489, 291, 14, 23809, 480, 18297, 511, 5725, 11561, 24, 1558, 12, 5544, 1454, 314, 2366, 298, 490, 298, 1246, 4514, 6534, 18965, 1380, 282, 298, 490, 298, 875, 901, 3509, 4875, 2774, 13, 24, 2685, 272, 4875, 63, 1624, 24, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 360, 4087, 63, 1624, 24, 63, 875, 358, 272, 543, 291, 14, 1855, 8, 7087, 12620, 9, 465, 1067, 26, 489, 2882, 63, 3317, 18, 14, 14973, 14, 7671, 8, 4087, 63, 1624, 24, 63, 576, 9, 272, 291, 14, 4080, 360, 698, 26, 25886, 63, 2796, 14, 14973, 14, 4144, 63, 875, 297, 2116, 620, 8, 1100, 14, 1971, 430, 819, 347, 511, 39, 11121, 2209, 8, 277, 304, 272, 17631, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 8, 267, 283, 19440, 63, 1188, 63, 26593, 63, 13825, 358, 272, 17631, 63, 1188, 275, 2882, 63, 3317, 18, 14, 14973, 342, 272, 17631, 63, 1188, 14, 28685, 8, 19440, 63, 576, 9, 272, 511, 63, 1974, 14, 13495, 2422, 7304, 1084, 8, 277, 12, 17631, 63, 1188, 9, 272, 291, 14, 629, 8, 19440, 63, 576, 12, 17631, 63, 1188, 14, 9436, 1012, 272, 17631, 63, 1574, 275, 1331, 14, 8293, 8, 19440, 63, 1188, 9, 272, 291, 14, 629, 8, 19440, 63, 576, 12, 17631, 63, 1574, 14, 9436, 1012, 819, 347, 511, 39, 11121, 10597, 8, 277, 304, 272, 17631, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 360, 19440, 63, 1188, 358, 272, 17631, 63, 1188, 275, 2882, 63, 3317, 18, 14, 12860, 10597, 342, 272, 17631, 63, 1188, 14, 28685, 8, 19440, 63, 576, 9, 272, 1006, 63, 409, 275, 2882, 63, 3317, 18, 14, 12860, 10597, 342, 272, 511, 63, 1974, 14, 1084, 2422, 10597, 8, 452, 63, 409, 9, 272, 291, 14, 629, 8, 452, 63, 409, 12, 17631, 63, 1188, 9, 272, 291, 14 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3922, 13, 17389, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 2366, 4113, 19383, 6169, 314, 17631, 1245, 14, 199, 199, 7443, 626, 314, 17631, 3788, 26511, 4036, 6040, 901, 730, 12, 12850, 642, 199, 396, 11187, 1536, 444, 281, 67, 11136, 436, 31866, 17429, 590, 1006, 402, 314, 6057, 436, 199, 12161, 1233, 315, 314, 8852, 3555, 14, 199, 199, 11768, 8, 75, 484, 265, 304, 221, 14076, 543, 11799, 63, 908, 63, 396, 31, 221, 2779, 3181, 1133, 1852, 282, 8852, 13918, 402, 199, 16517, 370, 1240, 642, 282, 511, 402, 314, 298, 1188, 2, 859, 12, 1314, 1454, 477, 3995, 470, 376, 199, 6198, 3217, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 25556, 32, 3098, 14, 957, 334, 39, 1135, 1089, 510, 14, 25924, 3171, 199, 199, 646, 1331, 199, 646, 3473, 199, 646, 4182, 199, 646, 5927, 199, 646, 984, 199, 199, 504, 6233, 14, 571, 1208, 492, 1300, 396, 199, 504, 6233, 14, 7204, 492, 2882, 63, 3317, 18, 199, 504, 6233, 14, 7204, 14, 4672, 492, 2986, 63, 12236, 199, 504, 6233, 14, 7204, 14, 4672, 492, 511, 63, 1974, 199, 504, 6233, 14, 7204, 492, 1245, 199, 199, 3, 2018, 876, 13, 18, 14, 22, 1630, 440, 1172, 365, 4904, 342, 503, 365, 4304, 342, 3423, 12, 880, 781, 1172, 199, 3, 370, 5647, 4154, 5705, 14, 199, 318, 365, 4304, 8, 637, 304, 523, 327, 16046, 365, 7078, 4472, 370, 6337, 14, 523, 372, 1139, 1137, 1139, 199, 318, 365, 4904, 8, 637, 304, 523, 327, 1010, 9693, 5431, 4697, 18527, 16046, 14, 523, 372, 440, 365, 4304, 8, 637, 9, 436, 365, 4304, 8, 637, 627, 378, 9, 199, 318, 6596, 6981, 17354, 8, 637, 304, 523, 372, 365, 4904, 8, 637, 9, 436, 334, 637, 690, 378, 9, 199, 318, 6596, 27814, 17354, 8, 637, 304, 523, 372, 365, 4904, 8, 637, 9, 436, 334, 637, 665, 378, 9, 421, 199, 533, 6430, 774, 8, 1095, 396, 14, 1746, 304, 819, 347, 511, 5725, 11561, 24, 1558, 8, 277, 304, 272, 340, 2986, 63, 12236, 14, 804, 342, 1137, 283, 1548, 356, 489, 291, 14, 23809, 480, 18297, 511, 5725, 11561, 24, 1558, 12, 5544, 1454, 314, 2366, 298, 490, 298, 1246, 4514, 6534, 18965, 1380, 282, 298, 490, 298, 875, 901, 3509, 4875, 2774, 13, 24, 2685, 272, 4875, 63, 1624, 24, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 360, 4087, 63, 1624, 24, 63, 875, 358, 272, 543, 291, 14, 1855, 8, 7087, 12620, 9, 465, 1067, 26, 489, 2882, 63, 3317, 18, 14, 14973, 14, 7671, 8, 4087, 63, 1624, 24, 63, 576, 9, 272, 291, 14, 4080, 360, 698, 26, 25886, 63, 2796, 14, 14973, 14, 4144, 63, 875, 297, 2116, 620, 8, 1100, 14, 1971, 430, 819, 347, 511, 39, 11121, 2209, 8, 277, 304, 272, 17631, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 8, 267, 283, 19440, 63, 1188, 63, 26593, 63, 13825, 358, 272, 17631, 63, 1188, 275, 2882, 63, 3317, 18, 14, 14973, 342, 272, 17631, 63, 1188, 14, 28685, 8, 19440, 63, 576, 9, 272, 511, 63, 1974, 14, 13495, 2422, 7304, 1084, 8, 277, 12, 17631, 63, 1188, 9, 272, 291, 14, 629, 8, 19440, 63, 576, 12, 17631, 63, 1188, 14, 9436, 1012, 272, 17631, 63, 1574, 275, 1331, 14, 8293, 8, 19440, 63, 1188, 9, 272, 291, 14, 629, 8, 19440, 63, 576, 12, 17631, 63, 1574, 14, 9436, 1012, 819, 347, 511, 39, 11121, 10597, 8, 277, 304, 272, 17631, 63, 576, 275, 511, 63, 1974, 14, 39, 11121, 1173, 1451, 360, 19440, 63, 1188, 358, 272, 17631, 63, 1188, 275, 2882, 63, 3317, 18, 14, 12860, 10597, 342, 272, 17631, 63, 1188, 14, 28685, 8, 19440, 63, 576, 9, 272, 1006, 63, 409, 275, 2882, 63, 3317, 18, 14, 12860, 10597, 342, 272, 511, 63, 1974, 14, 1084, 2422, 10597, 8, 452, 63, 409, 9, 272, 291, 14, 629, 8, 452, 63, 409, 12, 17631, 63, 1188, 9,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1, 1, 1, 1, 1, 1 ]
ejpbruel/servo
tests/wpt/web-platform-tests/websockets/handlers/echo_wsh.py
163
1219
#!/usr/bin/python from mod_pywebsocket import msgutil from mod_pywebsocket import common _GOODBYE_MESSAGE = u'Goodbye' def web_socket_do_extra_handshake(request): # This example handler accepts any request. See origin_check_wsh.py for how # to reject access from untrusted scripts based on origin value. if request.ws_requested_protocols: if "echo" in request.ws_requested_protocols: request.ws_protocol = "echo" def web_socket_transfer_data(request): while True: line = request.ws_stream.receive_message() if line is None: return if isinstance(line, unicode): request.ws_stream.send_message(line, binary=False) if line == _GOODBYE_MESSAGE: return else: request.ws_stream.send_message(line, binary=True) def web_socket_passive_closing_handshake(request): # Echo close status code and reason code, reason = request.ws_close_code, request.ws_close_reason # No status received is a reserved pseudo code representing an empty code, # so echo back an empty code in this case. if code == common.STATUS_NO_STATUS_RECEIVED: code = None return code, reason
mpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 504, 3413, 63, 21387, 492, 1499, 1974, 199, 504, 3413, 63, 21387, 492, 2863, 199, 199, 63, 17316, 2846, 57, 37, 63, 8272, 275, 399, 7, 20652, 16481, 7, 199, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 327, 961, 2893, 3016, 11479, 1263, 1056, 14, 1666, 6330, 63, 1074, 63, 87, 609, 14, 647, 367, 4212, 272, 327, 370, 17100, 2879, 687, 625, 17549, 10554, 4079, 641, 6330, 574, 14, 272, 340, 1056, 14, 3569, 63, 11151, 63, 16541, 26, 267, 340, 298, 7878, 2, 315, 1056, 14, 3569, 63, 11151, 63, 16541, 26, 288, 1056, 14, 3569, 63, 3922, 275, 298, 7878, 2, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1830, 715, 26, 267, 1004, 275, 1056, 14, 3569, 63, 1745, 14, 9391, 63, 1188, 342, 267, 340, 1004, 365, 488, 26, 288, 372, 267, 340, 1228, 8, 604, 12, 2649, 304, 288, 1056, 14, 3569, 63, 1745, 14, 2254, 63, 1188, 8, 604, 12, 3366, 29, 797, 9, 288, 340, 1004, 508, 485, 17316, 2846, 57, 37, 63, 8272, 26, 355, 372, 267, 587, 26, 288, 1056, 14, 3569, 63, 1745, 14, 2254, 63, 1188, 8, 604, 12, 3366, 29, 549, 9, 199, 199, 318, 3330, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 8, 1069, 304, 272, 327, 24980, 4002, 2004, 1233, 436, 4499, 272, 1233, 12, 4499, 275, 1056, 14, 3569, 63, 1600, 63, 600, 12, 1056, 14, 3569, 63, 1600, 63, 5764, 339, 327, 3091, 2004, 3086, 365, 282, 4644, 15984, 1233, 6144, 376, 2701, 1233, 12, 272, 327, 880, 11343, 1771, 376, 2701, 1233, 315, 642, 1930, 14, 272, 340, 1233, 508, 2863, 14, 6305, 63, 2826, 63, 6305, 63, 28467, 30487, 26, 267, 1233, 275, 488, 339, 372, 1233, 12, 4499, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 3413, 63, 21387, 492, 1499, 1974, 199, 504, 3413, 63, 21387, 492, 2863, 199, 199, 63, 17316, 2846, 57, 37, 63, 8272, 275, 399, 7, 20652, 16481, 7, 199, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 327, 961, 2893, 3016, 11479, 1263, 1056, 14, 1666, 6330, 63, 1074, 63, 87, 609, 14, 647, 367, 4212, 272, 327, 370, 17100, 2879, 687, 625, 17549, 10554, 4079, 641, 6330, 574, 14, 272, 340, 1056, 14, 3569, 63, 11151, 63, 16541, 26, 267, 340, 298, 7878, 2, 315, 1056, 14, 3569, 63, 11151, 63, 16541, 26, 288, 1056, 14, 3569, 63, 3922, 275, 298, 7878, 2, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1830, 715, 26, 267, 1004, 275, 1056, 14, 3569, 63, 1745, 14, 9391, 63, 1188, 342, 267, 340, 1004, 365, 488, 26, 288, 372, 267, 340, 1228, 8, 604, 12, 2649, 304, 288, 1056, 14, 3569, 63, 1745, 14, 2254, 63, 1188, 8, 604, 12, 3366, 29, 797, 9, 288, 340, 1004, 508, 485, 17316, 2846, 57, 37, 63, 8272, 26, 355, 372, 267, 587, 26, 288, 1056, 14, 3569, 63, 1745, 14, 2254, 63, 1188, 8, 604, 12, 3366, 29, 549, 9, 199, 199, 318, 3330, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 8, 1069, 304, 272, 327, 24980, 4002, 2004, 1233, 436, 4499, 272, 1233, 12, 4499, 275, 1056, 14, 3569, 63, 1600, 63, 600, 12, 1056, 14, 3569, 63, 1600, 63, 5764, 339, 327, 3091, 2004, 3086, 365, 282, 4644, 15984, 1233, 6144, 376, 2701, 1233, 12, 272, 327, 880, 11343, 1771, 376, 2701, 1233, 315, 642, 1930, 14, 272, 340, 1233, 508, 2863, 14, 6305, 63, 2826, 63, 6305, 63, 28467, 30487, 26, 267, 1233, 275, 488, 339, 372, 1233, 12, 4499, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
js0701/chromium-crosswalk
third_party/simplejson/ordered_dict.py
1039
3370
"""Drop-in replacement for collections.OrderedDict by Raymond Hettinger http://code.activestate.com/recipes/576693/ """ from UserDict import DictMixin # Modified from original to support Python 2.4, see # http://code.google.com/p/simplejson/issues/detail?id=53 try: all except NameError: def all(seq): for elem in seq: if not elem: return False return True class OrderedDict(dict, DictMixin): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__end except AttributeError: self.clear() self.update(*args, **kwds) def clear(self): self.__end = end = [] end += [None, end, end] # sentinel node for doubly linked list self.__map = {} # key --> [key, prev, next] dict.clear(self) def __setitem__(self, key, value): if key not in self: end = self.__end curr = end[1] curr[2] = end[1] = self.__map[key] = [key, curr, end] dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) key, prev, next = self.__map.pop(key) prev[2] = next next[1] = prev def __iter__(self): end = self.__end curr = end[2] while curr is not end: yield curr[0] curr = curr[2] def __reversed__(self): end = self.__end curr = end[1] while curr is not end: yield curr[0] curr = curr[1] def popitem(self, last=True): if not self: raise KeyError('dictionary is empty') # Modified from original to support Python 2.4, see # http://code.google.com/p/simplejson/issues/detail?id=53 if last: key = reversed(self).next() else: key = iter(self).next() value = self.pop(key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] tmp = self.__map, self.__end del self.__map, self.__end inst_dict = vars(self).copy() self.__map, self.__end = tmp if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def keys(self): return list(self) setdefault = DictMixin.setdefault update = DictMixin.update pop = DictMixin.pop values = DictMixin.values items = DictMixin.items iterkeys = DictMixin.iterkeys itervalues = DictMixin.itervalues iteritems = DictMixin.iteritems def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return len(self)==len(other) and \ all(p==q for p, q in zip(self.items(), other.items())) return dict.__eq__(self, other) def __ne__(self, other): return not self == other
bsd-3-clause
[ 624, 11070, 13, 262, 8343, 367, 5055, 14, 16882, 701, 30703, 2106, 68, 869, 386, 1337, 281, 199, 199, 1014, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 199, 624, 199, 504, 32241, 492, 7448, 4256, 199, 199, 3, 22016, 687, 3379, 370, 2291, 2018, 499, 14, 20, 12, 1937, 199, 3, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 4129, 1001, 15, 10115, 15, 5506, 31, 344, 29, 2481, 199, 893, 26, 272, 1006, 199, 2590, 12746, 26, 272, 347, 1006, 8, 3610, 304, 267, 367, 6193, 315, 5412, 26, 288, 340, 440, 6193, 26, 355, 372, 756, 267, 372, 715, 199, 199, 533, 8773, 8, 807, 12, 7448, 4256, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 500, 267, 871, 4281, 26, 288, 291, 14, 3584, 342, 267, 291, 14, 873, 2031, 589, 12, 1011, 10340, 9, 339, 347, 5436, 8, 277, 304, 267, 291, 855, 500, 275, 1284, 275, 942, 267, 1284, 847, 359, 403, 12, 1284, 12, 1284, 61, 260, 327, 13792, 1031, 367, 28584, 590, 10632, 769, 267, 291, 855, 1130, 275, 1052, 463, 327, 790, 10541, 359, 498, 12, 5071, 12, 2163, 61, 267, 1211, 14, 3584, 8, 277, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 340, 790, 440, 315, 291, 26, 288, 1284, 275, 291, 855, 500, 288, 8230, 275, 1284, 59, 17, 61, 288, 8230, 59, 18, 61, 275, 1284, 59, 17, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 498, 12, 8230, 12, 1284, 61, 267, 1211, 855, 8617, 721, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 1211, 855, 13228, 721, 277, 12, 790, 9, 267, 790, 12, 5071, 12, 2163, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 5071, 59, 18, 61, 275, 2163, 267, 2163, 59, 17, 61, 275, 5071, 339, 347, 636, 1661, 721, 277, 304, 267, 1284, 275, 291, 855, 500, 267, 8230, 275, 1284, 59, 18, 61, 267, 1830, 8230, 365, 440, 1284, 26, 288, 1995, 8230, 59, 16, 61, 288, 8230, 275, 8230, 59, 18, 61, 339, 347, 636, 13501, 721, 277, 304, 267, 1284, 275, 291, 855, 500, 267, 8230, 275, 1284, 59, 17, 61, 267, 1830, 8230, 365, 440, 1284, 26, 288, 1995, 8230, 59, 16, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 4560, 1053, 8, 277, 12, 2061, 29, 549, 304, 267, 340, 440, 291, 26, 288, 746, 4067, 360, 9086, 365, 2701, 358, 267, 327, 22016, 687, 3379, 370, 2291, 2018, 499, 14, 20, 12, 1937, 267, 327, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 4129, 1001, 15, 10115, 15, 5506, 31, 344, 29, 2481, 267, 340, 2061, 26, 288, 790, 275, 10822, 8, 277, 680, 2184, 342, 267, 587, 26, 288, 790, 275, 2740, 8, 277, 680, 2184, 342, 267, 574, 275, 291, 14, 1935, 8, 498, 9, 267, 372, 790, 12, 574, 339, 347, 636, 5270, 721, 277, 304, 267, 2974, 275, 3474, 75, 12, 291, 59, 75, 2677, 367, 1022, 315, 291, 61, 267, 3529, 275, 291, 855, 1130, 12, 291, 855, 500, 267, 2150, 291, 855, 1130, 12, 291, 855, 500, 267, 2727, 63, 807, 275, 6802, 8, 277, 680, 1574, 342, 267, 291, 855, 1130, 12, 291, 855, 500, 275, 3529, 267, 340, 2727, 63, 807, 26, 288, 372, 334, 277, 855, 533, 3108, 334, 1744, 4706, 2727, 63, 807, 9, 267, 372, 291, 855, 533, 3108, 334, 1744, 4258, 339, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 9, 339, 29408, 275, 7448, 4256, 14, 5486, 272, 1678, 275, 7448, 4256, 14, 873, 272, 4560, 275, 7448, 4256, 14, 1935, 272, 1338, 275, 7448, 4256, 14, 1459, 272, 2974, 275, 7448, 4256, 14, 1744, 272, 25706, 275, 7448, 4256, 14, 16007, 272, 24451, 275, 7448, 4256, 14, 13012, 272, 10849, 275, 7448, 4256, 14, 4611, 339, 347, 636, 2722, 721, 277, 304, 267, 340, 440, 291, 26, 288, 372, 1543, 83, 11716, 450, 334, 277, 855, 533, 4914, 354, 3108, 9, 267, 372, 1543, 83, 4042, 82, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 1744, 1012, 339, 347, 1331, 8, 277, 304, 267, 372, 291, 855, 533, 721, 277, 9, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 6076, 12, 574, 29, 403, 304, 267, 366, 275, 843, 342, 267, 367, 790, 315, 6076, 26, 288, 366, 59, 498, 61, 275, 574, 267, 372, 366, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 8773, 304, 288, 372, 822, 8, 277, 12694, 552, 8, 1848, 9, 436, 971, 673, 1006, 8, 80, 389, 81, 367, 299, 12, 1894, 315, 221, 3482, 8, 277, 14, 1744, 1062, 1163, 14, 1744, 4059, 267, 372, 1211, 855, 4077, 721, 277, 12, 1163, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11070, 13, 262, 8343, 367, 5055, 14, 16882, 701, 30703, 2106, 68, 869, 386, 1337, 281, 199, 199, 1014, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 199, 624, 199, 504, 32241, 492, 7448, 4256, 199, 199, 3, 22016, 687, 3379, 370, 2291, 2018, 499, 14, 20, 12, 1937, 199, 3, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 4129, 1001, 15, 10115, 15, 5506, 31, 344, 29, 2481, 199, 893, 26, 272, 1006, 199, 2590, 12746, 26, 272, 347, 1006, 8, 3610, 304, 267, 367, 6193, 315, 5412, 26, 288, 340, 440, 6193, 26, 355, 372, 756, 267, 372, 715, 199, 199, 533, 8773, 8, 807, 12, 7448, 4256, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 500, 267, 871, 4281, 26, 288, 291, 14, 3584, 342, 267, 291, 14, 873, 2031, 589, 12, 1011, 10340, 9, 339, 347, 5436, 8, 277, 304, 267, 291, 855, 500, 275, 1284, 275, 942, 267, 1284, 847, 359, 403, 12, 1284, 12, 1284, 61, 260, 327, 13792, 1031, 367, 28584, 590, 10632, 769, 267, 291, 855, 1130, 275, 1052, 463, 327, 790, 10541, 359, 498, 12, 5071, 12, 2163, 61, 267, 1211, 14, 3584, 8, 277, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 340, 790, 440, 315, 291, 26, 288, 1284, 275, 291, 855, 500, 288, 8230, 275, 1284, 59, 17, 61, 288, 8230, 59, 18, 61, 275, 1284, 59, 17, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 498, 12, 8230, 12, 1284, 61, 267, 1211, 855, 8617, 721, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 1211, 855, 13228, 721, 277, 12, 790, 9, 267, 790, 12, 5071, 12, 2163, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 5071, 59, 18, 61, 275, 2163, 267, 2163, 59, 17, 61, 275, 5071, 339, 347, 636, 1661, 721, 277, 304, 267, 1284, 275, 291, 855, 500, 267, 8230, 275, 1284, 59, 18, 61, 267, 1830, 8230, 365, 440, 1284, 26, 288, 1995, 8230, 59, 16, 61, 288, 8230, 275, 8230, 59, 18, 61, 339, 347, 636, 13501, 721, 277, 304, 267, 1284, 275, 291, 855, 500, 267, 8230, 275, 1284, 59, 17, 61, 267, 1830, 8230, 365, 440, 1284, 26, 288, 1995, 8230, 59, 16, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 4560, 1053, 8, 277, 12, 2061, 29, 549, 304, 267, 340, 440, 291, 26, 288, 746, 4067, 360, 9086, 365, 2701, 358, 267, 327, 22016, 687, 3379, 370, 2291, 2018, 499, 14, 20, 12, 1937, 267, 327, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 4129, 1001, 15, 10115, 15, 5506, 31, 344, 29, 2481, 267, 340, 2061, 26, 288, 790, 275, 10822, 8, 277, 680, 2184, 342, 267, 587, 26, 288, 790, 275, 2740, 8, 277, 680, 2184, 342, 267, 574, 275, 291, 14, 1935, 8, 498, 9, 267, 372, 790, 12, 574, 339, 347, 636, 5270, 721, 277, 304, 267, 2974, 275, 3474, 75, 12, 291, 59, 75, 2677, 367, 1022, 315, 291, 61, 267, 3529, 275, 291, 855, 1130, 12, 291, 855, 500, 267, 2150, 291, 855, 1130, 12, 291, 855, 500, 267, 2727, 63, 807, 275, 6802, 8, 277, 680, 1574, 342, 267, 291, 855, 1130, 12, 291, 855, 500, 275, 3529, 267, 340, 2727, 63, 807, 26, 288, 372, 334, 277, 855, 533, 3108, 334, 1744, 4706, 2727, 63, 807, 9, 267, 372, 291, 855, 533, 3108, 334, 1744, 4258, 339, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 9, 339, 29408, 275, 7448, 4256, 14, 5486, 272, 1678, 275, 7448, 4256, 14, 873, 272, 4560, 275, 7448, 4256, 14, 1935, 272, 1338, 275, 7448, 4256, 14, 1459, 272, 2974, 275, 7448, 4256, 14, 1744, 272, 25706, 275, 7448, 4256, 14, 16007, 272, 24451, 275, 7448, 4256, 14, 13012, 272, 10849, 275, 7448, 4256, 14, 4611, 339, 347, 636, 2722, 721, 277, 304, 267, 340, 440, 291, 26, 288, 372, 1543, 83, 11716, 450, 334, 277, 855, 533, 4914, 354, 3108, 9, 267, 372, 1543, 83, 4042, 82, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 1744, 1012, 339, 347, 1331, 8, 277, 304, 267, 372, 291, 855, 533, 721, 277, 9, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 6076, 12, 574, 29, 403, 304, 267, 366, 275, 843, 342, 267, 367, 790, 315, 6076, 26, 288, 366, 59, 498, 61, 275, 574, 267, 372, 366, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 8773, 304, 288, 372, 822, 8, 277, 12694, 552, 8, 1848, 9, 436, 971, 673, 1006, 8, 80, 389, 81, 367, 299, 12, 1894, 315, 221, 3482, 8, 277, 14, 1744, 1062, 1163, 14, 1744, 4059, 267, 372, 1211, 855, 4077, 721, 277, 12, 1163, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 tornado.ioloop from proton.reactor import Container as BaseContainer from proton.handlers import IOHandler class TornadoLoopHandler: def __init__(self, loop=None, handler_base=None): self.loop = loop or tornado.ioloop.IOLoop.instance() self.io = handler_base or IOHandler() self.count = 0 def on_reactor_init(self, event): self.reactor = event.reactor def on_reactor_quiesced(self, event): event.reactor.yield_() def on_unhandled(self, name, event): event.dispatch(self.io) def _events(self, sel): events = self.loop.ERROR if sel.reading: events |= self.loop.READ if sel.writing: events |= self.loop.WRITE return events def _schedule(self, sel): if sel.deadline: self.loop.add_timeout(sel.deadline, lambda: self.expired(sel)) def _expired(self, sel): sel.expired() def _process(self): self.reactor.process() if not self.reactor.quiesced: self.loop.add_callback(self._process) def _callback(self, sel, events): if self.loop.READ & events: sel.readable() if self.loop.WRITE & events: sel.writable() self._process() def on_selectable_init(self, event): sel = event.context if sel.fileno() >= 0: self.loop.add_handler(sel.fileno(), lambda fd, events: self._callback(sel, events), self._events(sel)) self._schedule(sel) self.count += 1 def on_selectable_updated(self, event): sel = event.context if sel.fileno() > 0: self.loop.update_handler(sel.fileno(), self._events(sel)) self._schedule(sel) def on_selectable_final(self, event): sel = event.context if sel.fileno() > 0: self.loop.remove_handler(sel.fileno()) sel.release() self.count -= 1 if self.count == 0: self.loop.add_callback(self._stop) def _stop(self): self.reactor.stop() self.loop.stop() class Container(object): def __init__(self, *handlers, **kwargs): self.tornado_loop = kwargs.get('loop', tornado.ioloop.IOLoop.instance()) kwargs['global_handler'] = TornadoLoopHandler(self.tornado_loop, kwargs.get('handler_base', None)) self.container = BaseContainer(*handlers, **kwargs) def initialise(self): self.container.start() self.container.process() def run(self): self.initialise() self.tornado_loop.start() def touch(self): self._process() def _process(self): self.container.process() if not self.container.quiesced: self.tornado_loop.add_callback(self._process)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 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, 3, 199, 199, 646, 12148, 14, 27212, 199, 504, 557, 1860, 14, 13544, 492, 15395, 465, 3523, 4076, 199, 504, 557, 1860, 14, 5586, 492, 5004, 2461, 199, 199, 533, 377, 8622, 7382, 2461, 26, 339, 347, 636, 826, 721, 277, 12, 4438, 29, 403, 12, 3016, 63, 1095, 29, 403, 304, 267, 291, 14, 3813, 275, 4438, 503, 12148, 14, 27212, 14, 23152, 14, 842, 342, 267, 291, 14, 2308, 275, 3016, 63, 1095, 503, 5004, 2461, 342, 267, 291, 14, 835, 275, 378, 339, 347, 641, 63, 13544, 63, 826, 8, 277, 12, 1566, 304, 267, 291, 14, 13544, 275, 1566, 14, 13544, 339, 347, 641, 63, 13544, 63, 783, 397, 6867, 8, 277, 12, 1566, 304, 267, 1566, 14, 13544, 14, 11481, 12798, 339, 347, 641, 63, 23648, 8, 277, 12, 536, 12, 1566, 304, 267, 1566, 14, 6052, 8, 277, 14, 2308, 9, 339, 347, 485, 4368, 8, 277, 12, 13680, 304, 267, 4474, 275, 291, 14, 3813, 14, 3170, 267, 340, 13680, 14, 19332, 26, 288, 4474, 8901, 291, 14, 3813, 14, 5670, 267, 340, 13680, 14, 14827, 26, 288, 4474, 8901, 291, 14, 3813, 14, 10387, 267, 372, 4474, 339, 347, 485, 7211, 8, 277, 12, 13680, 304, 267, 340, 13680, 14, 22357, 26, 288, 291, 14, 3813, 14, 525, 63, 2593, 8, 5891, 14, 22357, 12, 2400, 26, 291, 14, 16340, 8, 5891, 430, 339, 347, 485, 16340, 8, 277, 12, 13680, 304, 267, 13680, 14, 16340, 342, 339, 347, 485, 1412, 8, 277, 304, 267, 291, 14, 13544, 14, 1412, 342, 267, 340, 440, 291, 14, 13544, 14, 783, 397, 6867, 26, 288, 291, 14, 3813, 14, 525, 63, 3058, 8, 277, 423, 1412, 9, 339, 347, 485, 3058, 8, 277, 12, 13680, 12, 4474, 304, 267, 340, 291, 14, 3813, 14, 5670, 1253, 4474, 26, 288, 13680, 14, 11875, 342, 267, 340, 291, 14, 3813, 14, 10387, 1253, 4474, 26, 288, 13680, 14, 15053, 342, 267, 291, 423, 1412, 342, 339, 347, 641, 63, 18837, 63, 826, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 2356, 378, 26, 288, 291, 14, 3813, 14, 525, 63, 2232, 8, 5891, 14, 9843, 1062, 2400, 6111, 12, 4474, 26, 291, 423, 3058, 8, 5891, 12, 4474, 395, 291, 423, 4368, 8, 5891, 430, 267, 291, 423, 7211, 8, 5891, 9, 267, 291, 14, 835, 847, 413, 339, 347, 641, 63, 18837, 63, 5334, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 690, 378, 26, 288, 291, 14, 3813, 14, 873, 63, 2232, 8, 5891, 14, 9843, 1062, 291, 423, 4368, 8, 5891, 430, 267, 291, 423, 7211, 8, 5891, 9, 339, 347, 641, 63, 18837, 63, 5094, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 690, 378, 26, 288, 291, 14, 3813, 14, 2168, 63, 2232, 8, 5891, 14, 9843, 1012, 267, 13680, 14, 3221, 342, 267, 291, 14, 835, 4862, 413, 267, 340, 291, 14, 835, 508, 378, 26, 288, 291, 14, 3813, 14, 525, 63, 3058, 8, 277, 423, 2379, 9, 339, 347, 485, 2379, 8, 277, 304, 267, 291, 14, 13544, 14, 2379, 342, 267, 291, 14, 3813, 14, 2379, 342, 199, 199, 533, 15395, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 5586, 12, 1011, 958, 304, 267, 291, 14, 18443, 63, 3813, 275, 2074, 14, 362, 360, 3813, 297, 12148, 14, 27212, 14, 23152, 14, 842, 1012, 267, 2074, 459, 2966, 63, 2232, 418, 275, 377, 8622, 7382, 2461, 8, 277, 14, 18443, 63, 3813, 12, 2074, 14, 362, 360, 2232, 63, 1095, 297, 488, 430, 267, 291, 14, 3600, 275, 3523, 4076, 2031, 5586, 12, 1011, 958, 9, 339, 347, 2536, 572, 8, 277, 304, 267, 291, 14, 3600, 14, 928, 342, 267, 291, 14, 3600, 14, 1412, 342, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 2747, 572, 342, 267, 291, 14, 18443, 63, 3813, 14, 928, 342, 339, 347, 12943, 8, 277, 304, 267, 291, 423, 1412, 342, 339, 347, 485, 1412, 8, 277, 304, 267, 291, 14, 3600, 14, 1412, 342, 267, 340, 440, 291, 14, 3600, 14, 783, 397, 6867, 26, 288, 291, 14, 18443, 63, 3813, 14, 525, 63, 3058, 8, 277, 423, 1412, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 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, 3, 199, 199, 646, 12148, 14, 27212, 199, 504, 557, 1860, 14, 13544, 492, 15395, 465, 3523, 4076, 199, 504, 557, 1860, 14, 5586, 492, 5004, 2461, 199, 199, 533, 377, 8622, 7382, 2461, 26, 339, 347, 636, 826, 721, 277, 12, 4438, 29, 403, 12, 3016, 63, 1095, 29, 403, 304, 267, 291, 14, 3813, 275, 4438, 503, 12148, 14, 27212, 14, 23152, 14, 842, 342, 267, 291, 14, 2308, 275, 3016, 63, 1095, 503, 5004, 2461, 342, 267, 291, 14, 835, 275, 378, 339, 347, 641, 63, 13544, 63, 826, 8, 277, 12, 1566, 304, 267, 291, 14, 13544, 275, 1566, 14, 13544, 339, 347, 641, 63, 13544, 63, 783, 397, 6867, 8, 277, 12, 1566, 304, 267, 1566, 14, 13544, 14, 11481, 12798, 339, 347, 641, 63, 23648, 8, 277, 12, 536, 12, 1566, 304, 267, 1566, 14, 6052, 8, 277, 14, 2308, 9, 339, 347, 485, 4368, 8, 277, 12, 13680, 304, 267, 4474, 275, 291, 14, 3813, 14, 3170, 267, 340, 13680, 14, 19332, 26, 288, 4474, 8901, 291, 14, 3813, 14, 5670, 267, 340, 13680, 14, 14827, 26, 288, 4474, 8901, 291, 14, 3813, 14, 10387, 267, 372, 4474, 339, 347, 485, 7211, 8, 277, 12, 13680, 304, 267, 340, 13680, 14, 22357, 26, 288, 291, 14, 3813, 14, 525, 63, 2593, 8, 5891, 14, 22357, 12, 2400, 26, 291, 14, 16340, 8, 5891, 430, 339, 347, 485, 16340, 8, 277, 12, 13680, 304, 267, 13680, 14, 16340, 342, 339, 347, 485, 1412, 8, 277, 304, 267, 291, 14, 13544, 14, 1412, 342, 267, 340, 440, 291, 14, 13544, 14, 783, 397, 6867, 26, 288, 291, 14, 3813, 14, 525, 63, 3058, 8, 277, 423, 1412, 9, 339, 347, 485, 3058, 8, 277, 12, 13680, 12, 4474, 304, 267, 340, 291, 14, 3813, 14, 5670, 1253, 4474, 26, 288, 13680, 14, 11875, 342, 267, 340, 291, 14, 3813, 14, 10387, 1253, 4474, 26, 288, 13680, 14, 15053, 342, 267, 291, 423, 1412, 342, 339, 347, 641, 63, 18837, 63, 826, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 2356, 378, 26, 288, 291, 14, 3813, 14, 525, 63, 2232, 8, 5891, 14, 9843, 1062, 2400, 6111, 12, 4474, 26, 291, 423, 3058, 8, 5891, 12, 4474, 395, 291, 423, 4368, 8, 5891, 430, 267, 291, 423, 7211, 8, 5891, 9, 267, 291, 14, 835, 847, 413, 339, 347, 641, 63, 18837, 63, 5334, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 690, 378, 26, 288, 291, 14, 3813, 14, 873, 63, 2232, 8, 5891, 14, 9843, 1062, 291, 423, 4368, 8, 5891, 430, 267, 291, 423, 7211, 8, 5891, 9, 339, 347, 641, 63, 18837, 63, 5094, 8, 277, 12, 1566, 304, 267, 13680, 275, 1566, 14, 1100, 267, 340, 13680, 14, 9843, 342, 690, 378, 26, 288, 291, 14, 3813, 14, 2168, 63, 2232, 8, 5891, 14, 9843, 1012, 267, 13680, 14, 3221, 342, 267, 291, 14, 835, 4862, 413, 267, 340, 291, 14, 835, 508, 378, 26, 288, 291, 14, 3813, 14, 525, 63, 3058, 8, 277, 423, 2379, 9, 339, 347, 485, 2379, 8, 277, 304, 267, 291, 14, 13544, 14, 2379, 342, 267, 291, 14, 3813, 14, 2379, 342, 199, 199, 533, 15395, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 5586, 12, 1011, 958, 304, 267, 291, 14, 18443, 63, 3813, 275, 2074, 14, 362, 360, 3813, 297, 12148, 14, 27212, 14, 23152, 14, 842, 1012, 267, 2074, 459, 2966, 63, 2232, 418, 275, 377, 8622, 7382, 2461, 8, 277, 14, 18443, 63, 3813, 12, 2074, 14, 362, 360, 2232, 63, 1095, 297, 488, 430, 267, 291, 14, 3600, 275, 3523, 4076, 2031, 5586, 12, 1011, 958, 9, 339, 347, 2536, 572, 8, 277, 304, 267, 291, 14, 3600, 14, 928, 342, 267, 291, 14, 3600, 14, 1412, 342, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 2747, 572, 342, 267, 291, 14, 18443, 63, 3813, 14, 928, 342, 339, 347, 12943, 8, 277, 304, 267, 291, 423, 1412, 342, 339, 347, 485, 1412, 8, 277, 304, 267, 291, 14, 3600, 14, 1412, 342, 267, 340, 440, 291, 14, 3600, 14, 783, 397, 6867, 26, 288, 291, 14, 18443, 63, 3813, 14, 525, 63, 3058, 8, 277, 423, 1412, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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WinColor(object): BLACK = 0 BLUE = 1 GREEN = 2 CYAN = 3 RED = 4 MAGENTA = 5 YELLOW = 6 GREY = 7 # from wincon.h class WinStyle(object): NORMAL = 0x00 # dim text, dim background BRIGHT = 0x08 # bright text, dim background class WinTerm(object): def __init__(self): self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes self.set_attrs(self._default) self._default_fore = self._fore self._default_back = self._back self._default_style = self._style def get_attrs(self): return self._fore + self._back * 16 + self._style def set_attrs(self, value): self._fore = value & 7 self._back = (value >> 4) & 7 self._style = value & WinStyle.BRIGHT def reset_all(self, on_stderr=None): self.set_attrs(self._default) self.set_console(attrs=self._default) def fore(self, fore=None, on_stderr=False): if fore is None: fore = self._default_fore self._fore = fore self.set_console(on_stderr=on_stderr) def back(self, back=None, on_stderr=False): if back is None: back = self._default_back self._back = back self.set_console(on_stderr=on_stderr) def style(self, style=None, on_stderr=False): if style is None: style = self._default_style self._style = style self.set_console(on_stderr=on_stderr) def set_console(self, attrs=None, on_stderr=False): if attrs is None: attrs = self.get_attrs() handle = win32.STDOUT if on_stderr: handle = win32.STDERR win32.SetConsoleTextAttribute(handle, attrs) def get_position(self, handle): position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition # Because Windows coordinates are 0-based, # and win32.SetConsoleCursorPosition expects 1-based. position.X += 1 position.Y += 1 return position def set_cursor_position(self, position=None, on_stderr=False): if position is None: #I'm not currently tracking the position, so there is no default. #position = self.get_position() return handle = win32.STDOUT if on_stderr: handle = win32.STDERR win32.SetConsoleCursorPosition(handle, position) def cursor_up(self, num_rows=0, on_stderr=False): if num_rows == 0: return handle = win32.STDOUT if on_stderr: handle = win32.STDERR position = self.get_position(handle) adjusted_position = (position.Y - num_rows, position.X) self.set_cursor_position(adjusted_position, on_stderr) def erase_data(self, mode=0, on_stderr=False): # 0 (or None) should clear from the cursor to the end of the screen. # 1 should clear from the cursor to the beginning of the screen. # 2 should clear the entire screen. (And maybe move cursor to (1,1)?) # # At the moment, I only support mode 2. From looking at the API, it # should be possible to calculate a different number of bytes to clear, # and to do so relative to the cursor position. if mode[0] not in (2,): return handle = win32.STDOUT if on_stderr: handle = win32.STDERR # here's where we'll home the cursor coord_screen = win32.COORD(0,0) csbi = win32.GetConsoleScreenBufferInfo(handle) # get the number of character cells in the current buffer dw_con_size = csbi.dwSize.X * csbi.dwSize.Y # fill the entire screen with blanks win32.FillConsoleOutputCharacter(handle, ' ', dw_con_size, coord_screen) # now set the buffer's attributes accordingly win32.FillConsoleOutputAttribute(handle, self.get_attrs(), dw_con_size, coord_screen ); # put the cursor at (0, 0) win32.SetConsoleCursorPosition(handle, (coord_screen.X, coord_screen.Y))
mit
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 504, 1275, 492, 4747, 708, 421, 199, 3, 687, 4747, 388, 14, 72, 199, 533, 13036, 4117, 8, 785, 304, 272, 26774, 257, 275, 378, 272, 31408, 259, 275, 413, 272, 598, 14824, 257, 275, 499, 272, 445, 57, 879, 259, 275, 650, 272, 23443, 258, 275, 841, 272, 603, 14565, 33, 275, 959, 272, 1488, 23575, 221, 275, 1227, 272, 598, 907, 57, 259, 275, 1520, 199, 199, 3, 687, 4747, 388, 14, 72, 199, 533, 13036, 6609, 8, 785, 304, 272, 653, 9623, 275, 378, 88, 383, 327, 8134, 1318, 12, 8134, 8020, 272, 11713, 2830, 275, 378, 88, 2036, 327, 330, 1019, 1318, 12, 8134, 8020, 421, 199, 533, 13036, 21676, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 885, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2676, 708, 14, 13850, 680, 87, 5379, 267, 291, 14, 409, 63, 3288, 8, 277, 423, 885, 9, 267, 291, 423, 885, 63, 1707, 275, 291, 423, 1707, 267, 291, 423, 885, 63, 894, 275, 291, 423, 894, 267, 291, 423, 885, 63, 2487, 275, 291, 423, 2487, 339, 347, 664, 63, 3288, 8, 277, 304, 267, 372, 291, 423, 1707, 435, 291, 423, 894, 627, 3193, 435, 291, 423, 2487, 339, 347, 663, 63, 3288, 8, 277, 12, 574, 304, 267, 291, 423, 1707, 275, 574, 1253, 1520, 267, 291, 423, 894, 275, 334, 585, 4331, 841, 9, 1253, 1520, 267, 291, 423, 2487, 275, 574, 1253, 13036, 6609, 14, 30976, 339, 347, 5305, 63, 452, 8, 277, 12, 641, 63, 3083, 29, 403, 304, 267, 291, 14, 409, 63, 3288, 8, 277, 423, 885, 9, 267, 291, 14, 409, 63, 6614, 8, 3288, 29, 277, 423, 885, 9, 339, 347, 11257, 8, 277, 12, 11257, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 11257, 365, 488, 26, 288, 11257, 275, 291, 423, 885, 63, 1707, 267, 291, 423, 1707, 275, 11257, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 1771, 8, 277, 12, 1771, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 1771, 365, 488, 26, 288, 1771, 275, 291, 423, 885, 63, 894, 267, 291, 423, 894, 275, 1771, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 3449, 8, 277, 12, 3449, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3449, 365, 488, 26, 288, 3449, 275, 291, 423, 885, 63, 2487, 267, 291, 423, 2487, 275, 3449, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 663, 63, 6614, 8, 277, 12, 3290, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3290, 365, 488, 26, 288, 3290, 275, 291, 14, 362, 63, 3288, 342, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 4747, 708, 14, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 664, 63, 3124, 8, 277, 12, 2429, 304, 267, 3421, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2479, 680, 10772, 32766, 267, 327, 13821, 5417, 8983, 787, 378, 13, 6788, 12, 267, 327, 436, 4747, 708, 14, 1084, 9270, 32766, 14292, 413, 13, 6788, 14, 267, 3421, 14, 56, 847, 413, 267, 3421, 14, 57, 847, 413, 267, 372, 3421, 2286, 347, 663, 63, 3937, 63, 3124, 8, 277, 12, 3421, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3421, 365, 488, 26, 288, 327, 41, 6704, 440, 5544, 15161, 314, 3421, 12, 880, 2337, 365, 949, 849, 14, 288, 327, 3124, 275, 291, 14, 362, 63, 3124, 342, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 4747, 708, 14, 1084, 9270, 32766, 8, 2479, 12, 3421, 9, 339, 347, 3920, 63, 384, 8, 277, 12, 1967, 63, 3838, 29, 16, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 1967, 63, 3838, 508, 378, 26, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 3421, 275, 291, 14, 362, 63, 3124, 8, 2479, 9, 267, 19477, 63, 3124, 275, 334, 3124, 14, 57, 446, 1967, 63, 3838, 12, 3421, 14, 56, 9, 267, 291, 14, 409, 63, 3937, 63, 3124, 8, 23395, 63, 3124, 12, 641, 63, 3083, 9, 339, 347, 28343, 63, 576, 8, 277, 12, 818, 29, 16, 12, 641, 63, 3083, 29, 797, 304, 267, 327, 378, 334, 269, 488, 9, 1077, 5436, 687, 314, 3920, 370, 314, 1284, 402, 314, 6426, 14, 267, 327, 413, 1077, 5436, 687, 314, 3920, 370, 314, 9608, 402, 314, 6426, 14, 267, 327, 499, 1077, 5436, 314, 8039, 6426, 14, 334, 3325, 11703, 4057, 3920, 370, 334, 17, 12, 17, 5547, 9, 267, 327, 267, 327, 2854, 314, 12427, 12, 473, 1454, 2291, 818, 499, 14, 11606, 10023, 737, 314, 3261, 12, 652, 267, 327, 259, 1077, 506, 3962, 370, 8671, 282, 3365, 1329, 402, 2783, 370, 5436, 12, 267, 327, 259, 436, 370, 886, 880, 3847, 370, 314, 3920, 3421, 14, 267, 340, 818, 59, 16, 61, 440, 315, 334, 18, 16095, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 327, 2348, 1159, 2382, 781, 7171, 5629, 314, 3920, 267, 11021, 63, 5410, 275, 4747, 708, 14, 21901, 8, 16, 12, 16, 9, 267, 7117, 4492, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2479, 9, 267, 327, 664, 314, 1329, 402, 4528, 10106, 315, 314, 1453, 3335, 267, 17594, 63, 388, 63, 890, 275, 7117, 4492, 14, 10772, 2320, 14, 56, 627, 7117, 4492, 14, 10772, 2320, 14, 57, 267, 327, 5554, 314, 8039, 6426, 543, 4596, 83, 267, 4747, 708, 14, 12914, 9270 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 504, 1275, 492, 4747, 708, 421, 199, 3, 687, 4747, 388, 14, 72, 199, 533, 13036, 4117, 8, 785, 304, 272, 26774, 257, 275, 378, 272, 31408, 259, 275, 413, 272, 598, 14824, 257, 275, 499, 272, 445, 57, 879, 259, 275, 650, 272, 23443, 258, 275, 841, 272, 603, 14565, 33, 275, 959, 272, 1488, 23575, 221, 275, 1227, 272, 598, 907, 57, 259, 275, 1520, 199, 199, 3, 687, 4747, 388, 14, 72, 199, 533, 13036, 6609, 8, 785, 304, 272, 653, 9623, 275, 378, 88, 383, 327, 8134, 1318, 12, 8134, 8020, 272, 11713, 2830, 275, 378, 88, 2036, 327, 330, 1019, 1318, 12, 8134, 8020, 421, 199, 533, 13036, 21676, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 885, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2676, 708, 14, 13850, 680, 87, 5379, 267, 291, 14, 409, 63, 3288, 8, 277, 423, 885, 9, 267, 291, 423, 885, 63, 1707, 275, 291, 423, 1707, 267, 291, 423, 885, 63, 894, 275, 291, 423, 894, 267, 291, 423, 885, 63, 2487, 275, 291, 423, 2487, 339, 347, 664, 63, 3288, 8, 277, 304, 267, 372, 291, 423, 1707, 435, 291, 423, 894, 627, 3193, 435, 291, 423, 2487, 339, 347, 663, 63, 3288, 8, 277, 12, 574, 304, 267, 291, 423, 1707, 275, 574, 1253, 1520, 267, 291, 423, 894, 275, 334, 585, 4331, 841, 9, 1253, 1520, 267, 291, 423, 2487, 275, 574, 1253, 13036, 6609, 14, 30976, 339, 347, 5305, 63, 452, 8, 277, 12, 641, 63, 3083, 29, 403, 304, 267, 291, 14, 409, 63, 3288, 8, 277, 423, 885, 9, 267, 291, 14, 409, 63, 6614, 8, 3288, 29, 277, 423, 885, 9, 339, 347, 11257, 8, 277, 12, 11257, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 11257, 365, 488, 26, 288, 11257, 275, 291, 423, 885, 63, 1707, 267, 291, 423, 1707, 275, 11257, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 1771, 8, 277, 12, 1771, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 1771, 365, 488, 26, 288, 1771, 275, 291, 423, 885, 63, 894, 267, 291, 423, 894, 275, 1771, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 3449, 8, 277, 12, 3449, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3449, 365, 488, 26, 288, 3449, 275, 291, 423, 885, 63, 2487, 267, 291, 423, 2487, 275, 3449, 267, 291, 14, 409, 63, 6614, 8, 265, 63, 3083, 29, 265, 63, 3083, 9, 339, 347, 663, 63, 6614, 8, 277, 12, 3290, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3290, 365, 488, 26, 288, 3290, 275, 291, 14, 362, 63, 3288, 342, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 4747, 708, 14, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 664, 63, 3124, 8, 277, 12, 2429, 304, 267, 3421, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2479, 680, 10772, 32766, 267, 327, 13821, 5417, 8983, 787, 378, 13, 6788, 12, 267, 327, 436, 4747, 708, 14, 1084, 9270, 32766, 14292, 413, 13, 6788, 14, 267, 3421, 14, 56, 847, 413, 267, 3421, 14, 57, 847, 413, 267, 372, 3421, 2286, 347, 663, 63, 3937, 63, 3124, 8, 277, 12, 3421, 29, 403, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 3421, 365, 488, 26, 288, 327, 41, 6704, 440, 5544, 15161, 314, 3421, 12, 880, 2337, 365, 949, 849, 14, 288, 327, 3124, 275, 291, 14, 362, 63, 3124, 342, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 4747, 708, 14, 1084, 9270, 32766, 8, 2479, 12, 3421, 9, 339, 347, 3920, 63, 384, 8, 277, 12, 1967, 63, 3838, 29, 16, 12, 641, 63, 3083, 29, 797, 304, 267, 340, 1967, 63, 3838, 508, 378, 26, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 3421, 275, 291, 14, 362, 63, 3124, 8, 2479, 9, 267, 19477, 63, 3124, 275, 334, 3124, 14, 57, 446, 1967, 63, 3838, 12, 3421, 14, 56, 9, 267, 291, 14, 409, 63, 3937, 63, 3124, 8, 23395, 63, 3124, 12, 641, 63, 3083, 9, 339, 347, 28343, 63, 576, 8, 277, 12, 818, 29, 16, 12, 641, 63, 3083, 29, 797, 304, 267, 327, 378, 334, 269, 488, 9, 1077, 5436, 687, 314, 3920, 370, 314, 1284, 402, 314, 6426, 14, 267, 327, 413, 1077, 5436, 687, 314, 3920, 370, 314, 9608, 402, 314, 6426, 14, 267, 327, 499, 1077, 5436, 314, 8039, 6426, 14, 334, 3325, 11703, 4057, 3920, 370, 334, 17, 12, 17, 5547, 9, 267, 327, 267, 327, 2854, 314, 12427, 12, 473, 1454, 2291, 818, 499, 14, 11606, 10023, 737, 314, 3261, 12, 652, 267, 327, 259, 1077, 506, 3962, 370, 8671, 282, 3365, 1329, 402, 2783, 370, 5436, 12, 267, 327, 259, 436, 370, 886, 880, 3847, 370, 314, 3920, 3421, 14, 267, 340, 818, 59, 16, 61, 440, 315, 334, 18, 16095, 288, 372, 267, 2429, 275, 4747, 708, 14, 13850, 267, 340, 641, 63, 3083, 26, 288, 2429, 275, 4747, 708, 14, 18472, 2666, 267, 327, 2348, 1159, 2382, 781, 7171, 5629, 314, 3920, 267, 11021, 63, 5410, 275, 4747, 708, 14, 21901, 8, 16, 12, 16, 9, 267, 7117, 4492, 275, 4747, 708, 14, 1002, 9270, 9616, 3299, 2354, 8, 2479, 9, 267, 327, 664, 314, 1329, 402, 4528, 10106, 315, 314, 1453, 3335, 267, 17594, 63, 388, 63, 890, 275, 7117, 4492, 14, 10772, 2320, 14, 56, 627, 7117, 4492, 14, 10772, 2320, 14, 57, 267, 327, 5554, 314, 8039, 6426, 543, 4596, 83, 267, 4747, 708, 14, 12914, 9270, 0 ]
[ 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1 ]
jeffreyjinfeng/scrapy
scrapy/pipelines/media.py
122
4947
from __future__ import print_function import logging from collections import defaultdict from twisted.internet.defer import Deferred, DeferredList from twisted.python.failure import Failure from scrapy.utils.defer import mustbe_deferred, defer_result from scrapy.utils.request import request_fingerprint from scrapy.utils.misc import arg_to_iter from scrapy.utils.log import failure_to_exc_info logger = logging.getLogger(__name__) class MediaPipeline(object): LOG_FAILED_RESULTS = True class SpiderInfo(object): def __init__(self, spider): self.spider = spider self.downloading = set() self.downloaded = {} self.waiting = defaultdict(list) def __init__(self, download_func=None): self.download_func = download_func @classmethod def from_crawler(cls, crawler): try: pipe = cls.from_settings(crawler.settings) except AttributeError: pipe = cls() pipe.crawler = crawler return pipe def open_spider(self, spider): self.spiderinfo = self.SpiderInfo(spider) def process_item(self, item, spider): info = self.spiderinfo requests = arg_to_iter(self.get_media_requests(item, info)) dlist = [self._process_request(r, info) for r in requests] dfd = DeferredList(dlist, consumeErrors=1) return dfd.addCallback(self.item_completed, item, info) def _process_request(self, request, info): fp = request_fingerprint(request) cb = request.callback or (lambda _: _) eb = request.errback request.callback = None request.errback = None # Return cached result if request was already seen if fp in info.downloaded: return defer_result(info.downloaded[fp]).addCallbacks(cb, eb) # Otherwise, wait for result wad = Deferred().addCallbacks(cb, eb) info.waiting[fp].append(wad) # Check if request is downloading right now to avoid doing it twice if fp in info.downloading: return wad # Download request checking media_to_download hook output first info.downloading.add(fp) dfd = mustbe_deferred(self.media_to_download, request, info) dfd.addCallback(self._check_media_to_download, request, info) dfd.addBoth(self._cache_result_and_execute_waiters, fp, info) dfd.addErrback(lambda f: logger.error( f.value, exc_info=failure_to_exc_info(f), extra={'spider': info.spider}) ) return dfd.addBoth(lambda _: wad) # it must return wad at last def _check_media_to_download(self, result, request, info): if result is not None: return result if self.download_func: # this ugly code was left only to support tests. TODO: remove dfd = mustbe_deferred(self.download_func, request, info.spider) dfd.addCallbacks( callback=self.media_downloaded, callbackArgs=(request, info), errback=self.media_failed, errbackArgs=(request, info)) else: request.meta['handle_httpstatus_all'] = True dfd = self.crawler.engine.download(request, info.spider) dfd.addCallbacks( callback=self.media_downloaded, callbackArgs=(request, info), errback=self.media_failed, errbackArgs=(request, info)) return dfd def _cache_result_and_execute_waiters(self, result, fp, info): if isinstance(result, Failure): # minimize cached information for failure result.cleanFailure() result.frames = [] result.stack = None info.downloading.remove(fp) info.downloaded[fp] = result # cache result for wad in info.waiting.pop(fp): defer_result(result).chainDeferred(wad) ### Overridable Interface def media_to_download(self, request, info): """Check request before starting download""" pass def get_media_requests(self, item, info): """Returns the media requests to download""" pass def media_downloaded(self, response, request, info): """Handler for success downloads""" return response def media_failed(self, failure, request, info): """Handler for failed downloads""" return failure def item_completed(self, results, item, info): """Called per item when all media requests has been processed""" if self.LOG_FAILED_RESULTS: for ok, value in results: if not ok: logger.error( '%(class)s found errors processing %(item)s', {'class': self.__class__.__name__, 'item': item}, exc_info=failure_to_exc_info(value), extra={'spider': info.spider} ) return item
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 17448, 1296, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 199, 504, 18918, 14, 1208, 14, 11610, 492, 1471, 1235, 63, 12116, 12, 10133, 63, 1099, 199, 504, 18918, 14, 1208, 14, 1069, 492, 1056, 63, 15077, 199, 504, 18918, 14, 1208, 14, 9923, 492, 1680, 63, 475, 63, 1661, 199, 504, 18918, 14, 1208, 14, 793, 492, 5988, 63, 475, 63, 2804, 63, 815, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12300, 17562, 8, 785, 304, 339, 5051, 63, 12299, 63, 23545, 275, 715, 339, 1021, 428, 12508, 2354, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 18094, 304, 288, 291, 14, 12856, 275, 18094, 288, 291, 14, 4249, 316, 275, 663, 342, 288, 291, 14, 19385, 275, 1052, 288, 291, 14, 14093, 275, 10018, 8, 513, 9, 339, 347, 636, 826, 721, 277, 12, 5235, 63, 1532, 29, 403, 304, 267, 291, 14, 4249, 63, 1532, 275, 5235, 63, 1532, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 862, 26, 288, 5200, 275, 843, 14, 504, 63, 1751, 8, 23972, 14, 1751, 9, 267, 871, 4281, 26, 288, 5200, 275, 843, 342, 267, 5200, 14, 23972, 275, 29550, 267, 372, 5200, 339, 347, 1551, 63, 12856, 8, 277, 12, 18094, 304, 267, 291, 14, 12856, 815, 275, 291, 14, 25157, 2354, 8, 12856, 9, 339, 347, 2112, 63, 1053, 8, 277, 12, 1242, 12, 18094, 304, 267, 2256, 275, 291, 14, 12856, 815, 267, 4145, 275, 1680, 63, 475, 63, 1661, 8, 277, 14, 362, 63, 4603, 63, 6615, 8, 1053, 12, 2256, 430, 267, 366, 513, 275, 359, 277, 423, 1412, 63, 1069, 8, 82, 12, 2256, 9, 367, 519, 315, 4145, 61, 267, 366, 2592, 275, 17448, 1296, 8, 68, 513, 12, 9451, 9298, 29, 17, 9, 267, 372, 366, 2592, 14, 10053, 8, 277, 14, 1053, 63, 12634, 12, 1242, 12, 2256, 9, 339, 347, 485, 1412, 63, 1069, 8, 277, 12, 1056, 12, 2256, 304, 267, 4090, 275, 1056, 63, 15077, 8, 1069, 9, 267, 7434, 275, 1056, 14, 3058, 503, 334, 2734, 24700, 20795, 267, 26669, 275, 1056, 14, 28940, 267, 1056, 14, 3058, 275, 488, 267, 1056, 14, 28940, 275, 488, 398, 327, 1432, 6328, 754, 340, 1056, 1990, 2575, 6775, 267, 340, 4090, 315, 2256, 14, 19385, 26, 288, 372, 10133, 63, 1099, 8, 815, 14, 19385, 59, 3997, 6575, 10053, 83, 8, 2894, 12, 26669, 9, 398, 327, 6630, 12, 3618, 367, 754, 267, 336, 350, 275, 17448, 1252, 10053, 83, 8, 2894, 12, 26669, 9, 267, 2256, 14, 14093, 59, 3997, 1055, 740, 8, 87, 350, 9, 398, 327, 2670, 340, 1056, 365, 25937, 2451, 3063, 370, 5126, 9689, 652, 13373, 267, 340, 4090, 315, 2256, 14, 4249, 316, 26, 288, 372, 336, 350, 398, 327, 17955, 1056, 7907, 5898, 63, 475, 63, 4249, 5759, 1072, 1642, 267, 2256, 14, 4249, 316, 14, 525, 8, 3997, 9, 267, 366, 2592, 275, 1471, 1235, 63, 12116, 8, 277, 14, 4603, 63, 475, 63, 4249, 12, 1056, 12, 2256, 9, 267, 366, 2592, 14, 10053, 8, 277, 423, 1074, 63, 4603, 63, 475, 63, 4249, 12, 1056, 12, 2256, 9, 267, 366, 2592, 14, 525, 18088, 8, 277, 423, 1637, 63, 1099, 63, 460, 63, 2526, 63, 758, 15266, 12, 4090, 12, 2256, 9, 267, 366, 2592, 14, 31554, 8, 2734, 289, 26, 2512, 14, 705, 8, 288, 289, 14, 585, 12, 3178, 63, 815, 29, 5328, 63, 475, 63, 2804, 63, 815, 8, 70, 395, 2402, 3713, 12856, 356, 2256, 14, 12856, 1552, 267, 776, 267, 372, 366, 2592, 14, 525, 18088, 8, 2734, 24700, 336, 350, 9, 221, 327, 652, 1471, 372, 336, 350, 737, 2061, 339, 347, 485, 1074, 63, 4603, 63, 475, 63, 4249, 8, 277, 12, 754, 12, 1056, 12, 2256, 304, 267, 340, 754, 365, 440, 488, 26, 288, 372, 754, 267, 340, 291, 14, 4249, 63, 1532, 26, 288, 327, 642, 23761, 1233, 1990, 3602, 1454, 370, 2291, 2295, 14, 3254, 26, 2813, 288, 366, 2592, 275, 1471, 1235, 63, 12116, 8, 277, 14, 4249, 63, 1532, 12, 1056, 12, 2256, 14, 12856, 9, 288, 366, 2592, 14, 10053, 83, 8, 355, 3233, 29, 277, 14, 4603, 63, 19385, 12, 3233, 6213, 2687, 1069, 12, 2256, 395, 355, 2329, 894, 29, 277, 14, 4603, 63, 4892, 12, 2329, 894, 6213, 2687, 1069, 12, 2256, 430, 267, 587, 26, 288, 1056, 14, 2024, 459, 2479, 63, 1014, 1205, 63, 452, 418, 275, 715, 288, 366, 2592, 275, 291, 14, 23972, 14, 3908, 14, 4249, 8, 1069, 12, 2256, 14, 12856, 9, 288, 366, 2592, 14, 10053, 83, 8, 355, 3233, 29, 277, 14, 4603, 63, 19385, 12, 3233, 6213, 2687, 1069, 12, 2256, 395, 355, 2329, 894, 29, 277, 14, 4603, 63, 4892, 12, 2329, 894, 6213, 2687, 1069, 12, 2256, 430, 267, 372, 366, 2592, 339, 347, 485, 1637, 63, 1099, 63, 460, 63, 2526, 63, 758, 15266, 8, 277, 12, 754, 12, 4090, 12, 2256, 304, 267, 340, 1228, 8, 1099, 12, 20367, 304, 288, 327, 24720, 6328, 2556, 367, 5988, 288, 754, 14, 3118, 6782, 342, 288, 754, 14, 8444, 275, 942, 288, 754, 14, 2340, 275, 488, 267, 2256, 14, 4249, 316, 14, 2168, 8, 3997, 9, 267, 2256, 14, 19385, 59, 3997, 61, 275, 754, 221, 327, 2581, 754, 267, 367, 336, 350, 315, 2256, 14, 14093, 14, 1935, 8, 3997, 304, 288, 10133, 63, 1099, 8, 1099, 680, 4429, 9937, 8, 87, 350, 9, 339, 6754, 7259, 1677, 461, 14816, 272, 347, 5898, 63, 475, 63, 4249, 8, 277, 12, 1056, 12, 2256, 304, 267, 408, 1799, 1056, 2544, 6617, 5235, 624, 267, 986, 339, 347, 664, 63, 4603, 63, 6615, 8, 277, 12, 1242, 12, 2256, 304, 267, 408, 3407, 314, 5898, 4145, 370, 5235, 624, 267, 986, 339, 347, 5898, 63, 19385, 8, 277, 12, 1177, 12, 1056, 12, 2256, 304, 267, 408, 2461, 367, 3182, 28242, 624 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 17448, 1296, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 199, 504, 18918, 14, 1208, 14, 11610, 492, 1471, 1235, 63, 12116, 12, 10133, 63, 1099, 199, 504, 18918, 14, 1208, 14, 1069, 492, 1056, 63, 15077, 199, 504, 18918, 14, 1208, 14, 9923, 492, 1680, 63, 475, 63, 1661, 199, 504, 18918, 14, 1208, 14, 793, 492, 5988, 63, 475, 63, 2804, 63, 815, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12300, 17562, 8, 785, 304, 339, 5051, 63, 12299, 63, 23545, 275, 715, 339, 1021, 428, 12508, 2354, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 18094, 304, 288, 291, 14, 12856, 275, 18094, 288, 291, 14, 4249, 316, 275, 663, 342, 288, 291, 14, 19385, 275, 1052, 288, 291, 14, 14093, 275, 10018, 8, 513, 9, 339, 347, 636, 826, 721, 277, 12, 5235, 63, 1532, 29, 403, 304, 267, 291, 14, 4249, 63, 1532, 275, 5235, 63, 1532, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 862, 26, 288, 5200, 275, 843, 14, 504, 63, 1751, 8, 23972, 14, 1751, 9, 267, 871, 4281, 26, 288, 5200, 275, 843, 342, 267, 5200, 14, 23972, 275, 29550, 267, 372, 5200, 339, 347, 1551, 63, 12856, 8, 277, 12, 18094, 304, 267, 291, 14, 12856, 815, 275, 291, 14, 25157, 2354, 8, 12856, 9, 339, 347, 2112, 63, 1053, 8, 277, 12, 1242, 12, 18094, 304, 267, 2256, 275, 291, 14, 12856, 815, 267, 4145, 275, 1680, 63, 475, 63, 1661, 8, 277, 14, 362, 63, 4603, 63, 6615, 8, 1053, 12, 2256, 430, 267, 366, 513, 275, 359, 277, 423, 1412, 63, 1069, 8, 82, 12, 2256, 9, 367, 519, 315, 4145, 61, 267, 366, 2592, 275, 17448, 1296, 8, 68, 513, 12, 9451, 9298, 29, 17, 9, 267, 372, 366, 2592, 14, 10053, 8, 277, 14, 1053, 63, 12634, 12, 1242, 12, 2256, 9, 339, 347, 485, 1412, 63, 1069, 8, 277, 12, 1056, 12, 2256, 304, 267, 4090, 275, 1056, 63, 15077, 8, 1069, 9, 267, 7434, 275, 1056, 14, 3058, 503, 334, 2734, 24700, 20795, 267, 26669, 275, 1056, 14, 28940, 267, 1056, 14, 3058, 275, 488, 267, 1056, 14, 28940, 275, 488, 398, 327, 1432, 6328, 754, 340, 1056, 1990, 2575, 6775, 267, 340, 4090, 315, 2256, 14, 19385, 26, 288, 372, 10133, 63, 1099, 8, 815, 14, 19385, 59, 3997, 6575, 10053, 83, 8, 2894, 12, 26669, 9, 398, 327, 6630, 12, 3618, 367, 754, 267, 336, 350, 275, 17448, 1252, 10053, 83, 8, 2894, 12, 26669, 9, 267, 2256, 14, 14093, 59, 3997, 1055, 740, 8, 87, 350, 9, 398, 327, 2670, 340, 1056, 365, 25937, 2451, 3063, 370, 5126, 9689, 652, 13373, 267, 340, 4090, 315, 2256, 14, 4249, 316, 26, 288, 372, 336, 350, 398, 327, 17955, 1056, 7907, 5898, 63, 475, 63, 4249, 5759, 1072, 1642, 267, 2256, 14, 4249, 316, 14, 525, 8, 3997, 9, 267, 366, 2592, 275, 1471, 1235, 63, 12116, 8, 277, 14, 4603, 63, 475, 63, 4249, 12, 1056, 12, 2256, 9, 267, 366, 2592, 14, 10053, 8, 277, 423, 1074, 63, 4603, 63, 475, 63, 4249, 12, 1056, 12, 2256, 9, 267, 366, 2592, 14, 525, 18088, 8, 277, 423, 1637, 63, 1099, 63, 460, 63, 2526, 63, 758, 15266, 12, 4090, 12, 2256, 9, 267, 366, 2592, 14, 31554, 8, 2734, 289, 26, 2512, 14, 705, 8, 288, 289, 14, 585, 12, 3178, 63, 815, 29, 5328, 63, 475, 63, 2804, 63, 815, 8, 70, 395, 2402, 3713, 12856, 356, 2256, 14, 12856, 1552, 267, 776, 267, 372, 366, 2592, 14, 525, 18088, 8, 2734, 24700, 336, 350, 9, 221, 327, 652, 1471, 372, 336, 350, 737, 2061, 339, 347, 485, 1074, 63, 4603, 63, 475, 63, 4249, 8, 277, 12, 754, 12, 1056, 12, 2256, 304, 267, 340, 754, 365, 440, 488, 26, 288, 372, 754, 267, 340, 291, 14, 4249, 63, 1532, 26, 288, 327, 642, 23761, 1233, 1990, 3602, 1454, 370, 2291, 2295, 14, 3254, 26, 2813, 288, 366, 2592, 275, 1471, 1235, 63, 12116, 8, 277, 14, 4249, 63, 1532, 12, 1056, 12, 2256, 14, 12856, 9, 288, 366, 2592, 14, 10053, 83, 8, 355, 3233, 29, 277, 14, 4603, 63, 19385, 12, 3233, 6213, 2687, 1069, 12, 2256, 395, 355, 2329, 894, 29, 277, 14, 4603, 63, 4892, 12, 2329, 894, 6213, 2687, 1069, 12, 2256, 430, 267, 587, 26, 288, 1056, 14, 2024, 459, 2479, 63, 1014, 1205, 63, 452, 418, 275, 715, 288, 366, 2592, 275, 291, 14, 23972, 14, 3908, 14, 4249, 8, 1069, 12, 2256, 14, 12856, 9, 288, 366, 2592, 14, 10053, 83, 8, 355, 3233, 29, 277, 14, 4603, 63, 19385, 12, 3233, 6213, 2687, 1069, 12, 2256, 395, 355, 2329, 894, 29, 277, 14, 4603, 63, 4892, 12, 2329, 894, 6213, 2687, 1069, 12, 2256, 430, 267, 372, 366, 2592, 339, 347, 485, 1637, 63, 1099, 63, 460, 63, 2526, 63, 758, 15266, 8, 277, 12, 754, 12, 4090, 12, 2256, 304, 267, 340, 1228, 8, 1099, 12, 20367, 304, 288, 327, 24720, 6328, 2556, 367, 5988, 288, 754, 14, 3118, 6782, 342, 288, 754, 14, 8444, 275, 942, 288, 754, 14, 2340, 275, 488, 267, 2256, 14, 4249, 316, 14, 2168, 8, 3997, 9, 267, 2256, 14, 19385, 59, 3997, 61, 275, 754, 221, 327, 2581, 754, 267, 367, 336, 350, 315, 2256, 14, 14093, 14, 1935, 8, 3997, 304, 288, 10133, 63, 1099, 8, 1099, 680, 4429, 9937, 8, 87, 350, 9, 339, 6754, 7259, 1677, 461, 14816, 272, 347, 5898, 63, 475, 63, 4249, 8, 277, 12, 1056, 12, 2256, 304, 267, 408, 1799, 1056, 2544, 6617, 5235, 624, 267, 986, 339, 347, 664, 63, 4603,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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 ]
carolFrohlich/nipype
nipype/pipeline/plugins/tests/test_debug.py
2
1618
# -*- coding: utf-8 -*- import os import nipype.interfaces.base as nib from tempfile import mkdtemp from shutil import rmtree from nipype.testing import assert_raises, assert_false import nipype.pipeline.engine as pe class InputSpec(nib.TraitedSpec): input1 = nib.traits.Int(desc='a random int') input2 = nib.traits.Int(desc='a random int') class OutputSpec(nib.TraitedSpec): output1 = nib.traits.List(nib.traits.Int, desc='outputs') class TestInterface(nib.BaseInterface): input_spec = InputSpec output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime def _list_outputs(self): outputs = self._outputs().get() outputs['output1'] = [1, self.inputs.input1] return outputs def callme(node, graph): pass def test_debug(): cur_dir = os.getcwd() temp_dir = mkdtemp(prefix='test_engine_') os.chdir(temp_dir) pipe = pe.Workflow(name='pipe') mod1 = pe.Node(interface=TestInterface(), name='mod1') mod2 = pe.MapNode(interface=TestInterface(), iterfield=['input1'], name='mod2') pipe.connect([(mod1, mod2, [('output1', 'input1')])]) pipe.base_dir = os.getcwd() mod1.inputs.input1 = 1 run_wf = lambda: pipe.run(plugin="Debug") yield assert_raises, ValueError, run_wf try: pipe.run(plugin="Debug", plugin_args={'callable': callme}) exception_raised = False except Exception: exception_raised = True yield assert_false, exception_raised os.chdir(cur_dir) rmtree(temp_dir)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 302, 711, 514, 14, 7436, 14, 1095, 465, 302, 1892, 199, 504, 5549, 492, 31781, 199, 504, 5145, 492, 20978, 199, 199, 504, 302, 711, 514, 14, 4776, 492, 702, 63, 3536, 12, 702, 63, 3910, 199, 646, 302, 711, 514, 14, 7379, 14, 3908, 465, 4837, 421, 199, 533, 6924, 5307, 8, 78, 1892, 14, 2437, 5703, 5307, 304, 272, 1324, 17, 275, 302, 1892, 14, 17668, 14, 3241, 8, 3257, 534, 65, 2196, 1109, 358, 272, 1324, 18, 275, 302, 1892, 14, 17668, 14, 3241, 8, 3257, 534, 65, 2196, 1109, 358, 421, 199, 533, 7242, 5307, 8, 78, 1892, 14, 2437, 5703, 5307, 304, 272, 1072, 17, 275, 302, 1892, 14, 17668, 14, 1296, 8, 78, 1892, 14, 17668, 14, 3241, 12, 4328, 534, 4467, 358, 421, 199, 533, 1379, 4267, 8, 78, 1892, 14, 1563, 4267, 304, 272, 1324, 63, 1650, 275, 6924, 5307, 272, 1072, 63, 1650, 275, 7242, 5307, 339, 347, 485, 1065, 63, 3266, 8, 277, 12, 8836, 304, 267, 8836, 14, 9913, 275, 378, 267, 372, 8836, 339, 347, 485, 513, 63, 4467, 8, 277, 304, 267, 4704, 275, 291, 423, 4467, 1252, 362, 342, 267, 4704, 459, 1199, 17, 418, 275, 359, 17, 12, 291, 14, 3711, 14, 1210, 17, 61, 267, 372, 4704, 421, 199, 318, 1240, 278, 8, 932, 12, 3343, 304, 272, 986, 421, 199, 318, 511, 63, 1757, 837, 272, 1094, 63, 694, 275, 747, 14, 9458, 342, 272, 2388, 63, 694, 275, 31781, 8, 1861, 534, 396, 63, 3908, 15452, 272, 747, 14, 8563, 8, 808, 63, 694, 9, 339, 5200, 275, 4837, 14, 17527, 8, 354, 534, 4990, 358, 272, 3413, 17, 275, 4837, 14, 1716, 8, 3266, 29, 774, 4267, 1062, 536, 534, 1494, 17, 358, 272, 3413, 18, 275, 4837, 14, 2956, 1716, 8, 3266, 29, 774, 4267, 1062, 1993, 2740, 698, 2968, 1210, 17, 995, 1993, 536, 534, 1494, 18, 358, 272, 5200, 14, 2242, 7694, 1494, 17, 12, 3413, 18, 12, 4274, 1199, 17, 297, 283, 1210, 17, 2023, 566, 272, 5200, 14, 1095, 63, 694, 275, 747, 14, 9458, 342, 272, 3413, 17, 14, 3711, 14, 1210, 17, 275, 413, 272, 1255, 63, 14114, 275, 2400, 26, 5200, 14, 1065, 8, 2718, 628, 7084, 531, 272, 1995, 702, 63, 3536, 12, 1722, 12, 1255, 63, 14114, 272, 862, 26, 267, 5200, 14, 1065, 8, 2718, 628, 7084, 401, 3589, 63, 589, 3713, 8296, 356, 1240, 278, 1552, 267, 1919, 63, 21597, 275, 756, 272, 871, 2186, 26, 267, 1919, 63, 21597, 275, 715, 272, 1995, 702, 63, 3910, 12, 1919, 63, 21597, 272, 747, 14, 8563, 8, 895, 63, 694, 9, 272, 20978, 8, 808, 63, 694, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 302, 711, 514, 14, 7436, 14, 1095, 465, 302, 1892, 199, 504, 5549, 492, 31781, 199, 504, 5145, 492, 20978, 199, 199, 504, 302, 711, 514, 14, 4776, 492, 702, 63, 3536, 12, 702, 63, 3910, 199, 646, 302, 711, 514, 14, 7379, 14, 3908, 465, 4837, 421, 199, 533, 6924, 5307, 8, 78, 1892, 14, 2437, 5703, 5307, 304, 272, 1324, 17, 275, 302, 1892, 14, 17668, 14, 3241, 8, 3257, 534, 65, 2196, 1109, 358, 272, 1324, 18, 275, 302, 1892, 14, 17668, 14, 3241, 8, 3257, 534, 65, 2196, 1109, 358, 421, 199, 533, 7242, 5307, 8, 78, 1892, 14, 2437, 5703, 5307, 304, 272, 1072, 17, 275, 302, 1892, 14, 17668, 14, 1296, 8, 78, 1892, 14, 17668, 14, 3241, 12, 4328, 534, 4467, 358, 421, 199, 533, 1379, 4267, 8, 78, 1892, 14, 1563, 4267, 304, 272, 1324, 63, 1650, 275, 6924, 5307, 272, 1072, 63, 1650, 275, 7242, 5307, 339, 347, 485, 1065, 63, 3266, 8, 277, 12, 8836, 304, 267, 8836, 14, 9913, 275, 378, 267, 372, 8836, 339, 347, 485, 513, 63, 4467, 8, 277, 304, 267, 4704, 275, 291, 423, 4467, 1252, 362, 342, 267, 4704, 459, 1199, 17, 418, 275, 359, 17, 12, 291, 14, 3711, 14, 1210, 17, 61, 267, 372, 4704, 421, 199, 318, 1240, 278, 8, 932, 12, 3343, 304, 272, 986, 421, 199, 318, 511, 63, 1757, 837, 272, 1094, 63, 694, 275, 747, 14, 9458, 342, 272, 2388, 63, 694, 275, 31781, 8, 1861, 534, 396, 63, 3908, 15452, 272, 747, 14, 8563, 8, 808, 63, 694, 9, 339, 5200, 275, 4837, 14, 17527, 8, 354, 534, 4990, 358, 272, 3413, 17, 275, 4837, 14, 1716, 8, 3266, 29, 774, 4267, 1062, 536, 534, 1494, 17, 358, 272, 3413, 18, 275, 4837, 14, 2956, 1716, 8, 3266, 29, 774, 4267, 1062, 1993, 2740, 698, 2968, 1210, 17, 995, 1993, 536, 534, 1494, 18, 358, 272, 5200, 14, 2242, 7694, 1494, 17, 12, 3413, 18, 12, 4274, 1199, 17, 297, 283, 1210, 17, 2023, 566, 272, 5200, 14, 1095, 63, 694, 275, 747, 14, 9458, 342, 272, 3413, 17, 14, 3711, 14, 1210, 17, 275, 413, 272, 1255, 63, 14114, 275, 2400, 26, 5200, 14, 1065, 8, 2718, 628, 7084, 531, 272, 1995, 702, 63, 3536, 12, 1722, 12, 1255, 63, 14114, 272, 862, 26, 267, 5200, 14, 1065, 8, 2718, 628, 7084, 401, 3589, 63, 589, 3713, 8296, 356, 1240, 278, 1552, 267, 1919, 63, 21597, 275, 756, 272, 871, 2186, 26, 267, 1919, 63, 21597, 275, 715, 272, 1995, 702, 63, 3910, 12, 1919, 63, 21597, 272, 747, 14, 8563, 8, 895, 63, 694, 9, 272, 20978, 8, 808, 63, 694, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sigma-random/peach
Peach/Agent/network.py
3
6903
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import sys import threading import os import re import socket from Peach.agent import Monitor try: def search_file(filename): """Find a file in a search path.""" search_path = os.getenv("path") paths = search_path.split(os.path.pathsep) for path in paths: if os.path.exists(os.path.join(path, filename)): return True return False if sys.platform == 'win32' and search_file("wpcap.dll"): import pcap elif sys.platform != 'win32': import pcap except: pass class PingMonitor(Monitor): """ This monitor will report a fault if it cannot ping the specified hostname. """ def __init__(self, args): """ Constructor. Arguments are supplied via the Peach XML file. @type args: Dictionary @param args: Dictionary of parameters """ self.hostname = str(args['hostname']).replace("'''", "") self._name = "PingMonitor" def DetectedFault(self): """ Check if a fault was detected. """ if sys.platform == "win32": ping_send_command = "ping -n 2 " ping_send_command3 = "ping -n 3 " ping_reply_regex = r"Reply from \d+\.\d+\.\d+\.\d+: bytes=" elif sys.platform == "linux2": ping_send_command = "ping -c 2 " ping_send_command3 = "ping -c 3 " ping_reply_regex = r"64 bytes from \d+\.\d+\.\d+\.\d+:" else: raise Exception("PingAgent running on unsupported platform " "{}".format(sys.platform)) pipe = os.popen(ping_send_command + self.hostname) buff = pipe.read() pipe.close() if re.compile(ping_reply_regex, re.M).search(buff) is not None: return False # If we didn't see a ping, let's try again with 3 pings just to make # sure. pipe = os.popen(ping_send_command3 + self.hostname) buff = pipe.read() pipe.close() if re.compile(ping_reply_regex, re.M).search(buff) is not None: return False return True class UdpThread(threading.Thread): """ Thread class for UdpMonitor """ def __init__(self, host, port): threading.Thread.__init__(self) threading.Thread.setDaemon(self, True) self._host = host self._port = port self.stopEvent = threading.Event() self.stopEvent.clear() self.receivedPacket = threading.Event() self.receivedPacket.clear() self.packets = [] def run(self): print("UdpThread(): Starting up UDP listener") sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((self._host, int(self._port))) sock.setblocking(False) while not self.stopEvent.isSet(): try: data = None data, addr = sock.recvfrom(65565) if data is not None and len(data) > 0: print("UdpThread: Received packet from {}".format(addr)) self.packets.append(data) self.receivedPacket.set() except socket.error: # Thrown if non-blocking and no packet available to receive. pass print("UdpThread: Shutting down") sock.close() class UdpMonitor(Monitor): """ Watches for incoming packets on a UDP port. If packet received will trigger fault saving data from packet. """ def __init__(self, args): self.host = str(args['host']).replace("'''", "") self.port = str(args['port']).replace("'''", "") self._name = "UdpMonitor" self.thread = None self.thread = UdpThread(self.host, self.port) self.thread.start() def GetMonitorData(self): data = "" for d in self.thread.packets: data += d self.thread.packets = [] self.thread.receivedPacket.clear() return {'UdpMonitor.txt': data} def OnShutdown(self): if self.thread is not None and self.thread.isAlive(): self.thread.stopEvent.set() self.thread.join() self.thread = None def DetectedFault(self): return self.thread.receivedPacket.isSet() class PcapThread(threading.Thread): def __init__(self, parent, device, filter, pcapFile): threading.Thread.__init__(self) threading.Thread.setDaemon(self, True) self._device = device self._filter = filter self._pcapFile = pcapFile self.stopEvent = threading.Event() self.stopEvent.clear() self.dumpClosed = threading.Event() self.dumpClosed.clear() self._packets = [] def run(self): print("PcapThread(): Starting up pcap") pc = pcap.pcap(self._device) pc.dumpopen(self._pcapFile) if self._filter is not None: pc.setfilter(self._filter) pc.setnonblock() print("PcapThread(): Packet capture loop") while not self.stopEvent.isSet(): # Do not remove print. For some reason packets are only captures # when it's there!!! print(".") pc.readpkts() pc.dumpclose() self.dumpClosed.set() class PcapMonitor(Monitor): """ Monitor network using pcap library. """ def __init__(self, args): try: self.device = str(args['device']).replace("'''", "") if len(self.device) < 1: self.device = pcap.getDefaultName() except: self.device = pcap.getDefaultName() self.filter = str(args['filter']).replace("'''", "") self.data = None self.tempFile = os.tmpnam() self.thread = None def OnTestStarting(self): self.thread = PcapThread(self, self.device, self.filter, self.tempFile) self.thread.start() self.data = None print("PcapMonitor: OnTestStarting done") def OnTestFinished(self): # Stop thread self.data = None if self.thread is not None and self.thread.isAlive(): self.thread.stopEvent.set() self.thread.join() self.thread.dumpClosed.wait() # Read dump f = open(self.tempFile, "rb") self.data = f.read() f.close() print("PcapMonitor: Thread joined, dump saved") self.thread = None def GetMonitorData(self): return {'Capture.pcap': self.data} def OnShutdown(self): if self.thread is not None and self.thread.isAlive(): self.thread.stopEvent.set() self.thread.join()
mpl-2.0
[ 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 646, 984, 199, 646, 5796, 199, 646, 747, 199, 646, 295, 199, 646, 2838, 199, 199, 504, 510, 10885, 14, 4054, 492, 26504, 421, 199, 893, 26, 272, 347, 2754, 63, 493, 8, 1501, 304, 267, 408, 6591, 282, 570, 315, 282, 2754, 931, 1041, 267, 2754, 63, 515, 275, 747, 14, 12959, 480, 515, 531, 267, 3792, 275, 2754, 63, 515, 14, 1294, 8, 736, 14, 515, 14, 17843, 9, 267, 367, 931, 315, 3792, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1788, 2298, 355, 372, 715, 267, 372, 756, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 436, 2754, 63, 493, 480, 87, 2352, 439, 14, 9259, 2349, 267, 492, 18606, 272, 916, 984, 14, 3246, 1137, 283, 2676, 708, 356, 267, 492, 18606, 199, 2590, 26, 272, 986, 421, 199, 533, 510, 316, 13189, 8, 13189, 304, 272, 408, 272, 961, 8372, 911, 3622, 282, 16898, 340, 652, 3913, 18249, 314, 2013, 6246, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 408, 267, 20297, 14, 7628, 787, 6841, 4799, 314, 510, 10885, 4692, 570, 14, 398, 768, 466, 198, 589, 26, 11932, 267, 768, 635, 198, 589, 26, 11932, 402, 2633, 267, 408, 267, 291, 14, 4269, 275, 620, 8, 589, 459, 4269, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 423, 354, 275, 298, 22638, 13189, 2, 339, 347, 1487, 4530, 16665, 8, 277, 304, 267, 408, 267, 2670, 340, 282, 16898, 1990, 10501, 14, 267, 408, 267, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 288, 18249, 63, 2254, 63, 1531, 275, 298, 4073, 446, 78, 499, 298, 288, 18249, 63, 2254, 63, 1531, 19, 275, 298, 4073, 446, 78, 650, 298, 288, 18249, 63, 8102, 63, 3821, 275, 519, 2, 14166, 687, 971, 68, 23294, 68, 23294, 68, 23294, 68, 11, 26, 2783, 628, 267, 916, 984, 14, 3246, 508, 298, 5135, 18, 582, 288, 18249, 63, 2254, 63, 1531, 275, 298, 4073, 446, 67, 499, 298, 288, 18249, 63, 2254, 63, 1531, 19, 275, 298, 4073, 446, 67, 650, 298, 288, 18249, 63, 8102, 63, 3821, 275, 519, 2, 772, 2783, 687, 971, 68, 23294, 68, 23294, 68, 23294, 68, 11, 5424, 267, 587, 26, 288, 746, 2186, 480, 22638, 7788, 3879, 641, 16313, 4298, 298, 1169, 11491, 1674, 908, 8, 1274, 14, 3246, 430, 267, 5200, 275, 747, 14, 12207, 8, 4073, 63, 2254, 63, 1531, 435, 291, 14, 4269, 9, 267, 17893, 275, 5200, 14, 739, 342, 267, 5200, 14, 1600, 342, 267, 340, 295, 14, 2014, 8, 4073, 63, 8102, 63, 3821, 12, 295, 14, 45, 680, 1733, 8, 16830, 9, 365, 440, 488, 26, 288, 372, 756, 267, 327, 982, 781, 9980, 1133, 1937, 282, 18249, 12, 4691, 1159, 862, 4020, 543, 650, 299, 780, 2951, 370, 1852, 267, 327, 3238, 14, 267, 5200, 275, 747, 14, 12207, 8, 4073, 63, 2254, 63, 1531, 19, 435, 291, 14, 4269, 9, 267, 17893, 275, 5200, 14, 739, 342, 267, 5200, 14, 1600, 342, 267, 340, 295, 14, 2014, 8, 4073, 63, 8102, 63, 3821, 12, 295, 14, 45, 680, 1733, 8, 16830, 9, 365, 440, 488, 26, 288, 372, 756, 267, 372, 715, 421, 199, 533, 738, 5780, 4436, 8, 12562, 14, 4436, 304, 272, 408, 272, 11086, 1021, 367, 738, 5780, 13189, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 304, 267, 5796, 14, 4436, 855, 826, 721, 277, 9, 267, 5796, 14, 4436, 14, 409, 20555, 8, 277, 12, 715, 9, 267, 291, 423, 1102, 275, 1591, 267, 291, 423, 719, 275, 1844, 267, 291, 14, 2379, 2390, 275, 5796, 14, 2390, 342, 267, 291, 14, 2379, 2390, 14, 3584, 342, 267, 291, 14, 9226, 2726, 275, 5796, 14, 2390, 342, 267, 291, 14, 9226, 2726, 14, 3584, 342, 267, 291, 14, 18853, 275, 942, 339, 347, 1255, 8, 277, 304, 267, 870, 480, 22086, 4436, 837, 24175, 1536, 21802, 11647, 531, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 6771, 14, 3409, 1332, 277, 423, 1102, 12, 1109, 8, 277, 423, 719, 1724, 267, 6771, 14, 409, 13091, 8, 797, 9, 267, 1830, 440, 291, 14, 2379, 2390, 14, 374, 1084, 837, 288, 862, 26, 355, 666, 275, 488, 355, 666, 12, 5552, 275, 6771, 14, 7637, 504, 8, 10027, 2182, 9, 355, 340, 666, 365, 440, 488, 436, 822, 8, 576, 9, 690, 378, 26, 490, 870, 480, 22086, 4436, 26, 799, 2525, 3644, 687, 8352, 908, 8, 2697, 430, 490, 291, 14, 18853, 14, 740, 8, 576, 9, 490, 291, 14, 9226, 2726, 14, 409, 342, 288, 871, 2838, 14, 705, 26, 355, 327, 3868, 18406, 340, 2222, 13, 13091, 436, 949, 3644, 2808, 370, 9128, 14, 355, 986, 267, 870, 480, 22086, 4436, 26, 5244, 337, 1337, 3224, 531, 267, 6771, 14, 1600, 342, 421, 199, 533, 738, 5780, 13189, 8, 13189, 304, 272, 408, 272, 29075, 397, 367, 12467, 14593, 641, 282, 21802, 1844, 14, 982, 3644, 3086, 911, 272, 6804, 16898, 13369, 666, 687, 3644, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 291, 14, 1102, 275, 620, 8, 589, 459, 1102, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 14, 719, 275, 620, 8, 589, 459, 719, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 423, 354, 275, 298, 22086, 13189, 2, 267, 291, 14, 2671, 275, 488, 267, 291, 14, 2671, 275, 738, 5780, 4436, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 291, 14, 2671, 14, 928, 342, 339, 347, 2372, 13189, 1451, 8, 277, 304, 267, 666, 275, 3087, 267, 367, 366, 315, 291, 14, 2671, 14, 18853, 26, 288, 666, 847, 366, 267 ]
[ 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 646, 984, 199, 646, 5796, 199, 646, 747, 199, 646, 295, 199, 646, 2838, 199, 199, 504, 510, 10885, 14, 4054, 492, 26504, 421, 199, 893, 26, 272, 347, 2754, 63, 493, 8, 1501, 304, 267, 408, 6591, 282, 570, 315, 282, 2754, 931, 1041, 267, 2754, 63, 515, 275, 747, 14, 12959, 480, 515, 531, 267, 3792, 275, 2754, 63, 515, 14, 1294, 8, 736, 14, 515, 14, 17843, 9, 267, 367, 931, 315, 3792, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1788, 2298, 355, 372, 715, 267, 372, 756, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 436, 2754, 63, 493, 480, 87, 2352, 439, 14, 9259, 2349, 267, 492, 18606, 272, 916, 984, 14, 3246, 1137, 283, 2676, 708, 356, 267, 492, 18606, 199, 2590, 26, 272, 986, 421, 199, 533, 510, 316, 13189, 8, 13189, 304, 272, 408, 272, 961, 8372, 911, 3622, 282, 16898, 340, 652, 3913, 18249, 314, 2013, 6246, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 408, 267, 20297, 14, 7628, 787, 6841, 4799, 314, 510, 10885, 4692, 570, 14, 398, 768, 466, 198, 589, 26, 11932, 267, 768, 635, 198, 589, 26, 11932, 402, 2633, 267, 408, 267, 291, 14, 4269, 275, 620, 8, 589, 459, 4269, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 423, 354, 275, 298, 22638, 13189, 2, 339, 347, 1487, 4530, 16665, 8, 277, 304, 267, 408, 267, 2670, 340, 282, 16898, 1990, 10501, 14, 267, 408, 267, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 288, 18249, 63, 2254, 63, 1531, 275, 298, 4073, 446, 78, 499, 298, 288, 18249, 63, 2254, 63, 1531, 19, 275, 298, 4073, 446, 78, 650, 298, 288, 18249, 63, 8102, 63, 3821, 275, 519, 2, 14166, 687, 971, 68, 23294, 68, 23294, 68, 23294, 68, 11, 26, 2783, 628, 267, 916, 984, 14, 3246, 508, 298, 5135, 18, 582, 288, 18249, 63, 2254, 63, 1531, 275, 298, 4073, 446, 67, 499, 298, 288, 18249, 63, 2254, 63, 1531, 19, 275, 298, 4073, 446, 67, 650, 298, 288, 18249, 63, 8102, 63, 3821, 275, 519, 2, 772, 2783, 687, 971, 68, 23294, 68, 23294, 68, 23294, 68, 11, 5424, 267, 587, 26, 288, 746, 2186, 480, 22638, 7788, 3879, 641, 16313, 4298, 298, 1169, 11491, 1674, 908, 8, 1274, 14, 3246, 430, 267, 5200, 275, 747, 14, 12207, 8, 4073, 63, 2254, 63, 1531, 435, 291, 14, 4269, 9, 267, 17893, 275, 5200, 14, 739, 342, 267, 5200, 14, 1600, 342, 267, 340, 295, 14, 2014, 8, 4073, 63, 8102, 63, 3821, 12, 295, 14, 45, 680, 1733, 8, 16830, 9, 365, 440, 488, 26, 288, 372, 756, 267, 327, 982, 781, 9980, 1133, 1937, 282, 18249, 12, 4691, 1159, 862, 4020, 543, 650, 299, 780, 2951, 370, 1852, 267, 327, 3238, 14, 267, 5200, 275, 747, 14, 12207, 8, 4073, 63, 2254, 63, 1531, 19, 435, 291, 14, 4269, 9, 267, 17893, 275, 5200, 14, 739, 342, 267, 5200, 14, 1600, 342, 267, 340, 295, 14, 2014, 8, 4073, 63, 8102, 63, 3821, 12, 295, 14, 45, 680, 1733, 8, 16830, 9, 365, 440, 488, 26, 288, 372, 756, 267, 372, 715, 421, 199, 533, 738, 5780, 4436, 8, 12562, 14, 4436, 304, 272, 408, 272, 11086, 1021, 367, 738, 5780, 13189, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 304, 267, 5796, 14, 4436, 855, 826, 721, 277, 9, 267, 5796, 14, 4436, 14, 409, 20555, 8, 277, 12, 715, 9, 267, 291, 423, 1102, 275, 1591, 267, 291, 423, 719, 275, 1844, 267, 291, 14, 2379, 2390, 275, 5796, 14, 2390, 342, 267, 291, 14, 2379, 2390, 14, 3584, 342, 267, 291, 14, 9226, 2726, 275, 5796, 14, 2390, 342, 267, 291, 14, 9226, 2726, 14, 3584, 342, 267, 291, 14, 18853, 275, 942, 339, 347, 1255, 8, 277, 304, 267, 870, 480, 22086, 4436, 837, 24175, 1536, 21802, 11647, 531, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 6771, 14, 3409, 1332, 277, 423, 1102, 12, 1109, 8, 277, 423, 719, 1724, 267, 6771, 14, 409, 13091, 8, 797, 9, 267, 1830, 440, 291, 14, 2379, 2390, 14, 374, 1084, 837, 288, 862, 26, 355, 666, 275, 488, 355, 666, 12, 5552, 275, 6771, 14, 7637, 504, 8, 10027, 2182, 9, 355, 340, 666, 365, 440, 488, 436, 822, 8, 576, 9, 690, 378, 26, 490, 870, 480, 22086, 4436, 26, 799, 2525, 3644, 687, 8352, 908, 8, 2697, 430, 490, 291, 14, 18853, 14, 740, 8, 576, 9, 490, 291, 14, 9226, 2726, 14, 409, 342, 288, 871, 2838, 14, 705, 26, 355, 327, 3868, 18406, 340, 2222, 13, 13091, 436, 949, 3644, 2808, 370, 9128, 14, 355, 986, 267, 870, 480, 22086, 4436, 26, 5244, 337, 1337, 3224, 531, 267, 6771, 14, 1600, 342, 421, 199, 533, 738, 5780, 13189, 8, 13189, 304, 272, 408, 272, 29075, 397, 367, 12467, 14593, 641, 282, 21802, 1844, 14, 982, 3644, 3086, 911, 272, 6804, 16898, 13369, 666, 687, 3644, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 291, 14, 1102, 275, 620, 8, 589, 459, 1102, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 14, 719, 275, 620, 8, 589, 459, 719, 13227, 1814, 480, 2344, 401, 6899, 267, 291, 423, 354, 275, 298, 22086, 13189, 2, 267, 291, 14, 2671, 275, 488, 267, 291, 14, 2671, 275, 738, 5780, 4436, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 291, 14, 2671, 14, 928, 342, 339, 347, 2372, 13189, 1451, 8, 277, 304, 267, 666, 275, 3087, 267, 367, 366, 315, 291, 14, 2671, 14, 18853, 26, 288, 666, 847, 366, 267,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1, 1, 1 ]
kenshay/ImageScript
ProgramData/SystemFiles/Python/Lib/test/test_class.py
86
18371
"Test the functionality of Python classes implementing operators." import unittest from test import test_support testmeths = [ # Binary operations "add", "radd", "sub", "rsub", "mul", "rmul", "div", "rdiv", "mod", "rmod", "divmod", "rdivmod", "pow", "rpow", "rshift", "rrshift", "lshift", "rlshift", "and", "rand", "or", "ror", "xor", "rxor", # List/dict operations "contains", "getitem", "getslice", "setitem", "setslice", "delitem", "delslice", # Unary operations "neg", "pos", "abs", # generic operations "init", ] # These need to return something other than None # "coerce", # "hash", # "str", # "repr", # "int", # "long", # "float", # "oct", # "hex", # These are separate because they can influence the test of other methods. # "getattr", # "setattr", # "delattr", callLst = [] def trackCall(f): def track(*args, **kwargs): callLst.append((f.__name__, args)) return f(*args, **kwargs) return track class AllTests: trackCall = trackCall @trackCall def __coerce__(self, *args): return (self,) + args @trackCall def __hash__(self, *args): return hash(id(self)) @trackCall def __str__(self, *args): return "AllTests" @trackCall def __repr__(self, *args): return "AllTests" @trackCall def __int__(self, *args): return 1 @trackCall def __float__(self, *args): return 1.0 @trackCall def __long__(self, *args): return 1L @trackCall def __oct__(self, *args): return '01' @trackCall def __hex__(self, *args): return '0x1' @trackCall def __cmp__(self, *args): return 0 # Synthesize all the other AllTests methods from the names in testmeths. method_template = """\ @trackCall def __%(method)s__(self, *args): pass """ for method in testmeths: exec method_template % locals() in AllTests.__dict__ del method, method_template class ClassTests(unittest.TestCase): def setUp(self): callLst[:] = [] def assertCallStack(self, expected_calls): actualCallList = callLst[:] # need to copy because the comparison below will add # additional calls to callLst if expected_calls != actualCallList: self.fail("Expected call list:\n %s\ndoes not match actual call list\n %s" % (expected_calls, actualCallList)) def testInit(self): foo = AllTests() self.assertCallStack([("__init__", (foo,))]) def testBinaryOps(self): testme = AllTests() # Binary operations callLst[:] = [] testme + 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__add__", (testme, 1))]) callLst[:] = [] 1 + testme self.assertCallStack([("__coerce__", (testme, 1)), ("__radd__", (testme, 1))]) callLst[:] = [] testme - 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__sub__", (testme, 1))]) callLst[:] = [] 1 - testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rsub__", (testme, 1))]) callLst[:] = [] testme * 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__mul__", (testme, 1))]) callLst[:] = [] 1 * testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rmul__", (testme, 1))]) if 1/2 == 0: callLst[:] = [] testme / 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__div__", (testme, 1))]) callLst[:] = [] 1 / testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rdiv__", (testme, 1))]) callLst[:] = [] testme % 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__mod__", (testme, 1))]) callLst[:] = [] 1 % testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rmod__", (testme, 1))]) callLst[:] = [] divmod(testme,1) self.assertCallStack([("__coerce__", (testme, 1)), ("__divmod__", (testme, 1))]) callLst[:] = [] divmod(1, testme) self.assertCallStack([("__coerce__", (testme, 1)), ("__rdivmod__", (testme, 1))]) callLst[:] = [] testme ** 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__pow__", (testme, 1))]) callLst[:] = [] 1 ** testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rpow__", (testme, 1))]) callLst[:] = [] testme >> 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__rshift__", (testme, 1))]) callLst[:] = [] 1 >> testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rrshift__", (testme, 1))]) callLst[:] = [] testme << 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__lshift__", (testme, 1))]) callLst[:] = [] 1 << testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rlshift__", (testme, 1))]) callLst[:] = [] testme & 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__and__", (testme, 1))]) callLst[:] = [] 1 & testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rand__", (testme, 1))]) callLst[:] = [] testme | 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__or__", (testme, 1))]) callLst[:] = [] 1 | testme self.assertCallStack([("__coerce__", (testme, 1)), ("__ror__", (testme, 1))]) callLst[:] = [] testme ^ 1 self.assertCallStack([("__coerce__", (testme, 1)), ("__xor__", (testme, 1))]) callLst[:] = [] 1 ^ testme self.assertCallStack([("__coerce__", (testme, 1)), ("__rxor__", (testme, 1))]) def testListAndDictOps(self): testme = AllTests() # List/dict operations class Empty: pass try: 1 in Empty() self.fail('failed, should have raised TypeError') except TypeError: pass callLst[:] = [] 1 in testme self.assertCallStack([('__contains__', (testme, 1))]) callLst[:] = [] testme[1] self.assertCallStack([('__getitem__', (testme, 1))]) callLst[:] = [] testme[1] = 1 self.assertCallStack([('__setitem__', (testme, 1, 1))]) callLst[:] = [] del testme[1] self.assertCallStack([('__delitem__', (testme, 1))]) callLst[:] = [] testme[:42] self.assertCallStack([('__getslice__', (testme, 0, 42))]) callLst[:] = [] testme[:42] = "The Answer" self.assertCallStack([('__setslice__', (testme, 0, 42, "The Answer"))]) callLst[:] = [] del testme[:42] self.assertCallStack([('__delslice__', (testme, 0, 42))]) callLst[:] = [] testme[2:1024:10] self.assertCallStack([('__getitem__', (testme, slice(2, 1024, 10)))]) callLst[:] = [] testme[2:1024:10] = "A lot" self.assertCallStack([('__setitem__', (testme, slice(2, 1024, 10), "A lot"))]) callLst[:] = [] del testme[2:1024:10] self.assertCallStack([('__delitem__', (testme, slice(2, 1024, 10)))]) callLst[:] = [] testme[:42, ..., :24:, 24, 100] self.assertCallStack([('__getitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100)))]) callLst[:] = [] testme[:42, ..., :24:, 24, 100] = "Strange" self.assertCallStack([('__setitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100), "Strange"))]) callLst[:] = [] del testme[:42, ..., :24:, 24, 100] self.assertCallStack([('__delitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100)))]) # Now remove the slice hooks to see if converting normal slices to # slice object works. getslice = AllTests.__getslice__ del AllTests.__getslice__ setslice = AllTests.__setslice__ del AllTests.__setslice__ delslice = AllTests.__delslice__ del AllTests.__delslice__ # XXX when using new-style classes the slice testme[:42] produces # slice(None, 42, None) instead of slice(0, 42, None). py3k will have # to change this test. callLst[:] = [] testme[:42] self.assertCallStack([('__getitem__', (testme, slice(0, 42, None)))]) callLst[:] = [] testme[:42] = "The Answer" self.assertCallStack([('__setitem__', (testme, slice(0, 42, None), "The Answer"))]) callLst[:] = [] del testme[:42] self.assertCallStack([('__delitem__', (testme, slice(0, 42, None)))]) # Restore the slice methods, or the tests will fail with regrtest -R. AllTests.__getslice__ = getslice AllTests.__setslice__ = setslice AllTests.__delslice__ = delslice @test_support.cpython_only def testDelItem(self): class A: ok = False def __delitem__(self, key): self.ok = True a = A() # Subtle: we need to call PySequence_SetItem, not PyMapping_SetItem. from _testcapi import sequence_delitem sequence_delitem(a, 2) self.assertTrue(a.ok) def testUnaryOps(self): testme = AllTests() callLst[:] = [] -testme self.assertCallStack([('__neg__', (testme,))]) callLst[:] = [] +testme self.assertCallStack([('__pos__', (testme,))]) callLst[:] = [] abs(testme) self.assertCallStack([('__abs__', (testme,))]) callLst[:] = [] int(testme) self.assertCallStack([('__int__', (testme,))]) callLst[:] = [] long(testme) self.assertCallStack([('__long__', (testme,))]) callLst[:] = [] float(testme) self.assertCallStack([('__float__', (testme,))]) callLst[:] = [] oct(testme) self.assertCallStack([('__oct__', (testme,))]) callLst[:] = [] hex(testme) self.assertCallStack([('__hex__', (testme,))]) def testMisc(self): testme = AllTests() callLst[:] = [] hash(testme) self.assertCallStack([('__hash__', (testme,))]) callLst[:] = [] repr(testme) self.assertCallStack([('__repr__', (testme,))]) callLst[:] = [] str(testme) self.assertCallStack([('__str__', (testme,))]) callLst[:] = [] testme == 1 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) callLst[:] = [] testme < 1 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) callLst[:] = [] testme > 1 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) callLst[:] = [] eval('testme <> 1') # XXX kill this in py3k self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) callLst[:] = [] testme != 1 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) callLst[:] = [] 1 == testme self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) callLst[:] = [] 1 < testme self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) callLst[:] = [] 1 > testme self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) callLst[:] = [] eval('1 <> testme') self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) callLst[:] = [] 1 != testme self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) def testGetSetAndDel(self): # Interfering tests class ExtraTests(AllTests): @trackCall def __getattr__(self, *args): return "SomeVal" @trackCall def __setattr__(self, *args): pass @trackCall def __delattr__(self, *args): pass testme = ExtraTests() callLst[:] = [] testme.spam self.assertCallStack([('__getattr__', (testme, "spam"))]) callLst[:] = [] testme.eggs = "spam, spam, spam and ham" self.assertCallStack([('__setattr__', (testme, "eggs", "spam, spam, spam and ham"))]) callLst[:] = [] del testme.cardinal self.assertCallStack([('__delattr__', (testme, "cardinal"))]) def testDel(self): x = [] class DelTest: def __del__(self): x.append("crab people, crab people") testme = DelTest() del testme import gc gc.collect() self.assertEqual(["crab people, crab people"], x) def testBadTypeReturned(self): # return values of some method are type-checked class BadTypeClass: def __int__(self): return None __float__ = __int__ __long__ = __int__ __str__ = __int__ __repr__ = __int__ __oct__ = __int__ __hex__ = __int__ for f in [int, float, long, str, repr, oct, hex]: self.assertRaises(TypeError, f, BadTypeClass()) def testMixIntsAndLongs(self): # mixing up ints and longs is okay class IntLongMixClass: @trackCall def __int__(self): return 42L @trackCall def __long__(self): return 64 mixIntAndLong = IntLongMixClass() callLst[:] = [] as_int = int(mixIntAndLong) self.assertEqual(type(as_int), long) self.assertEqual(as_int, 42L) self.assertCallStack([('__int__', (mixIntAndLong,))]) callLst[:] = [] as_long = long(mixIntAndLong) self.assertEqual(type(as_long), long) self.assertEqual(as_long, 64) self.assertCallStack([('__long__', (mixIntAndLong,))]) def testHashStuff(self): # Test correct errors from hash() on objects with comparisons but # no __hash__ class C0: pass hash(C0()) # This should work; the next two should raise TypeError class C1: def __cmp__(self, other): return 0 self.assertRaises(TypeError, hash, C1()) class C2: def __eq__(self, other): return 1 self.assertRaises(TypeError, hash, C2()) def testSFBug532646(self): # Test for SF bug 532646 class A: pass A.__call__ = A() a = A() try: a() # This should not segfault except RuntimeError: pass else: self.fail("Failed to raise RuntimeError") def testForExceptionsRaisedInInstanceGetattr2(self): # Tests for exceptions raised in instance_getattr2(). def booh(self): raise AttributeError("booh") class A: a = property(booh) try: A().a # Raised AttributeError: A instance has no attribute 'a' except AttributeError, x: if str(x) != "booh": self.fail("attribute error for A().a got masked: %s" % x) class E: __eq__ = property(booh) E() == E() # In debug mode, caused a C-level assert() to fail class I: __init__ = property(booh) try: # In debug mode, printed XXX undetected error and # raises AttributeError I() except AttributeError, x: pass else: self.fail("attribute error for I.__init__ got masked") def testHashComparisonOfMethods(self): # Test comparison and hash of methods class A: def __init__(self, x): self.x = x def f(self): pass def g(self): pass def __eq__(self, other): return self.x == other.x def __hash__(self): return self.x class B(A): pass a1 = A(1) a2 = A(2) self.assertEqual(a1.f, a1.f) self.assertNotEqual(a1.f, a2.f) self.assertNotEqual(a1.f, a1.g) self.assertEqual(a1.f, A(1).f) self.assertEqual(hash(a1.f), hash(a1.f)) self.assertEqual(hash(a1.f), hash(A(1).f)) self.assertNotEqual(A.f, a1.f) self.assertNotEqual(A.f, A.g) self.assertEqual(B.f, A.f) self.assertEqual(hash(B.f), hash(A.f)) # the following triggers a SystemError in 2.4 a = A(hash(A.f.im_func)^(-1)) hash(a.f) def testAttrSlots(self): class C: pass for c in C, C(): self.assertRaises(TypeError, type(c).__getattribute__, c, []) self.assertRaises(TypeError, type(c).__setattr__, c, [], []) def test_main(): with test_support.check_py3k_warnings( (".+__(get|set|del)slice__ has been removed", DeprecationWarning), ("classic int division", DeprecationWarning), ("<> not supported", DeprecationWarning)): test_support.run_unittest(ClassTests) if __name__=='__main__': test_main()
gpl-3.0
[ 2, 774, 314, 9330, 402, 2018, 3992, 18234, 10211, 2122, 199, 199, 646, 2882, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 396, 5247, 83, 275, 359, 199, 199, 3, 14161, 5331, 272, 298, 525, 401, 272, 298, 22958, 401, 272, 298, 954, 401, 272, 298, 82, 954, 401, 272, 298, 3703, 401, 272, 298, 27968, 401, 272, 298, 3015, 401, 272, 298, 82, 3015, 401, 272, 298, 1494, 401, 272, 298, 82, 1494, 401, 272, 298, 26997, 401, 272, 298, 82, 26997, 401, 272, 298, 8278, 401, 272, 298, 82, 8278, 401, 272, 298, 82, 4723, 401, 272, 298, 9734, 4723, 401, 272, 298, 23025, 2949, 401, 272, 298, 82, 23025, 2949, 401, 272, 298, 460, 401, 272, 298, 3759, 401, 272, 298, 269, 401, 272, 298, 451, 401, 272, 298, 15721, 401, 272, 298, 6872, 269, 401, 199, 199, 3, 3820, 15, 807, 5331, 272, 298, 6134, 401, 272, 298, 6095, 401, 272, 298, 32131, 401, 272, 298, 8617, 401, 272, 298, 2193, 3037, 401, 272, 298, 13228, 401, 272, 298, 271, 478, 3037, 401, 199, 199, 3, 1910, 695, 5331, 272, 298, 8705, 401, 272, 298, 1712, 401, 272, 298, 2101, 401, 199, 199, 3, 7809, 5331, 272, 298, 826, 401, 272, 1622, 199, 199, 3, 5723, 1929, 370, 372, 6020, 1163, 2419, 488, 199, 3, 259, 298, 14141, 401, 199, 3, 259, 298, 2227, 401, 199, 3, 259, 298, 495, 401, 199, 3, 259, 298, 2722, 401, 199, 3, 259, 298, 442, 401, 199, 3, 259, 298, 2809, 401, 199, 3, 259, 298, 1609, 401, 199, 3, 259, 298, 15560, 401, 199, 3, 259, 298, 4097, 401, 199, 199, 3, 5723, 787, 7396, 2952, 2985, 883, 315, 24585, 314, 511, 402, 1163, 3102, 14, 199, 3, 259, 298, 5675, 401, 199, 3, 259, 298, 10202, 401, 199, 3, 259, 298, 30831, 401, 199, 199, 1250, 30525, 275, 942, 199, 318, 4426, 2176, 8, 70, 304, 272, 347, 4426, 2031, 589, 12, 1011, 958, 304, 267, 1240, 30525, 14, 740, 1332, 70, 855, 354, 3108, 1249, 430, 267, 372, 289, 2031, 589, 12, 1011, 958, 9, 272, 372, 4426, 199, 199, 533, 2900, 2925, 26, 272, 4426, 2176, 275, 4426, 2176, 339, 768, 3885, 2176, 272, 347, 636, 14141, 721, 277, 12, 627, 589, 304, 267, 372, 334, 277, 4258, 435, 1249, 339, 768, 3885, 2176, 272, 347, 636, 2227, 721, 277, 12, 627, 589, 304, 267, 372, 2631, 8, 344, 8, 277, 430, 339, 768, 3885, 2176, 272, 347, 636, 495, 721, 277, 12, 627, 589, 304, 267, 372, 298, 2422, 2925, 2, 339, 768, 3885, 2176, 272, 347, 636, 2722, 721, 277, 12, 627, 589, 304, 267, 372, 298, 2422, 2925, 2, 339, 768, 3885, 2176, 272, 347, 636, 442, 721, 277, 12, 627, 589, 304, 267, 372, 413, 339, 768, 3885, 2176, 272, 347, 636, 1609, 721, 277, 12, 627, 589, 304, 267, 372, 413, 14, 16, 339, 768, 3885, 2176, 272, 347, 636, 2809, 721, 277, 12, 627, 589, 304, 267, 372, 413, 44, 339, 768, 3885, 2176, 272, 347, 636, 15560, 721, 277, 12, 627, 589, 304, 267, 372, 283, 614, 7, 339, 768, 3885, 2176, 272, 347, 636, 4097, 721, 277, 12, 627, 589, 304, 267, 372, 283, 16, 88, 17, 7, 339, 768, 3885, 2176, 272, 347, 636, 5730, 721, 277, 12, 627, 589, 304, 267, 372, 378, 199, 199, 3, 29988, 1589, 890, 1006, 314, 1163, 2900, 2925, 3102, 687, 314, 1561, 315, 511, 5247, 83, 14, 199, 199, 765, 63, 1160, 275, 9638, 199, 32, 3885, 2176, 199, 318, 636, 2840, 765, 9, 83, 721, 277, 12, 627, 589, 304, 272, 986, 199, 624, 199, 199, 509, 1083, 315, 511, 5247, 83, 26, 272, 2146, 1083, 63, 1160, 450, 9480, 342, 315, 2900, 2925, 855, 807, 363, 199, 199, 2264, 1083, 12, 1083, 63, 1160, 199, 199, 533, 8089, 2925, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1240, 30525, 5873, 275, 942, 339, 347, 702, 2176, 4851, 8, 277, 12, 1420, 63, 5352, 304, 267, 3503, 2176, 1296, 275, 1240, 30525, 5873, 221, 327, 1929, 370, 1331, 2952, 314, 9132, 5084, 911, 1050, 3660, 327, 4722, 4882, 370, 1240, 30525, 267, 340, 1420, 63, 5352, 1137, 3503, 2176, 1296, 26, 288, 291, 14, 1633, 480, 6964, 1240, 769, 3427, 78, 221, 450, 83, 60, 21175, 397, 440, 1336, 3503, 1240, 769, 60, 78, 221, 450, 83, 2, 450, 1993, 334, 2062, 63, 5352, 12, 3503, 2176, 1296, 430, 339, 347, 511, 9346, 8, 277, 304, 267, 3925, 275, 2900, 2925, 342, 267, 291, 14, 479, 2176, 4851, 779, 16232, 826, 13915, 334, 1421, 4641, 566, 339, 347, 511, 6636, 16452, 8, 277, 304, 267, 511, 278, 275, 2900, 2925, 342, 267, 327, 14161, 5331, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 435, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 525, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 435, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 22958, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 446, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 954, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 446, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 82, 954, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 627, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 3703, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 627, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 27968, 13915, 334, 396, 278, 12, 413, 18229, 398, 340, 413, 15, 18, 508, 378, 26 ]
[ 774, 314, 9330, 402, 2018, 3992, 18234, 10211, 2122, 199, 199, 646, 2882, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 396, 5247, 83, 275, 359, 199, 199, 3, 14161, 5331, 272, 298, 525, 401, 272, 298, 22958, 401, 272, 298, 954, 401, 272, 298, 82, 954, 401, 272, 298, 3703, 401, 272, 298, 27968, 401, 272, 298, 3015, 401, 272, 298, 82, 3015, 401, 272, 298, 1494, 401, 272, 298, 82, 1494, 401, 272, 298, 26997, 401, 272, 298, 82, 26997, 401, 272, 298, 8278, 401, 272, 298, 82, 8278, 401, 272, 298, 82, 4723, 401, 272, 298, 9734, 4723, 401, 272, 298, 23025, 2949, 401, 272, 298, 82, 23025, 2949, 401, 272, 298, 460, 401, 272, 298, 3759, 401, 272, 298, 269, 401, 272, 298, 451, 401, 272, 298, 15721, 401, 272, 298, 6872, 269, 401, 199, 199, 3, 3820, 15, 807, 5331, 272, 298, 6134, 401, 272, 298, 6095, 401, 272, 298, 32131, 401, 272, 298, 8617, 401, 272, 298, 2193, 3037, 401, 272, 298, 13228, 401, 272, 298, 271, 478, 3037, 401, 199, 199, 3, 1910, 695, 5331, 272, 298, 8705, 401, 272, 298, 1712, 401, 272, 298, 2101, 401, 199, 199, 3, 7809, 5331, 272, 298, 826, 401, 272, 1622, 199, 199, 3, 5723, 1929, 370, 372, 6020, 1163, 2419, 488, 199, 3, 259, 298, 14141, 401, 199, 3, 259, 298, 2227, 401, 199, 3, 259, 298, 495, 401, 199, 3, 259, 298, 2722, 401, 199, 3, 259, 298, 442, 401, 199, 3, 259, 298, 2809, 401, 199, 3, 259, 298, 1609, 401, 199, 3, 259, 298, 15560, 401, 199, 3, 259, 298, 4097, 401, 199, 199, 3, 5723, 787, 7396, 2952, 2985, 883, 315, 24585, 314, 511, 402, 1163, 3102, 14, 199, 3, 259, 298, 5675, 401, 199, 3, 259, 298, 10202, 401, 199, 3, 259, 298, 30831, 401, 199, 199, 1250, 30525, 275, 942, 199, 318, 4426, 2176, 8, 70, 304, 272, 347, 4426, 2031, 589, 12, 1011, 958, 304, 267, 1240, 30525, 14, 740, 1332, 70, 855, 354, 3108, 1249, 430, 267, 372, 289, 2031, 589, 12, 1011, 958, 9, 272, 372, 4426, 199, 199, 533, 2900, 2925, 26, 272, 4426, 2176, 275, 4426, 2176, 339, 768, 3885, 2176, 272, 347, 636, 14141, 721, 277, 12, 627, 589, 304, 267, 372, 334, 277, 4258, 435, 1249, 339, 768, 3885, 2176, 272, 347, 636, 2227, 721, 277, 12, 627, 589, 304, 267, 372, 2631, 8, 344, 8, 277, 430, 339, 768, 3885, 2176, 272, 347, 636, 495, 721, 277, 12, 627, 589, 304, 267, 372, 298, 2422, 2925, 2, 339, 768, 3885, 2176, 272, 347, 636, 2722, 721, 277, 12, 627, 589, 304, 267, 372, 298, 2422, 2925, 2, 339, 768, 3885, 2176, 272, 347, 636, 442, 721, 277, 12, 627, 589, 304, 267, 372, 413, 339, 768, 3885, 2176, 272, 347, 636, 1609, 721, 277, 12, 627, 589, 304, 267, 372, 413, 14, 16, 339, 768, 3885, 2176, 272, 347, 636, 2809, 721, 277, 12, 627, 589, 304, 267, 372, 413, 44, 339, 768, 3885, 2176, 272, 347, 636, 15560, 721, 277, 12, 627, 589, 304, 267, 372, 283, 614, 7, 339, 768, 3885, 2176, 272, 347, 636, 4097, 721, 277, 12, 627, 589, 304, 267, 372, 283, 16, 88, 17, 7, 339, 768, 3885, 2176, 272, 347, 636, 5730, 721, 277, 12, 627, 589, 304, 267, 372, 378, 199, 199, 3, 29988, 1589, 890, 1006, 314, 1163, 2900, 2925, 3102, 687, 314, 1561, 315, 511, 5247, 83, 14, 199, 199, 765, 63, 1160, 275, 9638, 199, 32, 3885, 2176, 199, 318, 636, 2840, 765, 9, 83, 721, 277, 12, 627, 589, 304, 272, 986, 199, 624, 199, 199, 509, 1083, 315, 511, 5247, 83, 26, 272, 2146, 1083, 63, 1160, 450, 9480, 342, 315, 2900, 2925, 855, 807, 363, 199, 199, 2264, 1083, 12, 1083, 63, 1160, 199, 199, 533, 8089, 2925, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1240, 30525, 5873, 275, 942, 339, 347, 702, 2176, 4851, 8, 277, 12, 1420, 63, 5352, 304, 267, 3503, 2176, 1296, 275, 1240, 30525, 5873, 221, 327, 1929, 370, 1331, 2952, 314, 9132, 5084, 911, 1050, 3660, 327, 4722, 4882, 370, 1240, 30525, 267, 340, 1420, 63, 5352, 1137, 3503, 2176, 1296, 26, 288, 291, 14, 1633, 480, 6964, 1240, 769, 3427, 78, 221, 450, 83, 60, 21175, 397, 440, 1336, 3503, 1240, 769, 60, 78, 221, 450, 83, 2, 450, 1993, 334, 2062, 63, 5352, 12, 3503, 2176, 1296, 430, 339, 347, 511, 9346, 8, 277, 304, 267, 3925, 275, 2900, 2925, 342, 267, 291, 14, 479, 2176, 4851, 779, 16232, 826, 13915, 334, 1421, 4641, 566, 339, 347, 511, 6636, 16452, 8, 277, 304, 267, 511, 278, 275, 2900, 2925, 342, 267, 327, 14161, 5331, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 435, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 525, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 435, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 22958, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 446, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 954, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 446, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 82, 954, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 511, 278, 627, 413, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 3703, 13915, 334, 396, 278, 12, 413, 18229, 398, 1240, 30525, 5873, 275, 942, 267, 413, 627, 511, 278, 267, 291, 14, 479, 2176, 4851, 779, 16232, 14141, 13915, 334, 396, 278, 12, 413, 1826, 1689, 363, 27968, 13915, 334, 396, 278, 12, 413, 18229, 398, 340, 413, 15, 18, 508, 378, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
DANCEcollaborative/forum-xblock
XBlock Integration Files/xdjangobb/xblock/lib/python2.7/site-packages/django/db/models/options.py
92
21544
import re from bisect import bisect from django.conf import settings from django.db.models.related import RelatedObject from django.db.models.fields.related import ManyToManyRel from django.db.models.fields import AutoField, FieldDoesNotExist from django.db.models.fields.proxy import OrderWrt from django.db.models.loading import get_models, app_cache_ready from django.utils.translation import activate, deactivate_all, get_language, string_concat from django.utils.encoding import force_unicode, smart_str from django.utils.datastructures import SortedDict # Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces". get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', class_name).lower().strip() DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering', 'unique_together', 'permissions', 'get_latest_by', 'order_with_respect_to', 'app_label', 'db_tablespace', 'abstract', 'managed', 'proxy', 'auto_created') class Options(object): def __init__(self, meta, app_label=None): self.local_fields, self.local_many_to_many = [], [] self.virtual_fields = [] self.module_name, self.verbose_name = None, None self.verbose_name_plural = None self.db_table = '' self.ordering = [] self.unique_together = [] self.permissions = [] self.object_name, self.app_label = None, app_label self.get_latest_by = None self.order_with_respect_to = None self.db_tablespace = settings.DEFAULT_TABLESPACE self.admin = None self.meta = meta self.pk = None self.has_auto_field, self.auto_field = False, None self.abstract = False self.managed = True self.proxy = False # For any class that is a proxy (including automatically created # classes for deferred object loading), proxy_for_model tells us # which class this model is proxying. Note that proxy_for_model # can create a chain of proxy models. For non-proxy models, the # variable is always None. self.proxy_for_model = None # For any non-abstract class, the concrete class is the model # in the end of the proxy_for_model chain. In particular, for # concrete models, the concrete_model is always the class itself. self.concrete_model = None self.parents = SortedDict() self.duplicate_targets = {} self.auto_created = False # To handle various inheritance situations, we need to track where # managers came from (concrete or abstract base classes). self.abstract_managers = [] self.concrete_managers = [] # List of all lookups defined in ForeignKey 'limit_choices_to' options # from *other* models. Needed for some admin checks. Internal use only. self.related_fkey_lookups = [] def contribute_to_class(self, cls, name): from django.db import connection from django.db.backends.util import truncate_name cls._meta = self self.installed = re.sub('\.models$', '', cls.__module__) in settings.INSTALLED_APPS # First, construct the default values for these options. self.object_name = cls.__name__ self.module_name = self.object_name.lower() self.verbose_name = get_verbose_name(self.object_name) # Next, apply any overridden values from 'class Meta'. if self.meta: meta_attrs = self.meta.__dict__.copy() for name in self.meta.__dict__: # Ignore any private attributes that Django doesn't care about. # NOTE: We can't modify a dictionary's contents while looping # over it, so we loop over the *original* dictionary instead. if name.startswith('_'): del meta_attrs[name] for attr_name in DEFAULT_NAMES: if attr_name in meta_attrs: setattr(self, attr_name, meta_attrs.pop(attr_name)) elif hasattr(self.meta, attr_name): setattr(self, attr_name, getattr(self.meta, attr_name)) # unique_together can be either a tuple of tuples, or a single # tuple of two strings. Normalize it to a tuple of tuples, so that # calling code can uniformly expect that. ut = meta_attrs.pop('unique_together', self.unique_together) if ut and not isinstance(ut[0], (tuple, list)): ut = (ut,) self.unique_together = ut # verbose_name_plural is a special case because it uses a 's' # by default. if self.verbose_name_plural is None: self.verbose_name_plural = string_concat(self.verbose_name, 's') # Any leftover attributes must be invalid. if meta_attrs != {}: raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys())) else: self.verbose_name_plural = string_concat(self.verbose_name, 's') del self.meta # If the db_table wasn't provided, use the app_label + module_name. if not self.db_table: self.db_table = "%s_%s" % (self.app_label, self.module_name) self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) def _prepare(self, model): if self.order_with_respect_to: self.order_with_respect_to = self.get_field(self.order_with_respect_to) self.ordering = ('_order',) model.add_to_class('_order', OrderWrt()) else: self.order_with_respect_to = None if self.pk is None: if self.parents: # Promote the first parent link in lieu of adding yet another # field. field = self.parents.value_for_index(0) # Look for a local field with the same name as the # first parent link. If a local field has already been # created, use it instead of promoting the parent already_created = [fld for fld in self.local_fields if fld.name == field.name] if already_created: field = already_created[0] field.primary_key = True self.setup_pk(field) else: auto = AutoField(verbose_name='ID', primary_key=True, auto_created=True) model.add_to_class('id', auto) # Determine any sets of fields that are pointing to the same targets # (e.g. two ForeignKeys to the same remote model). The query # construction code needs to know this. At the end of this, # self.duplicate_targets will map each duplicate field column to the # columns it duplicates. collections = {} for column, target in self.duplicate_targets.iteritems(): try: collections[target].add(column) except KeyError: collections[target] = set([column]) self.duplicate_targets = {} for elt in collections.itervalues(): if len(elt) == 1: continue for column in elt: self.duplicate_targets[column] = elt.difference(set([column])) def add_field(self, field): # Insert the given field in the order in which it was created, using # the "creation_counter" attribute of the field. # Move many-to-many related fields from self.fields into # self.many_to_many. if field.rel and isinstance(field.rel, ManyToManyRel): self.local_many_to_many.insert(bisect(self.local_many_to_many, field), field) if hasattr(self, '_m2m_cache'): del self._m2m_cache else: self.local_fields.insert(bisect(self.local_fields, field), field) self.setup_pk(field) if hasattr(self, '_field_cache'): del self._field_cache del self._field_name_cache if hasattr(self, '_name_map'): del self._name_map def add_virtual_field(self, field): self.virtual_fields.append(field) def setup_pk(self, field): if not self.pk and field.primary_key: self.pk = field field.serialize = False def setup_proxy(self, target): """ Does the internal setup so that the current model is a proxy for "target". """ self.pk = target._meta.pk self.proxy_for_model = target self.db_table = target._meta.db_table def __repr__(self): return '<Options for %s>' % self.object_name def __str__(self): return "%s.%s" % (smart_str(self.app_label), smart_str(self.module_name)) def verbose_name_raw(self): """ There are a few places where the untranslated verbose name is needed (so that we get the same value regardless of currently active locale). """ lang = get_language() deactivate_all() raw = force_unicode(self.verbose_name) activate(lang) return raw verbose_name_raw = property(verbose_name_raw) def _fields(self): """ The getter for self.fields. This returns the list of field objects available to this model (including through parent models). Callers are not permitted to modify this list, since it's a reference to this instance (not a copy). """ try: self._field_name_cache except AttributeError: self._fill_fields_cache() return self._field_name_cache fields = property(_fields) def get_fields_with_model(self): """ Returns a sequence of (field, model) pairs for all fields. The "model" element is None for fields on the current model. Mostly of use when constructing queries so that we know which model a field belongs to. """ try: self._field_cache except AttributeError: self._fill_fields_cache() return self._field_cache def _fill_fields_cache(self): cache = [] for parent in self.parents: for field, model in parent._meta.get_fields_with_model(): if model: cache.append((field, model)) else: cache.append((field, parent)) cache.extend([(f, None) for f in self.local_fields]) self._field_cache = tuple(cache) self._field_name_cache = [x for x, _ in cache] def _many_to_many(self): try: self._m2m_cache except AttributeError: self._fill_m2m_cache() return self._m2m_cache.keys() many_to_many = property(_many_to_many) def get_m2m_with_model(self): """ The many-to-many version of get_fields_with_model(). """ try: self._m2m_cache except AttributeError: self._fill_m2m_cache() return self._m2m_cache.items() def _fill_m2m_cache(self): cache = SortedDict() for parent in self.parents: for field, model in parent._meta.get_m2m_with_model(): if model: cache[field] = model else: cache[field] = parent for field in self.local_many_to_many: cache[field] = None self._m2m_cache = cache def get_field(self, name, many_to_many=True): """ Returns the requested field by name. Raises FieldDoesNotExist on error. """ to_search = many_to_many and (self.fields + self.many_to_many) or self.fields for f in to_search: if f.name == name: return f raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, name)) def get_field_by_name(self, name): """ Returns the (field_object, model, direct, m2m), where field_object is the Field instance for the given name, model is the model containing this field (None for local fields), direct is True if the field exists on this model, and m2m is True for many-to-many relations. When 'direct' is False, 'field_object' is the corresponding RelatedObject for this field (since the field doesn't have an instance associated with it). Uses a cache internally, so after the first access, this is very fast. """ try: try: return self._name_map[name] except AttributeError: cache = self.init_name_map() return cache[name] except KeyError: raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, name)) def get_all_field_names(self): """ Returns a list of all field names that are possible for this model (including reverse relation names). This is used for pretty printing debugging output (a list of choices), so any internal-only field names are not included. """ try: cache = self._name_map except AttributeError: cache = self.init_name_map() names = cache.keys() names.sort() # Internal-only names end with "+" (symmetrical m2m related names being # the main example). Trim them. return [val for val in names if not val.endswith('+')] def init_name_map(self): """ Initialises the field name -> field object mapping. """ cache = {} # We intentionally handle related m2m objects first so that symmetrical # m2m accessor names can be overridden, if necessary. for f, model in self.get_all_related_m2m_objects_with_model(): cache[f.field.related_query_name()] = (f, model, False, True) for f, model in self.get_all_related_objects_with_model(): cache[f.field.related_query_name()] = (f, model, False, False) for f, model in self.get_m2m_with_model(): cache[f.name] = (f, model, True, True) for f, model in self.get_fields_with_model(): cache[f.name] = (f, model, True, False) if app_cache_ready(): self._name_map = cache return cache def get_add_permission(self): return 'add_%s' % self.object_name.lower() def get_change_permission(self): return 'change_%s' % self.object_name.lower() def get_delete_permission(self): return 'delete_%s' % self.object_name.lower() def get_all_related_objects(self, local_only=False, include_hidden=False, include_proxy_eq=False): return [k for k, v in self.get_all_related_objects_with_model( local_only=local_only, include_hidden=include_hidden, include_proxy_eq=include_proxy_eq)] def get_all_related_objects_with_model(self, local_only=False, include_hidden=False, include_proxy_eq=False): """ Returns a list of (related-object, model) pairs. Similar to get_fields_with_model(). """ try: self._related_objects_cache except AttributeError: self._fill_related_objects_cache() predicates = [] if local_only: predicates.append(lambda k, v: not v) if not include_hidden: predicates.append(lambda k, v: not k.field.rel.is_hidden()) cache = (self._related_objects_proxy_cache if include_proxy_eq else self._related_objects_cache) return filter(lambda t: all([p(*t) for p in predicates]), cache.items()) def _fill_related_objects_cache(self): cache = SortedDict() parent_list = self.get_parent_list() for parent in self.parents: for obj, model in parent._meta.get_all_related_objects_with_model(include_hidden=True): if (obj.field.creation_counter < 0 or obj.field.rel.parent_link) and obj.model not in parent_list: continue if not model: cache[obj] = parent else: cache[obj] = model # Collect also objects which are in relation to some proxy child/parent of self. proxy_cache = cache.copy() for klass in get_models(include_auto_created=True, only_installed=False): for f in klass._meta.local_fields: if f.rel and not isinstance(f.rel.to, basestring): if self == f.rel.to._meta: cache[RelatedObject(f.rel.to, klass, f)] = None proxy_cache[RelatedObject(f.rel.to, klass, f)] = None elif self.concrete_model == f.rel.to._meta.concrete_model: proxy_cache[RelatedObject(f.rel.to, klass, f)] = None self._related_objects_cache = cache self._related_objects_proxy_cache = proxy_cache def get_all_related_many_to_many_objects(self, local_only=False): try: cache = self._related_many_to_many_cache except AttributeError: cache = self._fill_related_many_to_many_cache() if local_only: return [k for k, v in cache.items() if not v] return cache.keys() def get_all_related_m2m_objects_with_model(self): """ Returns a list of (related-m2m-object, model) pairs. Similar to get_fields_with_model(). """ try: cache = self._related_many_to_many_cache except AttributeError: cache = self._fill_related_many_to_many_cache() return cache.items() def _fill_related_many_to_many_cache(self): cache = SortedDict() parent_list = self.get_parent_list() for parent in self.parents: for obj, model in parent._meta.get_all_related_m2m_objects_with_model(): if obj.field.creation_counter < 0 and obj.model not in parent_list: continue if not model: cache[obj] = parent else: cache[obj] = model for klass in get_models(only_installed=False): for f in klass._meta.local_many_to_many: if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta: cache[RelatedObject(f.rel.to, klass, f)] = None if app_cache_ready(): self._related_many_to_many_cache = cache return cache def get_base_chain(self, model): """ Returns a list of parent classes leading to 'model' (order from closet to most distant ancestor). This has to handle the case were 'model' is a granparent or even more distant relation. """ if not self.parents: return if model in self.parents: return [model] for parent in self.parents: res = parent._meta.get_base_chain(model) if res: res.insert(0, parent) return res raise TypeError('%r is not an ancestor of this model' % model._meta.module_name) def get_parent_list(self): """ Returns a list of all the ancestor of this model as a list. Useful for determining if something is an ancestor, regardless of lineage. """ result = set() for parent in self.parents: result.add(parent) result.update(parent._meta.get_parent_list()) return result def get_ancestor_link(self, ancestor): """ Returns the field on the current model which points to the given "ancestor". This is possible an indirect link (a pointer to a parent model, which points, eventually, to the ancestor). Used when constructing table joins for model inheritance. Returns None if the model isn't an ancestor of this one. """ if ancestor in self.parents: return self.parents[ancestor] for parent in self.parents: # Tries to get a link field from the immediate parent parent_link = parent._meta.get_ancestor_link(ancestor) if parent_link: # In case of a proxied model, the first link # of the chain to the ancestor is that parent # links return self.parents[parent] or parent_link def get_ordered_objects(self): "Returns a list of Options objects that are ordered with respect to this object." if not hasattr(self, '_ordered_objects'): objects = [] # TODO #for klass in get_models(get_app(self.app_label)): # opts = klass._meta # if opts.order_with_respect_to and opts.order_with_respect_to.rel \ # and self == opts.order_with_respect_to.rel.to._meta: # objects.append(opts) self._ordered_objects = objects return self._ordered_objects def pk_index(self): """ Returns the index of the primary key field in the self.fields list. """ return self.fields.index(self.pk)
mit
[ 646, 295, 199, 504, 19063, 492, 19063, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 14, 992, 14, 2407, 492, 20116, 1692, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 492, 15517, 6749, 5640, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 9195, 792, 12, 29994, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 3280, 492, 9240, 55, 2591, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 992, 12, 1145, 63, 1637, 63, 2179, 199, 504, 1639, 14, 1208, 14, 6893, 492, 15422, 12, 25560, 63, 452, 12, 664, 63, 3671, 12, 1059, 63, 9419, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 199, 3, 12707, 314, 3376, 63, 354, 701, 13806, 687, 6026, 35, 7461, 370, 298, 21636, 543, 7883, 1674, 199, 362, 63, 3832, 63, 354, 275, 2400, 1021, 63, 354, 26, 295, 14, 954, 360, 1332, 2229, 28, 1524, 65, 13, 90, 11057, 33, 13, 58, 566, 92, 779, 33, 13, 58, 61, 2229, 21282, 33, 13, 58, 11752, 4, 1724, 297, 283, 8522, 17, 297, 1021, 63, 354, 680, 2325, 1252, 1913, 342, 199, 199, 3472, 63, 14546, 275, 661, 3832, 63, 354, 297, 283, 3832, 63, 354, 63, 10019, 297, 283, 697, 63, 1224, 297, 283, 7128, 297, 326, 283, 3235, 63, 6314, 297, 283, 6060, 297, 283, 362, 63, 7410, 63, 991, 297, 326, 283, 1648, 63, 1045, 63, 27872, 63, 475, 297, 283, 571, 63, 1302, 297, 283, 697, 63, 26730, 297, 326, 283, 6198, 297, 283, 11122, 297, 283, 3280, 297, 283, 2495, 63, 3966, 358, 199, 199, 533, 8394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3404, 12, 1145, 63, 1302, 29, 403, 304, 267, 291, 14, 1832, 63, 955, 12, 291, 14, 1832, 63, 3479, 63, 475, 63, 3479, 275, 990, 942, 267, 291, 14, 2065, 63, 955, 275, 942, 267, 291, 14, 578, 63, 354, 12, 291, 14, 3832, 63, 354, 275, 488, 12, 488, 267, 291, 14, 3832, 63, 354, 63, 10019, 275, 488, 267, 291, 14, 697, 63, 1224, 275, 2125, 267, 291, 14, 7128, 275, 942, 267, 291, 14, 3235, 63, 6314, 275, 221, 942, 267, 291, 14, 6060, 275, 221, 942, 267, 291, 14, 785, 63, 354, 12, 291, 14, 571, 63, 1302, 275, 488, 12, 1145, 63, 1302, 267, 291, 14, 362, 63, 7410, 63, 991, 275, 488, 267, 291, 14, 1648, 63, 1045, 63, 27872, 63, 475, 275, 488, 267, 291, 14, 697, 63, 26730, 275, 2202, 14, 3472, 63, 10129, 44, 9136, 267, 291, 14, 2113, 275, 488, 267, 291, 14, 2024, 275, 3404, 267, 291, 14, 2051, 275, 488, 267, 291, 14, 1989, 63, 2495, 63, 698, 12, 291, 14, 2495, 63, 698, 275, 756, 12, 488, 267, 291, 14, 6198, 275, 756, 267, 291, 14, 11122, 275, 715, 267, 291, 14, 3280, 275, 756, 267, 327, 2104, 1263, 1021, 626, 365, 282, 4566, 334, 15768, 5847, 2737, 267, 327, 3992, 367, 12309, 909, 8697, 395, 4566, 63, 509, 63, 1238, 26544, 2739, 267, 327, 1314, 1021, 642, 1402, 365, 4566, 316, 14, 3390, 626, 4566, 63, 509, 63, 1238, 267, 327, 883, 1218, 282, 6036, 402, 4566, 1709, 14, 2104, 2222, 13, 3280, 1709, 12, 314, 267, 327, 1750, 365, 3544, 488, 14, 267, 291, 14, 3280, 63, 509, 63, 1238, 275, 488, 267, 327, 2104, 1263, 2222, 13, 6198, 1021, 12, 314, 13801, 1021, 365, 314, 1402, 267, 327, 315, 314, 1284, 402, 314, 4566, 63, 509, 63, 1238, 6036, 14, 1010, 6770, 12, 367, 267, 327, 13801, 1709, 12, 314, 13801, 63, 1238, 365, 3544, 314, 1021, 6337, 14, 267, 291, 14, 13455, 63, 1238, 275, 488, 267, 291, 14, 8859, 275, 27432, 2141, 342, 267, 291, 14, 11081, 63, 4684, 275, 1052, 267, 291, 14, 2495, 63, 3966, 275, 756, 398, 327, 4005, 2429, 7750, 15433, 24325, 12, 781, 1929, 370, 4426, 2382, 267, 327, 19680, 20382, 687, 334, 13455, 503, 9006, 1300, 3992, 680, 267, 291, 14, 6198, 63, 16259, 275, 942, 267, 291, 14, 13455, 63, 16259, 275, 942, 398, 327, 3820, 402, 1006, 16807, 3247, 315, 12718, 283, 3097, 63, 4577, 63, 475, 7, 1511, 267, 327, 687, 627, 1848, 10, 1709, 14, 28196, 367, 2005, 4628, 5920, 14, 12624, 675, 1454, 14, 267, 291, 14, 2407, 63, 70, 498, 63, 17438, 275, 942, 339, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 304, 267, 687, 1639, 14, 697, 492, 1950, 267, 687, 1639, 14, 697, 14, 7765, 14, 1974, 492, 14547, 63, 354, 398, 843, 423, 2024, 275, 291, 267, 291, 14, 7657, 275, 295, 14, 954, 2258, 14, 992, 4268, 3260, 843, 855, 578, 3368, 315, 2202, 14, 15942, 63, 14219, 267, 327, 7758, 12, 6982, 314, 849, 1338, 367, 3520, 1511, 14, 267, 291, 14, 785, 63, 354, 275, 843, 855, 354, 363, 267, 291, 14, 578, 63, 354, 275, 291, 14, 785, 63, 354, 14, 2325, 342, 267, 291, 14, 3832, 63, 354, 275, 664, 63, 3832, 63, 354, 8, 277, 14, 785, 63, 354, 9, 398, 327, 16840, 12, 4838, 1263, 10087, 1338, 687, 283, 533, 6288, 1370, 267, 340, 291, 14, 2024, 26, 288, 3404, 63, 3288, 275, 291, 14, 2024, 855, 807, 4343, 1574, 342, 288, 367, 536, 315, 291, 14, 2024, 855, 807, 10651, 355, 327, 14092, 1263, 5726, 3004, 626, 5634, 3181, 1133, 10296, 3595, 14, 355, 327, 6944, 26, 2136, 883, 1133, 2811, 282, 2600, 1159, 4072, 1830, 4438, 316, 355, 327, 1806, 652, 12, 880, 781, 4438, 1806, 314, 627, 5043, 10, 2600, 3140, 14, 355, 340, 536, 14, 2460, 30018, 490, 2150, 3404, 63, 3288, 59, 354, 61, 288, 367, 1921, 63, 354, 315, 6186, 63, 14546, 26, 355, 340, 1921, 63, 354, 315, 3404, 63, 3288, 26, 490, 5371, 8, 277, 12, 1921, 63, 354, 12, 3404, 63, 3288, 14, 1935, 8, 962, 63, 354, 430, 355, 916, 2688, 8, 277, 14, 2024, 12, 1921, 63, 354, 304, 490, 5371, 8, 277, 12, 1921 ]
[ 295, 199, 504, 19063, 492, 19063, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 14, 992, 14, 2407, 492, 20116, 1692, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 492, 15517, 6749, 5640, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 9195, 792, 12, 29994, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 3280, 492, 9240, 55, 2591, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 992, 12, 1145, 63, 1637, 63, 2179, 199, 504, 1639, 14, 1208, 14, 6893, 492, 15422, 12, 25560, 63, 452, 12, 664, 63, 3671, 12, 1059, 63, 9419, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 199, 3, 12707, 314, 3376, 63, 354, 701, 13806, 687, 6026, 35, 7461, 370, 298, 21636, 543, 7883, 1674, 199, 362, 63, 3832, 63, 354, 275, 2400, 1021, 63, 354, 26, 295, 14, 954, 360, 1332, 2229, 28, 1524, 65, 13, 90, 11057, 33, 13, 58, 566, 92, 779, 33, 13, 58, 61, 2229, 21282, 33, 13, 58, 11752, 4, 1724, 297, 283, 8522, 17, 297, 1021, 63, 354, 680, 2325, 1252, 1913, 342, 199, 199, 3472, 63, 14546, 275, 661, 3832, 63, 354, 297, 283, 3832, 63, 354, 63, 10019, 297, 283, 697, 63, 1224, 297, 283, 7128, 297, 326, 283, 3235, 63, 6314, 297, 283, 6060, 297, 283, 362, 63, 7410, 63, 991, 297, 326, 283, 1648, 63, 1045, 63, 27872, 63, 475, 297, 283, 571, 63, 1302, 297, 283, 697, 63, 26730, 297, 326, 283, 6198, 297, 283, 11122, 297, 283, 3280, 297, 283, 2495, 63, 3966, 358, 199, 199, 533, 8394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3404, 12, 1145, 63, 1302, 29, 403, 304, 267, 291, 14, 1832, 63, 955, 12, 291, 14, 1832, 63, 3479, 63, 475, 63, 3479, 275, 990, 942, 267, 291, 14, 2065, 63, 955, 275, 942, 267, 291, 14, 578, 63, 354, 12, 291, 14, 3832, 63, 354, 275, 488, 12, 488, 267, 291, 14, 3832, 63, 354, 63, 10019, 275, 488, 267, 291, 14, 697, 63, 1224, 275, 2125, 267, 291, 14, 7128, 275, 942, 267, 291, 14, 3235, 63, 6314, 275, 221, 942, 267, 291, 14, 6060, 275, 221, 942, 267, 291, 14, 785, 63, 354, 12, 291, 14, 571, 63, 1302, 275, 488, 12, 1145, 63, 1302, 267, 291, 14, 362, 63, 7410, 63, 991, 275, 488, 267, 291, 14, 1648, 63, 1045, 63, 27872, 63, 475, 275, 488, 267, 291, 14, 697, 63, 26730, 275, 2202, 14, 3472, 63, 10129, 44, 9136, 267, 291, 14, 2113, 275, 488, 267, 291, 14, 2024, 275, 3404, 267, 291, 14, 2051, 275, 488, 267, 291, 14, 1989, 63, 2495, 63, 698, 12, 291, 14, 2495, 63, 698, 275, 756, 12, 488, 267, 291, 14, 6198, 275, 756, 267, 291, 14, 11122, 275, 715, 267, 291, 14, 3280, 275, 756, 267, 327, 2104, 1263, 1021, 626, 365, 282, 4566, 334, 15768, 5847, 2737, 267, 327, 3992, 367, 12309, 909, 8697, 395, 4566, 63, 509, 63, 1238, 26544, 2739, 267, 327, 1314, 1021, 642, 1402, 365, 4566, 316, 14, 3390, 626, 4566, 63, 509, 63, 1238, 267, 327, 883, 1218, 282, 6036, 402, 4566, 1709, 14, 2104, 2222, 13, 3280, 1709, 12, 314, 267, 327, 1750, 365, 3544, 488, 14, 267, 291, 14, 3280, 63, 509, 63, 1238, 275, 488, 267, 327, 2104, 1263, 2222, 13, 6198, 1021, 12, 314, 13801, 1021, 365, 314, 1402, 267, 327, 315, 314, 1284, 402, 314, 4566, 63, 509, 63, 1238, 6036, 14, 1010, 6770, 12, 367, 267, 327, 13801, 1709, 12, 314, 13801, 63, 1238, 365, 3544, 314, 1021, 6337, 14, 267, 291, 14, 13455, 63, 1238, 275, 488, 267, 291, 14, 8859, 275, 27432, 2141, 342, 267, 291, 14, 11081, 63, 4684, 275, 1052, 267, 291, 14, 2495, 63, 3966, 275, 756, 398, 327, 4005, 2429, 7750, 15433, 24325, 12, 781, 1929, 370, 4426, 2382, 267, 327, 19680, 20382, 687, 334, 13455, 503, 9006, 1300, 3992, 680, 267, 291, 14, 6198, 63, 16259, 275, 942, 267, 291, 14, 13455, 63, 16259, 275, 942, 398, 327, 3820, 402, 1006, 16807, 3247, 315, 12718, 283, 3097, 63, 4577, 63, 475, 7, 1511, 267, 327, 687, 627, 1848, 10, 1709, 14, 28196, 367, 2005, 4628, 5920, 14, 12624, 675, 1454, 14, 267, 291, 14, 2407, 63, 70, 498, 63, 17438, 275, 942, 339, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 304, 267, 687, 1639, 14, 697, 492, 1950, 267, 687, 1639, 14, 697, 14, 7765, 14, 1974, 492, 14547, 63, 354, 398, 843, 423, 2024, 275, 291, 267, 291, 14, 7657, 275, 295, 14, 954, 2258, 14, 992, 4268, 3260, 843, 855, 578, 3368, 315, 2202, 14, 15942, 63, 14219, 267, 327, 7758, 12, 6982, 314, 849, 1338, 367, 3520, 1511, 14, 267, 291, 14, 785, 63, 354, 275, 843, 855, 354, 363, 267, 291, 14, 578, 63, 354, 275, 291, 14, 785, 63, 354, 14, 2325, 342, 267, 291, 14, 3832, 63, 354, 275, 664, 63, 3832, 63, 354, 8, 277, 14, 785, 63, 354, 9, 398, 327, 16840, 12, 4838, 1263, 10087, 1338, 687, 283, 533, 6288, 1370, 267, 340, 291, 14, 2024, 26, 288, 3404, 63, 3288, 275, 291, 14, 2024, 855, 807, 4343, 1574, 342, 288, 367, 536, 315, 291, 14, 2024, 855, 807, 10651, 355, 327, 14092, 1263, 5726, 3004, 626, 5634, 3181, 1133, 10296, 3595, 14, 355, 327, 6944, 26, 2136, 883, 1133, 2811, 282, 2600, 1159, 4072, 1830, 4438, 316, 355, 327, 1806, 652, 12, 880, 781, 4438, 1806, 314, 627, 5043, 10, 2600, 3140, 14, 355, 340, 536, 14, 2460, 30018, 490, 2150, 3404, 63, 3288, 59, 354, 61, 288, 367, 1921, 63, 354, 315, 6186, 63, 14546, 26, 355, 340, 1921, 63, 354, 315, 3404, 63, 3288, 26, 490, 5371, 8, 277, 12, 1921, 63, 354, 12, 3404, 63, 3288, 14, 1935, 8, 962, 63, 354, 430, 355, 916, 2688, 8, 277, 14, 2024, 12, 1921, 63, 354, 304, 490, 5371, 8, 277, 12, 1921, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wdv4758h/ZipPy
lib-python/3/fileinput.py
5
14366
"""Helper class to quickly write a loop over all standard input files. Typical use is: import fileinput for line in fileinput.input(): process(line) This iterates over the lines of all files listed in sys.argv[1:], defaulting to sys.stdin if the list is empty. If a filename is '-' it is also replaced by sys.stdin. To specify an alternative list of filenames, pass it as the argument to input(). A single file name is also allowed. Functions filename(), lineno() return the filename and cumulative line number of the line that has just been read; filelineno() returns its line number in the current file; isfirstline() returns true iff the line just read is the first line of its file; isstdin() returns true iff the line was read from sys.stdin. Function nextfile() closes the current file so that the next iteration will read the first line from the next file (if any); lines not read from the file will not count towards the cumulative line count; the filename is not changed until after the first line of the next file has been read. Function close() closes the sequence. Before any lines have been read, filename() returns None and both line numbers are zero; nextfile() has no effect. After all lines have been read, filename() and the line number functions return the values pertaining to the last line read; nextfile() has no effect. All files are opened in text mode by default, you can override this by setting the mode parameter to input() or FileInput.__init__(). If an I/O error occurs during opening or reading a file, the IOError exception is raised. If sys.stdin is used more than once, the second and further use will return no lines, except perhaps for interactive use, or if it has been explicitly reset (e.g. using sys.stdin.seek(0)). Empty files are opened and immediately closed; the only time their presence in the list of filenames is noticeable at all is when the last file opened is empty. It is possible that the last line of a file doesn't end in a newline character; otherwise lines are returned including the trailing newline. Class FileInput is the implementation; its methods filename(), lineno(), fileline(), isfirstline(), isstdin(), nextfile() and close() correspond to the functions in the module. In addition it has a readline() method which returns the next input line, and a __getitem__() method which implements the sequence behavior. The sequence must be accessed in strictly sequential order; sequence access and readline() cannot be mixed. Optional in-place filtering: if the keyword argument inplace=1 is passed to input() or to the FileInput constructor, the file is moved to a backup file and standard output is directed to the input file. This makes it possible to write a filter that rewrites its input file in place. If the keyword argument backup=".<some extension>" is also given, it specifies the extension for the backup file, and the backup file remains around; by default, the extension is ".bak" and it is deleted when the output file is closed. In-place filtering is disabled when standard input is read. XXX The current implementation does not work for MS-DOS 8+3 filesystems. Performance: this module is unfortunately one of the slower ways of processing large numbers of input lines. Nevertheless, a significant speed-up has been obtained by using readlines(bufsize) instead of readline(). A new keyword argument, bufsize=N, is present on the input() function and the FileInput() class to override the default buffer size. XXX Possible additions: - optional getopt argument processing - isatty() - read(), read(size), even readlines() """ import sys, os __all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno", "isfirstline", "isstdin", "FileInput"] _state = None DEFAULT_BUFSIZE = 8*1024 def input(files=None, inplace=False, backup="", bufsize=0, mode="r", openhook=None): """input(files=None, inplace=False, backup="", bufsize=0, \ mode="r", openhook=None) Create an instance of the FileInput class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. The parameters to this function will be passed along to the constructor of the FileInput class. """ global _state if _state and _state._file: raise RuntimeError("input() already active") _state = FileInput(files, inplace, backup, bufsize, mode, openhook) return _state def close(): """Close the sequence.""" global _state state = _state _state = None if state: state.close() def nextfile(): """ Close the current file so that the next iteration will read the first line from the next file (if any); lines not read from the file will not count towards the cumulative line count. The filename is not changed until after the first line of the next file has been read. Before the first line has been read, this function has no effect; it cannot be used to skip the first file. After the last line of the last file has been read, this function has no effect. """ if not _state: raise RuntimeError("no active input()") return _state.nextfile() def filename(): """ Return the name of the file currently being read. Before the first line has been read, returns None. """ if not _state: raise RuntimeError("no active input()") return _state.filename() def lineno(): """ Return the cumulative line number of the line that has just been read. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line. """ if not _state: raise RuntimeError("no active input()") return _state.lineno() def filelineno(): """ Return the line number in the current file. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line within the file. """ if not _state: raise RuntimeError("no active input()") return _state.filelineno() def fileno(): """ Return the file number of the current file. When no file is currently opened, returns -1. """ if not _state: raise RuntimeError("no active input()") return _state.fileno() def isfirstline(): """ Returns true the line just read is the first line of its file, otherwise returns false. """ if not _state: raise RuntimeError("no active input()") return _state.isfirstline() def isstdin(): """ Returns true if the last line was read from sys.stdin, otherwise returns false. """ if not _state: raise RuntimeError("no active input()") return _state.isstdin() class FileInput: """class FileInput([files[, inplace[, backup[, mode[, openhook]]]]]) Class FileInput is the implementation of the module; its methods filename(), lineno(), fileline(), isfirstline(), isstdin(), fileno(), nextfile() and close() correspond to the functions of the same name in the module. In addition it has a readline() method which returns the next input line, and a __getitem__() method which implements the sequence behavior. The sequence must be accessed in strictly sequential order; random access and readline() cannot be mixed. """ def __init__(self, files=None, inplace=False, backup="", bufsize=0, mode="r", openhook=None): if isinstance(files, str): files = (files,) else: if files is None: files = sys.argv[1:] if not files: files = ('-',) else: files = tuple(files) self._files = files self._inplace = inplace self._backup = backup self._bufsize = bufsize or DEFAULT_BUFSIZE self._savestdout = None self._output = None self._filename = None self._lineno = 0 self._filelineno = 0 self._file = None self._isstdin = False self._backupfilename = None self._buffer = [] self._bufindex = 0 # restrict mode argument to reading modes if mode not in ('r', 'rU', 'U', 'rb'): raise ValueError("FileInput opening mode must be one of " "'r', 'rU', 'U' and 'rb'") self._mode = mode if openhook: if inplace: raise ValueError("FileInput cannot use an opening hook in inplace mode") if not callable(openhook): raise ValueError("FileInput openhook must be callable") self._openhook = openhook def __del__(self): self.close() def close(self): self.nextfile() self._files = () def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def __iter__(self): return self def __next__(self): try: line = self._buffer[self._bufindex] except IndexError: pass else: self._bufindex += 1 self._lineno += 1 self._filelineno += 1 return line line = self.readline() if not line: raise StopIteration return line def __getitem__(self, i): if i != self._lineno: raise RuntimeError("accessing lines out of order") try: return self.__next__() except StopIteration: raise IndexError("end of input reached") def nextfile(self): savestdout = self._savestdout self._savestdout = 0 if savestdout: sys.stdout = savestdout output = self._output self._output = 0 if output: output.close() file = self._file self._file = 0 if file and not self._isstdin: file.close() backupfilename = self._backupfilename self._backupfilename = 0 if backupfilename and not self._backup: try: os.unlink(backupfilename) except OSError: pass self._isstdin = False self._buffer = [] self._bufindex = 0 def readline(self): try: line = self._buffer[self._bufindex] except IndexError: pass else: self._bufindex += 1 self._lineno += 1 self._filelineno += 1 return line if not self._file: if not self._files: return "" self._filename = self._files[0] self._files = self._files[1:] self._filelineno = 0 self._file = None self._isstdin = False self._backupfilename = 0 if self._filename == '-': self._filename = '<stdin>' self._file = sys.stdin self._isstdin = True else: if self._inplace: self._backupfilename = ( self._filename + (self._backup or ".bak")) try: os.unlink(self._backupfilename) except os.error: pass # The next few lines may raise IOError os.rename(self._filename, self._backupfilename) self._file = open(self._backupfilename, self._mode) try: perm = os.fstat(self._file.fileno()).st_mode except OSError: self._output = open(self._filename, "w") else: mode = os.O_CREAT | os.O_WRONLY | os.O_TRUNC if hasattr(os, 'O_BINARY'): mode |= os.O_BINARY fd = os.open(self._filename, mode, perm) self._output = os.fdopen(fd, "w") try: if hasattr(os, 'chmod'): os.chmod(self._filename, perm) except OSError: pass self._savestdout = sys.stdout sys.stdout = self._output else: # This may raise IOError if self._openhook: self._file = self._openhook(self._filename, self._mode) else: self._file = open(self._filename, self._mode) self._buffer = self._file.readlines(self._bufsize) self._bufindex = 0 if not self._buffer: self.nextfile() # Recursive call return self.readline() def filename(self): return self._filename def lineno(self): return self._lineno def filelineno(self): return self._filelineno def fileno(self): if self._file: try: return self._file.fileno() except ValueError: return -1 else: return -1 def isfirstline(self): return self._filelineno == 1 def isstdin(self): return self._isstdin def hook_compressed(filename, mode): ext = os.path.splitext(filename)[1] if ext == '.gz': import gzip return gzip.open(filename, mode) elif ext == '.bz2': import bz2 return bz2.BZ2File(filename, mode) else: return open(filename, mode) def hook_encoded(encoding): import codecs def openhook(filename, mode): return codecs.open(filename, mode, encoding) return openhook def _test(): import getopt inplace = False backup = False opts, args = getopt.getopt(sys.argv[1:], "ib:") for o, a in opts: if o == '-i': inplace = True if o == '-b': backup = a for line in input(args, inplace=inplace, backup=backup): if line[-1:] == '\n': line = line[:-1] if line[-1:] == '\r': line = line[:-1] print("%d: %s[%d]%s %s" % (lineno(), filename(), filelineno(), isfirstline() and "*" or "", line)) print("%d: %s[%d]" % (lineno(), filename(), filelineno())) if __name__ == '__main__': _test()
bsd-3-clause
[ 624, 4433, 1021, 370, 23661, 2218, 282, 4438, 1806, 1006, 4465, 1324, 1584, 14, 199, 199, 26876, 675, 365, 26, 339, 492, 570, 1210, 272, 367, 1004, 315, 570, 1210, 14, 1210, 837, 267, 2112, 8, 604, 9, 199, 199, 2765, 2740, 2335, 1806, 314, 2385, 402, 1006, 1584, 10532, 315, 984, 14, 3020, 59, 17, 8429, 199, 885, 316, 370, 984, 14, 6626, 340, 314, 769, 365, 2701, 14, 221, 982, 282, 1788, 365, 10791, 652, 199, 374, 2597, 8717, 701, 984, 14, 6626, 14, 221, 4005, 4165, 376, 13943, 769, 402, 199, 10309, 12, 986, 652, 465, 314, 1423, 370, 1324, 1252, 221, 437, 2849, 570, 536, 365, 199, 12344, 4370, 14, 199, 199, 13967, 1788, 1062, 5874, 342, 372, 314, 1788, 436, 25814, 1004, 199, 1955, 402, 314, 1004, 626, 965, 2951, 2757, 1586, 27, 570, 3469, 342, 2529, 2399, 199, 604, 1329, 315, 314, 1453, 570, 27, 365, 2246, 604, 342, 2529, 2549, 17963, 314, 199, 604, 2951, 1586, 365, 314, 1642, 1004, 402, 2399, 570, 27, 365, 6626, 342, 2529, 2549, 199, 15126, 314, 1004, 1990, 1586, 687, 984, 14, 6626, 14, 221, 6801, 2163, 493, 342, 27811, 314, 199, 1818, 570, 880, 626, 314, 2163, 8494, 911, 1586, 314, 1642, 1004, 687, 199, 1589, 2163, 570, 334, 692, 1263, 2736, 2385, 440, 1586, 687, 314, 570, 911, 440, 2338, 199, 475, 4751, 314, 25814, 1004, 2338, 27, 314, 1788, 365, 440, 2896, 5133, 199, 4399, 314, 1642, 1004, 402, 314, 2163, 570, 965, 2757, 1586, 14, 221, 6801, 4002, 342, 199, 1251, 874, 314, 3414, 14, 199, 199, 13569, 1263, 2385, 1172, 2757, 1586, 12, 1788, 342, 2529, 488, 436, 3865, 1004, 199, 10548, 787, 4697, 27, 2163, 493, 342, 965, 949, 7763, 14, 221, 12836, 1006, 2385, 1172, 2757, 199, 739, 12, 1788, 342, 436, 314, 1004, 1329, 3423, 372, 314, 1338, 199, 529, 24522, 370, 314, 2061, 1004, 1586, 27, 2163, 493, 342, 965, 949, 7763, 14, 199, 199, 2422, 1584, 787, 12123, 315, 1318, 818, 701, 849, 12, 1265, 883, 4278, 642, 701, 199, 6031, 314, 818, 2725, 370, 1324, 342, 503, 3814, 3205, 855, 826, 31261, 199, 3917, 376, 473, 15, 47, 1125, 11058, 5309, 13618, 503, 7664, 282, 570, 12, 314, 5925, 199, 1971, 365, 4915, 14, 199, 199, 3917, 984, 14, 6626, 365, 1202, 1655, 2419, 5403, 12, 314, 3499, 436, 9848, 675, 911, 199, 1107, 949, 2385, 12, 871, 25358, 367, 12777, 675, 12, 503, 340, 652, 965, 2757, 199, 10306, 590, 5305, 334, 69, 14, 71, 14, 1808, 984, 14, 6626, 14, 5507, 8, 16, 4992, 199, 199, 4699, 1584, 787, 12123, 436, 9939, 6876, 27, 314, 1454, 900, 3932, 199, 21566, 315, 314, 769, 402, 6203, 365, 4245, 461, 737, 1006, 365, 1380, 314, 199, 2019, 570, 12123, 365, 2701, 14, 199, 199, 7940, 365, 3962, 626, 314, 2061, 1004, 402, 282, 570, 3181, 1133, 1284, 315, 282, 8057, 199, 10856, 27, 4257, 2385, 787, 2138, 5893, 314, 8520, 199, 12210, 14, 199, 199, 2543, 3814, 3205, 365, 314, 4514, 27, 2399, 3102, 1788, 1062, 199, 3469, 1062, 570, 604, 1062, 365, 2246, 604, 1062, 365, 6626, 1062, 2163, 493, 342, 436, 4002, 342, 199, 989, 22720, 370, 314, 3423, 315, 314, 859, 14, 221, 1010, 10234, 652, 965, 282, 199, 6407, 342, 1083, 1314, 2529, 314, 2163, 1324, 1004, 12, 436, 282, 199, 363, 6095, 4533, 1083, 1314, 9031, 314, 3414, 5953, 14, 221, 710, 199, 4041, 1471, 506, 13810, 315, 22699, 23381, 1865, 27, 3414, 199, 2732, 436, 14441, 342, 3913, 506, 13492, 14, 199, 199, 7012, 315, 13, 2778, 14545, 26, 340, 314, 4252, 1423, 16304, 29, 17, 365, 199, 12070, 370, 1324, 342, 503, 370, 314, 3814, 3205, 3787, 12, 314, 570, 365, 12155, 199, 475, 282, 6902, 570, 436, 4465, 1072, 365, 23667, 370, 314, 1324, 570, 14, 199, 2765, 7704, 652, 3962, 370, 2218, 282, 2457, 626, 295, 16334, 2399, 1324, 570, 199, 262, 4192, 14, 221, 982, 314, 4252, 1423, 6902, 628, 21455, 3972, 3329, 4335, 365, 2597, 199, 11809, 12, 652, 9314, 314, 3329, 367, 314, 6902, 570, 12, 436, 314, 6902, 199, 493, 25803, 6818, 27, 701, 849, 12, 314, 3329, 365, 3680, 27162, 2, 436, 652, 365, 199, 6062, 1380, 314, 1072, 570, 365, 6876, 14, 221, 1010, 13, 2778, 14545, 365, 199, 7011, 1380, 4465, 1324, 365, 1586, 14, 221, 5787, 710, 1453, 4514, 199, 9105, 440, 1736, 367, 14282, 13, 32735, 1695, 11, 19, 10036, 83, 14, 199, 199, 25635, 26, 642, 859, 365, 625, 21839, 1373, 402, 314, 26200, 15217, 402, 199, 6338, 7031, 5579, 402, 1324, 2385, 14, 221, 5612, 422, 1589, 2003, 12, 282, 16474, 199, 7625, 13, 384, 965, 2757, 15884, 701, 1808, 1586, 1278, 8, 19146, 9, 3140, 402, 199, 6407, 1252, 221, 437, 892, 4252, 1423, 12, 17080, 29, 46, 12, 365, 3451, 641, 314, 199, 1210, 342, 805, 436, 314, 3814, 3205, 342, 1021, 370, 4278, 314, 849, 199, 2738, 1568, 14, 199, 199, 13933, 18558, 32113, 26, 199, 199, 13, 2716, 12733, 1423, 6661, 199, 13, 365, 16623, 342, 199, 13, 1586, 1062, 1586, 8, 890, 395, 2755, 1586, 1278, 342, 199, 199, 624, 199, 199, 646, 984, 12, 747, 199, 199, 363, 452, 363, 275, 2097, 1210, 401, 298, 1600, 401, 298, 2184, 493, 401, 298, 1501, 401, 298, 3469, 401, 298, 493, 3469, 401, 1779, 298, 374, 2246, 604, 401, 298, 374, 6626, 401, 298, 1173, 3205, 937, 199, 199, 63, 929, 275, 488, 199, 199, 3472, 63, 21323, 4305, 275, 1695, 10, 7727, 199, 199, 318, 1324, 8, 1725, 29, 403, 12, 16304, 29, 797, 12, 6902, 8772, 17080, 29, 16, 12, 881, 818, 628, 82, 401, 1551, 3664, 29, 403, 304, 272, 408, 1210, 8, 1725, 29, 403, 12, 16304, 29, 797, 12, 6902, 8772, 17080, 29, 16, 12, 971, 199, 632, 628, 82, 401, 1551, 3664, 29, 403, 9, 339, 2790, 376, 1256, 402, 314, 3814, 3205, 1021, 14, 710, 1256, 911, 506, 1202, 272, 465, 2288, 1174, 367, 314, 3423, 402, 642, 859, 12, 436, 365, 2597, 2138, 272, 370, 675, 5309, 8494, 14, 710, 2633, 370, 642, 805, 911, 506, 3032, 272 ]
[ 4433, 1021, 370, 23661, 2218, 282, 4438, 1806, 1006, 4465, 1324, 1584, 14, 199, 199, 26876, 675, 365, 26, 339, 492, 570, 1210, 272, 367, 1004, 315, 570, 1210, 14, 1210, 837, 267, 2112, 8, 604, 9, 199, 199, 2765, 2740, 2335, 1806, 314, 2385, 402, 1006, 1584, 10532, 315, 984, 14, 3020, 59, 17, 8429, 199, 885, 316, 370, 984, 14, 6626, 340, 314, 769, 365, 2701, 14, 221, 982, 282, 1788, 365, 10791, 652, 199, 374, 2597, 8717, 701, 984, 14, 6626, 14, 221, 4005, 4165, 376, 13943, 769, 402, 199, 10309, 12, 986, 652, 465, 314, 1423, 370, 1324, 1252, 221, 437, 2849, 570, 536, 365, 199, 12344, 4370, 14, 199, 199, 13967, 1788, 1062, 5874, 342, 372, 314, 1788, 436, 25814, 1004, 199, 1955, 402, 314, 1004, 626, 965, 2951, 2757, 1586, 27, 570, 3469, 342, 2529, 2399, 199, 604, 1329, 315, 314, 1453, 570, 27, 365, 2246, 604, 342, 2529, 2549, 17963, 314, 199, 604, 2951, 1586, 365, 314, 1642, 1004, 402, 2399, 570, 27, 365, 6626, 342, 2529, 2549, 199, 15126, 314, 1004, 1990, 1586, 687, 984, 14, 6626, 14, 221, 6801, 2163, 493, 342, 27811, 314, 199, 1818, 570, 880, 626, 314, 2163, 8494, 911, 1586, 314, 1642, 1004, 687, 199, 1589, 2163, 570, 334, 692, 1263, 2736, 2385, 440, 1586, 687, 314, 570, 911, 440, 2338, 199, 475, 4751, 314, 25814, 1004, 2338, 27, 314, 1788, 365, 440, 2896, 5133, 199, 4399, 314, 1642, 1004, 402, 314, 2163, 570, 965, 2757, 1586, 14, 221, 6801, 4002, 342, 199, 1251, 874, 314, 3414, 14, 199, 199, 13569, 1263, 2385, 1172, 2757, 1586, 12, 1788, 342, 2529, 488, 436, 3865, 1004, 199, 10548, 787, 4697, 27, 2163, 493, 342, 965, 949, 7763, 14, 221, 12836, 1006, 2385, 1172, 2757, 199, 739, 12, 1788, 342, 436, 314, 1004, 1329, 3423, 372, 314, 1338, 199, 529, 24522, 370, 314, 2061, 1004, 1586, 27, 2163, 493, 342, 965, 949, 7763, 14, 199, 199, 2422, 1584, 787, 12123, 315, 1318, 818, 701, 849, 12, 1265, 883, 4278, 642, 701, 199, 6031, 314, 818, 2725, 370, 1324, 342, 503, 3814, 3205, 855, 826, 31261, 199, 3917, 376, 473, 15, 47, 1125, 11058, 5309, 13618, 503, 7664, 282, 570, 12, 314, 5925, 199, 1971, 365, 4915, 14, 199, 199, 3917, 984, 14, 6626, 365, 1202, 1655, 2419, 5403, 12, 314, 3499, 436, 9848, 675, 911, 199, 1107, 949, 2385, 12, 871, 25358, 367, 12777, 675, 12, 503, 340, 652, 965, 2757, 199, 10306, 590, 5305, 334, 69, 14, 71, 14, 1808, 984, 14, 6626, 14, 5507, 8, 16, 4992, 199, 199, 4699, 1584, 787, 12123, 436, 9939, 6876, 27, 314, 1454, 900, 3932, 199, 21566, 315, 314, 769, 402, 6203, 365, 4245, 461, 737, 1006, 365, 1380, 314, 199, 2019, 570, 12123, 365, 2701, 14, 199, 199, 7940, 365, 3962, 626, 314, 2061, 1004, 402, 282, 570, 3181, 1133, 1284, 315, 282, 8057, 199, 10856, 27, 4257, 2385, 787, 2138, 5893, 314, 8520, 199, 12210, 14, 199, 199, 2543, 3814, 3205, 365, 314, 4514, 27, 2399, 3102, 1788, 1062, 199, 3469, 1062, 570, 604, 1062, 365, 2246, 604, 1062, 365, 6626, 1062, 2163, 493, 342, 436, 4002, 342, 199, 989, 22720, 370, 314, 3423, 315, 314, 859, 14, 221, 1010, 10234, 652, 965, 282, 199, 6407, 342, 1083, 1314, 2529, 314, 2163, 1324, 1004, 12, 436, 282, 199, 363, 6095, 4533, 1083, 1314, 9031, 314, 3414, 5953, 14, 221, 710, 199, 4041, 1471, 506, 13810, 315, 22699, 23381, 1865, 27, 3414, 199, 2732, 436, 14441, 342, 3913, 506, 13492, 14, 199, 199, 7012, 315, 13, 2778, 14545, 26, 340, 314, 4252, 1423, 16304, 29, 17, 365, 199, 12070, 370, 1324, 342, 503, 370, 314, 3814, 3205, 3787, 12, 314, 570, 365, 12155, 199, 475, 282, 6902, 570, 436, 4465, 1072, 365, 23667, 370, 314, 1324, 570, 14, 199, 2765, 7704, 652, 3962, 370, 2218, 282, 2457, 626, 295, 16334, 2399, 1324, 570, 199, 262, 4192, 14, 221, 982, 314, 4252, 1423, 6902, 628, 21455, 3972, 3329, 4335, 365, 2597, 199, 11809, 12, 652, 9314, 314, 3329, 367, 314, 6902, 570, 12, 436, 314, 6902, 199, 493, 25803, 6818, 27, 701, 849, 12, 314, 3329, 365, 3680, 27162, 2, 436, 652, 365, 199, 6062, 1380, 314, 1072, 570, 365, 6876, 14, 221, 1010, 13, 2778, 14545, 365, 199, 7011, 1380, 4465, 1324, 365, 1586, 14, 221, 5787, 710, 1453, 4514, 199, 9105, 440, 1736, 367, 14282, 13, 32735, 1695, 11, 19, 10036, 83, 14, 199, 199, 25635, 26, 642, 859, 365, 625, 21839, 1373, 402, 314, 26200, 15217, 402, 199, 6338, 7031, 5579, 402, 1324, 2385, 14, 221, 5612, 422, 1589, 2003, 12, 282, 16474, 199, 7625, 13, 384, 965, 2757, 15884, 701, 1808, 1586, 1278, 8, 19146, 9, 3140, 402, 199, 6407, 1252, 221, 437, 892, 4252, 1423, 12, 17080, 29, 46, 12, 365, 3451, 641, 314, 199, 1210, 342, 805, 436, 314, 3814, 3205, 342, 1021, 370, 4278, 314, 849, 199, 2738, 1568, 14, 199, 199, 13933, 18558, 32113, 26, 199, 199, 13, 2716, 12733, 1423, 6661, 199, 13, 365, 16623, 342, 199, 13, 1586, 1062, 1586, 8, 890, 395, 2755, 1586, 1278, 342, 199, 199, 624, 199, 199, 646, 984, 12, 747, 199, 199, 363, 452, 363, 275, 2097, 1210, 401, 298, 1600, 401, 298, 2184, 493, 401, 298, 1501, 401, 298, 3469, 401, 298, 493, 3469, 401, 1779, 298, 374, 2246, 604, 401, 298, 374, 6626, 401, 298, 1173, 3205, 937, 199, 199, 63, 929, 275, 488, 199, 199, 3472, 63, 21323, 4305, 275, 1695, 10, 7727, 199, 199, 318, 1324, 8, 1725, 29, 403, 12, 16304, 29, 797, 12, 6902, 8772, 17080, 29, 16, 12, 881, 818, 628, 82, 401, 1551, 3664, 29, 403, 304, 272, 408, 1210, 8, 1725, 29, 403, 12, 16304, 29, 797, 12, 6902, 8772, 17080, 29, 16, 12, 971, 199, 632, 628, 82, 401, 1551, 3664, 29, 403, 9, 339, 2790, 376, 1256, 402, 314, 3814, 3205, 1021, 14, 710, 1256, 911, 506, 1202, 272, 465, 2288, 1174, 367, 314, 3423, 402, 642, 859, 12, 436, 365, 2597, 2138, 272, 370, 675, 5309, 8494, 14, 710, 2633, 370, 642, 805, 911, 506, 3032, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
infosiftr/openxenmanager
window_host.py
2
27126
# ----------------------------------------------------------------------- # OpenXenManager # # Copyright (C) 2009 Alberto Gonzalez Rodriguez alberto@pesadilla.org # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MER- # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ----------------------------------------------------------------------- #!/usr/bin/env python from window_host_nics import * from window_host_network import * from capabilities import capabilities_conf_text from threading import Thread from messages import messages_header import gtk class oxcWindowHost(oxcWindowHostNics, oxcWindowHostNetwork): """ Class to manage host tabs, host properties and host functions """ def on_btleavedomain_clicked(self, widget, data=None): """ Press "Leave Domain" on Users tab """ pass def on_btjoindomain_clicked(self, widget, data=None): """ Press "Join Domain" on Users tab """ pass def on_btadduser_clicked(self, widget, data=None): """ Press "Add user" on Users tab """ pass def on_btremoveuser_clicked(self, widget, data=None): """ Press "Remove user" on Users tab """ pass def on_btlogoutuser_clicked(self, widget, data=None): """ Press "Logout User" on Users tab """ pass def on_treeusers_cursor_changed(self, widget, data=None): """ Selected row in treeusers treeview """ pass def on_btchangerole_clicked(self, widget, data=None): """ Press "Join Domain" on Users tab """ pass def on_cancelfileexportmap_clicked(self, widget, data=None): """ Cancel dialog file export map to png """ self.builder.get_object("fileexportmap").hide() def on_acceptfileexportmap_clicked(self, widget, data=None): """ Accept dialog file export map to png """ filename = self.builder.get_object("fileexportmap").get_filename() pixbuf = gtk.gdk.Pixbuf( gtk.gdk.COLORSPACE_RGB, False, 8, 640, 480) pixmap = self.windowmap.widget.get_snapshot() pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, -1, -1) pixbuf.save(filename, 'png') self.builder.get_object("fileexportmap").hide() def on_btexportmap_clicked(self, widget, data=None): """ Function to export current map to PNG file """ self.builder.get_object("fileexportmap").set_current_name(self.selected_name + ".png") self.builder.get_object("fileexportmap").show() def on_check_map_options(self, widget, data=None): """ Function called when you check or uncheck a map option """ if not "maps" in self.config: self.config["maps"] = {} self.config["maps"][gtk.Buildable.get_name(widget)] = str(widget.get_active()) self.config.write() self.update_maps() def on_acceptfilenewupdate_clicked(self, widget, data=None): # When you press accept "new update" file chooser filename = self.builder.get_object("filenewupdate").get_filename() Thread(target=self.xc_servers[self.selected_host].upload_patch, \ args=(self.selected_ref, filename)).start() self.builder.get_object("updatemanager").hide() self.builder.get_object("filenewupdate").hide() def on_cancelfilenewupdate_clicked(self, widget, data=None): # When you press cancel "new update" file chooser self.builder.get_object("filenewupdate").hide() def on_btuploadnewupdate_clicked(self, widget, data=None): # When you press "Upload new update" (patch) self.builder.get_object("filterfilenewupdate").add_pattern("*.xsupdate") self.builder.get_object("filenewupdate").show() def on_btremoveupdate_clicked(self, wiget, data=None): # When you press "remove" (patch) treeupdates = self.builder.get_object("treeupdates") iter = treeupdates.get_selection().get_selected()[1] if iter: listupdates = self.builder.get_object("listupdates") patch_ref = listupdates.get_value(iter, 0) self.xc_servers[self.selected_host].remove_patch(self.selected_ref, patch_ref) self.builder.get_object("updatemanager").hide() def on_btapplypatch_clicked(self, widget, data=None): # When you press "apply patch" treeupdates = self.builder.get_object("treeupdates") treeupdatestatus = self.builder.get_object("treeupdatestatus") iter = treeupdates.get_selection().get_selected()[1] if iter: listupdates = self.builder.get_object("listupdates") patch_ref = listupdates.get_value(iter, 0) iter = treeupdatestatus.get_selection().get_selected()[1] if iter: listupdatestatus = self.builder.get_object("listupdatestatus") host_ref = listupdatestatus.get_value(iter, 0) self.xc_servers[self.selected_host].apply_patch(host_ref, patch_ref) self.builder.get_object("updatemanager").hide() def on_treeupdatestatus_cursor_changed(self, widget, data=None): # When you select a host in update manager iter = widget.get_selection().get_selected()[1] if iter: listupdatestatus = self.builder.get_object("listupdatestatus") self.builder.get_object("btapplypatch").set_sensitive(listupdatestatus.get_value(iter, 2)) def on_treeupdates_cursor_changed(self, widget, data=None): # When you select a patch iter = widget.get_selection().get_selected()[1] if iter: listupdates = self.builder.get_object("listupdates") ref = listupdates.get_value(iter, 0) name = self.xc_servers[self.selected_host].all_pool_patch[ref]['name_label'] desc = self.xc_servers[self.selected_host].all_pool_patch[ref]['name_description'] version = self.xc_servers[self.selected_host].all_pool_patch[ref]['version'] guidance = self.xc_servers[self.selected_host].all_pool_patch[ref]['after_apply_guidance'] self.builder.get_object("lblupdatename").set_label(name) self.builder.get_object("lblupdatedesc").set_label(desc) self.builder.get_object("lblupdateversion").set_label(version) guidance_text = "" for guid in guidance: if guid in messages_header: guidance_text += messages_header[guid] + "\n" else: guidance_text += guid self.builder.get_object("lblupdateguidance").set_label(guidance_text) host_patches = self.xc_servers[self.selected_host].all_pool_patch[ref]["host_patches"] self.builder.get_object("btremoveupdate").set_sensitive(len(host_patches) == 0) listupdatestatus = self.builder.get_object("listupdatestatus") listupdatestatus.clear() for host in self.xc_servers[self.selected_host].all_hosts.keys(): name = self.xc_servers[self.selected_host].all_hosts[host]['name_label'] found = False for host_patch in host_patches: host2 = self.xc_servers[self.selected_host].all_host_patch[host_patch]['host'] if host == host2: found = True timestamp = self.xc_servers[self.selected_host].all_host_patch[host_patch]['timestamp_applied'] patch_text = "<span foreground='green'>%s - applied (%s)</span>" % (name, \ self.xc_servers[self.selected_host].format_date(timestamp)) listupdatestatus.append([host, patch_text, False]) if not found: patch_text = "<span foreground='red'>%s - not applied</span>" % (name) listupdatestatus.append([host, patch_text, True]) def on_closeupdatemanager_clicked(self, widget, data=None): """ Function called when you close "update manager" window """ self.builder.get_object("updatemanager").hide() def on_txttemplatesearch_changed(self, widget, data=None): """ Function called when you type something on search template list (newvm) """ self.modelfiltertpl.refilter() def update_report_total_size_time(self): """ Update the total size and the total time on report status window """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") totalsize, totaltime = 0, 0 for i in range(0, listreport.__len__()): iter = listreport.get_iter((i,)) if listreport.get_value(iter, 1): totalsize += listreport.get_value(iter, 7) totaltime += listreport.get_value(iter, 8) self.builder.get_object("lblreportotalsize").set_label("< %s" % (self.convert_bytes(totalsize))) self.builder.get_object("lblreportotaltime").set_label("< %d minutes" % (int(totaltime)/60)) def on_cellrenderertoggle1_toggled(self, widget, data=None): """ Function called when you change the state of checkbox on report tree """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") iter = treereport.get_selection().get_selected()[1] if iter: listreport.set_value(iter, 1, not widget.get_active()) self.update_report_total_size_time() def on_treereport_cursor_changed(self, widget, data=None): """ Function called when you select a item on report """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") iter = treereport.get_selection().get_selected()[1] if iter: self.builder.get_object("lblreportdesc").set_label(listreport.get_value(iter, 4)) self.builder.get_object("lblreportsize").set_label(listreport.get_value(iter, 5)) self.builder.get_object("lblreporttime").set_label(listreport.get_value(iter, 6) + " seconds") conf = listreport.get_value(iter, 9) self.builder.get_object("lblreportconf").set_label(capabilities_conf_text[conf-1]) def on_acceptstatusreport_clicked(self, widget, data=None): """ Function called when you accept status report dialog """ from time import strftime self.builder.get_object("filesavereport").set_current_name(strftime("status-report-%Y-%m-%d-%H-%M-%S.tar")) self.builder.get_object("filesavereport").show() self.builder.get_object("statusreport").hide() def on_acceptfilereport_clicked(self, widget, data=None): """ Function called when you accept save report file chooser dialog """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") totalsize, totaltime = 0, 0 refs = [] for i in range(0, listreport.__len__()): iter = listreport.get_iter((i,)) if listreport.get_value(iter, 1): refs.append(listreport.get_value(iter, 0)) destination = self.builder.get_object("filesavereport").get_filename() Thread(target=self.xc_servers[self.selected_host].host_download_status_report, \ args=(self.selected_ref, ",".join(refs), destination, self.selected_name)).start() self.builder.get_object("filesavereport").hide() def on_cancelfilereport_clicked(self, widget, data=None): """ Function called when you cancel save report file chooser dialog """ self.builder.get_object("filesavereport").hide() def on_cancelstatusreport_clicked(self, widget, data=None): """ Function called when you cancel status report dialog """ self.builder.get_object("statusreport").hide() def on_clearallstatusreport_clicked(self, widget, data=None): """ Uncheck all checkbox for each status report """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") for i in range(0, listreport.__len__()): iter = listreport.get_iter((i,)) listreport.set_value(iter, 1, False) self.update_report_total_size_time() def on_selectallstatusreport_clicked(self, widget, data=None): """ Check all checkbox for each status report """ treereport = self.builder.get_object("treereport") listreport = self.builder.get_object("listreport") for i in range(0, listreport.__len__()): iter = listreport.get_iter((i,)) listreport.set_value(iter, 1, True) self.update_report_total_size_time() def on_txtcurrentpw_changed(self, widget, data=None): """ Function called when you change text on "current password", "type new password" or "re-enter new password" On change server password window """ # If some textfield is empty, then disable button if len(self.builder.get_object("txtcurrentpw").get_text()) and \ len(self.builder.get_object("txtnewpw").get_text()) and \ len(self.builder.get_object("txtrenewpw").get_text()) and \ (self.builder.get_object("txtnewpw").get_text() == self.builder.get_object("txtrenewpw").get_text()): self.builder.get_object("acceptchangepassword").set_sensitive(True) else: self.builder.get_object("acceptchangepassword").set_sensitive(False) def on_cancelchangepassword_clicked(self, widget, data=None): """ Function called when you press "Cancel" button on "Change Server Password" window """ self.builder.get_object("changepassword").hide() def on_acceptchangepassword_clicked(self, widget, data=None): """ Function called when you press "OK" button on "Change Server Password" window """ old = self.xc_servers[self.selected_host].password typed = self.builder.get_object("txtcurrentpw").get_text() if typed != old: self.builder.get_object("lblwrongpw").show() else: new = self.builder.get_object("txtnewpw").get_text() self.xc_servers[self.selected_host].change_server_password(old, new) self.builder.get_object("changepassword").hide() def update_tab_host_nics(self): """ Function called to fill host nics """ if self.treeview.get_cursor()[1]: listhostnics = self.builder.get_object("listhostnics") host = self.selected_host # Fill list "listhostnics" self.xc_servers[host].fill_host_nics(self.selected_ref, \ listhostnics) treehostnics = self.builder.get_object("treehostnics") # Select the first as default treehostnics.set_cursor((0,), treehostnics.get_column(0)) treehostnics.get_selection().select_path((0, )) iter = listhostnics.get_iter((0, )) # Get the reference of first selected ref = self.builder.get_object("listhostnics").get_value(iter, 8) nic_bond_master_of = self.xc_servers[self.selected_host].all_pif[ref]['bond_master_of'] # If is already on a bond if len(nic_bond_master_of): # Enable remove bond button self.builder.get_object("bthostnicremove").set_sensitive(True) else: # Disable remove bond button self.builder.get_object("bthostnicremove").set_sensitive(False) def update_tab_host_network(self): """ Function called to fill host networks """ if self.treeview.get_cursor()[1]: listhostnetwork= self.builder.get_object("listhostnetwork") host = self.selected_host # Fill list "listhostnetwork" self.xc_servers[host].fill_host_network(self.selected_ref, \ listhostnetwork) treehostnetwork = self.builder.get_object("treehostnetwork") # Select the first as default treehostnetwork.set_cursor((0,), treehostnetwork.get_column(0)) treehostnetwork.get_selection().select_path((0, 0)) iter = listhostnetwork.get_iter((0,0)) # Get the reference of first selected ref = self.builder.get_object("listhostnetwork").get_value(iter, 7) # Get the pifs from selected network network_pifs = self.xc_servers[self.selected_host].all_network[ref]['PIFs'] # Enable "remove network" by default self.builder.get_object("bthostnetworkremove").set_sensitive(True) for pif in network_pifs: # If is physical then disable it if self.xc_servers[self.selected_host].all_pif[pif]['physical'] == True: self.builder.get_object("bthostnetworkremove").set_sensitive(False) break def on_radiomgmtipmanual_toggled(self, widget, data=None): """ On "management interface" radio "manual ip" selected """ self.builder.get_object("txtmgmtip").set_sensitive(widget.get_active()) self.builder.get_object("txtmgmtmask").set_sensitive(widget.get_active()) self.builder.get_object("txtmgmtgw").set_sensitive(widget.get_active()) def on_radiomgmtdnsmanual_toggled(self, widget, data=None): """ On "management interface" radio "manual dns" selected """ self.builder.get_object("txtmgmtdns1").set_sensitive(widget.get_active()) self.builder.get_object("txtmgmtdns2").set_sensitive(widget.get_active()) def on_cancelmgmtinterface_clicked(self, widget, data=None): """ On "cancel" button pressed on "management interface" """ self.builder.get_object("mgmtinterface").hide() def on_checkpoolserver_toggled(self, widget, data=None): """ Function called on "new pool" window, when you check a server to join to pool """ listpoolvms = self.builder.get_object("listpoolvms") iter = listpoolvms.get_iter((int(data),)) # Field 4 (beginning on 0) contains if check could be modified if listpoolvms.get_value(iter, 4): # widget.get_active() contains last state: enabled o disabled listpoolvms.set(iter, 2, not widget.get_active()) def on_cancelnewpool_clicked(self, widget, data=None): """ On "cancel" button pressed on "new pool" """ self.builder.get_object("newpool").hide() def on_acceptnewpool_clicked(self, widget, data=None): """ On "accept" button pressed on "new pool" """ listpoolvms = self.builder.get_object("listpoolvms") listpoolmaster = self.builder.get_object("listpoolmaster") combopoolmaster = self.builder.get_object("combopoolmaster") # If a master pool is selected.. if combopoolmaster.get_active_iter(): name = self.builder.get_object("txtpoolname").get_text() desc = self.builder.get_object("txtpooldesc").get_text() # Get the reference the selected iter ref = listpoolmaster.get_value(combopoolmaster.get_active_iter(), 0) # Create a pool self.xc_servers[ref].create_pool(name, desc) # For each server on treeview for i in range(0, listpoolvms.__len__()): iter = listpoolvms.get_iter((int(i),)) # If is checked if listpoolvms.get_value(iter, 2): host = listpoolvms.get_value(iter, 0) # And is not "Master" if listpoolvms.get_value(iter, 3) == "": # Join to pool self.xc_servers[host].join_pool(self.xc_servers[ref].host, self.xc_servers[ref].user, self.xc_servers[ref].password) self.builder.get_object("newpool").hide() def on_combopoolmaster_changed(self, widget, data=None): # FIXME: active the selected on treeview and set as "Master" listpoolvms = self.builder.get_object("listpoolvms") listpoolmaster = self.builder.get_object("listpoolmaster") combopoolmaster = self.builder.get_object("combopoolmaster") if widget.get_active_iter(): ref = listpoolmaster.get_value(widget.get_active_iter(),0) for i in range(0, listpoolvms.__len__()): iter = listpoolvms.get_iter((int(i),)) if listpoolvms.get_value(iter, 3) == "Master": listpoolvms.set(iter, 3, "", 2, False, 4, True) if listpoolvms.get_value(iter, 0) == ref: listpoolvms.set(iter, 3, "Master", 2, True, 4, False) def on_canceldialogreconfigure_clicked(self, widget, data=None): """ On "cancel" button pressed on confirmation of "management interface" """ self.builder.get_object("dialogreconfigure").hide() def on_closewarninglicense_clicked(self, widget, data=None): """ On "close" button pressed on warning alert """ self.builder.get_object("warninglicense").hide() def on_accepthostdmesg_clicked(self, widget, data=None): """ On "accept" button pressed on dmesg dialog """ self.builder.get_object("hostdmesg").hide() def on_acceptdialogreconfigure_clicked(self, widget, data=None): """ On "accept" button pressed on confirmation dialog to reconfigure interface """ listmgmtinterfaces = self.builder.get_object("listmgmtinterfaces") treemgmtinterfaces = self.builder.get_object("treemgmtinterfaces") selection = treemgmtinterfaces.get_selection() pif_ref = listmgmtinterfaces.get_value(selection.get_selected()[1],0) combomgmtnetworks = self.builder.get_object("combomgmtnetworks") listmgmtnetworks = self.builder.get_object("listmgmtnetworks") iter = combomgmtnetworks.get_active_iter() # Get selected network and rest of elements network_ref = listmgmtnetworks.get_value(iter, 0) ip = self.builder.get_object("txtmgmtip").get_text() mask = self.builder.get_object("txtmgmtmask").get_text() gw = self.builder.get_object("txtmgmtgw").get_text() dns1 = self.builder.get_object("txtmgmtdns1").get_text() dns2 = self.builder.get_object("txtmgmtdns2").get_text() radiomgmtipdhcp = self.builder.get_object("radiomgmtipdhcp") radiomgmtdnsdhcp = self.builder.get_object("radiomgmtdnsdhcp") if radiomgmtdnsdhcp.get_active(): dns = "" else: dns = dns1 + "," + dns2 if radiomgmtipdhcp.get_active(): configuration_mode = "DHCP" else: configuration_mode = "Static" # Call to reconfigure interface with specified configuration self.xc_servers[self.selected_host].reconfigure_pif(pif_ref, configuration_mode, ip, mask, gw, dns, self.selected_ref) # Hide both windows: management window and confirmation self.builder.get_object("dialogreconfigure").hide() self.builder.get_object("mgmtinterface").hide() def on_acceptmgmtinterface_clicked(self, widget, data=None): """ On "accept" button pressed on confirmation dialog to reconfigure interface change is a variable, if is False doesn't change anything, if is True show reconfigure window confirmation """ listmgmtinterfaces = self.builder.get_object("listmgmtinterfaces") treemgmtinterfaces = self.builder.get_object("treemgmtinterfaces") # Get selected pif selection = treemgmtinterfaces.get_selection() pif_ref = listmgmtinterfaces.get_value(selection.get_selected()[1],0) combomgmtnetworks = self.builder.get_object("combomgmtnetworks") listmgmtnetworks = self.builder.get_object("listmgmtnetworks") # Get selected pif info pif = self.xc_servers[self.selected_host].all_pif[pif_ref] iter = combomgmtnetworks.get_active_iter() # Get selected network_ref pif = self.xc_servers[self.selected_host].all_pif[pif_ref] network_ref = listmgmtnetworks.get_value(iter, 0) if pif['network'] != network_ref: change = True radiomgmtipmanual = self.builder.get_object("radiomgmtipmanual") radiomgmtipdhcp = self.builder.get_object("radiomgmtipdhcp") radiomgmtdnsmanual = self.builder.get_object("radiomgmtdnsmanual") radiomgmtdnsdhcp = self.builder.get_object("radiomgmtdnsdhcp") ip = self.builder.get_object("txtmgmtip").get_text() mask = self.builder.get_object("txtmgmtmask").get_text() gw = self.builder.get_object("txtmgmtgw").get_text() dns1 = self.builder.get_object("txtmgmtdns1").get_text() dns2 = self.builder.get_object("txtmgmtdns2").get_text() change = False if pif['ip_configuration_mode'] == "DHCP" and radiomgmtipmanual.get_active(): change = True if pif['ip_configuration_mode'] != "DHCP" and radiomgmtipdhcp.get_active(): change = True if ip != pif['IP'] or mask != pif['netmask'] or gw != pif['gateway']: change = True if pif['DNS'] == "" and radiomgmtdnsmanual.get_active(): change = True if pif['DNS'] != "" and radiomgmtdnsdhcp.get_active(): change = True if dns1 + "," + dns2 != pif['DNS']: change = True # If some parameter was changed, show confirmation dialog, if not hide magement interface window if change: self.builder.get_object("dialogreconfigure").show() else: self.builder.get_object("mgmtinterface").hide()
gpl-2.0
[ 3, 5620, 12797, 199, 3, 3232, 30643, 2988, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4580, 605, 475, 598, 265, 90, 1895, 90, 820, 364, 322, 71, 310, 90, 741, 605, 475, 32, 321, 2231, 22429, 416, 14, 1308, 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, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 603, 540, 13, 199, 3, 6624, 1441, 2477, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 3, 199, 3, 5620, 12797, 199, 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 4353, 63, 1102, 63, 28004, 492, 627, 221, 199, 504, 4353, 63, 1102, 63, 1200, 492, 627, 221, 199, 504, 14918, 492, 14918, 63, 2190, 63, 505, 199, 504, 5796, 492, 11086, 199, 504, 3788, 492, 3788, 63, 1291, 199, 646, 8116, 199, 199, 533, 312, 1812, 4301, 4965, 8, 79, 1812, 4301, 4965, 46, 2932, 12, 312, 1812, 4301, 4965, 4491, 304, 272, 408, 272, 8089, 370, 9635, 1591, 12187, 12, 1591, 4382, 436, 1591, 3423, 5591, 408, 339, 347, 641, 63, 66, 1118, 4292, 79, 973, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 23679, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 743, 688, 79, 973, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 13005, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 525, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 1123, 922, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 2168, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 5587, 922, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 11646, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 2445, 548, 2876, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 2350, 3707, 63, 3937, 63, 2489, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 3240, 2820, 1962, 315, 3123, 3707, 3123, 1345, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 335, 621, 3478, 274, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 13005, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 67, 554, 12059, 3790, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 28374, 9592, 570, 4843, 2341, 370, 25296, 267, 408, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 8191, 342, 5591, 347, 641, 63, 5694, 493, 3790, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 15506, 9592, 570, 4843, 2341, 370, 25296, 267, 408, 267, 1788, 275, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 362, 63, 1501, 342, 267, 25505, 1436, 275, 8116, 14, 24697, 14, 25747, 1436, 8, 8116, 14, 24697, 14, 25671, 48, 4121, 63, 12067, 12, 756, 12, 1695, 12, 5049, 16, 12, 29504, 9, 267, 29876, 275, 291, 14, 3806, 1130, 14, 3440, 14, 362, 63, 4753, 342, 267, 25505, 1436, 14, 362, 63, 504, 63, 5485, 461, 8, 6644, 1130, 12, 29876, 14, 362, 63, 2326, 1130, 1062, 378, 12, 378, 12, 378, 12, 378, 12, 446, 17, 12, 446, 17, 9, 267, 25505, 1436, 14, 2117, 8, 1501, 12, 283, 4524, 358, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 8191, 342, 221, 2286, 347, 641, 63, 66, 3858, 719, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 6801, 370, 4843, 1453, 2341, 370, 26951, 570, 267, 408, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 409, 63, 1818, 63, 354, 8, 277, 14, 5511, 63, 354, 435, 3680, 4524, 531, 4960, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 2384, 342, 5591, 347, 641, 63, 1074, 63, 1130, 63, 1419, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 6801, 2797, 1380, 1265, 1104, 503, 625, 1074, 282, 2341, 945, 267, 408, 267, 340, 440, 298, 8919, 2, 315, 291, 14, 888, 26, 1467, 291, 14, 888, 905, 8919, 937, 275, 1052, 267, 291, 14, 888, 905, 8919, 9210, 12275, 14, 3425, 461, 14, 362, 63, 354, 8, 3440, 1874, 275, 620, 8, 3440, 14, 362, 63, 2682, 1012, 267, 291, 14, 888, 14, 952, 342, 267, 291, 14, 873, 63, 8919, 342, 339, 347, 641, 63, 5694, 493, 1222, 873, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 327, 3979, 1265, 15105, 4729, 298, 1222, 1678, 2, 570, 2468, 13041, 267, 1788, 275, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 1222, 873, 3471, 362, 63, 1501, 342, 267, 11086, 8, 1375, 29, 277, 14, 1812, 63, 5871, 59, 277, 14, 5511, 63, 1102, 1055, 5064, 63, 2068, 12, 971, 355, 1249, 2687, 277, 14, 5511, 63, 1121, 12, 1788, 4992, 928, 342, 398, 291, 14, 5649, 14, 362, 63, 785, 480, 873, 2609, 3471, 8191, 342, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 1222 ]
[ 5620, 12797, 199, 3, 3232, 30643, 2988, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4580, 605, 475, 598, 265, 90, 1895, 90, 820, 364, 322, 71, 310, 90, 741, 605, 475, 32, 321, 2231, 22429, 416, 14, 1308, 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, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 603, 540, 13, 199, 3, 6624, 1441, 2477, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 3, 199, 3, 5620, 12797, 199, 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 4353, 63, 1102, 63, 28004, 492, 627, 221, 199, 504, 4353, 63, 1102, 63, 1200, 492, 627, 221, 199, 504, 14918, 492, 14918, 63, 2190, 63, 505, 199, 504, 5796, 492, 11086, 199, 504, 3788, 492, 3788, 63, 1291, 199, 646, 8116, 199, 199, 533, 312, 1812, 4301, 4965, 8, 79, 1812, 4301, 4965, 46, 2932, 12, 312, 1812, 4301, 4965, 4491, 304, 272, 408, 272, 8089, 370, 9635, 1591, 12187, 12, 1591, 4382, 436, 1591, 3423, 5591, 408, 339, 347, 641, 63, 66, 1118, 4292, 79, 973, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 23679, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 743, 688, 79, 973, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 13005, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 525, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 1123, 922, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 2168, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 5587, 922, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 11646, 751, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 2445, 548, 2876, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 2350, 3707, 63, 3937, 63, 2489, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 3240, 2820, 1962, 315, 3123, 3707, 3123, 1345, 267, 408, 267, 986, 339, 347, 641, 63, 13061, 335, 621, 3478, 274, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 23583, 298, 13005, 14061, 2, 641, 20123, 5174, 267, 408, 267, 986, 339, 347, 641, 63, 67, 554, 12059, 3790, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 28374, 9592, 570, 4843, 2341, 370, 25296, 267, 408, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 8191, 342, 5591, 347, 641, 63, 5694, 493, 3790, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 15506, 9592, 570, 4843, 2341, 370, 25296, 267, 408, 267, 1788, 275, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 362, 63, 1501, 342, 267, 25505, 1436, 275, 8116, 14, 24697, 14, 25747, 1436, 8, 8116, 14, 24697, 14, 25671, 48, 4121, 63, 12067, 12, 756, 12, 1695, 12, 5049, 16, 12, 29504, 9, 267, 29876, 275, 291, 14, 3806, 1130, 14, 3440, 14, 362, 63, 4753, 342, 267, 25505, 1436, 14, 362, 63, 504, 63, 5485, 461, 8, 6644, 1130, 12, 29876, 14, 362, 63, 2326, 1130, 1062, 378, 12, 378, 12, 378, 12, 378, 12, 446, 17, 12, 446, 17, 9, 267, 25505, 1436, 14, 2117, 8, 1501, 12, 283, 4524, 358, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 8191, 342, 221, 2286, 347, 641, 63, 66, 3858, 719, 1130, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 6801, 370, 4843, 1453, 2341, 370, 26951, 570, 267, 408, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 409, 63, 1818, 63, 354, 8, 277, 14, 5511, 63, 354, 435, 3680, 4524, 531, 4960, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 3790, 1130, 3471, 2384, 342, 5591, 347, 641, 63, 1074, 63, 1130, 63, 1419, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 408, 267, 6801, 2797, 1380, 1265, 1104, 503, 625, 1074, 282, 2341, 945, 267, 408, 267, 340, 440, 298, 8919, 2, 315, 291, 14, 888, 26, 1467, 291, 14, 888, 905, 8919, 937, 275, 1052, 267, 291, 14, 888, 905, 8919, 9210, 12275, 14, 3425, 461, 14, 362, 63, 354, 8, 3440, 1874, 275, 620, 8, 3440, 14, 362, 63, 2682, 1012, 267, 291, 14, 888, 14, 952, 342, 267, 291, 14, 873, 63, 8919, 342, 339, 347, 641, 63, 5694, 493, 1222, 873, 63, 11276, 8, 277, 12, 3938, 12, 666, 29, 403, 304, 267, 327, 3979, 1265, 15105, 4729, 298, 1222, 1678, 2, 570, 2468, 13041, 267, 1788, 275, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 1222, 873, 3471, 362, 63, 1501, 342, 267, 11086, 8, 1375, 29, 277, 14, 1812, 63, 5871, 59, 277, 14, 5511, 63, 1102, 1055, 5064, 63, 2068, 12, 971, 355, 1249, 2687, 277, 14, 5511, 63, 1121, 12, 1788, 4992, 928, 342, 398, 291, 14, 5649, 14, 362, 63, 785, 480, 873, 2609, 3471, 8191, 342, 267, 291, 14, 5649, 14, 362, 63, 785, 480, 493, 1222, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mahendra-r/edx-platform
common/test/acceptance/tests/video/test_video_events.py
50
13897
"""Ensure videos emit proper events""" import datetime import json import ddt import unittest from ..helpers import EventsTestMixin from .test_video_module import VideoBaseTest from ...pages.lms.video.video import _parse_time_str from openedx.core.lib.tests.assertions.events import assert_event_matches, assert_events_equal from opaque_keys.edx.keys import UsageKey, CourseKey class VideoEventsTestMixin(EventsTestMixin, VideoBaseTest): """ Useful helper methods to test video player event emission. """ def assert_payload_contains_ids(self, video_event): """ Video events should all contain "id" and "code" attributes in their payload. This function asserts that those fields are present and have correct values. """ video_descriptors = self.course_fixture.get_nested_xblocks(category='video') video_desc = video_descriptors[0] video_locator = UsageKey.from_string(video_desc.locator) expected_event = { 'event': { 'id': video_locator.html_id(), 'code': '3_yD_cEKoCk' } } self.assert_events_match([expected_event], [video_event]) def assert_valid_control_event_at_time(self, video_event, time_in_seconds): """ Video control events should contain valid ID fields and a valid "currentTime" field. This function asserts that those fields are present and have correct values. """ current_time = json.loads(video_event['event'])['currentTime'] self.assertAlmostEqual(current_time, time_in_seconds, delta=1) def assert_field_type(self, event_dict, field, field_type): """Assert that a particular `field` in the `event_dict` has a particular type""" self.assertIn(field, event_dict, '{0} not found in the root of the event'.format(field)) self.assertTrue( isinstance(event_dict[field], field_type), 'Expected "{key}" to be a "{field_type}", but it has the value "{value}" of type "{t}"'.format( key=field, value=event_dict[field], t=type(event_dict[field]), field_type=field_type, ) ) class VideoEventsTest(VideoEventsTestMixin): """ Test video player event emission """ @unittest.skip('AN-5867') def test_video_control_events(self): """ Scenario: Video component is rendered in the LMS in Youtube mode without HTML5 sources Given the course has a Video component in "Youtube" mode And I play the video And I watch 5 seconds of it And I pause the video Then a "load_video" event is emitted And a "play_video" event is emitted And a "pause_video" event is emitted """ def is_video_event(event): """Filter out anything other than the video events of interest""" return event['event_type'] in ('load_video', 'play_video', 'pause_video') captured_events = [] with self.capture_events(is_video_event, number_of_matches=3, captured_events=captured_events): self.navigate_to_video() self.video.click_player_button('play') self.video.wait_for_position('0:05') self.video.click_player_button('pause') for idx, video_event in enumerate(captured_events): self.assert_payload_contains_ids(video_event) if idx == 0: assert_event_matches({'event_type': 'load_video'}, video_event) elif idx == 1: assert_event_matches({'event_type': 'play_video'}, video_event) self.assert_valid_control_event_at_time(video_event, 0) elif idx == 2: assert_event_matches({'event_type': 'pause_video'}, video_event) self.assert_valid_control_event_at_time(video_event, self.video.seconds) def test_strict_event_format(self): """ This test makes a very strong assertion about the fields present in events. The goal of it is to ensure that new fields are not added to all events mistakenly. It should be the only existing test that is updated when new top level fields are added to all events. """ captured_events = [] with self.capture_events(lambda e: e['event_type'] == 'load_video', captured_events=captured_events): self.navigate_to_video() load_video_event = captured_events[0] # Validate the event payload self.assert_payload_contains_ids(load_video_event) # We cannot predict the value of these fields so we make weaker assertions about them dynamic_string_fields = ( 'accept_language', 'agent', 'host', 'ip', 'event', 'session' ) for field in dynamic_string_fields: self.assert_field_type(load_video_event, field, basestring) self.assertIn(field, load_video_event, '{0} not found in the root of the event'.format(field)) del load_video_event[field] # A weak assertion for the timestamp as well self.assert_field_type(load_video_event, 'time', datetime.datetime) del load_video_event['time'] # Note that all unpredictable fields have been deleted from the event at this point course_key = CourseKey.from_string(self.course_id) static_fields_pattern = { 'context': { 'course_id': unicode(course_key), 'org_id': course_key.org, 'path': '/event', 'user_id': self.user_info['user_id'] }, 'event_source': 'browser', 'event_type': 'load_video', 'username': self.user_info['username'], 'page': self.browser.current_url, 'referer': self.browser.current_url, 'name': 'load_video', } assert_events_equal(static_fields_pattern, load_video_event) @ddt.ddt class VideoBumperEventsTest(VideoEventsTestMixin): """ Test bumper video event emission """ # helper methods def watch_video_and_skip(self): """ Wait 5 seconds and press "skip" button. """ self.video.wait_for_position('0:05') self.video.click_player_button('skip_bumper') def watch_video_and_dismiss(self): """ Wait 5 seconds and press "do not show again" button. """ self.video.wait_for_position('0:05') self.video.click_player_button('do_not_show_again') def wait_for_state(self, state='finished'): """ Wait until video will be in given state. Finished state means that video is played to the end. """ self.video.wait_for_state(state) def add_bumper(self): """ Add video bumper to the course. """ additional_data = { u'video_bumper': { u'value': { "transcripts": {}, "video_id": "video_001" } } } self.course_fixture.add_advanced_settings(additional_data) @ddt.data( ('edx.video.bumper.skipped', watch_video_and_skip), ('edx.video.bumper.dismissed', watch_video_and_dismiss), ('edx.video.bumper.stopped', wait_for_state) ) @ddt.unpack def test_video_control_events(self, event_type, action): """ Scenario: Video component with pre-roll emits events correctly Given the course has a Video component in "Youtube" mode with pre-roll enabled And I click on the video poster And the pre-roll video start playing And I watch (5 seconds/5 seconds/to the end of) it And I click (skip/do not show again) video button Then a "edx.video.bumper.loaded" event is emitted And a "edx.video.bumper.played" event is emitted And a "edx.video.bumper.skipped/dismissed/stopped" event is emitted And a "load_video" event is emitted And a "play_video" event is emitted """ def is_video_event(event): """Filter out anything other than the video events of interest""" return event['event_type'] in ( 'edx.video.bumper.loaded', 'edx.video.bumper.played', 'edx.video.bumper.skipped', 'edx.video.bumper.dismissed', 'edx.video.bumper.stopped', 'load_video', 'play_video', 'pause_video' ) and self.video.state != 'buffering' captured_events = [] self.add_bumper() with self.capture_events(is_video_event, number_of_matches=5, captured_events=captured_events): self.navigate_to_video_no_render() self.video.click_on_poster() self.video.wait_for_video_bumper_render() sources, duration = self.video.sources[0], self.video.duration action(self) # Filter subsequent events that appear due to bufferisation: edx.video.bumper.played # As bumper does not emit pause event, we filter subsequent edx.video.bumper.played events from # the list, except first. filtered_events = [] for video_event in captured_events: is_played_event = video_event['event_type'] == 'edx.video.bumper.played' appears_again = filtered_events and video_event['event_type'] == filtered_events[-1]['event_type'] if is_played_event and appears_again: continue filtered_events.append(video_event) for idx, video_event in enumerate(filtered_events): if idx < 3: self.assert_bumper_payload_contains_ids(video_event, sources, duration) else: self.assert_payload_contains_ids(video_event) if idx == 0: assert_event_matches({'event_type': 'edx.video.bumper.loaded'}, video_event) elif idx == 1: assert_event_matches({'event_type': 'edx.video.bumper.played'}, video_event) self.assert_valid_control_event_at_time(video_event, 0) elif idx == 2: assert_event_matches({'event_type': event_type}, video_event) elif idx == 3: assert_event_matches({'event_type': 'load_video'}, video_event) elif idx == 4: assert_event_matches({'event_type': 'play_video'}, video_event) self.assert_valid_control_event_at_time(video_event, 0) def assert_bumper_payload_contains_ids(self, video_event, sources, duration): """ Bumper video events should all contain "host_component_id", "bumper_id", "duration", "code" attributes in their payload. This function asserts that those fields are present and have correct values. """ self.add_bumper() video_descriptors = self.course_fixture.get_nested_xblocks(category='video') video_desc = video_descriptors[0] video_locator = UsageKey.from_string(video_desc.locator) expected_event = { 'event': { 'host_component_id': video_locator.html_id(), 'bumper_id': sources, 'duration': _parse_time_str(duration), 'code': 'html5' } } self.assert_events_match([expected_event], [video_event]) def test_strict_event_format(self): """ This test makes a very strong assertion about the fields present in events. The goal of it is to ensure that new fields are not added to all events mistakenly. It should be the only existing test that is updated when new top level fields are added to all events. """ captured_events = [] self.add_bumper() filter_event = lambda e: e['event_type'] == 'edx.video.bumper.loaded' with self.capture_events(filter_event, captured_events=captured_events): self.navigate_to_video_no_render() self.video.click_on_poster() load_video_event = captured_events[0] # Validate the event payload sources, duration = self.video.sources[0], self.video.duration self.assert_bumper_payload_contains_ids(load_video_event, sources, duration) # We cannot predict the value of these fields so we make weaker assertions about them dynamic_string_fields = ( 'accept_language', 'agent', 'host', 'ip', 'event', 'session' ) for field in dynamic_string_fields: self.assert_field_type(load_video_event, field, basestring) self.assertIn(field, load_video_event, '{0} not found in the root of the event'.format(field)) del load_video_event[field] # A weak assertion for the timestamp as well self.assert_field_type(load_video_event, 'time', datetime.datetime) del load_video_event['time'] # Note that all unpredictable fields have been deleted from the event at this point course_key = CourseKey.from_string(self.course_id) static_fields_pattern = { 'context': { 'course_id': unicode(course_key), 'org_id': course_key.org, 'path': '/event', 'user_id': self.user_info['user_id'] }, 'event_source': 'browser', 'event_type': 'edx.video.bumper.loaded', 'username': self.user_info['username'], 'page': self.browser.current_url, 'referer': self.browser.current_url, 'name': 'edx.video.bumper.loaded', } assert_events_equal(static_fields_pattern, load_video_event)
agpl-3.0
[ 624, 13913, 22010, 8689, 5576, 4474, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 366, 3583, 199, 646, 2882, 199, 199, 504, 2508, 7546, 492, 27982, 22060, 199, 504, 1275, 396, 63, 3722, 63, 578, 492, 15709, 23170, 199, 504, 2263, 5856, 14, 15807, 14, 3722, 14, 3722, 492, 485, 1122, 63, 521, 63, 495, 199, 199, 504, 22709, 14, 1018, 14, 773, 14, 2219, 14, 305, 13049, 14, 4368, 492, 702, 63, 1430, 63, 6742, 12, 702, 63, 4368, 63, 1452, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 11028, 1197, 12, 22574, 421, 199, 533, 15709, 11770, 22060, 8, 11770, 22060, 12, 15709, 23170, 304, 272, 408, 272, 18491, 5922, 3102, 370, 511, 3991, 7748, 1566, 325, 2250, 14, 272, 408, 272, 347, 702, 63, 4749, 63, 6134, 63, 1580, 8, 277, 12, 3991, 63, 1430, 304, 267, 408, 267, 15709, 4474, 1077, 1006, 1395, 298, 344, 2, 436, 298, 600, 2, 3004, 315, 3932, 4886, 14, 398, 961, 805, 702, 83, 626, 5204, 1504, 787, 3451, 436, 1172, 3211, 1338, 14, 267, 408, 267, 3991, 63, 17752, 275, 291, 14, 1972, 63, 5997, 14, 362, 63, 6376, 63, 88, 4166, 8, 3710, 534, 3722, 358, 267, 3991, 63, 3257, 275, 3991, 63, 17752, 59, 16, 61, 267, 3991, 63, 6354, 275, 11028, 1197, 14, 504, 63, 875, 8, 3722, 63, 3257, 14, 6354, 9, 398, 1420, 63, 1430, 275, 469, 288, 283, 1430, 356, 469, 355, 283, 344, 356, 3991, 63, 6354, 14, 1360, 63, 344, 1062, 355, 283, 600, 356, 283, 19, 63, 89, 36, 63, 67, 11959, 79, 35, 75, 7, 288, 789, 267, 789, 267, 291, 14, 479, 63, 4368, 63, 1431, 779, 2062, 63, 1430, 467, 359, 3722, 63, 1430, 566, 339, 347, 702, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 277, 12, 3991, 63, 1430, 12, 900, 63, 262, 63, 4515, 304, 267, 408, 267, 15709, 3304, 4474, 1077, 1395, 1686, 2870, 1504, 436, 282, 1686, 298, 1818, 1366, 2, 901, 14, 398, 961, 805, 702, 83, 626, 5204, 1504, 787, 3451, 436, 1172, 3211, 1338, 14, 267, 408, 267, 1453, 63, 521, 275, 2022, 14, 3640, 8, 3722, 63, 1430, 459, 1430, 1105, 459, 1818, 1366, 418, 267, 291, 14, 7904, 8, 1818, 63, 521, 12, 900, 63, 262, 63, 4515, 12, 5762, 29, 17, 9, 339, 347, 702, 63, 698, 63, 466, 8, 277, 12, 1566, 63, 807, 12, 901, 12, 901, 63, 466, 304, 267, 408, 9699, 626, 282, 6770, 658, 698, 64, 315, 314, 658, 1430, 63, 807, 64, 965, 282, 6770, 730, 624, 267, 291, 14, 4080, 8, 698, 12, 1566, 63, 807, 12, 5041, 16, 93, 440, 1911, 315, 314, 1738, 402, 314, 1566, 1370, 908, 8, 698, 430, 267, 291, 14, 1815, 8, 288, 1228, 8, 1430, 63, 807, 59, 698, 467, 901, 63, 466, 395, 288, 283, 6964, 5310, 498, 7063, 370, 506, 282, 5310, 698, 63, 466, 10750, 1325, 652, 965, 314, 574, 5310, 585, 7063, 402, 730, 5310, 84, 7063, 1370, 908, 8, 355, 790, 29, 698, 12, 355, 574, 29, 1430, 63, 807, 59, 698, 467, 355, 307, 29, 466, 8, 1430, 63, 807, 59, 698, 2522, 355, 901, 63, 466, 29, 698, 63, 466, 12, 288, 776, 267, 776, 421, 199, 533, 15709, 11770, 774, 8, 9166, 11770, 22060, 304, 272, 408, 1379, 3991, 7748, 1566, 325, 2250, 408, 339, 768, 2796, 14, 2759, 360, 879, 13, 21, 14927, 358, 272, 347, 511, 63, 3722, 63, 2785, 63, 4368, 8, 277, 304, 267, 408, 267, 22840, 26, 15709, 3931, 365, 8018, 315, 314, 27540, 315, 1488, 7715, 818, 1928, 4163, 21, 5274, 267, 9138, 314, 2518, 965, 282, 15709, 3931, 315, 298, 57, 7715, 2, 818, 267, 6061, 473, 5232, 314, 3991, 267, 6061, 473, 9626, 959, 4696, 402, 652, 267, 6061, 473, 16834, 314, 3991, 267, 9442, 282, 298, 912, 63, 3722, 2, 1566, 365, 19515, 267, 6061, 282, 298, 2802, 63, 3722, 2, 1566, 365, 19515, 267, 6061, 282, 298, 11241, 63, 3722, 2, 1566, 365, 19515, 267, 408, 398, 347, 365, 63, 3722, 63, 1430, 8, 1430, 304, 288, 408, 4131, 734, 7003, 1163, 2419, 314, 3991, 4474, 402, 13518, 624, 288, 372, 1566, 459, 1430, 63, 466, 418, 315, 661, 912, 63, 3722, 297, 283, 2802, 63, 3722, 297, 283, 11241, 63, 3722, 358, 398, 17487, 63, 4368, 275, 942, 267, 543, 291, 14, 12685, 63, 4368, 8, 374, 63, 3722, 63, 1430, 12, 1329, 63, 1618, 63, 6742, 29, 19, 12, 17487, 63, 4368, 29, 28345, 63, 4368, 304, 288, 291, 14, 15595, 3237, 63, 475, 63, 3722, 342, 288, 291, 14, 3722, 14, 4891, 63, 6147, 63, 3887, 360, 2802, 358, 288, 291, 14, 3722, 14, 2573, 63, 509, 63, 3124, 360, 16, 26, 1717, 358, 288, 291, 14, 3722, 14, 4891, 63, 6147, 63, 3887, 360, 11241, 358, 398, 367, 4280, 12, 3991, 63, 1430, 315, 3874, 8, 28345, 63, 4368, 304, 288, 291, 14, 479, 63, 4749, 63, 6134, 63, 1580, 8, 3722, 63, 1430, 9, 288, 340, 4280, 508, 378, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 912, 63, 3722, 2267, 3991, 63, 1430, 9, 288, 916, 4280, 508, 413, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 2802, 63, 3722, 2267, 3991, 63, 1430, 9, 355, 291, 14, 479, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 3722, 63, 1430, 12, 378, 9, 288, 916, 4280, 508, 499, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 11241, 63, 3722, 2267, 3991, 63, 1430, 9, 355, 291, 14, 479, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 3722, 63, 1430, 12, 291, 14, 3722, 14, 4515, 9, 339, 347, 511, 63, 4768, 63, 1430, 63, 908, 8, 277, 304, 267, 408, 267, 961, 511, 7704, 282, 7437, 16925, 14412, 3595, 314, 1504, 3451, 315, 4474, 14, 710, 14850, 402, 652, 365, 370, 4868, 626, 892, 267, 1504, 787, 440, 3483, 370, 1006, 4474, 27572, 65, 917, 590, 14, 2779, 1077, 506, 314, 1454, 3411, 511 ]
[ 13913, 22010, 8689, 5576, 4474, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 366, 3583, 199, 646, 2882, 199, 199, 504, 2508, 7546, 492, 27982, 22060, 199, 504, 1275, 396, 63, 3722, 63, 578, 492, 15709, 23170, 199, 504, 2263, 5856, 14, 15807, 14, 3722, 14, 3722, 492, 485, 1122, 63, 521, 63, 495, 199, 199, 504, 22709, 14, 1018, 14, 773, 14, 2219, 14, 305, 13049, 14, 4368, 492, 702, 63, 1430, 63, 6742, 12, 702, 63, 4368, 63, 1452, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 11028, 1197, 12, 22574, 421, 199, 533, 15709, 11770, 22060, 8, 11770, 22060, 12, 15709, 23170, 304, 272, 408, 272, 18491, 5922, 3102, 370, 511, 3991, 7748, 1566, 325, 2250, 14, 272, 408, 272, 347, 702, 63, 4749, 63, 6134, 63, 1580, 8, 277, 12, 3991, 63, 1430, 304, 267, 408, 267, 15709, 4474, 1077, 1006, 1395, 298, 344, 2, 436, 298, 600, 2, 3004, 315, 3932, 4886, 14, 398, 961, 805, 702, 83, 626, 5204, 1504, 787, 3451, 436, 1172, 3211, 1338, 14, 267, 408, 267, 3991, 63, 17752, 275, 291, 14, 1972, 63, 5997, 14, 362, 63, 6376, 63, 88, 4166, 8, 3710, 534, 3722, 358, 267, 3991, 63, 3257, 275, 3991, 63, 17752, 59, 16, 61, 267, 3991, 63, 6354, 275, 11028, 1197, 14, 504, 63, 875, 8, 3722, 63, 3257, 14, 6354, 9, 398, 1420, 63, 1430, 275, 469, 288, 283, 1430, 356, 469, 355, 283, 344, 356, 3991, 63, 6354, 14, 1360, 63, 344, 1062, 355, 283, 600, 356, 283, 19, 63, 89, 36, 63, 67, 11959, 79, 35, 75, 7, 288, 789, 267, 789, 267, 291, 14, 479, 63, 4368, 63, 1431, 779, 2062, 63, 1430, 467, 359, 3722, 63, 1430, 566, 339, 347, 702, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 277, 12, 3991, 63, 1430, 12, 900, 63, 262, 63, 4515, 304, 267, 408, 267, 15709, 3304, 4474, 1077, 1395, 1686, 2870, 1504, 436, 282, 1686, 298, 1818, 1366, 2, 901, 14, 398, 961, 805, 702, 83, 626, 5204, 1504, 787, 3451, 436, 1172, 3211, 1338, 14, 267, 408, 267, 1453, 63, 521, 275, 2022, 14, 3640, 8, 3722, 63, 1430, 459, 1430, 1105, 459, 1818, 1366, 418, 267, 291, 14, 7904, 8, 1818, 63, 521, 12, 900, 63, 262, 63, 4515, 12, 5762, 29, 17, 9, 339, 347, 702, 63, 698, 63, 466, 8, 277, 12, 1566, 63, 807, 12, 901, 12, 901, 63, 466, 304, 267, 408, 9699, 626, 282, 6770, 658, 698, 64, 315, 314, 658, 1430, 63, 807, 64, 965, 282, 6770, 730, 624, 267, 291, 14, 4080, 8, 698, 12, 1566, 63, 807, 12, 5041, 16, 93, 440, 1911, 315, 314, 1738, 402, 314, 1566, 1370, 908, 8, 698, 430, 267, 291, 14, 1815, 8, 288, 1228, 8, 1430, 63, 807, 59, 698, 467, 901, 63, 466, 395, 288, 283, 6964, 5310, 498, 7063, 370, 506, 282, 5310, 698, 63, 466, 10750, 1325, 652, 965, 314, 574, 5310, 585, 7063, 402, 730, 5310, 84, 7063, 1370, 908, 8, 355, 790, 29, 698, 12, 355, 574, 29, 1430, 63, 807, 59, 698, 467, 355, 307, 29, 466, 8, 1430, 63, 807, 59, 698, 2522, 355, 901, 63, 466, 29, 698, 63, 466, 12, 288, 776, 267, 776, 421, 199, 533, 15709, 11770, 774, 8, 9166, 11770, 22060, 304, 272, 408, 1379, 3991, 7748, 1566, 325, 2250, 408, 339, 768, 2796, 14, 2759, 360, 879, 13, 21, 14927, 358, 272, 347, 511, 63, 3722, 63, 2785, 63, 4368, 8, 277, 304, 267, 408, 267, 22840, 26, 15709, 3931, 365, 8018, 315, 314, 27540, 315, 1488, 7715, 818, 1928, 4163, 21, 5274, 267, 9138, 314, 2518, 965, 282, 15709, 3931, 315, 298, 57, 7715, 2, 818, 267, 6061, 473, 5232, 314, 3991, 267, 6061, 473, 9626, 959, 4696, 402, 652, 267, 6061, 473, 16834, 314, 3991, 267, 9442, 282, 298, 912, 63, 3722, 2, 1566, 365, 19515, 267, 6061, 282, 298, 2802, 63, 3722, 2, 1566, 365, 19515, 267, 6061, 282, 298, 11241, 63, 3722, 2, 1566, 365, 19515, 267, 408, 398, 347, 365, 63, 3722, 63, 1430, 8, 1430, 304, 288, 408, 4131, 734, 7003, 1163, 2419, 314, 3991, 4474, 402, 13518, 624, 288, 372, 1566, 459, 1430, 63, 466, 418, 315, 661, 912, 63, 3722, 297, 283, 2802, 63, 3722, 297, 283, 11241, 63, 3722, 358, 398, 17487, 63, 4368, 275, 942, 267, 543, 291, 14, 12685, 63, 4368, 8, 374, 63, 3722, 63, 1430, 12, 1329, 63, 1618, 63, 6742, 29, 19, 12, 17487, 63, 4368, 29, 28345, 63, 4368, 304, 288, 291, 14, 15595, 3237, 63, 475, 63, 3722, 342, 288, 291, 14, 3722, 14, 4891, 63, 6147, 63, 3887, 360, 2802, 358, 288, 291, 14, 3722, 14, 2573, 63, 509, 63, 3124, 360, 16, 26, 1717, 358, 288, 291, 14, 3722, 14, 4891, 63, 6147, 63, 3887, 360, 11241, 358, 398, 367, 4280, 12, 3991, 63, 1430, 315, 3874, 8, 28345, 63, 4368, 304, 288, 291, 14, 479, 63, 4749, 63, 6134, 63, 1580, 8, 3722, 63, 1430, 9, 288, 340, 4280, 508, 378, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 912, 63, 3722, 2267, 3991, 63, 1430, 9, 288, 916, 4280, 508, 413, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 2802, 63, 3722, 2267, 3991, 63, 1430, 9, 355, 291, 14, 479, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 3722, 63, 1430, 12, 378, 9, 288, 916, 4280, 508, 499, 26, 355, 702, 63, 1430, 63, 6742, 3252, 1430, 63, 466, 356, 283, 11241, 63, 3722, 2267, 3991, 63, 1430, 9, 355, 291, 14, 479, 63, 1078, 63, 2785, 63, 1430, 63, 292, 63, 521, 8, 3722, 63, 1430, 12, 291, 14, 3722, 14, 4515, 9, 339, 347, 511, 63, 4768, 63, 1430, 63, 908, 8, 277, 304, 267, 408, 267, 961, 511, 7704, 282, 7437, 16925, 14412, 3595, 314, 1504, 3451, 315, 4474, 14, 710, 14850, 402, 652, 365, 370, 4868, 626, 892, 267, 1504, 787, 440, 3483, 370, 1006, 4474, 27572, 65, 917, 590, 14, 2779, 1077, 506, 314, 1454, 3411, 511, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
FederatedAI/FATE
python/federatedml/statistic/intersect/rsa_cache/redis_adaptor.py
2
2586
# # Copyright 2019 The FATE 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. # import os from arch.api.utils import conf_utils import redis from federatedml.util import LOGGER def singleton(cls, *args, **kw): instances = {} def _singleton(): key = str(cls) + str(os.getpid()) if key not in instances: instances[key] = cls(*args, **kw) return instances[key] return _singleton @singleton class RedisAdaptor(object): def __init__(self): config = conf_utils.get_base_config("redis", {}).copy() self.pool = redis.ConnectionPool(host=config['host'], port=config['port'], password=config['password'], \ max_connections=config['max_connections'], db=config['db']) LOGGER.info('init redis connection pool.') def get_conn(self): return redis.Redis(connection_pool=self.pool, decode_responses=True) def get(self, key): try: conn = self.get_conn() value = conn.get(key) if value: LOGGER.info('get from redis, {}:{}'.format(key, value)) else: LOGGER.info('get from redis return nil, key={}'.format(key)) return value except Exception as e: LOGGER.exception(e) LOGGER.error('get from redis failed') return None def setex(self, key, value, expire_seconds=10800): try: conn = self.get_conn() conn.setex(key, expire_seconds, value) LOGGER.info('set {}:{} {} into redis.'.format(key, value, expire_seconds)) except Exception as e: LOGGER.exception(e) LOGGER.info('set {}:{} {} into redis failed.'.format(key, value, expire_seconds)) def delete(self, *key): try: conn = self.get_conn() conn.delete(*key) LOGGER.info('del {} from redis.'.format(*key)) except Exception as e: LOGGER.exception(e) LOGGER.info('del {} from redis failed.'.format(*key))
apache-2.0
[ 3, 199, 3, 221, 1898, 20312, 710, 481, 1951, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 747, 199, 504, 3819, 14, 1246, 14, 1208, 492, 3743, 63, 1208, 199, 646, 16967, 199, 504, 1964, 424, 972, 757, 14, 1974, 492, 20184, 421, 199, 318, 19768, 8, 1886, 12, 627, 589, 12, 1011, 829, 304, 272, 4454, 275, 1052, 339, 347, 485, 24675, 837, 267, 790, 275, 620, 8, 1886, 9, 435, 620, 8, 736, 14, 17829, 1012, 267, 340, 790, 440, 315, 4454, 26, 288, 4454, 59, 498, 61, 275, 843, 2031, 589, 12, 1011, 829, 9, 267, 372, 4454, 59, 498, 61, 339, 372, 485, 24675, 421, 199, 32, 24675, 199, 533, 25496, 2767, 6182, 269, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1101, 275, 3743, 63, 1208, 14, 362, 63, 1095, 63, 888, 480, 15369, 401, 13056, 1574, 342, 267, 291, 14, 2293, 275, 16967, 14, 23929, 8, 1102, 29, 888, 459, 1102, 995, 1844, 29, 888, 459, 719, 995, 2505, 29, 888, 459, 2060, 995, 971, 1467, 1390, 63, 7995, 29, 888, 459, 988, 63, 7995, 995, 1592, 29, 888, 459, 697, 1105, 267, 20184, 14, 815, 360, 826, 16967, 1950, 4203, 2659, 339, 347, 664, 63, 1631, 8, 277, 304, 267, 372, 16967, 14, 29605, 8, 2105, 63, 2293, 29, 277, 14, 2293, 12, 4849, 63, 10360, 29, 549, 9, 339, 347, 664, 8, 277, 12, 790, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 574, 275, 2557, 14, 362, 8, 498, 9, 288, 340, 574, 26, 355, 20184, 14, 815, 360, 362, 687, 16967, 12, 24702, 11123, 908, 8, 498, 12, 574, 430, 288, 587, 26, 355, 20184, 14, 815, 360, 362, 687, 16967, 372, 32644, 12, 790, 27244, 908, 8, 498, 430, 288, 372, 574, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 705, 360, 362, 687, 16967, 3405, 358, 288, 372, 488, 339, 347, 542, 3858, 8, 277, 12, 790, 12, 574, 12, 16667, 63, 4515, 29, 709, 6718, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 2557, 14, 261, 3858, 8, 498, 12, 16667, 63, 4515, 12, 574, 9, 288, 20184, 14, 815, 360, 409, 24702, 2440, 1052, 1901, 16967, 17374, 908, 8, 498, 12, 574, 12, 16667, 63, 4515, 430, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 815, 360, 409, 24702, 2440, 1052, 1901, 16967, 3405, 17374, 908, 8, 498, 12, 574, 12, 16667, 63, 4515, 430, 339, 347, 3145, 8, 277, 12, 627, 498, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 2557, 14, 1807, 2031, 498, 9, 288, 20184, 14, 815, 360, 2264, 1052, 687, 16967, 17374, 908, 2031, 498, 430, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 815, 360, 2264, 1052, 687, 16967, 3405, 17374, 908, 2031, 498, 430, 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 ]
[ 199, 3, 221, 1898, 20312, 710, 481, 1951, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 747, 199, 504, 3819, 14, 1246, 14, 1208, 492, 3743, 63, 1208, 199, 646, 16967, 199, 504, 1964, 424, 972, 757, 14, 1974, 492, 20184, 421, 199, 318, 19768, 8, 1886, 12, 627, 589, 12, 1011, 829, 304, 272, 4454, 275, 1052, 339, 347, 485, 24675, 837, 267, 790, 275, 620, 8, 1886, 9, 435, 620, 8, 736, 14, 17829, 1012, 267, 340, 790, 440, 315, 4454, 26, 288, 4454, 59, 498, 61, 275, 843, 2031, 589, 12, 1011, 829, 9, 267, 372, 4454, 59, 498, 61, 339, 372, 485, 24675, 421, 199, 32, 24675, 199, 533, 25496, 2767, 6182, 269, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1101, 275, 3743, 63, 1208, 14, 362, 63, 1095, 63, 888, 480, 15369, 401, 13056, 1574, 342, 267, 291, 14, 2293, 275, 16967, 14, 23929, 8, 1102, 29, 888, 459, 1102, 995, 1844, 29, 888, 459, 719, 995, 2505, 29, 888, 459, 2060, 995, 971, 1467, 1390, 63, 7995, 29, 888, 459, 988, 63, 7995, 995, 1592, 29, 888, 459, 697, 1105, 267, 20184, 14, 815, 360, 826, 16967, 1950, 4203, 2659, 339, 347, 664, 63, 1631, 8, 277, 304, 267, 372, 16967, 14, 29605, 8, 2105, 63, 2293, 29, 277, 14, 2293, 12, 4849, 63, 10360, 29, 549, 9, 339, 347, 664, 8, 277, 12, 790, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 574, 275, 2557, 14, 362, 8, 498, 9, 288, 340, 574, 26, 355, 20184, 14, 815, 360, 362, 687, 16967, 12, 24702, 11123, 908, 8, 498, 12, 574, 430, 288, 587, 26, 355, 20184, 14, 815, 360, 362, 687, 16967, 372, 32644, 12, 790, 27244, 908, 8, 498, 430, 288, 372, 574, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 705, 360, 362, 687, 16967, 3405, 358, 288, 372, 488, 339, 347, 542, 3858, 8, 277, 12, 790, 12, 574, 12, 16667, 63, 4515, 29, 709, 6718, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 2557, 14, 261, 3858, 8, 498, 12, 16667, 63, 4515, 12, 574, 9, 288, 20184, 14, 815, 360, 409, 24702, 2440, 1052, 1901, 16967, 17374, 908, 8, 498, 12, 574, 12, 16667, 63, 4515, 430, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 815, 360, 409, 24702, 2440, 1052, 1901, 16967, 3405, 17374, 908, 8, 498, 12, 574, 12, 16667, 63, 4515, 430, 339, 347, 3145, 8, 277, 12, 627, 498, 304, 267, 862, 26, 288, 2557, 275, 291, 14, 362, 63, 1631, 342, 288, 2557, 14, 1807, 2031, 498, 9, 288, 20184, 14, 815, 360, 2264, 1052, 687, 16967, 17374, 908, 2031, 498, 430, 267, 871, 2186, 465, 325, 26, 288, 20184, 14, 1971, 8, 69, 9, 288, 20184, 14, 815, 360, 2264, 1052, 687, 16967, 3405, 17374, 908, 2031, 498, 430, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lmazuel/azure-sdk-for-python
azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/operation.py
2
1096
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class Operation(Model): """CDN REST API operation. :param name: Operation name: {provider}/{resource}/{operation} :type name: str :param display: The object that represents the operation. :type display: ~azure.mgmt.applicationinsights.models.OperationDisplay """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, } def __init__(self, name=None, display=None): super(Operation, self).__init__() self.name = name self.display = display
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 17954, 8, 1685, 304, 272, 408, 7695, 46, 14880, 3261, 3439, 14, 339, 520, 635, 536, 26, 17954, 536, 26, 469, 3780, 16152, 1927, 16152, 5735, 93, 272, 520, 466, 536, 26, 620, 272, 520, 635, 2929, 26, 710, 909, 626, 8469, 314, 3439, 14, 272, 520, 466, 2929, 26, 6146, 9078, 14, 9752, 14, 3578, 262, 22727, 83, 14, 992, 14, 6044, 7687, 272, 408, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 354, 356, 791, 498, 356, 283, 354, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 2918, 356, 791, 498, 356, 283, 2918, 297, 283, 466, 356, 283, 6044, 7687, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 2929, 29, 403, 304, 267, 1613, 8, 6044, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 536, 267, 291, 14, 2918, 275, 2929, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 17954, 8, 1685, 304, 272, 408, 7695, 46, 14880, 3261, 3439, 14, 339, 520, 635, 536, 26, 17954, 536, 26, 469, 3780, 16152, 1927, 16152, 5735, 93, 272, 520, 466, 536, 26, 620, 272, 520, 635, 2929, 26, 710, 909, 626, 8469, 314, 3439, 14, 272, 520, 466, 2929, 26, 6146, 9078, 14, 9752, 14, 3578, 262, 22727, 83, 14, 992, 14, 6044, 7687, 272, 408, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 354, 356, 791, 498, 356, 283, 354, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 2918, 356, 791, 498, 356, 283, 2918, 297, 283, 466, 356, 283, 6044, 7687, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 2929, 29, 403, 304, 267, 1613, 8, 6044, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 536, 267, 291, 14, 2918, 275, 2929, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ajhager/copycat
copycat/workspace/string.py
1
12784
# Copyright (c) 2007-2017 Joseph Hager. # # Copycat is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License, # as published by the Free Software Foundation. # # Copycat 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 Copycat; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. """String""" import random import copycat.toolbox as toolbox class String(object): """String is a letter string in the workspace. This could be the initial string, modified string or target string. Each object in a string has a unique string number that identifies it from other objects in the string.""" def __init__(self, workspace, string): self.workspace = workspace self.slipnet = self.workspace.slipnet self.name = string self.highest_string_number = -1 self.length = len(string) self.letters = {} self.groups = {} self.proposed_groups = {} self.object_positions = {} self.left_right_bonds = {} self.from_to_bonds = {} self.proposed_bonds = {} self.intra_string_unhappiness = 0 self.bonds_to_scan_distribution = range(self.length) def add_to_object_positions(self, obj, position): """Add an object to the object positions.""" if position in self.object_positions: self.object_positions[position].append(obj) else: self.object_positions[position] = [obj] def remove_from_object_positions(self, obj, position): """Remove an object from the object positions.""" if obj in self.object_positions[position]: self.object_positions[position].remove(obj) def add_letter(self, letter): """Add a letter to the string.""" self.highest_string_number += 1 letter.string_number = self.highest_string_number position = letter.left_string_position self.letters[position] = letter self.add_to_object_positions(letter, position) def get_letters(self): """Return a list of letters in the string.""" return [self.letters[index] for index in sorted(self.letters.keys())] def get_letter(self, position): """Return the letter at the given position in the string.""" return self.letters.get(position) def get_random_letter(self): """Return a random letter from the string.""" return random.choice(self.get_letters()) def get_leftmost_letter(self): """Return the leftmost letter in the string.""" return self.letters.get(0) def get_rightmost_letter(self): """Return the rightmost letter in the string.""" return self.letters.get(len(self.letters) - 1) def add_group(self, group): """Add a group to the string.""" self.highest_string_number += 1 group.string_number = self.highest_string_number self.groups[group.left_object.string_number] = group self.add_to_object_positions(group, group.left_string_position) self.add_to_object_positions(group, group.right_string_position) def remove_group(self, group): """Remove a group from the string.""" if group.left_object.string_number in self.groups: del self.groups[group.left_object.string_number] self.remove_from_object_positions(group, group.left_string_position) self.remove_from_object_positions(group, group.right_string_position) def get_groups(self): """Return a list of groups in the string.""" return list(self.groups.values()) def get_group(self, position): """Return the group at the given position in letters. Positions start at 0 and refer to the position of the leftmost object in the group.""" return self.get_letter(position).group def get_existing_group(self, group): """Return the group in the string if it has the same properties as the given group.""" existing_group = self.groups.get(group.left_object.string_number) if existing_group: if existing_group.length == group.length and \ existing_group.group_category == group.group_category and \ existing_group.direction_category == group.direction_category: return existing_group def add_proposed_group(self, group): """Add a proposed group to the string.""" position = (group.left_object.string_number, group.right_object.string_number) if position in self.proposed_groups: self.proposed_groups[position].append(group) else: self.proposed_groups[position] = [group] def remove_proposed_group(self, group): """Remove a proposed group from the string.""" position = (group.left_object.string_number, group.right_object.string_number) items = self.proposed_groups.get(position, []) if group in items: self.proposed_groups[position].remove(group) def get_proposed_groups(self): """Return a list of the proposed groups in the string.""" return list(set(toolbox.flatten(self.proposed_groups.values()))) def get_proposed_group(self, first, second): """Return the proposed group at first, second position.""" return self.proposed_groups.get((first, second)) def add_bond(self, bond): """Add a bond to the string, sameness bonds in both directions.""" left_number = bond.left_object.string_number right_number = bond.right_object.string_number self.left_right_bonds[(left_number, right_number)] = bond from_number = bond.from_object.string_number to_number = bond.to_object.string_number self.from_to_bonds[(from_number, to_number)] = bond if bond.bond_category == self.slipnet.plato_sameness: self.left_right_bonds[(right_number, left_number)] = bond self.from_to_bonds[(to_number, from_number)] = bond def remove_bond(self, bond): """Remove a built bond from the string.""" left_number = bond.left_object.string_number right_number = bond.right_object.string_number if (left_number, right_number) in self.left_right_bonds: del self.left_right_bonds[(left_number, right_number)] from_number = bond.from_object.string_number to_number = bond.to_object.string_number if (from_number, to_number) in self.from_to_bonds: del self.from_to_bonds[(from_number, to_number)] if bond.bond_category == self.slipnet.plato_sameness: if (right_number, left_number) in self.left_right_bonds: del self.left_right_bonds[(right_number, left_number)] if (to_number, from_number) in self.from_to_bonds: del self.from_to_bonds[(to_number, from_number)] def get_bonds(self): """Return a list of the built bonds in the string.""" return list(set(self.from_to_bonds.values())) def get_bond(self, from_object, to_object): """Return the bond between the two objects, if any.""" return self.from_to_bonds.get((from_object.string_number, to_object.string_number)) def get_existing_bond(self, bond): """Return the bond in the string if it has the same properties as the given bond.""" existing_bond = self.get_bond(bond.from_object, bond.to_object) if existing_bond: if existing_bond.bond_category == bond.bond_category and \ existing_bond.direction_category == bond.direction_category: return existing_bond def add_proposed_bond(self, bond): """Add the proposed bond to the string.""" position = (bond.from_object.string_number, bond.to_object.string_number) if position in self.proposed_bonds: self.proposed_bonds[position].append(bond) else: self.proposed_bonds[position] = [bond] def remove_proposed_bond(self, bond): """Add the proposed bond to the string.""" position = (bond.from_object.string_number, bond.to_object.string_number) if position in self.proposed_bonds: items = self.proposed_bonds[position] if bond in items: self.proposed_bonds[position].remove(bond) def get_proposed_bonds(self): """Return a list of proposed bonds in the string.""" return list(set(toolbox.flatten(self.proposed_bonds.values()))) def get_proposed_bond(self, first, second): """Return a proposed bonds at first, second in the string.""" return self.proposed_bonds.get((first, second)) def get_objects(self, category=None): """Return the list of objects of the given object category. If no category is given, return all objects.""" if category == self.slipnet.plato_letter: return self.get_letters() elif category == self.slipnet.plato_group: return self.get_groups() return self.get_letters() + self.get_groups() def get_non_string_spanning_objects(self): """Return all objects that do not span the entire string.""" return [o for o in self.get_objects() if not o.spans_whole_string()] def get_random_object(self, method=None): """Return a random object from the string.""" if method: objects = self.get_objects() values = [getattr(obj, method) for obj in objects] values = self.workspace.temperature_adjusted_values(values) return objects[toolbox.weighted_index(values)] return random.choice(self.get_objects()) def get_random_leftmost_object(self): """Return a random leftmost object from the string.""" leftmost_objects = [] category = self.slipnet.plato_string_position_category for obj in self.get_objects(): if obj.get_descriptor(category) == self.slipnet.plato_leftmost: leftmost_objects.append(obj) if leftmost_objects: values = [obj.relative_importance for obj in leftmost_objects] return toolbox.weighted_select(values, leftmost_objects) def update_relative_importances(self): """Update the relative, normalized importances of all the objects in the string.""" raw_importance = sum([o.raw_importance for o in self.get_objects()]) for obj in self.get_objects(): if raw_importance == 0: importance = 0 else: quot = obj.raw_importance / float(raw_importance) importance = round(100 * quot) obj.relative_importance = importance def update_intra_string_unhappiness(self): """Calculate the average of the intra-string unhappiness of all the objects in the string.""" unhappiness = [o.intra_string_unhappiness for o in self.get_objects()] self.intra_string_unhappiness = round(toolbox.average(*unhappiness)) def local_bond_category_relevance(self, bond_category): """A function of how many bonds in the string have the given bond category. This function is not perfect; it gives just a rough estimate of the relevance of this bond category.""" objects = self.get_non_string_spanning_objects() if len(objects) == 1: return 0 bond_count = 0 for obj in objects: if obj.right_bond: if obj.right_bond.bond_category == bond_category: bond_count += 1 return 100 * (float(bond_count) / (len(objects) - 1)) def local_direction_category_relevance(self, direction_category): """A function of how many bonds in the string have the given direction category. This function is not perfect; it gives just a rough estimate of the relevance of this direction category.""" objects = self.get_non_string_spanning_objects() if len(objects) == 1: return 0 bond_count = 0 for obj in objects: if obj.right_bond: if obj.right_bond.direction_category == direction_category: bond_count += 1 return 100 * (float(bond_count) / (len(objects) - 1))
gpl-2.0
[ 3, 1898, 334, 67, 9, 10219, 13, 10680, 1603, 3362, 838, 869, 1456, 14, 199, 3, 199, 3, 11247, 3385, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 1015, 499, 402, 314, 1664, 1696, 1684, 844, 12, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 11247, 3385, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 11247, 3385, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 1558, 624, 199, 199, 646, 2196, 199, 199, 646, 1331, 3385, 14, 3557, 1977, 465, 4744, 1977, 199, 199, 533, 2624, 8, 785, 304, 272, 408, 1558, 365, 282, 8082, 1059, 315, 314, 14466, 14, 339, 961, 4293, 506, 314, 2536, 1059, 12, 6042, 1059, 503, 1347, 1059, 14, 272, 7048, 909, 315, 282, 1059, 965, 282, 3747, 1059, 1329, 626, 22975, 272, 652, 687, 1163, 2251, 315, 314, 1059, 1041, 339, 347, 636, 826, 721, 277, 12, 14466, 12, 1059, 304, 267, 291, 14, 13249, 275, 14466, 267, 291, 14, 83, 3587, 846, 275, 291, 14, 13249, 14, 83, 3587, 846, 267, 291, 14, 354, 275, 1059, 267, 291, 14, 31381, 63, 875, 63, 1955, 275, 446, 17, 267, 291, 14, 1267, 275, 822, 8, 875, 9, 267, 291, 14, 16415, 275, 1052, 267, 291, 14, 2634, 275, 1052, 267, 291, 14, 15676, 63, 2634, 275, 1052, 267, 291, 14, 785, 63, 12658, 275, 1052, 267, 291, 14, 3039, 63, 1019, 63, 27816, 275, 1052, 267, 291, 14, 504, 63, 475, 63, 27816, 275, 1052, 267, 291, 14, 15676, 63, 27816, 275, 1052, 267, 291, 14, 442, 345, 63, 875, 63, 324, 72, 571, 9585, 275, 378, 267, 291, 14, 27816, 63, 475, 63, 6282, 63, 4972, 275, 1425, 8, 277, 14, 1267, 9, 339, 347, 1050, 63, 475, 63, 785, 63, 12658, 8, 277, 12, 1559, 12, 3421, 304, 267, 408, 1123, 376, 909, 370, 314, 909, 12266, 1041, 267, 340, 3421, 315, 291, 14, 785, 63, 12658, 26, 288, 291, 14, 785, 63, 12658, 59, 3124, 1055, 740, 8, 1113, 9, 267, 587, 26, 288, 291, 14, 785, 63, 12658, 59, 3124, 61, 275, 359, 1113, 61, 339, 347, 2813, 63, 504, 63, 785, 63, 12658, 8, 277, 12, 1559, 12, 3421, 304, 267, 408, 5587, 376, 909, 687, 314, 909, 12266, 1041, 267, 340, 1559, 315, 291, 14, 785, 63, 12658, 59, 3124, 2189, 288, 291, 14, 785, 63, 12658, 59, 3124, 1055, 2168, 8, 1113, 9, 339, 347, 1050, 63, 9269, 8, 277, 12, 8082, 304, 267, 408, 1123, 282, 8082, 370, 314, 1059, 1041, 267, 291, 14, 31381, 63, 875, 63, 1955, 847, 413, 267, 8082, 14, 875, 63, 1955, 275, 291, 14, 31381, 63, 875, 63, 1955, 267, 3421, 275, 8082, 14, 3039, 63, 875, 63, 3124, 267, 291, 14, 16415, 59, 3124, 61, 275, 8082, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 9269, 12, 3421, 9, 339, 347, 664, 63, 16415, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 14435, 315, 314, 1059, 1041, 267, 372, 359, 277, 14, 16415, 59, 1080, 61, 367, 1478, 315, 3355, 8, 277, 14, 16415, 14, 1612, 24821, 339, 347, 664, 63, 9269, 8, 277, 12, 3421, 304, 267, 408, 1767, 314, 8082, 737, 314, 1627, 3421, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 3124, 9, 339, 347, 664, 63, 2355, 63, 9269, 8, 277, 304, 267, 408, 1767, 282, 2196, 8082, 687, 314, 1059, 1041, 267, 372, 2196, 14, 5095, 8, 277, 14, 362, 63, 16415, 1012, 339, 347, 664, 63, 3039, 2786, 63, 9269, 8, 277, 304, 267, 408, 1767, 314, 29971, 8082, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 16, 9, 339, 347, 664, 63, 1019, 2786, 63, 9269, 8, 277, 304, 267, 408, 1767, 314, 2451, 2786, 8082, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 552, 8, 277, 14, 16415, 9, 446, 413, 9, 339, 347, 1050, 63, 923, 8, 277, 12, 1572, 304, 267, 408, 1123, 282, 1572, 370, 314, 1059, 1041, 267, 291, 14, 31381, 63, 875, 63, 1955, 847, 413, 267, 1572, 14, 875, 63, 1955, 275, 291, 14, 31381, 63, 875, 63, 1955, 267, 291, 14, 2634, 59, 923, 14, 3039, 63, 785, 14, 875, 63, 1955, 61, 275, 1572, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 3039, 63, 875, 63, 3124, 9, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 1019, 63, 875, 63, 3124, 9, 339, 347, 2813, 63, 923, 8, 277, 12, 1572, 304, 267, 408, 5587, 282, 1572, 687, 314, 1059, 1041, 267, 340, 1572, 14, 3039, 63, 785, 14, 875, 63, 1955, 315, 291, 14, 2634, 26, 288, 2150, 291, 14, 2634, 59, 923, 14, 3039, 63, 785, 14, 875, 63, 1955, 61, 267, 291, 14, 2168, 63, 504, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 3039, 63, 875, 63, 3124, 9, 267, 291, 14, 2168, 63, 504, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 1019, 63, 875, 63, 3124, 9, 339, 347, 664, 63, 2634, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 4652, 315, 314, 1059, 1041, 267, 372, 769, 8, 277, 14, 2634, 14, 1459, 1012, 339, 347, 664, 63, 923, 8, 277, 12, 3421, 304, 267, 408, 1767, 314, 1572, 737, 314, 1627, 3421, 315, 14435, 14, 398, 4376, 6150, 1343, 737, 378, 436, 10618, 370, 314, 3421, 402, 314, 29971, 909, 267, 315, 314, 1572, 1041, 267, 372, 291, 14, 362, 63, 9269 ]
[ 1898, 334, 67, 9, 10219, 13, 10680, 1603, 3362, 838, 869, 1456, 14, 199, 3, 199, 3, 11247, 3385, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 1015, 499, 402, 314, 1664, 1696, 1684, 844, 12, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 11247, 3385, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 11247, 3385, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 1558, 624, 199, 199, 646, 2196, 199, 199, 646, 1331, 3385, 14, 3557, 1977, 465, 4744, 1977, 199, 199, 533, 2624, 8, 785, 304, 272, 408, 1558, 365, 282, 8082, 1059, 315, 314, 14466, 14, 339, 961, 4293, 506, 314, 2536, 1059, 12, 6042, 1059, 503, 1347, 1059, 14, 272, 7048, 909, 315, 282, 1059, 965, 282, 3747, 1059, 1329, 626, 22975, 272, 652, 687, 1163, 2251, 315, 314, 1059, 1041, 339, 347, 636, 826, 721, 277, 12, 14466, 12, 1059, 304, 267, 291, 14, 13249, 275, 14466, 267, 291, 14, 83, 3587, 846, 275, 291, 14, 13249, 14, 83, 3587, 846, 267, 291, 14, 354, 275, 1059, 267, 291, 14, 31381, 63, 875, 63, 1955, 275, 446, 17, 267, 291, 14, 1267, 275, 822, 8, 875, 9, 267, 291, 14, 16415, 275, 1052, 267, 291, 14, 2634, 275, 1052, 267, 291, 14, 15676, 63, 2634, 275, 1052, 267, 291, 14, 785, 63, 12658, 275, 1052, 267, 291, 14, 3039, 63, 1019, 63, 27816, 275, 1052, 267, 291, 14, 504, 63, 475, 63, 27816, 275, 1052, 267, 291, 14, 15676, 63, 27816, 275, 1052, 267, 291, 14, 442, 345, 63, 875, 63, 324, 72, 571, 9585, 275, 378, 267, 291, 14, 27816, 63, 475, 63, 6282, 63, 4972, 275, 1425, 8, 277, 14, 1267, 9, 339, 347, 1050, 63, 475, 63, 785, 63, 12658, 8, 277, 12, 1559, 12, 3421, 304, 267, 408, 1123, 376, 909, 370, 314, 909, 12266, 1041, 267, 340, 3421, 315, 291, 14, 785, 63, 12658, 26, 288, 291, 14, 785, 63, 12658, 59, 3124, 1055, 740, 8, 1113, 9, 267, 587, 26, 288, 291, 14, 785, 63, 12658, 59, 3124, 61, 275, 359, 1113, 61, 339, 347, 2813, 63, 504, 63, 785, 63, 12658, 8, 277, 12, 1559, 12, 3421, 304, 267, 408, 5587, 376, 909, 687, 314, 909, 12266, 1041, 267, 340, 1559, 315, 291, 14, 785, 63, 12658, 59, 3124, 2189, 288, 291, 14, 785, 63, 12658, 59, 3124, 1055, 2168, 8, 1113, 9, 339, 347, 1050, 63, 9269, 8, 277, 12, 8082, 304, 267, 408, 1123, 282, 8082, 370, 314, 1059, 1041, 267, 291, 14, 31381, 63, 875, 63, 1955, 847, 413, 267, 8082, 14, 875, 63, 1955, 275, 291, 14, 31381, 63, 875, 63, 1955, 267, 3421, 275, 8082, 14, 3039, 63, 875, 63, 3124, 267, 291, 14, 16415, 59, 3124, 61, 275, 8082, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 9269, 12, 3421, 9, 339, 347, 664, 63, 16415, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 14435, 315, 314, 1059, 1041, 267, 372, 359, 277, 14, 16415, 59, 1080, 61, 367, 1478, 315, 3355, 8, 277, 14, 16415, 14, 1612, 24821, 339, 347, 664, 63, 9269, 8, 277, 12, 3421, 304, 267, 408, 1767, 314, 8082, 737, 314, 1627, 3421, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 3124, 9, 339, 347, 664, 63, 2355, 63, 9269, 8, 277, 304, 267, 408, 1767, 282, 2196, 8082, 687, 314, 1059, 1041, 267, 372, 2196, 14, 5095, 8, 277, 14, 362, 63, 16415, 1012, 339, 347, 664, 63, 3039, 2786, 63, 9269, 8, 277, 304, 267, 408, 1767, 314, 29971, 8082, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 16, 9, 339, 347, 664, 63, 1019, 2786, 63, 9269, 8, 277, 304, 267, 408, 1767, 314, 2451, 2786, 8082, 315, 314, 1059, 1041, 267, 372, 291, 14, 16415, 14, 362, 8, 552, 8, 277, 14, 16415, 9, 446, 413, 9, 339, 347, 1050, 63, 923, 8, 277, 12, 1572, 304, 267, 408, 1123, 282, 1572, 370, 314, 1059, 1041, 267, 291, 14, 31381, 63, 875, 63, 1955, 847, 413, 267, 1572, 14, 875, 63, 1955, 275, 291, 14, 31381, 63, 875, 63, 1955, 267, 291, 14, 2634, 59, 923, 14, 3039, 63, 785, 14, 875, 63, 1955, 61, 275, 1572, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 3039, 63, 875, 63, 3124, 9, 267, 291, 14, 525, 63, 475, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 1019, 63, 875, 63, 3124, 9, 339, 347, 2813, 63, 923, 8, 277, 12, 1572, 304, 267, 408, 5587, 282, 1572, 687, 314, 1059, 1041, 267, 340, 1572, 14, 3039, 63, 785, 14, 875, 63, 1955, 315, 291, 14, 2634, 26, 288, 2150, 291, 14, 2634, 59, 923, 14, 3039, 63, 785, 14, 875, 63, 1955, 61, 267, 291, 14, 2168, 63, 504, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 3039, 63, 875, 63, 3124, 9, 267, 291, 14, 2168, 63, 504, 63, 785, 63, 12658, 8, 923, 12, 1572, 14, 1019, 63, 875, 63, 3124, 9, 339, 347, 664, 63, 2634, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 4652, 315, 314, 1059, 1041, 267, 372, 769, 8, 277, 14, 2634, 14, 1459, 1012, 339, 347, 664, 63, 923, 8, 277, 12, 3421, 304, 267, 408, 1767, 314, 1572, 737, 314, 1627, 3421, 315, 14435, 14, 398, 4376, 6150, 1343, 737, 378, 436, 10618, 370, 314, 3421, 402, 314, 29971, 909, 267, 315, 314, 1572, 1041, 267, 372, 291, 14, 362, 63, 9269, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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iler # # # # [Author] # # Muris Kurgas aka j0rgan # j0rgan [at] remote-exploit [dot] org # http://www.remote-exploit.org # http://www.azuzi.me # # # # [License] # # 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 # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See 'docs/LICENSE' for more information. import sys import os import ftplib import ConfigParser import urllib import gzip import csv # Reading configuration file... config = ConfigParser.ConfigParser() config.read('cupp.cfg') years = config.get('years', 'years').split(',') chars = config.get('specialchars', 'chars').split(',') numfrom = config.getint('nums','from') numto = config.getint('nums','to') wcfrom = config.getint('nums','wcfrom') wcto = config.getint('nums','wcto') threshold = config.getint('nums','threshold') # 1337 mode configs, well you can add more lines if you add it to config file too. # You will need to add more lines in two places in cupp.py code as well... a = config.get('leet','a') i = config.get('leet','i') e = config.get('leet','e') t = config.get('leet','t') o = config.get('leet','o') s = config.get('leet','s') g = config.get('leet','g') z = config.get('leet','z') # for concatenations... def concats(seq, start, stop): for mystr in seq: for num in xrange(start, stop): yield mystr + str(num) # for sorting and making combinations... def komb(seq, start): for mystr in seq: for mystr1 in start: yield mystr + mystr1 if len(sys.argv) < 2 or sys.argv[1] == '-h': print " ___________ " print " \033[07m cupp.py! \033[27m # Common" print " \ # User" print " \ \033[1;31m,__,\033[1;m # Passwords" print " \ \033[1;31m(\033[1;moo\033[1;31m)____\033[1;m # Profiler" print " \033[1;31m(__) )\ \033[1;m " print " \033[1;31m ||--|| \033[1;m\033[05m*\033[25m\033[1;m [ Muris Kurgas | j0rgan@remote-exploit.org ]\r\n\r\n" print " [ Options ]\r\n" print " -h You are looking at it baby! :)" print " For more help take a look in docs/README" print " Global configuration file is cupp.cfg\n" print " -i Interactive questions for user password profiling\r\n" print " -w Use this option to improve existing dictionary," print " or WyD.pl output to make some pwnsauce\r\n" print " -l Download huge wordlists from repository\r\n" print " -a Parse default usernames and passwords directly from Alecto DB." print " Project Alecto uses purified databases of Phenoelit and CIRT" print " which where merged and enhanced.\r\n" print " -v Version of the program\r\n" exit() elif sys.argv[1] == '-v': print "\r\n \033[1;31m[ cupp.py ] v3.1\033[1;m\r\n" print " * Hacked up by j0rgan - j0rgan@remote-exploit.org" print " * http://www.remote-exploit.org\r\n" print " Take a look docs/README file for more info about the program\r\n" exit() elif sys.argv[1] == '-w': if len(sys.argv) < 3: print "\r\n[Usage]: "+sys.argv[0]+" -w [FILENAME]\r\n" exit() fajl = open(sys.argv[2], "r") listic = fajl.readlines() linije = 0 for line in listic: linije += 1 listica = [] for x in listic: listica += x.split() print "\r\n *************************************************" print " * \033[1;31mWARNING!!!\033[1;m *" print " * Using large wordlists in some *" print " * options bellow is NOT recommended! *" print " *************************************************\r\n" conts = raw_input("[>] Do you want to concatenate all words from wordlist? Y/[N]: ").lower() if conts == "y" and linije > threshold: print "\r\n[-] Maximum number of words for concatenation is "+str(threshold) print "[-] Check configuration file for increasing this number.\r\n" conts = raw_input("[>] Do you want to concatenate all words from wordlist? Y/[N]: ").lower() conts = conts cont = [''] if conts == "y": for cont1 in listica: for cont2 in listica: if listica.index(cont1) != listica.index(cont2): cont.append(cont1+cont2) spechars = [''] spechars1 = raw_input("[>] Do you want to add special chars at the end of words? Y/[N]: ").lower() if spechars1 == "y": for spec1 in chars: spechars.append(spec1) for spec2 in chars: spechars.append(spec1+spec2) for spec3 in chars: spechars.append(spec1+spec2+spec3) randnum = raw_input("[>] Do you want to add some random numbers at the end of words? Y/[N]").lower() leetmode = raw_input("[>]Leet mode? (i.e. leet = 1337) Y/[N]: ").lower() kombinacija1 = list(komb(listica, years)) kombinacija2 = [''] if conts == "y": kombinacija2 = list(komb(cont, years)) kombinacija3 = [''] kombinacija4 = [''] if spechars1 == "y": kombinacija3 = list(komb(listica, spechars)) if conts == "y": kombinacija4 = list(komb(cont, spechars)) kombinacija5 = [''] kombinacija6 = [''] if randnum == "y": kombinacija5 = list(concats(listica, numfrom, numto)) if conts == "y": kombinacija6 = list(concats(cont, numfrom, numto)) print "\r\n[+] Now making a dictionary..." print "[+] Sorting list and removing duplicates..." komb_unique1 = dict.fromkeys(kombinacija1).keys() komb_unique2 = dict.fromkeys(kombinacija2).keys() komb_unique3 = dict.fromkeys(kombinacija3).keys() komb_unique4 = dict.fromkeys(kombinacija4).keys() komb_unique5 = dict.fromkeys(kombinacija5).keys() komb_unique6 = dict.fromkeys(kombinacija6).keys() komb_unique7 = dict.fromkeys(listica).keys() komb_unique8 = dict.fromkeys(cont).keys() uniqlist = komb_unique1+komb_unique2+komb_unique3+komb_unique4+komb_unique5+komb_unique6+komb_unique7+komb_unique8 unique_lista = dict.fromkeys(uniqlist).keys() unique_leet = [] if leetmode == "y": for x in unique_lista: # if you want to add more leet chars, you will need to add more lines in cupp.cfg too... x = x.replace('a',a) x = x.replace('i',i) x = x.replace('e',e) x = x.replace('t',t) x = x.replace('o',o) x = x.replace('s',s) x = x.replace('g',g) x = x.replace('z',z) unique_leet.append(x) unique_list = unique_lista + unique_leet unique_list_finished = [] for x in unique_list: if len(x) > wcfrom and len(x) < wcto: unique_list_finished.append(x) f = open ( sys.argv[2]+'.cupp.txt', 'w' ) unique_list_finished.sort() f.write (os.linesep.join(unique_list_finished)) f = open ( sys.argv[2]+'.cupp.txt', 'r' ) lines = 0 for line in f: lines += 1 f.close() print "[+] Saving dictionary to \033[1;31m"+sys.argv[2]+".cupp.txt\033[1;m, counting \033[1;31m"+str(lines)+" words.\033[1;m" print "[+] Now load your pistolero with \033[1;31m"+sys.argv[2]+".cupp.txt\033[1;m and shoot! Good luck!" fajl.close() exit() elif sys.argv[1] == '-i': print "\r\n[+] Insert the informations about the victim to make a dictionary" print "[+] If you don't know all the info, just hit enter when asked! ;)\r\n" # We need some informations first! name = raw_input("[>] Name: ").lower() while len(name) == 0 or name == " " or name == " " or name == " ": print "\r\n[-] You must enter a name at least!" name = raw_input("[>] Name: ").lower() name = str(name) surname = raw_input("[>] Surname: ").lower() nick = raw_input("[>] Nickname: ").lower() birthdate = raw_input("[>] Birthdate (DDMMYYYY): ") while len(birthdate) != 0 and len(birthdate) != 8: print "\r\n[-] You must enter 8 digits for birthday!" birthdate = raw_input("[>] Birthdate (DDMMYYYY): ") birthdate = str(birthdate) print "\r\n" wife = raw_input("[>] Wife's(husband's) name: ").lower() wifen = raw_input("[>] Wife's(husband's) nickname: ").lower() wifeb = raw_input("[>] Wife's(husband's) birthdate (DDMMYYYY): ") while len(wifeb) != 0 and len(wifeb) != 8: print "\r\n[-] You must enter 8 digits for birthday!" wifeb = raw_input("[>] Wife's(husband's) birthdate (DDMMYYYY): ") wifeb = str(wifeb) print "\r\n" kid = raw_input("[>] Child's name: ").lower() kidn = raw_input("[>] Child's nickname: ").lower() kidb = raw_input("[>] Child's birthdate (DDMMYYYY): ") while len(kidb) != 0 and len(kidb) != 8: print "\r\n[-] You must enter 8 digits for birthday!" kidb = raw_input("[>] Child's birthdate (DDMMYYYY): ") kidb = str(kidb) print "\r\n" pet = raw_input("[>] Pet's name: ").lower() company = raw_input("[>] Company name: ").lower() print "\r\n" words = [''] oth = raw_input("[>] Do you want to add some key words about the victim? Y/[N]: ").lower() if oth == "y": words = raw_input("[>] Please enter the words, separated by comma. [i.e. hacker, juice, black]: ").lower().split(", ") spechars = [''] spechars1 = raw_input("[>] Do you want to add special chars at the end of words? Y/[N]: ").lower() if spechars1 == "y": for spec1 in chars: spechars.append(spec1) for spec2 in chars: spechars.append(spec1+spec2) for spec3 in chars: spechars.append(spec1+spec2+spec3) randnum = raw_input("[>] Do you want to add some random numbers at the end of words? Y/[N]").lower() leetmode = raw_input("[>] Leet mode? (i.e. leet = 1337) Y/[N]: ").lower() print "\r\n[+] Now making a dictionary..." # Now me must do some string modifications... # Birthdays first birthdate_yy = birthdate[-2:] birthdate_yyy = birthdate[-3:] birthdate_yyyy = birthdate[-4:] birthdate_xd = birthdate[1:2] birthdate_xm = birthdate[3:4] birthdate_dd = birthdate[:2] birthdate_mm = birthdate[2:4] wifeb_yy = wifeb[-2:] wifeb_yyy = wifeb[-3:] wifeb_yyyy = wifeb[-4:] wifeb_xd = wifeb[1:2] wifeb_xm = wifeb[3:4] wifeb_dd = wifeb[:2] wifeb_mm = wifeb[2:4] kidb_yy = kidb[-2:] kidb_yyy = kidb[-3:] kidb_yyyy = kidb[-4:] kidb_xd = kidb[1:2] kidb_xm = kidb[3:4] kidb_dd = kidb[:2] kidb_mm = kidb[2:4] # Convert first letters to uppercase... nameup = name.title() surnameup = surname.title() nickup = nick.title() wifeup = wife.title() wifenup = wifen.title() kidup = kid.title() kidnup = kidn.title() petup = pet.title() companyup = company.title() wordsup = [] for words1 in words: wordsup.append(words1.title()) word = words+wordsup # reverse a name rev_name = name[::-1] rev_nameup = nameup[::-1] rev_nick = nick[::-1] rev_nickup = nickup[::-1] rev_wife = wife[::-1] rev_wifeup = wifeup[::-1] rev_kid = kid[::-1] rev_kidup = kidup[::-1] reverse = [rev_name, rev_nameup, rev_nick, rev_nickup, rev_wife, rev_wifeup, rev_kid, rev_kidup] rev_n = [rev_name, rev_nameup, rev_nick, rev_nickup] rev_w = [rev_wife, rev_wifeup] rev_k = [rev_kid, rev_kidup] # Let's do some serious work! This will be a mess of code, but... who cares? :) # Birthdays combinations bds = [birthdate_yy, birthdate_yyy, birthdate_yyyy, birthdate_xd, birthdate_xm, birthdate_dd, birthdate_mm] bdss = [] for bds1 in bds: bdss.append(bds1) for bds2 in bds: if bds.index(bds1) != bds.index(bds2): bdss.append(bds1+bds2) for bds3 in bds: if bds.index(bds1) != bds.index(bds2) and bds.index(bds2) != bds.index(bds3) and bds.index(bds1) != bds.index(bds3): bdss.append(bds1+bds2+bds3) # For a woman... wbds = [wifeb_yy, wifeb_yyy, wifeb_yyyy, wifeb_xd, wifeb_xm, wifeb_dd, wifeb_mm] wbdss = [] for wbds1 in wbds: wbdss.append(wbds1) for wbds2 in wbds: if wbds.index(wbds1) != wbds.index(wbds2): wbdss.append(wbds1+wbds2) for wbds3 in wbds: if wbds.index(wbds1) != wbds.index(wbds2) and wbds.index(wbds2) != wbds.index(wbds3) and wbds.index(wbds1) != wbds.index(wbds3): wbdss.append(wbds1+wbds2+wbds3) # and a child... kbds = [kidb_yy, kidb_yyy, kidb_yyyy, kidb_xd, kidb_xm, kidb_dd, kidb_mm] kbdss = [] for kbds1 in kbds: kbdss.append(kbds1) for kbds2 in kbds: if kbds.index(kbds1) != kbds.index(kbds2): kbdss.append(kbds1+kbds2) for kbds3 in kbds: if kbds.index(kbds1) != kbds.index(kbds2) and kbds.index(kbds2) != kbds.index(kbds3) and kbds.index(kbds1) != kbds.index(kbds3): kbdss.append(kbds1+kbds2+kbds3) # string combinations.... kombinaac = [pet, petup, company, companyup] kombina = [name, surname, nick, nameup, surnameup, nickup] kombinaw = [wife, wifen, wifeup, wifenup, surname, surnameup] kombinak = [kid, kidn, kidup, kidnup, surname, surnameup] kombinaa = [] for kombina1 in kombina: kombinaa.append(kombina1) for kombina2 in kombina: if kombina.index(kombina1) != kombina.index(kombina2) and kombina.index(kombina1.title()) != kombina.index(kombina2.title()): kombinaa.append(kombina1+kombina2) kombinaaw = [] for kombina1 in kombinaw: kombinaaw.append(kombina1) for kombina2 in kombinaw: if kombinaw.index(kombina1) != kombinaw.index(kombina2) and kombinaw.index(kombina1.title()) != kombinaw.index(kombina2.title()): kombinaaw.append(kombina1+kombina2) kombinaak = [] for kombina1 in kombinak: kombinaak.append(kombina1) for kombina2 in kombinak: if kombinak.index(kombina1) != kombinak.index(kombina2) and kombinak.index(kombina1.title()) != kombinak.index(kombina2.title()): kombinaak.append(kombina1+kombina2) komb1 = list(komb(kombinaa, bdss)) komb2 = list(komb(kombinaaw, wbdss)) komb3 = list(komb(kombinaak, kbdss)) komb4 = list(komb(kombinaa, years)) komb5 = list(komb(kombinaac, years)) komb6 = list(komb(kombinaaw, years)) komb7 = list(komb(kombinaak, years)) komb8 = list(komb(word, bdss)) komb9 = list(komb(word, wbdss)) komb10 = list(komb(word, kbdss)) komb11 = list(komb(word, years)) komb12 = [''] komb13 = [''] komb14 = [''] komb15 = [''] komb16 = [''] komb21 = [''] if randnum == "y": komb12 = list(concats(word, numfrom, numto)) komb13 = list(concats(kombinaa, numfrom, numto)) komb14 = list(concats(kombinaac, numfrom, numto)) komb15 = list(concats(kombinaaw, numfrom, numto)) komb16 = list(concats(kombinaak, numfrom, numto)) komb21 = list(concats(reverse, numfrom, numto)) komb17 = list(komb(reverse, years)) komb18 = list(komb(rev_w, wbdss)) komb19 = list(komb(rev_k, kbdss)) komb20 = list(komb(rev_n, bdss)) komb001 = [''] komb002 = [''] komb003 = [''] komb004 = [''] komb005 = [''] komb006 = [''] if spechars1 == "y": komb001 = list(komb(kombinaa, spechars)) komb002 = list(komb(kombinaac, spechars)) komb003 = list(komb(kombinaaw , spechars)) komb004 = list(komb(kombinaak , spechars)) komb005 = list(komb(word, spechars)) komb006 = list(komb(reverse, spechars)) print "[+] Sorting list and removing duplicates..." komb_unique1 = dict.fromkeys(komb1).keys() komb_unique2 = dict.fromkeys(komb2).keys() komb_unique3 = dict.fromkeys(komb3).keys() komb_unique4 = dict.fromkeys(komb4).keys() komb_unique5 = dict.fromkeys(komb5).keys() komb_unique6 = dict.fromkeys(komb6).keys() komb_unique7 = dict.fromkeys(komb7).keys() komb_unique8 = dict.fromkeys(komb8).keys() komb_unique9 = dict.fromkeys(komb9).keys() komb_unique10 = dict.fromkeys(komb10).keys() komb_unique11 = dict.fromkeys(komb11).keys() komb_unique12 = dict.fromkeys(komb12).keys() komb_unique13 = dict.fromkeys(komb13).keys() komb_unique14 = dict.fromkeys(komb14).keys() komb_unique15 = dict.fromkeys(komb15).keys() komb_unique16 = dict.fromkeys(komb16).keys() komb_unique17 = dict.fromkeys(komb17).keys() komb_unique18 = dict.fromkeys(komb18).keys() komb_unique19 = dict.fromkeys(komb19).keys() komb_unique20 = dict.fromkeys(komb20).keys() komb_unique21 = dict.fromkeys(komb21).keys() komb_unique01 = dict.fromkeys(kombinaa).keys() komb_unique02 = dict.fromkeys(kombinaac).keys() komb_unique03 = dict.fromkeys(kombinaaw).keys() komb_unique04 = dict.fromkeys(kombinaak).keys() komb_unique05 = dict.fromkeys(word).keys() komb_unique07 = dict.fromkeys(komb001).keys() komb_unique08 = dict.fromkeys(komb002).keys() komb_unique09 = dict.fromkeys(komb003).keys() komb_unique010 = dict.fromkeys(komb004).keys() komb_unique011 = dict.fromkeys(komb005).keys() komb_unique012 = dict.fromkeys(komb006).keys() uniqlist = bdss+wbdss+kbdss+reverse+komb_unique01+komb_unique02+komb_unique03+komb_unique04+komb_unique05+komb_unique1+komb_unique2+komb_unique3+komb_unique4+komb_unique5+komb_unique6+komb_unique7+komb_unique8+komb_unique9+komb_unique10+komb_unique11+komb_unique12+komb_unique13+komb_unique14+komb_unique15+komb_unique16+komb_unique17+komb_unique18+komb_unique19+komb_unique20+komb_unique21+komb_unique07+komb_unique08+komb_unique09+komb_unique010+komb_unique011+komb_unique012 unique_lista = dict.fromkeys(uniqlist).keys() unique_leet = [] if leetmode == "y": for x in unique_lista: # if you want to add more leet chars, you will need to add more lines in cupp.cfg too... x = x.replace('a',a) x = x.replace('i',i) x = x.replace('e',e) x = x.replace('t',t) x = x.replace('o',o) x = x.replace('s',s) x = x.replace('g',g) x = x.replace('z',z) unique_leet.append(x) unique_list = unique_lista + unique_leet unique_list_finished = [] for x in unique_list: if len(x) > wcfrom and len(x) < wcto: unique_list_finished.append(x) unique_list_finished.sort() f = open ( name+'.txt', 'w' ) f.write (os.linesep.join(unique_list_finished)) f = open ( name+'.txt', 'r' ) lines = 0 for line in f: lines += 1 f.close() print "[+] Saving dictionary to \033[1;31m"+name+".txt\033[1;m, counting \033[1;31m"+str(lines)+"\033[1;m words." print "[+] Now load your pistolero with \033[1;31m"+name+".txt\033[1;m and shoot! Good luck!" exit() elif sys.argv[1] == '-a': url = config.get('alecto','alectourl') print "\r\n[+] Checking if alectodb is not present..." if os.path.isfile('alectodb.csv.gz') == 0: print "[+] Downloading alectodb.csv.gz..." webFile = urllib.urlopen(url) localFile = open(url.split('/')[-1], 'w') localFile.write(webFile.read()) webFile.close() localFile.close() f = gzip.open('alectodb.csv.gz', 'rb') data = csv.reader(f) usernames = [] passwords = [] for row in data: usernames.append(row[5]) passwords.append(row[6]) gus = list(set(usernames)) gpa = list(set(passwords)) gus.sort() gpa.sort() print "\r\n[+] Exporting to alectodb-usernames.txt and alectodb-passwords.txt\r\n[+] Done." f = open ( 'alectodb-usernames.txt', 'w' ) f.write (os.linesep.join(gus)) f.close() f = open ( 'alectodb-passwords.txt', 'w' ) f.write (os.linesep.join(gpa)) f.close() f.close() sys.exit() elif sys.argv[1] == '-l': ftpname = config.get('downloader','ftpname') ftpurl = config.get('downloader','ftpurl') ftppath = config.get('downloader','ftppath') ftpuser = config.get('downloader','ftpuser') ftppass = config.get('downloader','ftppass') if os.path.isdir('dictionaries') == 0: os.mkdir('dictionaries') print " \r\n Choose the section you want to download:\r\n" print " 1 Moby 14 french 27 places" print " 2 afrikaans 15 german 28 polish" print " 3 american 16 hindi 39 random" print " 4 aussie 17 hungarian 30 religion" print " 5 chinese 18 italian 31 russian" print " 6 computer 19 japanese 32 science" print " 7 croatian 20 latin 33 spanish" print " 8 czech 21 literature 34 swahili" print " 9 danish 22 movieTV 35 swedish" print " 10 databases 23 music 36 turkish" print " 11 dictionaries 24 names 37 yiddish" print " 12 dutch 25 net 38 exit program" print " 13 finnish 26 norwegian \r\n" print " \r\n Files will be downloaded from "+ftpname+" repository" print " \r\n Tip: After downloading wordlist, you can improve it with -w option\r\n" filedown = raw_input("[>] Enter number: ") filedown.isdigit() while filedown.isdigit() == 0: print "\r\n[-] Wrong choice. " filedown = raw_input("[>] Enter number: ") filedown = str(filedown) while int(filedown) > 38: print "\r\n[-] Wrong choice. " filedown = raw_input("[>] Enter number: ") filedown = str(filedown) def handleDownload(block): file.write(block) print ".", def downloader(): ftp.login(ftpuser, ftppass) ftp.cwd(ftppath) def filequitter(): file.close() print ' done.' if filedown == "1": print "\r\n[+] connecting...\r\n" ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('Moby') if os.path.isdir('dictionaries/Moby/') == 0: os.mkdir('dictionaries/Moby/') dire = 'dictionaries/Moby/' file = open(dire+'mhyph.tar.gz', 'wb') print "\r\n[+] downloading mhyph.tar.gz..." ftp.retrbinary('RETR ' + 'mhyph.tar.gz', handleDownload) filequitter() file = open(dire+'mlang.tar.gz', 'wb') print "\r\n[+] downloading mlang.tar.gz..." ftp.retrbinary('RETR ' + 'mlang.tar.gz', handleDownload) filequitter() file = open(dire+'moby.tar.gz', 'wb') print "\r\n[+] downloading moby.tar.gz..." ftp.retrbinary('RETR ' + 'moby.tar.gz', handleDownload) filequitter() file = open(dire+'mpos.tar.gz', 'wb') print "\r\n[+] downloading mpos.tar.gz..." ftp.retrbinary('RETR ' + 'mpos.tar.gz', handleDownload) filequitter() file = open(dire+'mpron.tar.gz', 'wb') print "\r\n[+] downloading mpron.tar.gz..." ftp.retrbinary('RETR ' + 'mpron.tar.gz', handleDownload) filequitter() file = open(dire+'mthes.tar.gz', 'wb') print "\r\n[+] downloading mthes.tar.gz..." ftp.retrbinary('RETR ' + 'mthes.tar.gz', handleDownload) filequitter() file = open(dire+'mwords.tar.gz', 'wb') print "\r\n[+] downloading mwords.tar.gz..." ftp.retrbinary('RETR ' + 'mwords.tar.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "2": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('afrikaans') if os.path.isdir('dictionaries/afrikaans/') == 0: os.mkdir('dictionaries/afrikaans/') dire = 'dictionaries/afrikaans/' file = open(dire+'afr_dbf.zip', 'wb') print "\r\n[+] downloading afr_dbf.zip..." ftp.retrbinary('RETR ' + 'afr_dbf.zip', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "3": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('american') if os.path.isdir('dictionaries/american/') == 0: os.mkdir('dictionaries/american/') dire = 'dictionaries/american/' file = open(dire+'dic-0294.tar.gz', 'wb') print "\r\n[+] downloading dic-0294.tar.gz..." ftp.retrbinary('RETR ' + 'dic-0294.tar.gz', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "4": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('aussie') if os.path.isdir('dictionaries/aussie/') == 0: os.mkdir('dictionaries/aussie/') dire = 'dictionaries/aussie/' file = open(dire+'oz.Z', 'wb') print "\r\n[+] downloading oz.Z..." ftp.retrbinary('RETR ' + 'oz.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "5": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('chinese') if os.path.isdir('dictionaries/chinese/') == 0: os.mkdir('dictionaries/chinese/') dire = 'dictionaries/chinese/' file = open(dire+'chinese.Z', 'wb') print "\r\n[+] downloading chinese.Z..." ftp.retrbinary('RETR ' + 'chinese.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "6": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('computer') if os.path.isdir('dictionaries/computer/') == 0: os.mkdir('dictionaries/computer/') dire = 'dictionaries/computer/' file = open(dire+'Domains.Z', 'wb') print "\r\n[+] downloading Domains.Z..." ftp.retrbinary('RETR ' + 'Domains.Z', handleDownload) filequitter() file = open(dire+'Dosref.Z', 'wb') print "\r\n[+] downloading Dosref.Z..." ftp.retrbinary('RETR ' + 'Dosref.Z', handleDownload) filequitter() file = open(dire+'Ftpsites.Z', 'wb') print "\r\n[+] downloading Ftpsites.Z..." ftp.retrbinary('RETR ' + 'Ftpsites.Z', handleDownload) filequitter() file = open(dire+'Jargon.Z', 'wb') print "\r\n[+] downloading Jargon.Z..." ftp.retrbinary('RETR ' + 'Jargon.Z', handleDownload) filequitter() file = open(dire+'common-passwords.txt.Z', 'wb') print "\r\n[+] downloading common-passwords.txt.Z..." ftp.retrbinary('RETR ' + 'common-passwords.txt.Z', handleDownload) filequitter() file = open(dire+'etc-hosts.Z', 'wb') print "\r\n[+] downloading etc-hosts.Z..." ftp.retrbinary('RETR ' + 'etc-hosts.Z', handleDownload) filequitter() file = open(dire+'foldoc.gz', 'wb') print "\r\n[+] downloading foldoc.gz..." ftp.retrbinary('RETR ' + 'foldoc.gz', handleDownload) filequitter() file = open(dire+'language-list.Z', 'wb') print "\r\n[+] downloading language-list.Z..." ftp.retrbinary('RETR ' + 'language-list.Z', handleDownload) filequitter() file = open(dire+'unix.Z', 'wb') print "\r\n[+] downloading unix.Z..." ftp.retrbinary('RETR ' + 'unix.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "7": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('croatian') if os.path.isdir('dictionaries/croatian/') == 0: os.mkdir('dictionaries/croatian/') dire = 'dictionaries/croatian/' file = open(dire+'croatian.gz', 'wb') print "\r\n[+] downloading croatian.gz..." ftp.retrbinary('RETR ' + 'croatian.gz', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "8": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('czech') if os.path.isdir('dictionaries/czech/') == 0: os.mkdir('dictionaries/czech/') dire = 'dictionaries/czech/' file = open(dire+'czech-wordlist-ascii-cstug-novak.Z', 'wb') print "\r\n[+] downloading czech-wordlist-ascii-cstug-novak.Z..." ftp.retrbinary('RETR ' + 'czech-wordlist-ascii-cstug-novak.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "9": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('danish') if os.path.isdir('dictionaries/danish/') == 0: os.mkdir('dictionaries/danish/') dire = 'dictionaries/danish/' file = open(dire+'danish.words.Z', 'wb') print "\r\n[+] downloading danish.words.Z..." ftp.retrbinary('RETR ' + 'danish.words.Z', handleDownload) filequitter() file = open(dire+'dansk.zip', 'wb') print "\r\n[+] downloading dansk.zip..." ftp.retrbinary('RETR ' + 'dansk.zip', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "10": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('databases') if os.path.isdir('dictionaries/databases/') == 0: os.mkdir('dictionaries/databases/') dire = 'dictionaries/databases/' file = open(dire+'acronyms.Z', 'wb') print "\r\n[+] downloading acronyms.Z..." ftp.retrbinary('RETR ' + 'acronyms.Z', handleDownload) filequitter() file = open(dire+'att800.Z', 'wb') print "\r\n[+] downloading att800.Z..." ftp.retrbinary('RETR ' + 'att800.Z', handleDownload) filequitter() file = open(dire+'computer-companies.Z', 'wb') print "\r\n[+] downloading computer-companies.Z..." ftp.retrbinary('RETR ' + 'computer-companies.Z', handleDownload) filequitter() file = open(dire+'world_heritage.Z', 'wb') print "\r\n[+] downloading world_heritage.Z..." ftp.retrbinary('RETR ' + 'world_heritage.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "11": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('dictionaries') if os.path.isdir('dictionaries/dictionaries/') == 0: os.mkdir('dictionaries/dictionaries/') dire = 'dictionaries/dictionaries/' file = open(dire+'Antworth.gz', 'wb') print "\r\n[+] downloading Antworth.gz..." ftp.retrbinary('RETR ' + 'Antworth.gz', handleDownload) filequitter() file = open(dire+'CRL.words.gz', 'wb') print "\r\n[+] downloading CRL.words.gz..." ftp.retrbinary('RETR ' + 'CRL.words.gz', handleDownload) filequitter() file = open(dire+'Roget.words.gz', 'wb') print "\r\n[+] downloading Roget.words.gz..." ftp.retrbinary('RETR ' + 'Roget.words.gz', handleDownload) filequitter() file = open(dire+'Unabr.dict.gz', 'wb') print "\r\n[+] downloading Unabr.dict.gz..." ftp.retrbinary('RETR ' + 'Unabr.dict.gz', handleDownload) filequitter() file = open(dire+'Unix.dict.gz', 'wb') print "\r\n[+] downloading Unix.dict.gz..." ftp.retrbinary('RETR ' + 'Unix.dict.gz', handleDownload) filequitter() file = open(dire+'englex-dict.gz', 'wb') print "\r\n[+] downloading englex-dict.gz..." ftp.retrbinary('RETR ' + 'englex-dict.gz', handleDownload) filequitter() file = open(dire+'knuth_britsh.gz', 'wb') print "\r\n[+] downloading knuth_britsh.gz..." ftp.retrbinary('RETR ' + 'knuth_britsh.gz', handleDownload) filequitter() file = open(dire+'knuth_words.gz', 'wb') print "\r\n[+] downloading knuth_words.gz..." ftp.retrbinary('RETR ' + 'knuth_words.gz', handleDownload) filequitter() file = open(dire+'pocket-dic.gz', 'wb') print "\r\n[+] downloading pocket-dic.gz..." ftp.retrbinary('RETR ' + 'pocket-dic.gz', handleDownload) filequitter() file = open(dire+'shakesp-glossary.gz', 'wb') print "\r\n[+] downloading shakesp-glossary.gz..." ftp.retrbinary('RETR ' + 'shakesp-glossary.gz', handleDownload) filequitter() file = open(dire+'special.eng.gz', 'wb') print "\r\n[+] downloading special.eng.gz..." ftp.retrbinary('RETR ' + 'special.eng.gz', handleDownload) filequitter() file = open(dire+'words-english.gz', 'wb') print "\r\n[+] downloading words-english.gz..." ftp.retrbinary('RETR ' + 'words-english.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "12": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('dutch') if os.path.isdir('dictionaries/dutch/') == 0: os.mkdir('dictionaries/dutch/') dire = 'dictionaries/dutch/' file = open(dire+'words.dutch.Z', 'wb') print "\r\n[+] downloading words.dutch.Z..." ftp.retrbinary('RETR ' + 'words.dutch.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "13": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('finnish') if os.path.isdir('dictionaries/finnish/') == 0: os.mkdir('dictionaries/finnish/') dire = 'dictionaries/finnish/' file = open(dire+'finnish.gz', 'wb') print "\r\n[+] downloading finnish.gz..." ftp.retrbinary('RETR ' + 'finnish.gz', handleDownload) filequitter() file = open(dire+'firstnames.finnish.gz', 'wb') print "\r\n[+] downloading firstnames.finnish.gz..." ftp.retrbinary('RETR ' + 'firstnames.finnish.gz', handleDownload) filequitter() file = open(dire+'words.finnish.FAQ.gz', 'wb') print "\r\n[+] downloading words.finnish.FAQ.gz..." ftp.retrbinary('RETR ' + 'words.finnish.FAQ.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "14": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('french') if os.path.isdir('dictionaries/french/') == 0: os.mkdir('dictionaries/french/') dire = 'dictionaries/french/' file = open(dire+'dico.Z', 'wb') print "\r\n[+] downloading dico.Z..." ftp.retrbinary('RETR ' + 'dico.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "15": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('german') if os.path.isdir('dictionaries/german/') == 0: os.mkdir('dictionaries/german/') dire = 'dictionaries/german/' file = open(dire+'deutsch.dic.Z', 'wb') print "\r\n[+] downloading deutsch.dic.Z..." ftp.retrbinary('RETR ' + 'deutsch.dic.Z', handleDownload) filequitter() file = open(dire+'germanl.Z', 'wb') print "\r\n[+] downloading germanl.Z..." ftp.retrbinary('RETR ' + 'germanl.Z', handleDownload) filequitter() file = open(dire+'words.german.Z', 'wb') print "\r\n[+] downloading words.german.Z..." ftp.retrbinary('RETR ' + 'words.german.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "16": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('hindi') if os.path.isdir('dictionaries/hindi/') == 0: os.mkdir('dictionaries/hindi/') dire = 'dictionaries/hindi/' file = open(dire+'hindu-names.Z', 'wb') print "\r\n[+] downloading hindu-names.Z..." ftp.retrbinary('RETR ' + 'hindu-names.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "17": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('hungarian') if os.path.isdir('dictionaries/hungarian/') == 0: os.mkdir('dictionaries/hungarian/') dire = 'dictionaries/hungarian/' file = open(dire+'hungarian.gz', 'wb') print "\r\n[+] downloading hungarian.gz..." ftp.retrbinary('RETR ' + 'hungarian.gz', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "18": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('italian') if os.path.isdir('dictionaries/italian/') == 0: os.mkdir('dictionaries/italian/') dire = 'dictionaries/italian/' file = open(dire+'words.italian.Z', 'wb') print "\r\n[+] downloading words.italian.Z..." ftp.retrbinary('RETR ' + 'words.italian.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "19": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('japanese') if os.path.isdir('dictionaries/japanese/') == 0: os.mkdir('dictionaries/japanese/') dire = 'dictionaries/japanese/' file = open(dire+'words.japanese.Z', 'wb') print "\r\n[+] downloading words.japanese.Z..." ftp.retrbinary('RETR ' + 'words.japanese.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "20": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('latin') if os.path.isdir('dictionaries/latin/') == 0: os.mkdir('dictionaries/latin/') dire = 'dictionaries/latin/' file = open(dire+'wordlist.aug.Z', 'wb') print "\r\n[+] downloading wordlist.aug.Z..." ftp.retrbinary('RETR ' + 'wordlist.aug.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "21": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('literature') if os.path.isdir('dictionaries/literature/') == 0: os.mkdir('dictionaries/literature/') dire = 'dictionaries/literature/' file = open(dire+'LCarrol.gz', 'wb') print "\r\n[+] downloading LCarrol.gz..." ftp.retrbinary('RETR ' + 'LCarrol.gz', handleDownload) filequitter() file = open(dire+'Paradise.Lost.gz', 'wb') print "\r\n[+] downloading Paradise.Lost.gz..." ftp.retrbinary('RETR ' + 'Paradise.Lost.gz', handleDownload) filequitter() file = open(dire+'aeneid.gz', 'wb') print "\r\n[+] downloading aeneid.gz..." ftp.retrbinary('RETR ' + 'aeneid.gz', handleDownload) filequitter() file = open(dire+'arthur.gz', 'wb') print "\r\n[+] downloading arthur.gz..." ftp.retrbinary('RETR ' + 'arthur.gz', handleDownload) filequitter() file = open(dire+'cartoon.gz', 'wb') print "\r\n[+] downloading cartoon.gz..." ftp.retrbinary('RETR ' + 'cartoon.gz', handleDownload) filequitter() file = open(dire+'cartoons-olivier.gz', 'wb') print "\r\n[+] downloading cartoons-olivier.gz..." ftp.retrbinary('RETR ' + 'cartoons-olivier.gz', handleDownload) filequitter() file = open(dire+'charlemagne.gz', 'wb') print "\r\n[+] downloading charlemagne.gz..." ftp.retrbinary('RETR ' + 'charlemagne.gz', handleDownload) filequitter() file = open(dire+'fable.gz', 'wb') print "\r\n[+] downloading fable.gz..." ftp.retrbinary('RETR ' + 'fable.gz', handleDownload) filequitter() file = open(dire+'iliad.gz', 'wb') print "\r\n[+] downloading iliad.gz..." ftp.retrbinary('RETR ' + 'iliad.gz', handleDownload) filequitter() file = open(dire+'myths-legends.gz', 'wb') print "\r\n[+] downloading myths-legends.gz..." ftp.retrbinary('RETR ' + 'myths-legends.gz', handleDownload) filequitter() file = open(dire+'odyssey.gz', 'wb') print "\r\n[+] downloading odyssey.gz..." ftp.retrbinary('RETR ' + 'odyssey.gz', handleDownload) filequitter() file = open(dire+'sf.gz', 'wb') print "\r\n[+] downloading sf.gz..." ftp.retrbinary('RETR ' + 'sf.gz', handleDownload) filequitter() file = open(dire+'shakespeare.gz', 'wb') print "\r\n[+] downloading shakespeare.gz..." ftp.retrbinary('RETR ' + 'shakespeare.gz', handleDownload) filequitter() file = open(dire+'tolkien.words.gz', 'wb') print "\r\n[+] downloading tolkien.words.gz..." ftp.retrbinary('RETR ' + 'tolkien.words.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "22": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('movieTV') if os.path.isdir('dictionaries/movieTV/') == 0: os.mkdir('dictionaries/movieTV/') dire = 'dictionaries/movieTV/' file = open(dire+'Movies.Z', 'wb') print "\r\n[+] downloading Movies.Z..." ftp.retrbinary('RETR ' + 'Movies.Z', handleDownload) filequitter() file = open(dire+'Python.Z', 'wb') print "\r\n[+] downloading Python.Z..." ftp.retrbinary('RETR ' + 'Python.Z', handleDownload) filequitter() file = open(dire+'Trek.Z', 'wb') print "\r\n[+] downloading Trek.Z..." ftp.retrbinary('RETR ' + 'Trek.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "23": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('music') if os.path.isdir('dictionaries/music/') == 0: os.mkdir('dictionaries/music/') dire = 'dictionaries/music/' file = open(dire+'music-classical.gz', 'wb') print "\r\n[+] downloading music-classical.gz..." ftp.retrbinary('RETR ' + 'music-classical.gz', handleDownload) filequitter() file = open(dire+'music-country.gz', 'wb') print "\r\n[+] downloading music-country.gz..." ftp.retrbinary('RETR ' + 'music-country.gz', handleDownload) filequitter() file = open(dire+'music-jazz.gz', 'wb') print "\r\n[+] downloading music-jazz.gz..." ftp.retrbinary('RETR ' + 'music-jazz.gz', handleDownload) filequitter() file = open(dire+'music-other.gz', 'wb') print "\r\n[+] downloading music-other.gz..." ftp.retrbinary('RETR ' + 'music-other.gz', handleDownload) filequitter() file = open(dire+'music-rock.gz', 'wb') print "\r\n[+] downloading music-rock.gz..." ftp.retrbinary('RETR ' + 'music-rock.gz', handleDownload) filequitter() file = open(dire+'music-shows.gz', 'wb') print "\r\n[+] downloading music-shows.gz..." ftp.retrbinary('RETR ' + 'music-shows.gz', handleDownload) filequitter() file = open(dire+'rock-groups.gz', 'wb') print "\r\n[+] downloading rock-groups.gz..." ftp.retrbinary('RETR ' + 'rock-groups.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "24": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('names') if os.path.isdir('dictionaries/names/') == 0: os.mkdir('dictionaries/names/') dire = 'dictionaries/names/' file = open(dire+'ASSurnames.gz', 'wb') print "\r\n[+] downloading ASSurnames.gz..." ftp.retrbinary('RETR ' + 'ASSurnames.gz', handleDownload) filequitter() file = open(dire+'Congress.gz', 'wb') print "\r\n[+] downloading Congress.gz..." ftp.retrbinary('RETR ' + 'Congress.gz', handleDownload) filequitter() file = open(dire+'Family-Names.gz', 'wb') print "\r\n[+] downloading Family-Names.gz..." ftp.retrbinary('RETR ' + 'Family-Names.gz', handleDownload) filequitter() file = open(dire+'Given-Names.gz', 'wb') print "\r\n[+] downloading Given-Names.gz..." ftp.retrbinary('RETR ' + 'Given-Names.gz', handleDownload) filequitter() file = open(dire+'actor-givenname.gz', 'wb') print "\r\n[+] downloading actor-givenname.gz..." ftp.retrbinary('RETR ' + 'actor-givenname.gz', handleDownload) filequitter() file = open(dire+'actor-surname.gz', 'wb') print "\r\n[+] downloading actor-surname.gz..." ftp.retrbinary('RETR ' + 'actor-surname.gz', handleDownload) filequitter() file = open(dire+'cis-givenname.gz', 'wb') print "\r\n[+] downloading cis-givenname.gz..." ftp.retrbinary('RETR ' + 'cis-givenname.gz', handleDownload) filequitter() file = open(dire+'cis-surname.gz', 'wb') print "\r\n[+] downloading cis-surname.gz..." ftp.retrbinary('RETR ' + 'cis-surname.gz', handleDownload) filequitter() file = open(dire+'crl-names.gz', 'wb') print "\r\n[+] downloading crl-names.gz..." ftp.retrbinary('RETR ' + 'crl-names.gz', handleDownload) filequitter() file = open(dire+'famous.gz', 'wb') print "\r\n[+] downloading famous.gz..." ftp.retrbinary('RETR ' + 'famous.gz', handleDownload) filequitter() file = open(dire+'fast-names.gz', 'wb') print "\r\n[+] downloading fast-names.gz..." ftp.retrbinary('RETR ' + 'fast-names.gz', handleDownload) filequitter() file = open(dire+'female-names-kantr.gz', 'wb') print "\r\n[+] downloading female-names-kantr.gz..." ftp.retrbinary('RETR ' + 'female-names-kantr.gz', handleDownload) filequitter() file = open(dire+'female-names.gz', 'wb') print "\r\n[+] downloading female-names.gz..." ftp.retrbinary('RETR ' + 'female-names.gz', handleDownload) filequitter() file = open(dire+'givennames-ol.gz', 'wb') print "\r\n[+] downloading givennames-ol.gz..." ftp.retrbinary('RETR ' + 'givennames-ol.gz', handleDownload) filequitter() file = open(dire+'male-names-kantr.gz', 'wb') print "\r\n[+] downloading male-names-kantr.gz..." ftp.retrbinary('RETR ' + 'male-names-kantr.gz', handleDownload) filequitter() file = open(dire+'male-names.gz', 'wb') print "\r\n[+] downloading male-names.gz..." ftp.retrbinary('RETR ' + 'male-names.gz', handleDownload) filequitter() file = open(dire+'movie-characters.gz', 'wb') print "\r\n[+] downloading movie-characters.gz..." ftp.retrbinary('RETR ' + 'movie-characters.gz', handleDownload) filequitter() file = open(dire+'names.french.gz', 'wb') print "\r\n[+] downloading names.french.gz..." ftp.retrbinary('RETR ' + 'names.french.gz', handleDownload) filequitter() file = open(dire+'names.hp.gz', 'wb') print "\r\n[+] downloading names.hp.gz..." ftp.retrbinary('RETR ' + 'names.hp.gz', handleDownload) filequitter() file = open(dire+'other-names.gz', 'wb') print "\r\n[+] downloading other-names.gz..." ftp.retrbinary('RETR ' + 'other-names.gz', handleDownload) filequitter() file = open(dire+'shakesp-names.gz', 'wb') print "\r\n[+] downloading shakesp-names.gz..." ftp.retrbinary('RETR ' + 'shakesp-names.gz', handleDownload) filequitter() file = open(dire+'surnames-ol.gz', 'wb') print "\r\n[+] downloading surnames-ol.gz..." ftp.retrbinary('RETR ' + 'surnames-ol.gz', handleDownload) filequitter() file = open(dire+'surnames.finnish.gz', 'wb') print "\r\n[+] downloading surnames.finnish.gz..." ftp.retrbinary('RETR ' + 'surnames.finnish.gz', handleDownload) filequitter() file = open(dire+'usenet-names.gz', 'wb') print "\r\n[+] downloading usenet-names.gz..." ftp.retrbinary('RETR ' + 'usenet-names.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "25": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('net') if os.path.isdir('dictionaries/net/') == 0: os.mkdir('dictionaries/net/') dire = 'dictionaries/net/' file = open(dire+'hosts-txt.Z', 'wb') print "\r\n[+] downloading hosts-txt.Z..." ftp.retrbinary('RETR ' + 'hosts-txt.Z', handleDownload) filequitter() file = open(dire+'inet-machines.Z', 'wb') print "\r\n[+] downloading inet-machines.Z..." ftp.retrbinary('RETR ' + 'inet-machines.Z', handleDownload) filequitter() file = open(dire+'usenet-loginids.Z', 'wb') print "\r\n[+] downloading usenet-loginids.Z..." ftp.retrbinary('RETR ' + 'usenet-loginids.Z', handleDownload) filequitter() file = open(dire+'usenet-machines.Z', 'wb') print "\r\n[+] downloading usenet-machines.Z..." ftp.retrbinary('RETR ' + 'usenet-machines.Z', handleDownload) filequitter() file = open(dire+'uunet-sites.Z', 'wb') print "\r\n[+] downloading uunet-sites.Z..." ftp.retrbinary('RETR ' + 'uunet-sites.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "26": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('norwegian') if os.path.isdir('dictionaries/norwegian/') == 0: os.mkdir('dictionaries/norwegian/') dire = 'dictionaries/norwegian/' file = open(dire+'words.norwegian.Z', 'wb') print "\r\n[+] downloading words.norwegian.Z..." ftp.retrbinary('RETR ' + 'words.norwegian.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "27": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('places') if os.path.isdir('dictionaries/places/') == 0: os.mkdir('dictionaries/places/') dire = 'dictionaries/places/' file = open(dire+'Colleges.Z', 'wb') print "\r\n[+] downloading Colleges.Z..." ftp.retrbinary('RETR ' + 'Colleges.Z', handleDownload) filequitter() file = open(dire+'US-counties.Z', 'wb') print "\r\n[+] downloading US-counties.Z..." ftp.retrbinary('RETR ' + 'US-counties.Z', handleDownload) filequitter() file = open(dire+'World.factbook.Z', 'wb') print "\r\n[+] downloading World.factbook.Z..." ftp.retrbinary('RETR ' + 'World.factbook.Z', handleDownload) filequitter() file = open(dire+'Zipcodes.Z', 'wb') print "\r\n[+] downloading Zipcodes.Z..." ftp.retrbinary('RETR ' + 'Zipcodes.Z', handleDownload) filequitter() file = open(dire+'places.Z', 'wb') print "\r\n[+] downloading places.Z..." ftp.retrbinary('RETR ' + 'places.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "28": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('polish') if os.path.isdir('dictionaries/polish/') == 0: os.mkdir('dictionaries/polish/') dire = 'dictionaries/polish/' file = open(dire+'words.polish.Z', 'wb') print "\r\n[+] downloading words.polish.Z..." ftp.retrbinary('RETR ' + 'words.polish.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "29": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('random') if os.path.isdir('dictionaries/random/') == 0: os.mkdir('dictionaries/random/') dire = 'dictionaries/random/' file = open(dire+'Ethnologue.gz', 'wb') print "\r\n[+] downloading Ethnologue.gz..." ftp.retrbinary('RETR ' + 'Ethnologue.gz', handleDownload) filequitter() file = open(dire+'abbr.gz', 'wb') print "\r\n[+] downloading abbr.gz..." ftp.retrbinary('RETR ' + 'abbr.gz', handleDownload) filequitter() file = open(dire+'chars.gz', 'wb') print "\r\n[+] downloading chars.gz..." ftp.retrbinary('RETR ' + 'chars.gz', handleDownload) filequitter() file = open(dire+'dogs.gz', 'wb') print "\r\n[+] downloading dogs.gz..." ftp.retrbinary('RETR ' + 'dogs.gz', handleDownload) filequitter() file = open(dire+'drugs.gz', 'wb') print "\r\n[+] downloading drugs.gz..." ftp.retrbinary('RETR ' + 'drugs.gz', handleDownload) filequitter() file = open(dire+'junk.gz', 'wb') print "\r\n[+] downloading junk.gz..." ftp.retrbinary('RETR ' + 'junk.gz', handleDownload) filequitter() file = open(dire+'numbers.gz', 'wb') print "\r\n[+] downloading numbers.gz..." ftp.retrbinary('RETR ' + 'numbers.gz', handleDownload) filequitter() file = open(dire+'phrases.gz', 'wb') print "\r\n[+] downloading phrases.gz..." ftp.retrbinary('RETR ' + 'phrases.gz', handleDownload) filequitter() file = open(dire+'sports.gz', 'wb') print "\r\n[+] downloading sports.gz..." ftp.retrbinary('RETR ' + 'sports.gz', handleDownload) filequitter() file = open(dire+'statistics.gz', 'wb') print "\r\n[+] downloading statistics.gz..." ftp.retrbinary('RETR ' + 'statistics.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "30": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('religion') if os.path.isdir('dictionaries/religion/') == 0: os.mkdir('dictionaries/religion/') dire = 'dictionaries/religion/' file = open(dire+'Koran.Z', 'wb') print "\r\n[+] downloading Koran.Z..." ftp.retrbinary('RETR ' + 'Koran.Z', handleDownload) filequitter() file = open(dire+'kjbible.Z', 'wb') print "\r\n[+] downloading kjbible.Z..." ftp.retrbinary('RETR ' + 'kjbible.Z', handleDownload) filequitter() file = open(dire+'norse.Z', 'wb') print "\r\n[+] downloading norse.Z..." ftp.retrbinary('RETR ' + 'norse.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "31": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('russian') if os.path.isdir('dictionaries/russian/') == 0: os.mkdir('dictionaries/russian/') dire = 'dictionaries/russian/' file = open(dire+'russian.lst.Z', 'wb') print "\r\n[+] downloading russian.lst.Z..." ftp.retrbinary('RETR ' + 'russian.lst.Z', handleDownload) filequitter() file = open(dire+'russian_words.koi8.Z', 'wb') print "\r\n[+] downloading russian_words.koi8.Z..." ftp.retrbinary('RETR ' + 'russian_words.koi8.Z', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "32": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('science') if os.path.isdir('dictionaries/science/') == 0: os.mkdir('dictionaries/science/') dire = 'dictionaries/science/' file = open(dire+'Acr-diagnosis.gz', 'wb') print "\r\n[+] downloading Acr-diagnosis.gz..." ftp.retrbinary('RETR ' + 'Acr-diagnosis.gz', handleDownload) filequitter() file = open(dire+'Algae.gz', 'wb') print "\r\n[+] downloading Algae.gz..." ftp.retrbinary('RETR ' + 'Algae.gz', handleDownload) filequitter() file = open(dire+'Bacteria.gz', 'wb') print "\r\n[+] downloading Bacteria.gz..." ftp.retrbinary('RETR ' + 'Bacteria.gz', handleDownload) filequitter() file = open(dire+'Fungi.gz', 'wb') print "\r\n[+] downloading Fungi.gz..." ftp.retrbinary('RETR ' + 'Fungi.gz', handleDownload) filequitter() file = open(dire+'Microalgae.gz', 'wb') print "\r\n[+] downloading Microalgae.gz..." ftp.retrbinary('RETR ' + 'Microalgae.gz', handleDownload) filequitter() file = open(dire+'Viruses.gz', 'wb') print "\r\n[+] downloading Viruses.gz..." ftp.retrbinary('RETR ' + 'Viruses.gz', handleDownload) filequitter() file = open(dire+'asteroids.Z', 'wb') print "\r\n[+] downloading asteroids.Z..." ftp.retrbinary('RETR ' + 'asteroids.Z', handleDownload) filequitter() file = open(dire+'biology.Z', 'wb') print "\r\n[+] downloading biology.Z..." ftp.retrbinary('RETR ' + 'biology.Z', handleDownload) filequitter() file = open(dire+'tech.gz', 'wb') print "\r\n[+] downloading tech.gz..." ftp.retrbinary('RETR ' + 'tech.gz', handleDownload) filequitter() print '[+] files saved to '+ dire ftp.quit() exit() if filedown == "33": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('spanish') if os.path.isdir('dictionaries/spanish/') == 0: os.mkdir('dictionaries/spanish/') dire = 'dictionaries/spanish/' file = open(dire+'words.spanish.Z', 'wb') print "\r\n[+] downloading words.spanish.Z..." ftp.retrbinary('RETR ' + 'words.spanish.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "34": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('swahili') if os.path.isdir('dictionaries/swahili/') == 0: os.mkdir('dictionaries/swahili/') dire = 'dictionaries/swahili/' file = open(dire+'swahili.gz', 'wb') print "\r\n[+] downloading swahili.gz..." ftp.retrbinary('RETR ' + 'swahili.gz', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "35": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('swedish') if os.path.isdir('dictionaries/swedish/') == 0: os.mkdir('dictionaries/swedish/') dire = 'dictionaries/swedish/' file = open(dire+'words.swedish.Z', 'wb') print "\r\n[+] downloading words.swedish.Z..." ftp.retrbinary('RETR ' + 'words.swedish.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "36": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('turkish') if os.path.isdir('dictionaries/turkish/') == 0: os.mkdir('dictionaries/turkish/') dire = 'dictionaries/turkish/' file = open(dire+'turkish.dict.gz', 'wb') print "\r\n[+] downloading turkish.dict.gz..." ftp.retrbinary('RETR ' + 'turkish.dict.gz', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() if filedown == "37": print "[+] connecting..." ftp = ftplib.FTP(ftpurl) downloader() ftp.cwd('yiddish') if os.path.isdir('dictionaries/yiddish/') == 0: os.mkdir('dictionaries/yiddish/') dire = 'dictionaries/yiddish/' file = open(dire+'yiddish.Z', 'wb') print "\r\n[+] downloading yiddish.Z..." ftp.retrbinary('RETR ' + 'yiddish.Z', handleDownload) filequitter() print '[+] file saved to '+ dire ftp.quit() exit() else: print '[-] leaving.' exit() else: print "\r\n[Usage]: "+sys.argv[0] +" [OPTIONS] \r\n" print "[Help]: "+sys.argv[0] +" -h\r\n" exit()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 221, 359, 9184, 61, 199, 3, 199, 3, 221, 445, 2160, 48, 650, 14, 17, 199, 3, 221, 13964, 2876, 8325, 3148, 14386, 82, 199, 3, 199, 3, 199, 3, 199, 3, 221, 359, 5949, 61, 199, 3, 199, 3, 221, 603, 17656, 1804, 17629, 305, 282, 7351, 1335, 16, 12430, 290, 199, 3, 221, 1335, 16, 12430, 290, 359, 292, 61, 3982, 13, 16971, 390, 359, 3287, 61, 5981, 199, 3, 221, 1455, 921, 1544, 14, 3846, 13, 16971, 390, 14, 1308, 199, 3, 221, 1455, 921, 1544, 14, 4651, 9494, 73, 14, 278, 199, 3, 199, 3, 199, 3, 199, 3, 221, 359, 3761, 61, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 3, 221, 1666, 283, 4757, 15, 3961, 7, 367, 1655, 2556, 14, 199, 199, 646, 984, 199, 646, 747, 199, 646, 14904, 773, 199, 646, 14196, 199, 646, 4011, 199, 646, 11756, 199, 646, 7392, 421, 199, 3, 799, 5384, 2897, 570, 1396, 199, 888, 275, 14196, 14, 15218, 342, 199, 888, 14, 739, 360, 17500, 80, 14, 4128, 358, 199, 199, 18431, 275, 1101, 14, 362, 360, 18431, 297, 283, 18431, 1959, 1294, 11917, 199, 6574, 275, 1101, 14, 362, 360, 6664, 6574, 297, 283, 6574, 1959, 1294, 11917, 199, 199, 1507, 504, 275, 1101, 14, 26627, 360, 16084, 1673, 504, 358, 199, 1507, 475, 275, 1101, 14, 26627, 360, 16084, 1673, 475, 358, 199, 199, 13683, 504, 275, 1101, 14, 26627, 360, 16084, 1673, 13683, 504, 358, 199, 87, 319, 79, 275, 1101, 14, 26627, 360, 16084, 1673, 87, 319, 79, 358, 199, 199, 7227, 275, 1101, 14, 26627, 360, 16084, 1673, 7227, 358, 199, 199, 3, 413, 11062, 818, 11585, 12, 5521, 1265, 883, 1050, 1655, 2385, 340, 1265, 1050, 652, 370, 1101, 570, 4634, 14, 199, 3, 2047, 911, 1929, 370, 1050, 1655, 2385, 315, 2877, 9825, 315, 286, 384, 80, 14, 647, 1233, 465, 5521, 1396, 199, 65, 275, 1101, 14, 362, 360, 274, 386, 1673, 65, 358, 199, 73, 275, 1101, 14, 362, 360, 274, 386, 1673, 73, 358, 199, 69, 275, 1101, 14, 362, 360, 274, 386, 1673, 69, 358, 199, 84, 275, 1101, 14, 362, 360, 274, 386, 1673, 84, 358, 199, 79, 275, 1101, 14, 362, 360, 274, 386, 1673, 79, 358, 199, 83, 275, 1101, 14, 362, 360, 274, 386, 1673, 83, 358, 199, 71, 275, 1101, 14, 362, 360, 274, 386, 1673, 71, 358, 199, 90, 275, 1101, 14, 362, 360, 274, 386, 1673, 90, 358, 421, 199, 3, 367, 16758, 1298, 1396, 199, 199, 318, 406, 25729, 8, 3610, 12, 1343, 12, 3631, 304, 272, 367, 3002, 495, 315, 5412, 26, 267, 367, 1967, 315, 4945, 8, 928, 12, 3631, 304, 288, 1995, 3002, 495, 435, 620, 8, 1507, 9, 421, 199, 3, 367, 13351, 436, 10663, 15821, 1396, 199, 199, 318, 1022, 24370, 8, 3610, 12, 1343, 304, 272, 367, 3002, 495, 315, 5412, 26, 267, 367, 3002, 495, 17, 315, 1343, 26, 288, 1995, 3002, 495, 435, 3002, 495, 17, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 199, 198, 1361, 298, 636, 7785, 63, 298, 199, 198, 1361, 298, 971, 8762, 59, 1780, 77, 221, 286, 384, 80, 14, 647, 1, 971, 8762, 59, 1465, 77, 4483, 327, 13964, 2, 3777, 199, 198, 1361, 298, 420, 971, 9326, 327, 2876, 2, 199, 198, 1361, 298, 755, 971, 257, 971, 8762, 59, 17, 27, 2192, 77, 12, 3108, 60, 8762, 59, 17, 27, 77, 3777, 327, 8325, 3148, 2, 9948, 198, 1361, 298, 263, 971, 221, 971, 8762, 59, 17, 27, 2192, 77, 2961, 8762, 59, 17, 27, 9273, 60, 8762, 59, 17, 27, 2192, 77, 9, 4741, 60, 8762, 59, 17, 27, 77, 260, 327, 14386, 82, 2, 199, 198, 1361, 298, 3698, 971, 8762, 59, 17, 27, 2192, 77, 8, 3368, 259, 776, 60, 971, 8762, 59, 17, 27, 77, 221, 298, 199, 198, 1361, 298, 3698, 971, 8762, 59, 17, 27, 2192, 77, 257, 12208, 306, 10644, 971, 8762, 59, 17, 27, 77, 60, 8762, 59, 1717, 77, 7590, 8762, 59, 821, 77, 60, 8762, 59, 17, 27, 77, 420, 359, 603, 17656, 1804, 17629, 305, 1204, 1335, 16, 12430, 290, 32, 3846, 13, 16971, 390, 14, 1308, 1622, 60, 82, 60, 78, 60, 82, 60, 78, 2, 8299, 198, 1361, 298, 198, 59, 8394, 1622, 60, 82, 60, 78, 2, 199, 198, 1361, 298, 198, 13, 72, 198, 5556, 787, 10023, 737, 652, 330, 17585, 1, 520, 2924, 199, 198, 1361, 298, 221, 1057, 2104, 1655, 1720, 5452, 282, 3648, 315, 9149, 15, 18195, 2, 199, 198, 1361, 298, 1057, 13641, 2897, 570, 365, 286, 384, 80, 14, 4128, 60, 78, 2, 198, 421, 198, 1361, 298, 198, 13, 73, 198, 23879, 23071, 367, 922, 2505, 30238, 60, 82, 60, 78, 2, 8299, 198, 1361, 298, 198, 13, 87, 198, 6119, 642, 945, 370, 19053, 3411, 2600, 4589, 199, 198, 1361, 298, 1057, 503, 644, 89, 36, 14, 1168, 1072, 370, 1852, 2005, 19206, 561, 65, 3683, 60, 82, 60, 78 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 221, 359, 9184, 61, 199, 3, 199, 3, 221, 445, 2160, 48, 650, 14, 17, 199, 3, 221, 13964, 2876, 8325, 3148, 14386, 82, 199, 3, 199, 3, 199, 3, 199, 3, 221, 359, 5949, 61, 199, 3, 199, 3, 221, 603, 17656, 1804, 17629, 305, 282, 7351, 1335, 16, 12430, 290, 199, 3, 221, 1335, 16, 12430, 290, 359, 292, 61, 3982, 13, 16971, 390, 359, 3287, 61, 5981, 199, 3, 221, 1455, 921, 1544, 14, 3846, 13, 16971, 390, 14, 1308, 199, 3, 221, 1455, 921, 1544, 14, 4651, 9494, 73, 14, 278, 199, 3, 199, 3, 199, 3, 199, 3, 221, 359, 3761, 61, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 3, 221, 1666, 283, 4757, 15, 3961, 7, 367, 1655, 2556, 14, 199, 199, 646, 984, 199, 646, 747, 199, 646, 14904, 773, 199, 646, 14196, 199, 646, 4011, 199, 646, 11756, 199, 646, 7392, 421, 199, 3, 799, 5384, 2897, 570, 1396, 199, 888, 275, 14196, 14, 15218, 342, 199, 888, 14, 739, 360, 17500, 80, 14, 4128, 358, 199, 199, 18431, 275, 1101, 14, 362, 360, 18431, 297, 283, 18431, 1959, 1294, 11917, 199, 6574, 275, 1101, 14, 362, 360, 6664, 6574, 297, 283, 6574, 1959, 1294, 11917, 199, 199, 1507, 504, 275, 1101, 14, 26627, 360, 16084, 1673, 504, 358, 199, 1507, 475, 275, 1101, 14, 26627, 360, 16084, 1673, 475, 358, 199, 199, 13683, 504, 275, 1101, 14, 26627, 360, 16084, 1673, 13683, 504, 358, 199, 87, 319, 79, 275, 1101, 14, 26627, 360, 16084, 1673, 87, 319, 79, 358, 199, 199, 7227, 275, 1101, 14, 26627, 360, 16084, 1673, 7227, 358, 199, 199, 3, 413, 11062, 818, 11585, 12, 5521, 1265, 883, 1050, 1655, 2385, 340, 1265, 1050, 652, 370, 1101, 570, 4634, 14, 199, 3, 2047, 911, 1929, 370, 1050, 1655, 2385, 315, 2877, 9825, 315, 286, 384, 80, 14, 647, 1233, 465, 5521, 1396, 199, 65, 275, 1101, 14, 362, 360, 274, 386, 1673, 65, 358, 199, 73, 275, 1101, 14, 362, 360, 274, 386, 1673, 73, 358, 199, 69, 275, 1101, 14, 362, 360, 274, 386, 1673, 69, 358, 199, 84, 275, 1101, 14, 362, 360, 274, 386, 1673, 84, 358, 199, 79, 275, 1101, 14, 362, 360, 274, 386, 1673, 79, 358, 199, 83, 275, 1101, 14, 362, 360, 274, 386, 1673, 83, 358, 199, 71, 275, 1101, 14, 362, 360, 274, 386, 1673, 71, 358, 199, 90, 275, 1101, 14, 362, 360, 274, 386, 1673, 90, 358, 421, 199, 3, 367, 16758, 1298, 1396, 199, 199, 318, 406, 25729, 8, 3610, 12, 1343, 12, 3631, 304, 272, 367, 3002, 495, 315, 5412, 26, 267, 367, 1967, 315, 4945, 8, 928, 12, 3631, 304, 288, 1995, 3002, 495, 435, 620, 8, 1507, 9, 421, 199, 3, 367, 13351, 436, 10663, 15821, 1396, 199, 199, 318, 1022, 24370, 8, 3610, 12, 1343, 304, 272, 367, 3002, 495, 315, 5412, 26, 267, 367, 3002, 495, 17, 315, 1343, 26, 288, 1995, 3002, 495, 435, 3002, 495, 17, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 199, 198, 1361, 298, 636, 7785, 63, 298, 199, 198, 1361, 298, 971, 8762, 59, 1780, 77, 221, 286, 384, 80, 14, 647, 1, 971, 8762, 59, 1465, 77, 4483, 327, 13964, 2, 3777, 199, 198, 1361, 298, 420, 971, 9326, 327, 2876, 2, 199, 198, 1361, 298, 755, 971, 257, 971, 8762, 59, 17, 27, 2192, 77, 12, 3108, 60, 8762, 59, 17, 27, 77, 3777, 327, 8325, 3148, 2, 9948, 198, 1361, 298, 263, 971, 221, 971, 8762, 59, 17, 27, 2192, 77, 2961, 8762, 59, 17, 27, 9273, 60, 8762, 59, 17, 27, 2192, 77, 9, 4741, 60, 8762, 59, 17, 27, 77, 260, 327, 14386, 82, 2, 199, 198, 1361, 298, 3698, 971, 8762, 59, 17, 27, 2192, 77, 8, 3368, 259, 776, 60, 971, 8762, 59, 17, 27, 77, 221, 298, 199, 198, 1361, 298, 3698, 971, 8762, 59, 17, 27, 2192, 77, 257, 12208, 306, 10644, 971, 8762, 59, 17, 27, 77, 60, 8762, 59, 1717, 77, 7590, 8762, 59, 821, 77, 60, 8762, 59, 17, 27, 77, 420, 359, 603, 17656, 1804, 17629, 305, 1204, 1335, 16, 12430, 290, 32, 3846, 13, 16971, 390, 14, 1308, 1622, 60, 82, 60, 78, 60, 82, 60, 78, 2, 8299, 198, 1361, 298, 198, 59, 8394, 1622, 60, 82, 60, 78, 2, 199, 198, 1361, 298, 198, 13, 72, 198, 5556, 787, 10023, 737, 652, 330, 17585, 1, 520, 2924, 199, 198, 1361, 298, 221, 1057, 2104, 1655, 1720, 5452, 282, 3648, 315, 9149, 15, 18195, 2, 199, 198, 1361, 298, 1057, 13641, 2897, 570, 365, 286, 384, 80, 14, 4128, 60, 78, 2, 198, 421, 198, 1361, 298, 198, 13, 73, 198, 23879, 23071, 367, 922, 2505, 30238, 60, 82, 60, 78, 2, 8299, 198, 1361, 298, 198, 13, 87, 198, 6119, 642, 945, 370, 19053, 3411, 2600, 4589, 199, 198, 1361, 298, 1057, 503, 644, 89, 36, 14, 1168, 1072, 370, 1852, 2005, 19206, 561, 65, 3683, 60, 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, 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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 ]
Feverup/ansible-modules-extras
notification/typetalk.py
54
3717
#!/usr/bin/python # -*- coding: utf-8 -*- # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: typetalk version_added: "1.6" short_description: Send a message to typetalk description: - Send a message to typetalk using typetalk API ( http://developers.typetalk.in/ ) options: client_id: description: - OAuth2 client ID required: true client_secret: description: - OAuth2 client secret required: true topic: description: - topic id to post message required: true msg: description: - message body required: true requirements: [ json ] author: "Takashi Someda (@tksmd)" ''' EXAMPLES = ''' - typetalk: client_id=12345 client_secret=12345 topic=1 msg="install completed" ''' import urllib try: import json except ImportError: try: import simplejson as json except ImportError: json = None def do_request(module, url, params, headers=None): data = urllib.urlencode(params) if headers is None: headers = dict() headers = dict(headers, **{ 'User-Agent': 'Ansible/typetalk module', }) r, info = fetch_url(module, url, data=data, headers=headers) if info['status'] != 200: exc = ConnectionError(info['msg']) exc.code = info['status'] raise exc return r def get_access_token(module, client_id, client_secret): params = { 'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'client_credentials', 'scope': 'topic.post' } res = do_request(module, 'https://typetalk.in/oauth2/access_token', params) return json.load(res)['access_token'] def send_message(module, client_id, client_secret, topic, msg): """ send message to typetalk """ try: access_token = get_access_token(module, client_id, client_secret) url = 'https://typetalk.in/api/v1/topics/%d' % topic headers = { 'Authorization': 'Bearer %s' % access_token, } do_request(module, url, {'message': msg}, headers) return True, {'access_token': access_token} except ConnectionError, e: return False, e def main(): module = AnsibleModule( argument_spec=dict( client_id=dict(required=True), client_secret=dict(required=True), topic=dict(required=True, type='int'), msg=dict(required=True), ), supports_check_mode=False ) if not json: module.fail_json(msg="json module is required") client_id = module.params["client_id"] client_secret = module.params["client_secret"] topic = module.params["topic"] msg = module.params["msg"] res, error = send_message(module, client_id, client_secret, topic, msg) if not res: module.fail_json(msg='fail to send message with response code %s' % error.code) module.exit_json(changed=True, topic=topic, msg=msg) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.urls import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 730, 21890, 199, 1023, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 3612, 63, 1802, 26, 10217, 282, 1245, 370, 730, 21890, 199, 1802, 26, 523, 446, 10217, 282, 1245, 370, 730, 21890, 1808, 730, 21890, 3261, 334, 1455, 921, 23826, 14, 466, 21890, 14, 262, 15, 776, 199, 1419, 26, 523, 1890, 63, 344, 26, 272, 1369, 26, 489, 446, 11715, 18, 1890, 2870, 272, 1415, 26, 2549, 523, 1890, 63, 4731, 26, 272, 1369, 26, 489, 446, 11715, 18, 1890, 7565, 272, 1415, 26, 2549, 523, 7482, 26, 272, 1369, 26, 489, 446, 7482, 1305, 370, 2963, 1245, 272, 1415, 26, 2549, 523, 1499, 26, 272, 1369, 26, 489, 446, 1245, 2396, 272, 1415, 26, 2549, 199, 7538, 26, 359, 2022, 1622, 199, 2502, 26, 298, 52, 1151, 1119, 73, 6601, 983, 8593, 2663, 83, 1064, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 730, 21890, 26, 1890, 63, 344, 29, 13261, 1890, 63, 4731, 29, 13261, 7482, 29, 17, 1499, 628, 3174, 9709, 2, 199, 2344, 199, 199, 646, 4011, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 13804, 465, 2022, 272, 871, 3545, 26, 267, 2022, 275, 488, 421, 199, 318, 886, 63, 1069, 8, 578, 12, 1166, 12, 1862, 12, 2323, 29, 403, 304, 272, 666, 275, 4011, 14, 10738, 8, 1162, 9, 272, 340, 2323, 365, 488, 26, 267, 2323, 275, 1211, 342, 272, 2323, 275, 1211, 8, 2139, 12, 31159, 267, 283, 1899, 13, 7788, 356, 283, 10047, 15, 466, 21890, 859, 297, 272, 3828, 272, 519, 12, 2256, 275, 5267, 63, 633, 8, 578, 12, 1166, 12, 666, 29, 576, 12, 2323, 29, 2139, 9, 272, 340, 2256, 459, 1205, 418, 1137, 1926, 26, 267, 3178, 275, 25417, 8, 815, 459, 1328, 1105, 267, 3178, 14, 600, 275, 2256, 459, 1205, 418, 267, 746, 3178, 272, 372, 519, 199, 199, 318, 664, 63, 2732, 63, 1418, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 304, 272, 1862, 275, 469, 267, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 267, 283, 1258, 63, 4731, 356, 1890, 63, 4731, 12, 267, 283, 17362, 63, 466, 356, 283, 1258, 63, 6942, 297, 267, 283, 2645, 356, 283, 5746, 14, 1932, 7, 272, 789, 272, 522, 275, 886, 63, 1069, 8, 578, 12, 283, 2859, 921, 466, 21890, 14, 262, 15, 6126, 18, 15, 2732, 63, 1418, 297, 1862, 9, 272, 372, 2022, 14, 912, 8, 470, 11820, 2732, 63, 1418, 418, 421, 199, 318, 3222, 63, 1188, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 7482, 12, 1499, 304, 272, 408, 272, 3222, 1245, 370, 730, 21890, 272, 408, 272, 862, 26, 267, 2879, 63, 1418, 275, 664, 63, 2732, 63, 1418, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 9, 267, 1166, 275, 283, 2859, 921, 466, 21890, 14, 262, 15, 1246, 15, 86, 17, 15, 11299, 3149, 68, 7, 450, 7482, 267, 2323, 275, 469, 288, 283, 11626, 356, 283, 3655, 21462, 450, 83, 7, 450, 2879, 63, 1418, 12, 267, 789, 267, 886, 63, 1069, 8, 578, 12, 1166, 12, 791, 1188, 356, 1499, 1386, 2323, 9, 267, 372, 715, 12, 791, 2732, 63, 1418, 356, 2879, 63, 1418, 93, 272, 871, 25417, 12, 325, 26, 267, 372, 756, 12, 325, 421, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1890, 63, 344, 29, 807, 8, 2427, 29, 549, 395, 288, 1890, 63, 4731, 29, 807, 8, 2427, 29, 549, 395, 288, 7482, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 442, 659, 288, 1499, 29, 807, 8, 2427, 29, 549, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 797, 272, 776, 339, 340, 440, 2022, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1001, 859, 365, 1415, 531, 339, 1890, 63, 344, 275, 859, 14, 1162, 905, 1258, 63, 344, 937, 272, 1890, 63, 4731, 275, 859, 14, 1162, 905, 1258, 63, 4731, 937, 272, 7482, 275, 859, 14, 1162, 905, 5746, 937, 272, 1499, 275, 859, 14, 1162, 905, 1328, 937, 339, 522, 12, 1125, 275, 3222, 63, 1188, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 7482, 12, 1499, 9, 272, 340, 440, 522, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 1633, 370, 3222, 1245, 543, 1177, 1233, 450, 83, 7, 450, 1125, 14, 600, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 7482, 29, 5746, 12, 1499, 29, 1328, 9, 421, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 627, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 730, 21890, 199, 1023, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 3612, 63, 1802, 26, 10217, 282, 1245, 370, 730, 21890, 199, 1802, 26, 523, 446, 10217, 282, 1245, 370, 730, 21890, 1808, 730, 21890, 3261, 334, 1455, 921, 23826, 14, 466, 21890, 14, 262, 15, 776, 199, 1419, 26, 523, 1890, 63, 344, 26, 272, 1369, 26, 489, 446, 11715, 18, 1890, 2870, 272, 1415, 26, 2549, 523, 1890, 63, 4731, 26, 272, 1369, 26, 489, 446, 11715, 18, 1890, 7565, 272, 1415, 26, 2549, 523, 7482, 26, 272, 1369, 26, 489, 446, 7482, 1305, 370, 2963, 1245, 272, 1415, 26, 2549, 523, 1499, 26, 272, 1369, 26, 489, 446, 1245, 2396, 272, 1415, 26, 2549, 199, 7538, 26, 359, 2022, 1622, 199, 2502, 26, 298, 52, 1151, 1119, 73, 6601, 983, 8593, 2663, 83, 1064, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 730, 21890, 26, 1890, 63, 344, 29, 13261, 1890, 63, 4731, 29, 13261, 7482, 29, 17, 1499, 628, 3174, 9709, 2, 199, 2344, 199, 199, 646, 4011, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 13804, 465, 2022, 272, 871, 3545, 26, 267, 2022, 275, 488, 421, 199, 318, 886, 63, 1069, 8, 578, 12, 1166, 12, 1862, 12, 2323, 29, 403, 304, 272, 666, 275, 4011, 14, 10738, 8, 1162, 9, 272, 340, 2323, 365, 488, 26, 267, 2323, 275, 1211, 342, 272, 2323, 275, 1211, 8, 2139, 12, 31159, 267, 283, 1899, 13, 7788, 356, 283, 10047, 15, 466, 21890, 859, 297, 272, 3828, 272, 519, 12, 2256, 275, 5267, 63, 633, 8, 578, 12, 1166, 12, 666, 29, 576, 12, 2323, 29, 2139, 9, 272, 340, 2256, 459, 1205, 418, 1137, 1926, 26, 267, 3178, 275, 25417, 8, 815, 459, 1328, 1105, 267, 3178, 14, 600, 275, 2256, 459, 1205, 418, 267, 746, 3178, 272, 372, 519, 199, 199, 318, 664, 63, 2732, 63, 1418, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 304, 272, 1862, 275, 469, 267, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 267, 283, 1258, 63, 4731, 356, 1890, 63, 4731, 12, 267, 283, 17362, 63, 466, 356, 283, 1258, 63, 6942, 297, 267, 283, 2645, 356, 283, 5746, 14, 1932, 7, 272, 789, 272, 522, 275, 886, 63, 1069, 8, 578, 12, 283, 2859, 921, 466, 21890, 14, 262, 15, 6126, 18, 15, 2732, 63, 1418, 297, 1862, 9, 272, 372, 2022, 14, 912, 8, 470, 11820, 2732, 63, 1418, 418, 421, 199, 318, 3222, 63, 1188, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 7482, 12, 1499, 304, 272, 408, 272, 3222, 1245, 370, 730, 21890, 272, 408, 272, 862, 26, 267, 2879, 63, 1418, 275, 664, 63, 2732, 63, 1418, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 9, 267, 1166, 275, 283, 2859, 921, 466, 21890, 14, 262, 15, 1246, 15, 86, 17, 15, 11299, 3149, 68, 7, 450, 7482, 267, 2323, 275, 469, 288, 283, 11626, 356, 283, 3655, 21462, 450, 83, 7, 450, 2879, 63, 1418, 12, 267, 789, 267, 886, 63, 1069, 8, 578, 12, 1166, 12, 791, 1188, 356, 1499, 1386, 2323, 9, 267, 372, 715, 12, 791, 2732, 63, 1418, 356, 2879, 63, 1418, 93, 272, 871, 25417, 12, 325, 26, 267, 372, 756, 12, 325, 421, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1890, 63, 344, 29, 807, 8, 2427, 29, 549, 395, 288, 1890, 63, 4731, 29, 807, 8, 2427, 29, 549, 395, 288, 7482, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 442, 659, 288, 1499, 29, 807, 8, 2427, 29, 549, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 797, 272, 776, 339, 340, 440, 2022, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1001, 859, 365, 1415, 531, 339, 1890, 63, 344, 275, 859, 14, 1162, 905, 1258, 63, 344, 937, 272, 1890, 63, 4731, 275, 859, 14, 1162, 905, 1258, 63, 4731, 937, 272, 7482, 275, 859, 14, 1162, 905, 5746, 937, 272, 1499, 275, 859, 14, 1162, 905, 1328, 937, 339, 522, 12, 1125, 275, 3222, 63, 1188, 8, 578, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 7482, 12, 1499, 9, 272, 340, 440, 522, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 1633, 370, 3222, 1245, 543, 1177, 1233, 450, 83, 7, 450, 1125, 14, 600, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 7482, 29, 5746, 12, 1499, 29, 1328, 9, 421, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 627, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
BozhkoAlexander/mtasa-blue
vendor/google-breakpad/src/tools/gyp/test/builddir/gyptest-all.py
185
2706
#!/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 the settings that cause a set of programs to be created in a specific build directory, and that no intermediate built files get created outside of that build directory hierarchy even when referred to with deeply-nested ../../.. paths. """ import TestGyp # TODO(mmoss): Make only supports (theoretically) a single, global build # directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than # gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other # generators support, so this doesn't work yet for make. # TODO(mmoss) Make also has the issue that the top-level Makefile is written to # the "--depth" location, which is one level above 'src', but then this test # moves 'src' somewhere else, leaving the Makefile behind, so make can't find # its sources. I'm not sure if make is wrong for writing outside the current # directory, or if the test is wrong for assuming everything generated is under # the current directory. # Android, Ninja, and CMake do not support setting the build directory. test = TestGyp.TestGyp(formats=['!make', '!ninja', '!android', '!cmake']) test.run_gyp('prog1.gyp', '--depth=..', chdir='src') if test.format == 'msvs': if test.uses_msbuild: test.must_contain('src/prog1.vcxproj', '<OutDir>..\\builddir\\Default\\</OutDir>') else: test.must_contain('src/prog1.vcproj', 'OutputDirectory="..\\builddir\\Default\\"') test.relocate('src', 'relocate/src') test.subdir('relocate/builddir') # Make sure that all the built ../../etc. files only get put under builddir, # by making all of relocate read-only and then making only builddir writable. test.writable('relocate', False) test.writable('relocate/builddir', True) # Suppress the test infrastructure's setting SYMROOT on the command line. test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') expect1 = """\ Hello from prog1.c Hello from func1.c """ expect2 = """\ Hello from subdir2/prog2.c Hello from func2.c """ expect3 = """\ Hello from subdir2/subdir3/prog3.c Hello from func3.c """ expect4 = """\ Hello from subdir2/subdir3/subdir4/prog4.c Hello from func4.c """ expect5 = """\ Hello from subdir2/subdir3/subdir4/subdir5/prog5.c Hello from func5.c """ def run_builddir(prog, expect): dir = 'relocate/builddir/Default/' test.run(program=test.workpath(dir + prog), stdout=expect) run_builddir('prog1', expect1) run_builddir('prog2', expect2) run_builddir('prog3', expect3) run_builddir('prog4', expect4) run_builddir('prog5', expect5) test.pass_test()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 7496, 314, 2202, 626, 7675, 282, 663, 402, 18572, 370, 506, 2737, 315, 199, 65, 2488, 1900, 2082, 12, 436, 626, 949, 13197, 6137, 1584, 199, 362, 2737, 9682, 402, 626, 1900, 2082, 14446, 2755, 1380, 199, 1121, 7165, 370, 543, 13217, 590, 13, 6376, 24272, 5093, 703, 3792, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 3, 3254, 8, 77, 573, 385, 304, 4155, 1454, 5171, 334, 1589, 720, 17269, 9, 282, 2849, 12, 2288, 1900, 199, 3, 2082, 334, 8304, 25686, 63, 12795, 6467, 63, 4831, 283, 1199, 63, 694, 659, 7830, 2419, 199, 3, 4902, 13, 493, 13, 6100, 2202, 334, 69, 14, 71, 14, 314, 8292, 315, 1900, 694, 14, 4312, 1038, 9, 626, 314, 1163, 199, 3, 16952, 2291, 12, 880, 642, 3181, 1133, 1736, 5966, 367, 1852, 14, 199, 3, 3254, 8, 77, 573, 385, 9, 4155, 2597, 965, 314, 4976, 626, 314, 2746, 13, 1896, 20618, 365, 5313, 370, 199, 3, 314, 4320, 4631, 2, 2909, 12, 1314, 365, 1373, 2166, 3432, 283, 2164, 297, 1325, 2066, 642, 511, 199, 3, 14569, 283, 2164, 7, 23430, 587, 12, 23188, 314, 20618, 22172, 12, 880, 1852, 883, 1133, 2342, 199, 3, 2399, 5274, 14, 473, 6704, 440, 3238, 340, 1852, 365, 6835, 367, 3575, 9682, 314, 1453, 199, 3, 2082, 12, 503, 340, 314, 511, 365, 6835, 367, 18002, 8137, 4046, 365, 1334, 199, 3, 314, 1453, 2082, 14, 199, 3, 14694, 12, 653, 4135, 12, 436, 21355, 886, 440, 2291, 4260, 314, 1900, 2082, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 1, 1875, 297, 14597, 8675, 297, 14597, 6238, 297, 14597, 16472, 1105, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2850, 4631, 29, 703, 297, 13097, 534, 2164, 358, 199, 692, 511, 14, 908, 508, 283, 8338, 356, 523, 340, 511, 14, 5589, 63, 14087, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 88, 5468, 297, 489, 2650, 30654, 30, 703, 1103, 21728, 1103, 2698, 1103, 1108, 30654, 5971, 523, 587, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 5468, 297, 489, 283, 2959, 6231, 628, 703, 1103, 21728, 1103, 2698, 1103, 9008, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 10622, 360, 18919, 15, 21728, 358, 199, 199, 3, 4155, 3238, 626, 1006, 314, 6137, 24272, 5093, 6839, 14, 1584, 1454, 664, 5324, 1334, 1900, 694, 12, 199, 3, 701, 10663, 1006, 402, 295, 6280, 1586, 13, 2118, 436, 2066, 10663, 1454, 1900, 694, 17267, 14, 199, 396, 14, 15053, 360, 18919, 297, 756, 9, 199, 396, 14, 15053, 360, 18919, 15, 21728, 297, 715, 9, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 511, 14, 1761, 12, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 17, 275, 9638, 199, 6257, 687, 13205, 17, 14, 67, 199, 6257, 687, 2562, 17, 14, 67, 199, 624, 199, 199, 4921, 18, 275, 9638, 199, 6257, 687, 15488, 18, 15, 6595, 18, 14, 67, 199, 6257, 687, 2562, 18, 14, 67, 199, 624, 199, 199, 4921, 19, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 6595, 19, 14, 67, 199, 6257, 687, 2562, 19, 14, 67, 199, 624, 199, 199, 4921, 20, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 6595, 20, 14, 67, 199, 6257, 687, 2562, 20, 14, 67, 199, 624, 199, 199, 4921, 21, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 10622, 21, 15, 6595, 21, 14, 67, 199, 6257, 687, 2562, 21, 14, 67, 199, 624, 199, 199, 318, 1255, 63, 21728, 8, 6595, 12, 4282, 304, 523, 2935, 275, 283, 18919, 15, 21728, 15, 2698, 4805, 523, 511, 14, 1065, 8, 6815, 29, 396, 14, 800, 515, 8, 694, 435, 13205, 395, 3839, 29, 4921, 9, 199, 199, 1065, 63, 21728, 360, 6595, 17, 297, 4282, 17, 9, 199, 1065, 63, 21728, 360, 6595, 18, 297, 4282, 18, 9, 199, 1065, 63, 21728, 360, 6595, 19, 297, 4282, 19, 9, 199, 1065, 63, 21728, 360, 6595, 20, 297, 4282, 20, 9, 199, 1065, 63, 21728, 360, 6595, 21, 297, 4282, 21, 9, 199, 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 ]
[ 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, 314, 2202, 626, 7675, 282, 663, 402, 18572, 370, 506, 2737, 315, 199, 65, 2488, 1900, 2082, 12, 436, 626, 949, 13197, 6137, 1584, 199, 362, 2737, 9682, 402, 626, 1900, 2082, 14446, 2755, 1380, 199, 1121, 7165, 370, 543, 13217, 590, 13, 6376, 24272, 5093, 703, 3792, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 3, 3254, 8, 77, 573, 385, 304, 4155, 1454, 5171, 334, 1589, 720, 17269, 9, 282, 2849, 12, 2288, 1900, 199, 3, 2082, 334, 8304, 25686, 63, 12795, 6467, 63, 4831, 283, 1199, 63, 694, 659, 7830, 2419, 199, 3, 4902, 13, 493, 13, 6100, 2202, 334, 69, 14, 71, 14, 314, 8292, 315, 1900, 694, 14, 4312, 1038, 9, 626, 314, 1163, 199, 3, 16952, 2291, 12, 880, 642, 3181, 1133, 1736, 5966, 367, 1852, 14, 199, 3, 3254, 8, 77, 573, 385, 9, 4155, 2597, 965, 314, 4976, 626, 314, 2746, 13, 1896, 20618, 365, 5313, 370, 199, 3, 314, 4320, 4631, 2, 2909, 12, 1314, 365, 1373, 2166, 3432, 283, 2164, 297, 1325, 2066, 642, 511, 199, 3, 14569, 283, 2164, 7, 23430, 587, 12, 23188, 314, 20618, 22172, 12, 880, 1852, 883, 1133, 2342, 199, 3, 2399, 5274, 14, 473, 6704, 440, 3238, 340, 1852, 365, 6835, 367, 3575, 9682, 314, 1453, 199, 3, 2082, 12, 503, 340, 314, 511, 365, 6835, 367, 18002, 8137, 4046, 365, 1334, 199, 3, 314, 1453, 2082, 14, 199, 3, 14694, 12, 653, 4135, 12, 436, 21355, 886, 440, 2291, 4260, 314, 1900, 2082, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 1, 1875, 297, 14597, 8675, 297, 14597, 6238, 297, 14597, 16472, 1105, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2850, 4631, 29, 703, 297, 13097, 534, 2164, 358, 199, 692, 511, 14, 908, 508, 283, 8338, 356, 523, 340, 511, 14, 5589, 63, 14087, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 88, 5468, 297, 489, 2650, 30654, 30, 703, 1103, 21728, 1103, 2698, 1103, 1108, 30654, 5971, 523, 587, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 5468, 297, 489, 283, 2959, 6231, 628, 703, 1103, 21728, 1103, 2698, 1103, 9008, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 10622, 360, 18919, 15, 21728, 358, 199, 199, 3, 4155, 3238, 626, 1006, 314, 6137, 24272, 5093, 6839, 14, 1584, 1454, 664, 5324, 1334, 1900, 694, 12, 199, 3, 701, 10663, 1006, 402, 295, 6280, 1586, 13, 2118, 436, 2066, 10663, 1454, 1900, 694, 17267, 14, 199, 396, 14, 15053, 360, 18919, 297, 756, 9, 199, 396, 14, 15053, 360, 18919, 15, 21728, 297, 715, 9, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 511, 14, 1761, 12, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 17, 275, 9638, 199, 6257, 687, 13205, 17, 14, 67, 199, 6257, 687, 2562, 17, 14, 67, 199, 624, 199, 199, 4921, 18, 275, 9638, 199, 6257, 687, 15488, 18, 15, 6595, 18, 14, 67, 199, 6257, 687, 2562, 18, 14, 67, 199, 624, 199, 199, 4921, 19, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 6595, 19, 14, 67, 199, 6257, 687, 2562, 19, 14, 67, 199, 624, 199, 199, 4921, 20, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 6595, 20, 14, 67, 199, 6257, 687, 2562, 20, 14, 67, 199, 624, 199, 199, 4921, 21, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 10622, 21, 15, 6595, 21, 14, 67, 199, 6257, 687, 2562, 21, 14, 67, 199, 624, 199, 199, 318, 1255, 63, 21728, 8, 6595, 12, 4282, 304, 523, 2935, 275, 283, 18919, 15, 21728, 15, 2698, 4805, 523, 511, 14, 1065, 8, 6815, 29, 396, 14, 800, 515, 8, 694, 435, 13205, 395, 3839, 29, 4921, 9, 199, 199, 1065, 63, 21728, 360, 6595, 17, 297, 4282, 17, 9, 199, 1065, 63, 21728, 360, 6595, 18, 297, 4282, 18, 9, 199, 1065, 63, 21728, 360, 6595, 19, 297, 4282, 19, 9, 199, 1065, 63, 21728, 360, 6595, 20, 297, 4282, 20, 9, 199, 1065, 63, 21728, 360, 6595, 21, 297, 4282, 21, 9, 199, 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, 0 ]
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0 ]
kajgan/e2
lib/python/Components/Converter/ConditionalShowHide.py
53
1460
from enigma import eTimer from Converter import Converter class ConditionalShowHide(Converter, object): def __init__(self, argstr): Converter.__init__(self, argstr) args = argstr.split(',') self.invert = "Invert" in args self.blink = "Blink" in args if self.blink: self.blinktime = len(args) == 2 and args[1].isdigit() and int(args[1]) or 500 self.timer = eTimer() self.timer.callback.append(self.blinkFunc) else: self.timer = None def blinkFunc(self): if self.blinking: for x in self.downstream_elements: x.visible = not x.visible def startBlinking(self): self.blinking = True self.timer.start(self.blinktime) def stopBlinking(self): self.blinking = False for x in self.downstream_elements: if x.visible: x.hide() self.timer.stop() def calcVisibility(self): b = self.source.boolean if b is None: return True b ^= self.invert return b def changed(self, what): vis = self.calcVisibility() if self.blink: if vis: self.startBlinking() else: self.stopBlinking() else: for x in self.downstream_elements: x.visible = vis def connectDownstream(self, downstream): Converter.connectDownstream(self, downstream) vis = self.calcVisibility() if self.blink: if vis: self.startBlinking() else: self.stopBlinking() else: downstream.visible = self.calcVisibility() def destroy(self): if self.timer: self.timer.callback.remove(self.blinkFunc)
gpl-2.0
[ 504, 655, 27021, 492, 325, 7929, 199, 504, 11801, 351, 492, 11801, 351, 199, 199, 533, 24191, 6824, 18224, 8, 11907, 12, 909, 304, 199, 198, 318, 636, 826, 721, 277, 12, 22494, 304, 507, 198, 11907, 855, 826, 721, 277, 12, 22494, 9, 507, 198, 589, 275, 22494, 14, 1294, 11917, 507, 198, 277, 14, 18957, 275, 298, 26498, 2, 315, 1249, 507, 198, 277, 14, 24042, 275, 298, 34, 1073, 2, 315, 1249, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 277, 14, 24042, 521, 275, 822, 8, 589, 9, 508, 499, 436, 1249, 59, 17, 1055, 13896, 342, 436, 1109, 8, 589, 59, 17, 566, 503, 6891, 686, 198, 277, 14, 7414, 275, 325, 7929, 342, 686, 198, 277, 14, 7414, 14, 3058, 14, 740, 8, 277, 14, 24042, 7465, 9, 507, 198, 2836, 26, 686, 198, 277, 14, 7414, 275, 488, 421, 198, 318, 330, 1073, 7465, 8, 277, 304, 507, 198, 692, 291, 14, 24042, 316, 26, 686, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 1585, 198, 88, 14, 6604, 275, 440, 671, 14, 6604, 421, 198, 318, 1343, 34, 1073, 316, 8, 277, 304, 507, 198, 277, 14, 24042, 316, 275, 715, 507, 198, 277, 14, 7414, 14, 928, 8, 277, 14, 24042, 521, 9, 421, 198, 318, 3631, 34, 1073, 316, 8, 277, 304, 507, 198, 277, 14, 24042, 316, 275, 756, 507, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 686, 198, 692, 671, 14, 6604, 26, 1585, 198, 88, 14, 8191, 342, 507, 198, 277, 14, 7414, 14, 2379, 342, 421, 198, 318, 12831, 24735, 8, 277, 304, 507, 198, 66, 275, 291, 14, 1365, 14, 4871, 507, 198, 692, 330, 365, 488, 26, 686, 198, 1107, 715, 507, 198, 66, 31753, 291, 14, 18957, 507, 198, 1107, 330, 421, 198, 318, 2896, 8, 277, 12, 4052, 304, 507, 198, 5068, 275, 291, 14, 8104, 24735, 342, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 692, 21370, 26, 1585, 198, 277, 14, 928, 34, 1073, 316, 342, 686, 198, 2836, 26, 1585, 198, 277, 14, 2379, 34, 1073, 316, 342, 507, 198, 2836, 26, 686, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 1585, 198, 88, 14, 6604, 275, 21370, 421, 198, 318, 4907, 3514, 1745, 8, 277, 12, 3224, 1745, 304, 507, 198, 11907, 14, 2242, 3514, 1745, 8, 277, 12, 3224, 1745, 9, 507, 198, 5068, 275, 291, 14, 8104, 24735, 342, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 692, 21370, 26, 1585, 198, 277, 14, 928, 34, 1073, 316, 342, 686, 198, 2836, 26, 1585, 198, 277, 14, 2379, 34, 1073, 316, 342, 507, 198, 2836, 26, 686, 198, 2110, 1745, 14, 6604, 275, 291, 14, 8104, 24735, 342, 421, 198, 318, 11972, 8, 277, 304, 507, 198, 692, 291, 14, 7414, 26, 686, 198, 277, 14, 7414, 14, 3058, 14, 2168, 8, 277, 14, 24042, 7465, 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 ]
[ 655, 27021, 492, 325, 7929, 199, 504, 11801, 351, 492, 11801, 351, 199, 199, 533, 24191, 6824, 18224, 8, 11907, 12, 909, 304, 199, 198, 318, 636, 826, 721, 277, 12, 22494, 304, 507, 198, 11907, 855, 826, 721, 277, 12, 22494, 9, 507, 198, 589, 275, 22494, 14, 1294, 11917, 507, 198, 277, 14, 18957, 275, 298, 26498, 2, 315, 1249, 507, 198, 277, 14, 24042, 275, 298, 34, 1073, 2, 315, 1249, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 277, 14, 24042, 521, 275, 822, 8, 589, 9, 508, 499, 436, 1249, 59, 17, 1055, 13896, 342, 436, 1109, 8, 589, 59, 17, 566, 503, 6891, 686, 198, 277, 14, 7414, 275, 325, 7929, 342, 686, 198, 277, 14, 7414, 14, 3058, 14, 740, 8, 277, 14, 24042, 7465, 9, 507, 198, 2836, 26, 686, 198, 277, 14, 7414, 275, 488, 421, 198, 318, 330, 1073, 7465, 8, 277, 304, 507, 198, 692, 291, 14, 24042, 316, 26, 686, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 1585, 198, 88, 14, 6604, 275, 440, 671, 14, 6604, 421, 198, 318, 1343, 34, 1073, 316, 8, 277, 304, 507, 198, 277, 14, 24042, 316, 275, 715, 507, 198, 277, 14, 7414, 14, 928, 8, 277, 14, 24042, 521, 9, 421, 198, 318, 3631, 34, 1073, 316, 8, 277, 304, 507, 198, 277, 14, 24042, 316, 275, 756, 507, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 686, 198, 692, 671, 14, 6604, 26, 1585, 198, 88, 14, 8191, 342, 507, 198, 277, 14, 7414, 14, 2379, 342, 421, 198, 318, 12831, 24735, 8, 277, 304, 507, 198, 66, 275, 291, 14, 1365, 14, 4871, 507, 198, 692, 330, 365, 488, 26, 686, 198, 1107, 715, 507, 198, 66, 31753, 291, 14, 18957, 507, 198, 1107, 330, 421, 198, 318, 2896, 8, 277, 12, 4052, 304, 507, 198, 5068, 275, 291, 14, 8104, 24735, 342, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 692, 21370, 26, 1585, 198, 277, 14, 928, 34, 1073, 316, 342, 686, 198, 2836, 26, 1585, 198, 277, 14, 2379, 34, 1073, 316, 342, 507, 198, 2836, 26, 686, 198, 509, 671, 315, 291, 14, 2110, 1745, 63, 5527, 26, 1585, 198, 88, 14, 6604, 275, 21370, 421, 198, 318, 4907, 3514, 1745, 8, 277, 12, 3224, 1745, 304, 507, 198, 11907, 14, 2242, 3514, 1745, 8, 277, 12, 3224, 1745, 9, 507, 198, 5068, 275, 291, 14, 8104, 24735, 342, 507, 198, 692, 291, 14, 24042, 26, 686, 198, 692, 21370, 26, 1585, 198, 277, 14, 928, 34, 1073, 316, 342, 686, 198, 2836, 26, 1585, 198, 277, 14, 2379, 34, 1073, 316, 342, 507, 198, 2836, 26, 686, 198, 2110, 1745, 14, 6604, 275, 291, 14, 8104, 24735, 342, 421, 198, 318, 11972, 8, 277, 304, 507, 198, 692, 291, 14, 7414, 26, 686, 198, 277, 14, 7414, 14, 3058, 14, 2168, 8, 277, 14, 24042, 7465, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bealdav/OCB
addons/share/wizard/__init__.py
448
1067
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import share_wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 8663, 63, 9819, 421, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 8663, 63, 9819, 421, 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, 32768, 32768, 32768, 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, 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, urlparse, urlunparse from django import template from django.contrib.admin.utils import quote from django.urls import Resolver404, get_script_prefix, resolve from django.utils.http import urlencode register = template.Library() @register.filter def admin_urlname(value, arg): return 'admin:%s_%s_%s' % (value.app_label, value.model_name, arg) @register.filter def admin_urlquote(value): return quote(value) @register.simple_tag(takes_context=True) def add_preserved_filters(context, url, popup=False, to_field=None): opts = context.get('opts') preserved_filters = context.get('preserved_filters') parsed_url = list(urlparse(url)) parsed_qs = dict(parse_qsl(parsed_url[4])) merged_qs = {} if opts and preserved_filters: preserved_filters = dict(parse_qsl(preserved_filters)) match_url = '/%s' % url.partition(get_script_prefix())[2] try: match = resolve(match_url) except Resolver404: pass else: current_url = '%s:%s' % (match.app_name, match.url_name) changelist_url = 'admin:%s_%s_changelist' % (opts.app_label, opts.model_name) if changelist_url == current_url and '_changelist_filters' in preserved_filters: preserved_filters = dict(parse_qsl(preserved_filters['_changelist_filters'])) merged_qs.update(preserved_filters) if popup: from django.contrib.admin.options import IS_POPUP_VAR merged_qs[IS_POPUP_VAR] = 1 if to_field: from django.contrib.admin.options import TO_FIELD_VAR merged_qs[TO_FIELD_VAR] = to_field merged_qs.update(parsed_qs) parsed_url[4] = urlencode(merged_qs) return urlunparse(parsed_url)
bsd-3-clause
[ 504, 4011, 14, 1122, 492, 2198, 63, 26714, 12, 7097, 12, 30111, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 6313, 199, 504, 1639, 14, 3603, 492, 26046, 5188, 12, 664, 63, 1579, 63, 1861, 12, 7512, 199, 504, 1639, 14, 1208, 14, 1014, 492, 16511, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 1541, 199, 318, 4628, 63, 633, 354, 8, 585, 12, 1680, 304, 272, 372, 283, 2113, 2689, 83, 4970, 83, 4970, 83, 7, 450, 334, 585, 14, 571, 63, 1302, 12, 574, 14, 1238, 63, 354, 12, 1680, 9, 421, 199, 32, 2683, 14, 1541, 199, 318, 4628, 63, 633, 3513, 8, 585, 304, 272, 372, 6313, 8, 585, 9, 421, 199, 32, 2683, 14, 4129, 63, 1450, 8, 31613, 63, 1100, 29, 549, 9, 199, 318, 1050, 63, 32104, 63, 4273, 8, 1100, 12, 1166, 12, 22365, 29, 797, 12, 370, 63, 698, 29, 403, 304, 272, 3999, 275, 1067, 14, 362, 360, 3291, 358, 272, 17731, 63, 4273, 275, 1067, 14, 362, 360, 32104, 63, 4273, 358, 339, 4565, 63, 633, 275, 769, 8, 10290, 8, 633, 430, 272, 4565, 63, 6177, 275, 1211, 8, 1122, 63, 26714, 8, 6751, 63, 633, 59, 20, 2459, 272, 9545, 63, 6177, 275, 1052, 339, 340, 3999, 436, 17731, 63, 4273, 26, 267, 17731, 63, 4273, 275, 1211, 8, 1122, 63, 26714, 8, 32104, 63, 4273, 430, 398, 1336, 63, 633, 275, 1994, 5, 83, 7, 450, 1166, 14, 5312, 8, 362, 63, 1579, 63, 1861, 18756, 18, 61, 267, 862, 26, 288, 1336, 275, 7512, 8, 1431, 63, 633, 9, 267, 871, 26046, 5188, 26, 288, 986, 267, 587, 26, 288, 1453, 63, 633, 275, 1543, 83, 2689, 83, 7, 450, 334, 1431, 14, 571, 63, 354, 12, 1336, 14, 633, 63, 354, 9, 288, 27579, 63, 633, 275, 283, 2113, 2689, 83, 4970, 83, 63, 19043, 7, 450, 334, 3291, 14, 571, 63, 1302, 12, 3999, 14, 1238, 63, 354, 9, 288, 340, 27579, 63, 633, 508, 1453, 63, 633, 436, 2513, 19043, 63, 4273, 7, 315, 17731, 63, 4273, 26, 355, 17731, 63, 4273, 275, 1211, 8, 1122, 63, 26714, 8, 32104, 63, 4273, 8680, 19043, 63, 4273, 5156, 398, 9545, 63, 6177, 14, 873, 8, 32104, 63, 4273, 9, 339, 340, 22365, 26, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2281, 63, 13531, 2160, 63, 5568, 267, 9545, 63, 6177, 59, 1311, 63, 13531, 2160, 63, 5568, 61, 275, 413, 272, 340, 370, 63, 698, 26, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2296, 63, 8609, 63, 5568, 267, 9545, 63, 6177, 59, 2566, 63, 8609, 63, 5568, 61, 275, 370, 63, 698, 339, 9545, 63, 6177, 14, 873, 8, 6751, 63, 6177, 9, 339, 4565, 63, 633, 59, 20, 61, 275, 16511, 8, 15269, 63, 6177, 9, 272, 372, 30111, 8, 6751, 63, 633, 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 ]
[ 4011, 14, 1122, 492, 2198, 63, 26714, 12, 7097, 12, 30111, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 6313, 199, 504, 1639, 14, 3603, 492, 26046, 5188, 12, 664, 63, 1579, 63, 1861, 12, 7512, 199, 504, 1639, 14, 1208, 14, 1014, 492, 16511, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 1541, 199, 318, 4628, 63, 633, 354, 8, 585, 12, 1680, 304, 272, 372, 283, 2113, 2689, 83, 4970, 83, 4970, 83, 7, 450, 334, 585, 14, 571, 63, 1302, 12, 574, 14, 1238, 63, 354, 12, 1680, 9, 421, 199, 32, 2683, 14, 1541, 199, 318, 4628, 63, 633, 3513, 8, 585, 304, 272, 372, 6313, 8, 585, 9, 421, 199, 32, 2683, 14, 4129, 63, 1450, 8, 31613, 63, 1100, 29, 549, 9, 199, 318, 1050, 63, 32104, 63, 4273, 8, 1100, 12, 1166, 12, 22365, 29, 797, 12, 370, 63, 698, 29, 403, 304, 272, 3999, 275, 1067, 14, 362, 360, 3291, 358, 272, 17731, 63, 4273, 275, 1067, 14, 362, 360, 32104, 63, 4273, 358, 339, 4565, 63, 633, 275, 769, 8, 10290, 8, 633, 430, 272, 4565, 63, 6177, 275, 1211, 8, 1122, 63, 26714, 8, 6751, 63, 633, 59, 20, 2459, 272, 9545, 63, 6177, 275, 1052, 339, 340, 3999, 436, 17731, 63, 4273, 26, 267, 17731, 63, 4273, 275, 1211, 8, 1122, 63, 26714, 8, 32104, 63, 4273, 430, 398, 1336, 63, 633, 275, 1994, 5, 83, 7, 450, 1166, 14, 5312, 8, 362, 63, 1579, 63, 1861, 18756, 18, 61, 267, 862, 26, 288, 1336, 275, 7512, 8, 1431, 63, 633, 9, 267, 871, 26046, 5188, 26, 288, 986, 267, 587, 26, 288, 1453, 63, 633, 275, 1543, 83, 2689, 83, 7, 450, 334, 1431, 14, 571, 63, 354, 12, 1336, 14, 633, 63, 354, 9, 288, 27579, 63, 633, 275, 283, 2113, 2689, 83, 4970, 83, 63, 19043, 7, 450, 334, 3291, 14, 571, 63, 1302, 12, 3999, 14, 1238, 63, 354, 9, 288, 340, 27579, 63, 633, 508, 1453, 63, 633, 436, 2513, 19043, 63, 4273, 7, 315, 17731, 63, 4273, 26, 355, 17731, 63, 4273, 275, 1211, 8, 1122, 63, 26714, 8, 32104, 63, 4273, 8680, 19043, 63, 4273, 5156, 398, 9545, 63, 6177, 14, 873, 8, 32104, 63, 4273, 9, 339, 340, 22365, 26, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2281, 63, 13531, 2160, 63, 5568, 267, 9545, 63, 6177, 59, 1311, 63, 13531, 2160, 63, 5568, 61, 275, 413, 272, 340, 370, 63, 698, 26, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2296, 63, 8609, 63, 5568, 267, 9545, 63, 6177, 59, 2566, 63, 8609, 63, 5568, 61, 275, 370, 63, 698, 339, 9545, 63, 6177, 14, 873, 8, 6751, 63, 6177, 9, 339, 4565, 63, 633, 59, 20, 61, 275, 16511, 8, 15269, 63, 6177, 9, 272, 372, 30111, 8, 6751, 63, 633, 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,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0, 0, 0 ]
ISCDtoolbox/FaciLe
pipeline/createDatabase.py
1
2873
import os import sys import numpy as np from copy import deepcopy import argparse #Parallel import subprocess as sp import multiprocessing as mp sys.path.append(os.path.join(os.path.dirname(__file__),"../projects/tools")) import msh import executable_paths as exe def parse(): parser = argparse.ArgumentParser(description="Creates mandible and masseter files for the database creation") parser.add_argument("-i", "--inputDir", help="input directory", type=str, required=True) parser.add_argument("-o", "--outputDir", help="output directory", type=str, required=True) return parser.parse_args() def checkArgs(args): if not os.path.exists(args.inputDir): print args.input + "is not a valid directory" sys.exit() if not len([f for f in os.listdir(args.inputDir) if f[0]=="."]) == 0: print args.inputDir + " is an empty directory" sys.exit() if not os.path.exists(args.outputDir): print args.outputDir + " does not exist, creating" os.system("mkdir " + args.outputDir) args.inputDir = os.path.abspath(args.inputDir) args.outputDir = os.path.abspath(args.outputDir) def command(cmd, displayOutput=False): err = 1 print "Running the command '" + cmd + "'" if displayOutput: err = os.system(cmd) else: err = os.system(cmd + " > tmp_out.txt 2>tmp_err.txt") if err: print "An error happened while executing:\n"+cmd+"\nLook in tmp_out.txt or tmp_err.txt for info\nExiting..." sys.exit() else: os.system("rm tmp_out.txt tmp_err.txt >/dev/null 2>&1") def work(in_file): """Defines the work unit on an input file""" root = '.'.join(in_file.split("/")[-1].split(".")[:-1]) if not os.path.exists("tmp_"+root): os.mkdir("tmp_"+root) os.chdir("tmp_"+root) os.system("cp /home/norgeot/dev/own/FaciLe/projects/warping/demo/sphere.o1.mesh ./sphere.mesh") cmd = " ".join([exe.processSkull, "-i " + in_file, "-t ../../OsTemplate.mesh",">",root+"_OUT.txt"]) print "Starting the skull processing for " + in_file #os.system(cmd) print "Skull processing finished for " + in_file #clean the working directories for ext in [".warped.mesh", ".box.1.o.", "mat","_OUT.txt"]: for f in os.listdir("."): if ext in f: os.rename(f, os.path.join(args.outputDir,f)) for f in os.listdir("."): if ".mesh" in f or ".sol" in f: #os.remove(f) #print f + " was successfully removed" a=2 return 0 if __name__=="__main__": args = parse() checkArgs(args) files = [os.path.join(args.inputDir,f) for f in os.listdir(args.inputDir) if ".mesh" in f] #Set up the parallel task pool to use all available processors count = mp.cpu_count() pool = mp.Pool(processes=count) pool.map(work, files)
gpl-3.0
[ 646, 747, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 504, 1331, 492, 14800, 199, 646, 7534, 199, 199, 3, 25721, 199, 646, 3873, 465, 2249, 199, 646, 12866, 465, 6118, 421, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2, 5093, 6776, 15, 2537, 2237, 199, 646, 333, 609, 199, 646, 7286, 63, 3771, 465, 14778, 199, 199, 318, 2198, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 10607, 2169, 328, 830, 436, 28065, 261, 351, 1584, 367, 314, 3050, 7143, 531, 272, 1798, 14, 525, 63, 2094, 6096, 73, 401, 4320, 1210, 3567, 401, 1720, 628, 1210, 2082, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 6096, 79, 401, 4320, 1199, 3567, 401, 1720, 628, 1199, 2082, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 372, 1798, 14, 1122, 63, 589, 342, 199, 318, 1104, 6213, 8, 589, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 589, 14, 1210, 3567, 304, 267, 870, 1249, 14, 1210, 435, 298, 374, 440, 282, 1686, 2082, 2, 267, 984, 14, 2224, 342, 272, 340, 440, 822, 779, 70, 367, 289, 315, 747, 14, 7374, 8, 589, 14, 1210, 3567, 9, 340, 289, 59, 16, 19219, 1674, 3135, 508, 378, 26, 267, 870, 1249, 14, 1210, 3567, 435, 298, 365, 376, 2701, 2082, 2, 267, 984, 14, 2224, 342, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 589, 14, 1199, 3567, 304, 267, 870, 1249, 14, 1199, 3567, 435, 298, 1630, 440, 2187, 12, 6425, 2, 267, 747, 14, 2253, 480, 8215, 298, 435, 1249, 14, 1199, 3567, 9, 272, 1249, 14, 1210, 3567, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1210, 3567, 9, 272, 1249, 14, 1199, 3567, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1199, 3567, 9, 199, 318, 1414, 8, 1760, 12, 2929, 2959, 29, 797, 304, 272, 2329, 275, 413, 272, 870, 298, 9602, 314, 1414, 5522, 435, 2088, 435, 21673, 339, 340, 2929, 2959, 26, 267, 2329, 275, 747, 14, 2253, 8, 1760, 9, 272, 587, 26, 267, 2329, 275, 747, 14, 2253, 8, 1760, 435, 298, 690, 3529, 63, 548, 14, 2424, 499, 30, 2791, 63, 1508, 14, 2424, 531, 339, 340, 2329, 26, 267, 870, 298, 2493, 1125, 21056, 1830, 14043, 3427, 78, 7709, 1760, 25789, 78, 20926, 315, 3529, 63, 548, 14, 2424, 503, 3529, 63, 1508, 14, 2424, 367, 2256, 60, 78, 6699, 316, 11500, 267, 984, 14, 2224, 342, 272, 587, 26, 267, 747, 14, 2253, 480, 5682, 3529, 63, 548, 14, 2424, 3529, 63, 1508, 14, 2424, 690, 15, 2374, 15, 2307, 499, 18181, 17, 531, 421, 199, 318, 1736, 8, 262, 63, 493, 304, 272, 408, 23891, 314, 1736, 4137, 641, 376, 1324, 570, 624, 272, 1738, 275, 15671, 904, 8, 262, 63, 493, 14, 1294, 19031, 1988, 17, 1055, 1294, 15857, 4439, 17, 566, 339, 340, 440, 747, 14, 515, 14, 2444, 480, 2791, 63, 7709, 1231, 304, 267, 747, 14, 8215, 480, 2791, 63, 7709, 1231, 9, 272, 747, 14, 8563, 480, 2791, 63, 7709, 1231, 9, 272, 747, 14, 2253, 480, 1850, 1182, 4219, 15, 6505, 303, 357, 15, 2374, 15, 944, 15, 1906, 559, 2553, 15, 6776, 15, 3281, 4073, 15, 8768, 15, 14980, 14, 79, 17, 14, 6480, 16605, 14980, 14, 6480, 531, 339, 2088, 275, 298, 3680, 904, 779, 5803, 14, 1412, 14194, 979, 12, 3905, 73, 298, 435, 315, 63, 493, 12, 3905, 84, 24272, 5093, 24351, 4231, 14, 6480, 401, 1743, 401, 1231, 30056, 1877, 14, 2424, 3135, 272, 870, 298, 14139, 314, 2386, 979, 6661, 367, 298, 435, 315, 63, 493, 272, 327, 736, 14, 2253, 8, 1760, 9, 272, 870, 298, 14194, 979, 6661, 9158, 367, 298, 435, 315, 63, 493, 339, 327, 3118, 314, 6449, 6602, 339, 367, 1599, 315, 359, 1674, 3281, 1915, 14, 6480, 401, 3680, 1977, 14, 17, 14, 79, 4765, 298, 569, 2266, 63, 1877, 14, 2424, 6229, 267, 367, 289, 315, 747, 14, 7374, 480, 30946, 288, 340, 1599, 315, 289, 26, 355, 747, 14, 8165, 8, 70, 12, 747, 14, 515, 14, 904, 8, 589, 14, 1199, 3567, 12, 70, 430, 272, 367, 289, 315, 747, 14, 7374, 480, 30946, 267, 340, 3680, 6480, 2, 315, 289, 503, 3680, 7873, 2, 315, 289, 26, 288, 327, 736, 14, 2168, 8, 70, 9, 288, 327, 1361, 289, 435, 298, 1990, 8792, 4829, 2, 288, 282, 29, 18, 339, 372, 378, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 339, 1249, 275, 2198, 342, 272, 1104, 6213, 8, 589, 9, 272, 1584, 275, 359, 736, 14, 515, 14, 904, 8, 589, 14, 1210, 3567, 12, 70, 9, 367, 289, 315, 747, 14, 7374, 8, 589, 14, 1210, 3567, 9, 340, 3680, 6480, 2, 315, 289, 61, 16478, 327, 1084, 1536, 314, 9861, 2120, 4203, 370, 675, 1006, 2808, 21620, 272, 2338, 275, 6118, 14, 3541, 63, 835, 342, 272, 4203, 275, 6118, 14, 5453, 8, 11816, 29, 835, 9, 272, 4203, 14, 1130, 8, 800, 12, 1584, 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 ]
[ 747, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 504, 1331, 492, 14800, 199, 646, 7534, 199, 199, 3, 25721, 199, 646, 3873, 465, 2249, 199, 646, 12866, 465, 6118, 421, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2, 5093, 6776, 15, 2537, 2237, 199, 646, 333, 609, 199, 646, 7286, 63, 3771, 465, 14778, 199, 199, 318, 2198, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 10607, 2169, 328, 830, 436, 28065, 261, 351, 1584, 367, 314, 3050, 7143, 531, 272, 1798, 14, 525, 63, 2094, 6096, 73, 401, 4320, 1210, 3567, 401, 1720, 628, 1210, 2082, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 1798, 14, 525, 63, 2094, 6096, 79, 401, 4320, 1199, 3567, 401, 1720, 628, 1199, 2082, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 372, 1798, 14, 1122, 63, 589, 342, 199, 318, 1104, 6213, 8, 589, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 589, 14, 1210, 3567, 304, 267, 870, 1249, 14, 1210, 435, 298, 374, 440, 282, 1686, 2082, 2, 267, 984, 14, 2224, 342, 272, 340, 440, 822, 779, 70, 367, 289, 315, 747, 14, 7374, 8, 589, 14, 1210, 3567, 9, 340, 289, 59, 16, 19219, 1674, 3135, 508, 378, 26, 267, 870, 1249, 14, 1210, 3567, 435, 298, 365, 376, 2701, 2082, 2, 267, 984, 14, 2224, 342, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 589, 14, 1199, 3567, 304, 267, 870, 1249, 14, 1199, 3567, 435, 298, 1630, 440, 2187, 12, 6425, 2, 267, 747, 14, 2253, 480, 8215, 298, 435, 1249, 14, 1199, 3567, 9, 272, 1249, 14, 1210, 3567, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1210, 3567, 9, 272, 1249, 14, 1199, 3567, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1199, 3567, 9, 199, 318, 1414, 8, 1760, 12, 2929, 2959, 29, 797, 304, 272, 2329, 275, 413, 272, 870, 298, 9602, 314, 1414, 5522, 435, 2088, 435, 21673, 339, 340, 2929, 2959, 26, 267, 2329, 275, 747, 14, 2253, 8, 1760, 9, 272, 587, 26, 267, 2329, 275, 747, 14, 2253, 8, 1760, 435, 298, 690, 3529, 63, 548, 14, 2424, 499, 30, 2791, 63, 1508, 14, 2424, 531, 339, 340, 2329, 26, 267, 870, 298, 2493, 1125, 21056, 1830, 14043, 3427, 78, 7709, 1760, 25789, 78, 20926, 315, 3529, 63, 548, 14, 2424, 503, 3529, 63, 1508, 14, 2424, 367, 2256, 60, 78, 6699, 316, 11500, 267, 984, 14, 2224, 342, 272, 587, 26, 267, 747, 14, 2253, 480, 5682, 3529, 63, 548, 14, 2424, 3529, 63, 1508, 14, 2424, 690, 15, 2374, 15, 2307, 499, 18181, 17, 531, 421, 199, 318, 1736, 8, 262, 63, 493, 304, 272, 408, 23891, 314, 1736, 4137, 641, 376, 1324, 570, 624, 272, 1738, 275, 15671, 904, 8, 262, 63, 493, 14, 1294, 19031, 1988, 17, 1055, 1294, 15857, 4439, 17, 566, 339, 340, 440, 747, 14, 515, 14, 2444, 480, 2791, 63, 7709, 1231, 304, 267, 747, 14, 8215, 480, 2791, 63, 7709, 1231, 9, 272, 747, 14, 8563, 480, 2791, 63, 7709, 1231, 9, 272, 747, 14, 2253, 480, 1850, 1182, 4219, 15, 6505, 303, 357, 15, 2374, 15, 944, 15, 1906, 559, 2553, 15, 6776, 15, 3281, 4073, 15, 8768, 15, 14980, 14, 79, 17, 14, 6480, 16605, 14980, 14, 6480, 531, 339, 2088, 275, 298, 3680, 904, 779, 5803, 14, 1412, 14194, 979, 12, 3905, 73, 298, 435, 315, 63, 493, 12, 3905, 84, 24272, 5093, 24351, 4231, 14, 6480, 401, 1743, 401, 1231, 30056, 1877, 14, 2424, 3135, 272, 870, 298, 14139, 314, 2386, 979, 6661, 367, 298, 435, 315, 63, 493, 272, 327, 736, 14, 2253, 8, 1760, 9, 272, 870, 298, 14194, 979, 6661, 9158, 367, 298, 435, 315, 63, 493, 339, 327, 3118, 314, 6449, 6602, 339, 367, 1599, 315, 359, 1674, 3281, 1915, 14, 6480, 401, 3680, 1977, 14, 17, 14, 79, 4765, 298, 569, 2266, 63, 1877, 14, 2424, 6229, 267, 367, 289, 315, 747, 14, 7374, 480, 30946, 288, 340, 1599, 315, 289, 26, 355, 747, 14, 8165, 8, 70, 12, 747, 14, 515, 14, 904, 8, 589, 14, 1199, 3567, 12, 70, 430, 272, 367, 289, 315, 747, 14, 7374, 480, 30946, 267, 340, 3680, 6480, 2, 315, 289, 503, 3680, 7873, 2, 315, 289, 26, 288, 327, 736, 14, 2168, 8, 70, 9, 288, 327, 1361, 289, 435, 298, 1990, 8792, 4829, 2, 288, 282, 29, 18, 339, 372, 378, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 339, 1249, 275, 2198, 342, 272, 1104, 6213, 8, 589, 9, 272, 1584, 275, 359, 736, 14, 515, 14, 904, 8, 589, 14, 1210, 3567, 12, 70, 9, 367, 289, 315, 747, 14, 7374, 8, 589, 14, 1210, 3567, 9, 340, 3680, 6480, 2, 315, 289, 61, 16478, 327, 1084, 1536, 314, 9861, 2120, 4203, 370, 675, 1006, 2808, 21620, 272, 2338, 275, 6118, 14, 3541, 63, 835, 342, 272, 4203, 275, 6118, 14, 5453, 8, 11816, 29, 835, 9, 272, 4203, 14, 1130, 8, 800, 12, 1584, 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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0, 0, 0, 0, 0, 0 ]
thaim/ansible
test/units/modules/network/check_point/test_cp_mgmt_access_layer_facts.py
19
2859
# Ansible module to manage CheckPoint Firewall (c) 2019 # # 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/>. # from __future__ import absolute_import, division, print_function __metaclass__ = type import pytest from units.modules.utils import set_module_args, exit_json, fail_json, AnsibleExitJson from ansible.module_utils import basic from ansible.modules.network.check_point import cp_mgmt_access_layer_facts OBJECT = { "from": 1, "to": 1, "total": 6, "objects": [ "53de74b7-8f19-4cbe-99fc-a81ef0759bad" ] } SHOW_PLURAL_PAYLOAD = { 'limit': 1, 'details_level': 'uid' } SHOW_SINGLE_PAYLOAD = { 'name': 'object_which_is_not_exist' } api_call_object = 'access-layer' api_call_object_plural_version = 'access-layers' failure_msg = '''{u'message': u'Requested object [object_which_is_not_exist] not found', u'code': u'generic_err_object_not_found'}''' class TestCheckpointAccessLayerFacts(object): module = cp_mgmt_access_layer_facts @pytest.fixture(autouse=True) def module_mock(self, mocker): return mocker.patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json) @pytest.fixture def connection_mock(self, mocker): connection_class_mock = mocker.patch('ansible.module_utils.network.checkpoint.checkpoint.Connection') return connection_class_mock.return_value def test_show_single_object_which_is_not_exist(self, mocker, connection_mock): connection_mock.send_request.return_value = (404, failure_msg) try: result = self._run_module(SHOW_SINGLE_PAYLOAD) except Exception as e: result = e.args[0] assert result['failed'] assert 'Checkpoint device returned error 404 with message ' + failure_msg == result['msg'] def test_show_few_objects(self, mocker, connection_mock): connection_mock.send_request.return_value = (200, OBJECT) result = self._run_module(SHOW_PLURAL_PAYLOAD) assert not result['changed'] assert OBJECT == result['ansible_facts'][api_call_object_plural_version] def _run_module(self, module_args): set_module_args(module_args) with pytest.raises(AnsibleExitJson) as ex: self.module.main() return ex.value.args[0]
mit
[ 3, 2622, 859, 370, 9635, 2670, 3428, 15967, 7567, 334, 67, 9, 20312, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 4613, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 12, 4458, 63, 1001, 12, 2449, 63, 1001, 12, 2622, 6699, 9653, 199, 199, 504, 3242, 14, 578, 63, 1208, 492, 5678, 199, 504, 3242, 14, 3112, 14, 1200, 14, 1074, 63, 1403, 492, 7667, 63, 9752, 63, 2732, 63, 1897, 63, 5047, 199, 199, 9868, 275, 469, 272, 298, 504, 582, 413, 12, 272, 298, 475, 582, 413, 12, 272, 298, 2923, 582, 1227, 12, 272, 298, 1462, 582, 359, 267, 298, 2481, 271, 1342, 66, 23, 13, 24, 70, 1167, 13, 20, 67, 1235, 13, 1020, 3003, 13, 65, 2835, 2829, 1780, 1427, 4087, 2, 272, 1622, 199, 93, 199, 199, 19085, 63, 2749, 1230, 748, 63, 24647, 275, 469, 272, 283, 3097, 356, 413, 12, 272, 283, 5087, 63, 1896, 356, 283, 1535, 7, 199, 93, 199, 199, 19085, 63, 16425, 63, 24647, 275, 469, 272, 283, 354, 356, 283, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 7, 199, 93, 199, 199, 1246, 63, 1250, 63, 785, 275, 283, 2732, 13, 1897, 7, 199, 1246, 63, 1250, 63, 785, 63, 10019, 63, 1023, 275, 283, 2732, 13, 4359, 7, 199, 5328, 63, 1328, 275, 1449, 91, 85, 6704, 69, 712, 356, 399, 7, 17935, 909, 359, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 61, 440, 1911, 297, 399, 7, 600, 356, 399, 7, 6767, 63, 1508, 63, 785, 63, 1397, 63, 4214, 936, 2344, 421, 199, 533, 1379, 22005, 3946, 5003, 25821, 8, 785, 304, 272, 859, 275, 7667, 63, 9752, 63, 2732, 63, 1897, 63, 5047, 339, 768, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 272, 347, 859, 63, 1805, 8, 277, 12, 15981, 304, 267, 372, 15981, 14, 2068, 14, 6048, 8, 4316, 14, 10047, 2377, 12, 4458, 63, 1001, 29, 2224, 63, 1001, 12, 2449, 63, 1001, 29, 1633, 63, 1001, 9, 339, 768, 4462, 14, 5997, 272, 347, 1950, 63, 1805, 8, 277, 12, 15981, 304, 267, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 10109, 14, 10109, 14, 3225, 358, 267, 372, 1950, 63, 533, 63, 1805, 14, 1107, 63, 585, 339, 347, 511, 63, 2384, 63, 4780, 63, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 8, 277, 12, 15981, 12, 1950, 63, 1805, 304, 267, 1950, 63, 1805, 14, 2254, 63, 1069, 14, 1107, 63, 585, 275, 334, 5188, 12, 5988, 63, 1328, 9, 267, 862, 26, 288, 754, 275, 291, 423, 1065, 63, 578, 8, 19085, 63, 16425, 63, 24647, 9, 267, 871, 2186, 465, 325, 26, 288, 754, 275, 325, 14, 589, 59, 16, 61, 398, 702, 754, 459, 4892, 418, 267, 702, 283, 22005, 2243, 2138, 1125, 7901, 543, 1245, 283, 435, 5988, 63, 1328, 508, 754, 459, 1328, 418, 339, 347, 511, 63, 2384, 63, 70, 546, 63, 1462, 8, 277, 12, 15981, 12, 1950, 63, 1805, 304, 267, 1950, 63, 1805, 14, 2254, 63, 1069, 14, 1107, 63, 585, 275, 334, 1840, 12, 28652, 5550, 9, 267, 754, 275, 291, 423, 1065, 63, 578, 8, 19085, 63, 2749, 1230, 748, 63, 24647, 9, 398, 702, 440, 754, 459, 2489, 418, 267, 702, 28652, 5550, 508, 754, 459, 4853, 63, 5047, 3488, 1246, 63, 1250, 63, 785, 63, 10019, 63, 1023, 61, 339, 347, 485, 1065, 63, 578, 8, 277, 12, 859, 63, 589, 304, 267, 663, 63, 578, 63, 589, 8, 578, 63, 589, 9, 267, 543, 4613, 14, 3536, 8, 10047, 6699, 9653, 9, 465, 444, 26, 288, 291, 14, 578, 14, 973, 342, 267, 372, 444, 14, 585, 14, 589, 59, 16, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2622, 859, 370, 9635, 2670, 3428, 15967, 7567, 334, 67, 9, 20312, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 4613, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 12, 4458, 63, 1001, 12, 2449, 63, 1001, 12, 2622, 6699, 9653, 199, 199, 504, 3242, 14, 578, 63, 1208, 492, 5678, 199, 504, 3242, 14, 3112, 14, 1200, 14, 1074, 63, 1403, 492, 7667, 63, 9752, 63, 2732, 63, 1897, 63, 5047, 199, 199, 9868, 275, 469, 272, 298, 504, 582, 413, 12, 272, 298, 475, 582, 413, 12, 272, 298, 2923, 582, 1227, 12, 272, 298, 1462, 582, 359, 267, 298, 2481, 271, 1342, 66, 23, 13, 24, 70, 1167, 13, 20, 67, 1235, 13, 1020, 3003, 13, 65, 2835, 2829, 1780, 1427, 4087, 2, 272, 1622, 199, 93, 199, 199, 19085, 63, 2749, 1230, 748, 63, 24647, 275, 469, 272, 283, 3097, 356, 413, 12, 272, 283, 5087, 63, 1896, 356, 283, 1535, 7, 199, 93, 199, 199, 19085, 63, 16425, 63, 24647, 275, 469, 272, 283, 354, 356, 283, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 7, 199, 93, 199, 199, 1246, 63, 1250, 63, 785, 275, 283, 2732, 13, 1897, 7, 199, 1246, 63, 1250, 63, 785, 63, 10019, 63, 1023, 275, 283, 2732, 13, 4359, 7, 199, 5328, 63, 1328, 275, 1449, 91, 85, 6704, 69, 712, 356, 399, 7, 17935, 909, 359, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 61, 440, 1911, 297, 399, 7, 600, 356, 399, 7, 6767, 63, 1508, 63, 785, 63, 1397, 63, 4214, 936, 2344, 421, 199, 533, 1379, 22005, 3946, 5003, 25821, 8, 785, 304, 272, 859, 275, 7667, 63, 9752, 63, 2732, 63, 1897, 63, 5047, 339, 768, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 272, 347, 859, 63, 1805, 8, 277, 12, 15981, 304, 267, 372, 15981, 14, 2068, 14, 6048, 8, 4316, 14, 10047, 2377, 12, 4458, 63, 1001, 29, 2224, 63, 1001, 12, 2449, 63, 1001, 29, 1633, 63, 1001, 9, 339, 768, 4462, 14, 5997, 272, 347, 1950, 63, 1805, 8, 277, 12, 15981, 304, 267, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 10109, 14, 10109, 14, 3225, 358, 267, 372, 1950, 63, 533, 63, 1805, 14, 1107, 63, 585, 339, 347, 511, 63, 2384, 63, 4780, 63, 785, 63, 6777, 63, 374, 63, 1397, 63, 4494, 8, 277, 12, 15981, 12, 1950, 63, 1805, 304, 267, 1950, 63, 1805, 14, 2254, 63, 1069, 14, 1107, 63, 585, 275, 334, 5188, 12, 5988, 63, 1328, 9, 267, 862, 26, 288, 754, 275, 291, 423, 1065, 63, 578, 8, 19085, 63, 16425, 63, 24647, 9, 267, 871, 2186, 465, 325, 26, 288, 754, 275, 325, 14, 589, 59, 16, 61, 398, 702, 754, 459, 4892, 418, 267, 702, 283, 22005, 2243, 2138, 1125, 7901, 543, 1245, 283, 435, 5988, 63, 1328, 508, 754, 459, 1328, 418, 339, 347, 511, 63, 2384, 63, 70, 546, 63, 1462, 8, 277, 12, 15981, 12, 1950, 63, 1805, 304, 267, 1950, 63, 1805, 14, 2254, 63, 1069, 14, 1107, 63, 585, 275, 334, 1840, 12, 28652, 5550, 9, 267, 754, 275, 291, 423, 1065, 63, 578, 8, 19085, 63, 2749, 1230, 748, 63, 24647, 9, 398, 702, 440, 754, 459, 2489, 418, 267, 702, 28652, 5550, 508, 754, 459, 4853, 63, 5047, 3488, 1246, 63, 1250, 63, 785, 63, 10019, 63, 1023, 61, 339, 347, 485, 1065, 63, 578, 8, 277, 12, 859, 63, 589, 304, 267, 663, 63, 578, 63, 589, 8, 578, 63, 589, 9, 267, 543, 4613, 14, 3536, 8, 10047, 6699, 9653, 9, 465, 444, 26, 288, 291, 14, 578, 14, 973, 342, 267, 372, 444, 14, 585, 14, 589, 59, 16, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
blackzw/openwrt_sdk_dev1
staging_dir/host/lib/python2.7/email/quoprimime.py
246
10848
# Copyright (C) 2001-2006 Python Software Foundation # Author: Ben Gertzfield # Contact: email-sig@python.org """Quoted-printable content transfer encoding per RFCs 2045-2047. This module handles the content transfer encoding method defined in RFC 2045 to encode US ASCII-like 8-bit data called `quoted-printable'. It is used to safely encode text that is in a character set similar to the 7-bit US ASCII character set, but that includes some 8-bit characters that are normally not allowed in email bodies or headers. Quoted-printable is very space-inefficient for encoding binary files; use the email.base64mime module for that instead. This module provides an interface to encode and decode both headers and bodies with quoted-printable encoding. RFC 2045 defines a method for including character set information in an `encoded-word' in a header. This method is commonly used for 8-bit real names in To:/From:/Cc: etc. fields, as well as Subject: lines. This module does not do the line wrapping or end-of-line character conversion necessary for proper internationalized headers; it only does dumb encoding and decoding. To deal with the various line wrapping issues, use the email.header module. """ __all__ = [ 'body_decode', 'body_encode', 'body_quopri_check', 'body_quopri_len', 'decode', 'decodestring', 'encode', 'encodestring', 'header_decode', 'header_encode', 'header_quopri_check', 'header_quopri_len', 'quote', 'unquote', ] import re from string import hexdigits from email.utils import fix_eols CRLF = '\r\n' NL = '\n' # See also Charset.py MISC_LEN = 7 hqre = re.compile(r'[^-a-zA-Z0-9!*+/ ]') bqre = re.compile(r'[^ !-<>-~\t]') # Helpers def header_quopri_check(c): """Return True if the character should be escaped with header quopri.""" return bool(hqre.match(c)) def body_quopri_check(c): """Return True if the character should be escaped with body quopri.""" return bool(bqre.match(c)) def header_quopri_len(s): """Return the length of str when it is encoded with header quopri.""" count = 0 for c in s: if hqre.match(c): count += 3 else: count += 1 return count def body_quopri_len(str): """Return the length of str when it is encoded with body quopri.""" count = 0 for c in str: if bqre.match(c): count += 3 else: count += 1 return count def _max_append(L, s, maxlen, extra=''): if not L: L.append(s.lstrip()) elif len(L[-1]) + len(s) <= maxlen: L[-1] += extra + s else: L.append(s.lstrip()) def unquote(s): """Turn a string in the form =AB to the ASCII character with value 0xab""" return chr(int(s[1:3], 16)) def quote(c): return "=%02X" % ord(c) def header_encode(header, charset="iso-8859-1", keep_eols=False, maxlinelen=76, eol=NL): """Encode a single header line with quoted-printable (like) encoding. Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but used specifically for email header fields to allow charsets with mostly 7 bit characters (and some 8 bit) to remain more or less readable in non-RFC 2045 aware mail clients. charset names the character set to use to encode the header. It defaults to iso-8859-1. The resulting string will be in the form: "=?charset?q?I_f=E2rt_in_your_g=E8n=E8ral_dire=E7tion?\\n =?charset?q?Silly_=C8nglish_Kn=EEghts?=" with each line wrapped safely at, at most, maxlinelen characters (defaults to 76 characters). If maxlinelen is None, the entire string is encoded in one chunk with no splitting. End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted to the canonical email line separator \\r\\n unless the keep_eols parameter is True (the default is False). Each line of the header will be terminated in the value of eol, which defaults to "\\n". Set this to "\\r\\n" if you are using the result of this function directly in email. """ # Return empty headers unchanged if not header: return header if not keep_eols: header = fix_eols(header) # Quopri encode each line, in encoded chunks no greater than maxlinelen in # length, after the RFC chrome is added in. quoted = [] if maxlinelen is None: # An obnoxiously large number that's good enough max_encoded = 100000 else: max_encoded = maxlinelen - len(charset) - MISC_LEN - 1 for c in header: # Space may be represented as _ instead of =20 for readability if c == ' ': _max_append(quoted, '_', max_encoded) # These characters can be included verbatim elif not hqre.match(c): _max_append(quoted, c, max_encoded) # Otherwise, replace with hex value like =E2 else: _max_append(quoted, "=%02X" % ord(c), max_encoded) # Now add the RFC chrome to each encoded chunk and glue the chunks # together. BAW: should we be able to specify the leading whitespace in # the joiner? joiner = eol + ' ' return joiner.join(['=?%s?q?%s?=' % (charset, line) for line in quoted]) def encode(body, binary=False, maxlinelen=76, eol=NL): """Encode with quoted-printable, wrapping at maxlinelen characters. If binary is False (the default), end-of-line characters will be converted to the canonical email end-of-line sequence \\r\\n. Otherwise they will be left verbatim. Each line of encoded text will end with eol, which defaults to "\\n". Set this to "\\r\\n" if you will be using the result of this function directly in an email. Each line will be wrapped at, at most, maxlinelen characters (defaults to 76 characters). Long lines will have the `soft linefeed' quoted-printable character "=" appended to them, so the decoded text will be identical to the original text. """ if not body: return body if not binary: body = fix_eols(body) # BAW: We're accumulating the body text by string concatenation. That # can't be very efficient, but I don't have time now to rewrite it. It # just feels like this algorithm could be more efficient. encoded_body = '' lineno = -1 # Preserve line endings here so we can check later to see an eol needs to # be added to the output later. lines = body.splitlines(1) for line in lines: # But strip off line-endings for processing this line. if line.endswith(CRLF): line = line[:-2] elif line[-1] in CRLF: line = line[:-1] lineno += 1 encoded_line = '' prev = None linelen = len(line) # Now we need to examine every character to see if it needs to be # quopri encoded. BAW: again, string concatenation is inefficient. for j in range(linelen): c = line[j] prev = c if bqre.match(c): c = quote(c) elif j+1 == linelen: # Check for whitespace at end of line; special case if c not in ' \t': encoded_line += c prev = c continue # Check to see to see if the line has reached its maximum length if len(encoded_line) + len(c) >= maxlinelen: encoded_body += encoded_line + '=' + eol encoded_line = '' encoded_line += c # Now at end of line.. if prev and prev in ' \t': # Special case for whitespace at end of file if lineno + 1 == len(lines): prev = quote(prev) if len(encoded_line) + len(prev) > maxlinelen: encoded_body += encoded_line + '=' + eol + prev else: encoded_body += encoded_line + prev # Just normal whitespace at end of line else: encoded_body += encoded_line + prev + '=' + eol encoded_line = '' # Now look at the line we just finished and it has a line ending, we # need to add eol to the end of the line. if lines[lineno].endswith(CRLF) or lines[lineno][-1] in CRLF: encoded_body += encoded_line + eol else: encoded_body += encoded_line encoded_line = '' return encoded_body # For convenience and backwards compatibility w/ standard base64 module body_encode = encode encodestring = encode # BAW: I'm not sure if the intent was for the signature of this function to be # the same as base64MIME.decode() or not... def decode(encoded, eol=NL): """Decode a quoted-printable string. Lines are separated with eol, which defaults to \\n. """ if not encoded: return encoded # BAW: see comment in encode() above. Again, we're building up the # decoded string with string concatenation, which could be done much more # efficiently. decoded = '' for line in encoded.splitlines(): line = line.rstrip() if not line: decoded += eol continue i = 0 n = len(line) while i < n: c = line[i] if c != '=': decoded += c i += 1 # Otherwise, c == "=". Are we at the end of the line? If so, add # a soft line break. elif i+1 == n: i += 1 continue # Decode if in form =AB elif i+2 < n and line[i+1] in hexdigits and line[i+2] in hexdigits: decoded += unquote(line[i:i+3]) i += 3 # Otherwise, not in form =AB, pass literally else: decoded += c i += 1 if i == n: decoded += eol # Special case if original string did not end with eol if not encoded.endswith(eol) and decoded.endswith(eol): decoded = decoded[:-1] return decoded # For convenience and backwards compatibility w/ standard base64 module body_decode = decode decodestring = decode def _unquote_match(match): """Turn a match in the form =AB to the ASCII character with value 0xab""" s = match.group(0) return unquote(s) # Header decoding is done a bit differently def header_decode(s): """Decode a string encoded with RFC 2045 MIME header `Q' encoding. This function does not parse a full MIME header value encoded with quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use the high level email.header class for that functionality. """ s = s.replace('_', ' ') return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s)
gpl-2.0
[ 3, 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 199, 3, 6529, 26, 26844, 22261, 3903, 698, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 199, 624, 24115, 13, 20557, 1564, 9307, 2644, 1126, 7329, 83, 499, 12618, 13, 6686, 23, 14, 199, 199, 2765, 859, 10022, 314, 1564, 9307, 2644, 1083, 3247, 315, 7329, 499, 12618, 199, 475, 3752, 19635, 10485, 13, 2930, 1695, 13, 2075, 666, 2797, 658, 9888, 13, 20557, 1370, 221, 2779, 365, 1202, 370, 199, 2231, 70, 7742, 3752, 1318, 626, 365, 315, 282, 4528, 663, 8545, 370, 314, 1520, 13, 2075, 19635, 10485, 199, 10856, 663, 12, 1325, 626, 6952, 2005, 1695, 13, 2075, 4110, 626, 787, 12252, 440, 199, 6541, 315, 3031, 1234, 18245, 503, 2323, 14, 199, 199, 24115, 13, 20557, 365, 7437, 4601, 13, 1132, 70, 5134, 367, 2644, 3366, 1584, 27, 675, 314, 199, 2123, 14, 1095, 772, 7626, 859, 367, 626, 3140, 14, 199, 199, 2765, 859, 6571, 376, 3217, 370, 3752, 436, 4849, 3865, 2323, 436, 1234, 18245, 199, 1045, 10999, 13, 20557, 2644, 14, 199, 199, 14468, 499, 12618, 7890, 282, 1083, 367, 5893, 4528, 663, 2556, 315, 376, 199, 64, 8167, 13, 1027, 7, 315, 282, 1406, 14, 221, 961, 1083, 365, 28829, 1202, 367, 1695, 13, 2075, 3363, 1561, 199, 262, 4005, 11254, 2532, 11254, 21426, 26, 5423, 14, 1504, 12, 465, 5521, 465, 26793, 26, 2385, 14, 199, 199, 2765, 859, 1630, 440, 886, 314, 1004, 19696, 503, 1284, 13, 1618, 13, 604, 4528, 199, 15083, 5784, 367, 5576, 10757, 6279, 1759, 2323, 27, 652, 1454, 199, 9105, 32490, 2644, 436, 15952, 14, 221, 4005, 7962, 543, 314, 7750, 1004, 199, 87, 15521, 10876, 12, 675, 314, 3031, 14, 1291, 859, 14, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2030, 63, 2708, 297, 272, 283, 2030, 63, 2143, 297, 272, 283, 2030, 63, 392, 21993, 63, 1074, 297, 272, 283, 2030, 63, 392, 21993, 63, 552, 297, 272, 283, 2708, 297, 272, 283, 2708, 875, 297, 272, 283, 2143, 297, 272, 283, 2143, 875, 297, 272, 283, 1291, 63, 2708, 297, 272, 283, 1291, 63, 2143, 297, 272, 283, 1291, 63, 392, 21993, 63, 1074, 297, 272, 283, 1291, 63, 392, 21993, 63, 552, 297, 272, 283, 3513, 297, 272, 283, 12240, 297, 272, 1622, 199, 199, 646, 295, 199, 199, 504, 1059, 492, 6318, 7022, 199, 504, 3031, 14, 1208, 492, 5325, 63, 69, 1446, 199, 199, 35, 20190, 275, 1557, 82, 60, 78, 7, 199, 14176, 275, 1557, 78, 7, 199, 199, 3, 1666, 2597, 29392, 14, 647, 199, 9674, 35, 63, 5304, 275, 1520, 199, 199, 21550, 264, 275, 295, 14, 2014, 8, 82, 16122, 13, 65, 13, 6353, 13, 58, 16, 13, 25, 1, 10, 19616, 1622, 358, 199, 23907, 264, 275, 295, 14, 2014, 8, 82, 16122, 8546, 13, 16137, 13, 94, 60, 84, 10374, 4388, 201, 199, 3, 11642, 83, 199, 318, 1406, 63, 392, 21993, 63, 1074, 8, 67, 304, 272, 408, 1767, 715, 340, 314, 4528, 1077, 506, 11077, 543, 1406, 2173, 21993, 1041, 272, 372, 2155, 8, 21550, 264, 14, 1431, 8, 67, 430, 421, 199, 318, 2396, 63, 392, 21993, 63, 1074, 8, 67, 304, 272, 408, 1767, 715, 340, 314, 4528, 1077, 506, 11077, 543, 2396, 2173, 21993, 1041, 272, 372, 2155, 8, 23907, 264, 14, 1431, 8, 67, 430, 421, 199, 318, 1406, 63, 392, 21993, 63, 552, 8, 83, 304, 272, 408, 1767, 314, 2582, 402, 620, 1380, 652, 365, 5737, 543, 1406, 2173, 21993, 1041, 272, 2338, 275, 378, 272, 367, 286, 315, 308, 26, 267, 340, 394, 81, 264, 14, 1431, 8, 67, 304, 288, 2338, 847, 650, 267, 587, 26, 288, 2338, 847, 413, 272, 372, 2338, 421, 199, 318, 2396, 63, 392, 21993, 63, 552, 8, 495, 304, 272, 408, 1767, 314, 2582, 402, 620, 1380, 652, 365, 5737, 543, 2396, 2173, 21993, 1041, 272, 2338, 275, 378, 272, 367, 286, 315, 620, 26, 267, 340, 330, 81, 264, 14, 1431, 8, 67, 304, 288, 2338, 847, 650, 267, 587, 26, 288, 2338, 847, 413, 272, 372, 2338, 421, 199, 318, 485, 988, 63, 740, 8, 44, 12, 308, 12, 21037, 12, 2402, 9280, 272, 340, 440, 491, 26, 267, 491, 14, 740, 8, 83, 14, 10124, 1012, 272, 916, 822, 8, 44, 1988, 17, 566, 435, 822, 8, 83, 9, 2695, 21037, 26, 267, 491, 1988, 17, 61, 847, 2402, 435, 308, 272, 587, 26, 267, 491, 14, 740, 8, 83, 14, 10124, 1012, 421, 199, 318, 14342, 8, 83, 304, 272, 408, 16838, 282, 1059, 315, 314, 1824, 275, 1217, 370, 314, 10485, 4528, 543, 574, 378, 10097, 624, 272, 372, 8678, 8, 442, 8, 83, 59, 17, 26, 19, 467, 3193, 430, 421, 199, 318, 6313, 8, 67, 304, 272, 372, 298, 2458, 996, 56, 2, 450, 6206, 8, 67, 9, 4388, 201, 199, 318, 1406, 63, 2143, 8, 1291, 12, 5960, 628, 4595, 13, 4830, 13, 17, 401, 4215, 63, 69, 1446, 29, 797, 12, 2116, 1390, 604, 552, 29, 2114, 12, 17645, 29, 14176, 304, 272, 408, 9686, 282, 2849, 1406, 1004, 543, 10999, 13, 20557, 334, 2930, 9, 2644, 14, 339, 11391, 1942, 315, 7329, 499, 12618, 12, 642, 658, 49, 7, 2644, 365, 8545, 370, 10999, 13, 20557, 12, 1325, 272, 1202, 22543, 367, 3031, 1406, 1504, 370, 2040, 1495, 2193, 543, 19762, 1520, 272, 4546, 4110, 334, 460, 2005, 1695, 4546, 9, 370, 5706, 1655, 503, 6656, 12701, 315, 2222, 13, 14468, 272, 499, 12618, 20381, 6016, 13431, 14, 339, 5960, 1561, 314, 4528, 663, 370, 675, 370, 3752, 314, 1406, 14, 221, 2779, 4243, 272, 370, 11601, 13, 4830, 13, 17, 14, 339, 710, 9183, 1059, 911, 506, 315, 314, 1824, 26, 339, 298, 18048, 6043, 31, 81, 31, 41, 63, 70, 29, 37, 18, 2591, 63, 262, 63, 12695, 63, 71, 29, 37, 24, 78, 29, 37, 24, 13984, 63, 328, 264, 29, 37, 23, 296, 31, 1103, 78, 489, 24785, 6043, 31, 81, 31, 51, 382, 590, 10683, 35, 24, 2753, 1891, 63, 43, 78, 29, 8699, 913, 83, 31 ]
[ 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 199, 3, 6529, 26, 26844, 22261, 3903, 698, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 199, 624, 24115, 13, 20557, 1564, 9307, 2644, 1126, 7329, 83, 499, 12618, 13, 6686, 23, 14, 199, 199, 2765, 859, 10022, 314, 1564, 9307, 2644, 1083, 3247, 315, 7329, 499, 12618, 199, 475, 3752, 19635, 10485, 13, 2930, 1695, 13, 2075, 666, 2797, 658, 9888, 13, 20557, 1370, 221, 2779, 365, 1202, 370, 199, 2231, 70, 7742, 3752, 1318, 626, 365, 315, 282, 4528, 663, 8545, 370, 314, 1520, 13, 2075, 19635, 10485, 199, 10856, 663, 12, 1325, 626, 6952, 2005, 1695, 13, 2075, 4110, 626, 787, 12252, 440, 199, 6541, 315, 3031, 1234, 18245, 503, 2323, 14, 199, 199, 24115, 13, 20557, 365, 7437, 4601, 13, 1132, 70, 5134, 367, 2644, 3366, 1584, 27, 675, 314, 199, 2123, 14, 1095, 772, 7626, 859, 367, 626, 3140, 14, 199, 199, 2765, 859, 6571, 376, 3217, 370, 3752, 436, 4849, 3865, 2323, 436, 1234, 18245, 199, 1045, 10999, 13, 20557, 2644, 14, 199, 199, 14468, 499, 12618, 7890, 282, 1083, 367, 5893, 4528, 663, 2556, 315, 376, 199, 64, 8167, 13, 1027, 7, 315, 282, 1406, 14, 221, 961, 1083, 365, 28829, 1202, 367, 1695, 13, 2075, 3363, 1561, 199, 262, 4005, 11254, 2532, 11254, 21426, 26, 5423, 14, 1504, 12, 465, 5521, 465, 26793, 26, 2385, 14, 199, 199, 2765, 859, 1630, 440, 886, 314, 1004, 19696, 503, 1284, 13, 1618, 13, 604, 4528, 199, 15083, 5784, 367, 5576, 10757, 6279, 1759, 2323, 27, 652, 1454, 199, 9105, 32490, 2644, 436, 15952, 14, 221, 4005, 7962, 543, 314, 7750, 1004, 199, 87, 15521, 10876, 12, 675, 314, 3031, 14, 1291, 859, 14, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2030, 63, 2708, 297, 272, 283, 2030, 63, 2143, 297, 272, 283, 2030, 63, 392, 21993, 63, 1074, 297, 272, 283, 2030, 63, 392, 21993, 63, 552, 297, 272, 283, 2708, 297, 272, 283, 2708, 875, 297, 272, 283, 2143, 297, 272, 283, 2143, 875, 297, 272, 283, 1291, 63, 2708, 297, 272, 283, 1291, 63, 2143, 297, 272, 283, 1291, 63, 392, 21993, 63, 1074, 297, 272, 283, 1291, 63, 392, 21993, 63, 552, 297, 272, 283, 3513, 297, 272, 283, 12240, 297, 272, 1622, 199, 199, 646, 295, 199, 199, 504, 1059, 492, 6318, 7022, 199, 504, 3031, 14, 1208, 492, 5325, 63, 69, 1446, 199, 199, 35, 20190, 275, 1557, 82, 60, 78, 7, 199, 14176, 275, 1557, 78, 7, 199, 199, 3, 1666, 2597, 29392, 14, 647, 199, 9674, 35, 63, 5304, 275, 1520, 199, 199, 21550, 264, 275, 295, 14, 2014, 8, 82, 16122, 13, 65, 13, 6353, 13, 58, 16, 13, 25, 1, 10, 19616, 1622, 358, 199, 23907, 264, 275, 295, 14, 2014, 8, 82, 16122, 8546, 13, 16137, 13, 94, 60, 84, 10374, 4388, 201, 199, 3, 11642, 83, 199, 318, 1406, 63, 392, 21993, 63, 1074, 8, 67, 304, 272, 408, 1767, 715, 340, 314, 4528, 1077, 506, 11077, 543, 1406, 2173, 21993, 1041, 272, 372, 2155, 8, 21550, 264, 14, 1431, 8, 67, 430, 421, 199, 318, 2396, 63, 392, 21993, 63, 1074, 8, 67, 304, 272, 408, 1767, 715, 340, 314, 4528, 1077, 506, 11077, 543, 2396, 2173, 21993, 1041, 272, 372, 2155, 8, 23907, 264, 14, 1431, 8, 67, 430, 421, 199, 318, 1406, 63, 392, 21993, 63, 552, 8, 83, 304, 272, 408, 1767, 314, 2582, 402, 620, 1380, 652, 365, 5737, 543, 1406, 2173, 21993, 1041, 272, 2338, 275, 378, 272, 367, 286, 315, 308, 26, 267, 340, 394, 81, 264, 14, 1431, 8, 67, 304, 288, 2338, 847, 650, 267, 587, 26, 288, 2338, 847, 413, 272, 372, 2338, 421, 199, 318, 2396, 63, 392, 21993, 63, 552, 8, 495, 304, 272, 408, 1767, 314, 2582, 402, 620, 1380, 652, 365, 5737, 543, 2396, 2173, 21993, 1041, 272, 2338, 275, 378, 272, 367, 286, 315, 620, 26, 267, 340, 330, 81, 264, 14, 1431, 8, 67, 304, 288, 2338, 847, 650, 267, 587, 26, 288, 2338, 847, 413, 272, 372, 2338, 421, 199, 318, 485, 988, 63, 740, 8, 44, 12, 308, 12, 21037, 12, 2402, 9280, 272, 340, 440, 491, 26, 267, 491, 14, 740, 8, 83, 14, 10124, 1012, 272, 916, 822, 8, 44, 1988, 17, 566, 435, 822, 8, 83, 9, 2695, 21037, 26, 267, 491, 1988, 17, 61, 847, 2402, 435, 308, 272, 587, 26, 267, 491, 14, 740, 8, 83, 14, 10124, 1012, 421, 199, 318, 14342, 8, 83, 304, 272, 408, 16838, 282, 1059, 315, 314, 1824, 275, 1217, 370, 314, 10485, 4528, 543, 574, 378, 10097, 624, 272, 372, 8678, 8, 442, 8, 83, 59, 17, 26, 19, 467, 3193, 430, 421, 199, 318, 6313, 8, 67, 304, 272, 372, 298, 2458, 996, 56, 2, 450, 6206, 8, 67, 9, 4388, 201, 199, 318, 1406, 63, 2143, 8, 1291, 12, 5960, 628, 4595, 13, 4830, 13, 17, 401, 4215, 63, 69, 1446, 29, 797, 12, 2116, 1390, 604, 552, 29, 2114, 12, 17645, 29, 14176, 304, 272, 408, 9686, 282, 2849, 1406, 1004, 543, 10999, 13, 20557, 334, 2930, 9, 2644, 14, 339, 11391, 1942, 315, 7329, 499, 12618, 12, 642, 658, 49, 7, 2644, 365, 8545, 370, 10999, 13, 20557, 12, 1325, 272, 1202, 22543, 367, 3031, 1406, 1504, 370, 2040, 1495, 2193, 543, 19762, 1520, 272, 4546, 4110, 334, 460, 2005, 1695, 4546, 9, 370, 5706, 1655, 503, 6656, 12701, 315, 2222, 13, 14468, 272, 499, 12618, 20381, 6016, 13431, 14, 339, 5960, 1561, 314, 4528, 663, 370, 675, 370, 3752, 314, 1406, 14, 221, 2779, 4243, 272, 370, 11601, 13, 4830, 13, 17, 14, 339, 710, 9183, 1059, 911, 506, 315, 314, 1824, 26, 339, 298, 18048, 6043, 31, 81, 31, 41, 63, 70, 29, 37, 18, 2591, 63, 262, 63, 12695, 63, 71, 29, 37, 24, 78, 29, 37, 24, 13984, 63, 328, 264, 29, 37, 23, 296, 31, 1103, 78, 489, 24785, 6043, 31, 81, 31, 51, 382, 590, 10683, 35, 24, 2753, 1891, 63, 43, 78, 29, 8699, 913, 83, 31, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
weimingtom/python-for-android
python3-alpha/python3-src/Lib/multiprocessing/process.py
45
9778
# # Module providing the `Process` class which emulates `threading.Thread` # # multiprocessing/process.py # # Copyright (c) 2006-2008, R Oudkerk # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of author nor the names of any contributors may be # used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. # __all__ = ['Process', 'current_process', 'active_children'] # # Imports # import os import sys import signal import itertools from _weakrefset import WeakSet # # # try: ORIGINAL_DIR = os.path.abspath(os.getcwd()) except OSError: ORIGINAL_DIR = None # # Public functions # def current_process(): ''' Return process object representing the current process ''' return _current_process def active_children(): ''' Return list of process objects corresponding to live child processes ''' _cleanup() return list(_current_process._children) # # # def _cleanup(): # check for processes which have finished for p in list(_current_process._children): if p._popen.poll() is not None: _current_process._children.discard(p) # # The `Process` class # class Process(object): ''' Process objects represent activity that is run in a separate process The class is analagous to `threading.Thread` ''' _Popen = None def __init__(self, group=None, target=None, name=None, args=(), kwargs={}): assert group is None, 'group argument must be None for now' count = next(_current_process._counter) self._identity = _current_process._identity + (count,) self._authkey = _current_process._authkey self._daemonic = _current_process._daemonic self._tempdir = _current_process._tempdir self._parent_pid = os.getpid() self._popen = None self._target = target self._args = tuple(args) self._kwargs = dict(kwargs) self._name = name or type(self).__name__ + '-' + \ ':'.join(str(i) for i in self._identity) _dangling.add(self) def run(self): ''' Method to be run in sub-process; can be overridden in sub-class ''' if self._target: self._target(*self._args, **self._kwargs) def start(self): ''' Start child process ''' assert self._popen is None, 'cannot start a process twice' assert self._parent_pid == os.getpid(), \ 'can only start a process object created by current process' assert not _current_process._daemonic, \ 'daemonic processes are not allowed to have children' _cleanup() if self._Popen is not None: Popen = self._Popen else: from .forking import Popen self._popen = Popen(self) _current_process._children.add(self) def terminate(self): ''' Terminate process; sends SIGTERM signal or uses TerminateProcess() ''' self._popen.terminate() def join(self, timeout=None): ''' Wait until child process terminates ''' assert self._parent_pid == os.getpid(), 'can only join a child process' assert self._popen is not None, 'can only join a started process' res = self._popen.wait(timeout) if res is not None: _current_process._children.discard(self) def is_alive(self): ''' Return whether process is alive ''' if self is _current_process: return True assert self._parent_pid == os.getpid(), 'can only test a child process' if self._popen is None: return False self._popen.poll() return self._popen.returncode is None @property def name(self): return self._name @name.setter def name(self, name): assert isinstance(name, str), 'name must be a string' self._name = name @property def daemon(self): ''' Return whether process is a daemon ''' return self._daemonic @daemon.setter def daemon(self, daemonic): ''' Set whether process is a daemon ''' assert self._popen is None, 'process has already started' self._daemonic = daemonic @property def authkey(self): return self._authkey @authkey.setter def authkey(self, authkey): ''' Set authorization key of process ''' self._authkey = AuthenticationString(authkey) @property def exitcode(self): ''' Return exit code of process or `None` if it has yet to stop ''' if self._popen is None: return self._popen return self._popen.poll() @property def ident(self): ''' Return identifier (PID) of process or `None` if it has yet to start ''' if self is _current_process: return os.getpid() else: return self._popen and self._popen.pid pid = ident def __repr__(self): if self is _current_process: status = 'started' elif self._parent_pid != os.getpid(): status = 'unknown' elif self._popen is None: status = 'initial' else: if self._popen.poll() is not None: status = self.exitcode else: status = 'started' if type(status) is int: if status == 0: status = 'stopped' else: status = 'stopped[%s]' % _exitcode_to_name.get(status, status) return '<%s(%s, %s%s)>' % (type(self).__name__, self._name, status, self._daemonic and ' daemon' or '') ## def _bootstrap(self): from . import util global _current_process try: self._children = set() self._counter = itertools.count(1) if sys.stdin is not None: try: sys.stdin.close() sys.stdin = open(os.devnull) except (OSError, ValueError): pass old_process = _current_process _current_process = self try: util._finalizer_registry.clear() util._run_after_forkers() finally: # delay finalization of the old process object until after # _run_after_forkers() is executed del old_process util.info('child process calling self.run()') try: self.run() exitcode = 0 finally: util._exit_function() except SystemExit as e: if not e.args: exitcode = 1 elif type(e.args[0]) is int: exitcode = e.args[0] else: sys.stderr.write(e.args[0] + '\n') sys.stderr.flush() exitcode = 1 except: exitcode = 1 import traceback sys.stderr.write('Process %s:\n' % self.name) sys.stderr.flush() traceback.print_exc() util.info('process exiting with exitcode %d' % exitcode) return exitcode # # We subclass bytes to avoid accidental transmission of auth keys over network # class AuthenticationString(bytes): def __reduce__(self): from .forking import Popen if not Popen.thread_is_spawning(): raise TypeError( 'Pickling an AuthenticationString object is ' 'disallowed for security reasons' ) return AuthenticationString, (bytes(self),) # # Create object representing the main process # class _MainProcess(Process): def __init__(self): self._identity = () self._daemonic = False self._name = 'MainProcess' self._parent_pid = None self._popen = None self._counter = itertools.count(1) self._children = set() self._authkey = AuthenticationString(os.urandom(32)) self._tempdir = None _current_process = _MainProcess() del _MainProcess # # Give names to some return codes # _exitcode_to_name = {} for name, signum in list(signal.__dict__.items()): if name[:3]=='SIG' and '_' not in name: _exitcode_to_name[-signum] = name # For debug and leak testing _dangling = WeakSet()
apache-2.0
[ 3, 199, 3, 5673, 13070, 314, 658, 3498, 64, 1021, 1314, 17423, 2335, 658, 12562, 14, 4436, 64, 199, 3, 199, 3, 12866, 15, 1412, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 4132, 6590, 314, 1561, 402, 1263, 8417, 1443, 506, 199, 3, 259, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 259, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 199, 3, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 199, 3, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 199, 3, 9712, 9784, 14, 199, 3, 199, 199, 363, 452, 363, 275, 788, 3498, 297, 283, 1818, 63, 1412, 297, 283, 2682, 63, 3223, 418, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 4673, 199, 646, 7975, 199, 504, 485, 21330, 409, 492, 28224, 1084, 199, 199, 3, 199, 3, 199, 3, 199, 199, 893, 26, 272, 1549, 1277, 13384, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 9458, 1012, 199, 2590, 6440, 26, 272, 1549, 1277, 13384, 63, 3022, 275, 488, 199, 199, 3, 199, 3, 1684, 3423, 199, 3, 199, 199, 318, 1453, 63, 1412, 837, 272, 1449, 272, 1432, 2112, 909, 6144, 314, 1453, 2112, 272, 1449, 272, 372, 485, 1818, 63, 1412, 199, 199, 318, 4702, 63, 3223, 837, 272, 1449, 272, 1432, 769, 402, 2112, 2251, 5226, 370, 12166, 1982, 10358, 272, 1449, 272, 485, 7661, 342, 272, 372, 769, 1547, 1818, 63, 1412, 423, 3223, 9, 199, 199, 3, 199, 3, 199, 3, 199, 199, 318, 485, 7661, 837, 272, 327, 1104, 367, 10358, 1314, 1172, 9158, 272, 367, 299, 315, 769, 1547, 1818, 63, 1412, 423, 3223, 304, 267, 340, 299, 423, 12207, 14, 6843, 342, 365, 440, 488, 26, 288, 485, 1818, 63, 1412, 423, 3223, 14, 14394, 8, 80, 9, 199, 199, 3, 199, 3, 710, 658, 3498, 64, 1021, 199, 3, 199, 199, 533, 7132, 8, 785, 304, 272, 1449, 272, 7132, 2251, 2954, 10679, 626, 365, 1255, 315, 282, 7396, 2112, 339, 710, 1021, 365, 376, 279, 643, 1785, 370, 658, 12562, 14, 4436, 64, 272, 1449, 272, 485, 7942, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1572, 29, 403, 12, 1347, 29, 403, 12, 536, 29, 403, 12, 1249, 16729, 2074, 16420, 267, 702, 1572, 365, 488, 12, 283, 923, 1423, 1471, 506, 488, 367, 3063, 7, 267, 2338, 275, 2163, 1547, 1818, 63, 1412, 423, 5337, 9, 267, 291, 423, 5582, 275, 485, 1818, 63, 1412, 423, 5582, 435, 334, 835, 4258, 267, 291, 423, 1178, 498, 275, 485, 1818, 63, 1412, 423, 1178, 498, 267, 291, 423, 10824, 530, 275, 485, 1818, 63, 1412, 423, 10824, 530, 267, 291, 423, 11567, 275, 485, 1818, 63, 1412, 423, 11567, 267, 291, 423, 1708, 63, 3150, 275, 747, 14, 17829, 342, 267, 291, 423, 12207, 275, 488, 267, 291, 423, 1375, 275, 1347, 267, 291, 423, 589, 275, 2008, 8, 589, 9, 267, 291, 423, 958, 275, 1211, 8, 958, 9, 267, 291, 423, 354, 275, 536, 503, 730, 8, 277, 2843, 354, 363, 435, 10791, 435, 971, 2151, 29010, 904, 8, 495, 8, 73, 9, 367, 284, 315, 291, 423, 5582, 9, 267, 485, 68, 26896, 14, 525, 8, 277, 9, 339, 347, 1255, 8, 277, 304, 267, 1449, 267, 9075, 370, 506, 1255, 315, 1007, 13, 1412, 27, 883, 506, 10087, 315, 1007, 13, 533, 267, 1449, 267, 340, 291, 423, 1375, 26, 288, 291, 423, 1375, 2031, 277, 423, 589, 12, 1011, 277, 423, 958, 9, 339, 347, 1343, 8, 277, 304, 267, 1449, 267, 7707, 1982, 2112, 267, 1449, 267, 702, 291, 423, 12207, 365, 488, 12, 283, 11250, 1343, 282, 2112, 13373, 7, 267, 702, 291, 423, 1708, 63, 3150, 508, 747, 14, 17829, 1062, 971, 2049, 283, 2425, 1454, 1343, 282, 2112, 909, 2737, 701, 1453, 2112, 7, 267, 702, 440, 485, 1818, 63, 1412, 423, 10824, 530, 12, 971, 2049, 283, 10824, 530, 10358, 787, 440, 4370, 370, 1172, 4978, 7, 267, 485, 7661, 342, 267, 340, 291, 423, 7942, 365, 440, 488, 26, 288, 13995, 275, 291, 423, 7942, 267, 587, 26, 288, 687, 1275, 11796, 316, 492, 13995, 267, 291, 423, 12207, 275, 13995, 8, 277, 9, 267, 485, 1818, 63, 1412, 423, 3223, 14, 525, 8, 277, 9, 339, 347, 15095, 8, 277, 304, 267, 1449, 267, 20429, 323, 2112, 27, 16178, 15522, 16718, 4673, 503, 4440, 20429, 323, 3498, 342, 267, 1449, 267, 291, 423, 12207, 14, 14478, 342, 339, 347, 4263, 8, 277 ]
[ 199, 3, 5673, 13070, 314, 658, 3498, 64, 1021, 1314, 17423, 2335, 658, 12562, 14, 4436, 64, 199, 3, 199, 3, 12866, 15, 1412, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 4132, 6590, 314, 1561, 402, 1263, 8417, 1443, 506, 199, 3, 259, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 259, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 199, 3, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 199, 3, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 199, 3, 9712, 9784, 14, 199, 3, 199, 199, 363, 452, 363, 275, 788, 3498, 297, 283, 1818, 63, 1412, 297, 283, 2682, 63, 3223, 418, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 4673, 199, 646, 7975, 199, 504, 485, 21330, 409, 492, 28224, 1084, 199, 199, 3, 199, 3, 199, 3, 199, 199, 893, 26, 272, 1549, 1277, 13384, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 9458, 1012, 199, 2590, 6440, 26, 272, 1549, 1277, 13384, 63, 3022, 275, 488, 199, 199, 3, 199, 3, 1684, 3423, 199, 3, 199, 199, 318, 1453, 63, 1412, 837, 272, 1449, 272, 1432, 2112, 909, 6144, 314, 1453, 2112, 272, 1449, 272, 372, 485, 1818, 63, 1412, 199, 199, 318, 4702, 63, 3223, 837, 272, 1449, 272, 1432, 769, 402, 2112, 2251, 5226, 370, 12166, 1982, 10358, 272, 1449, 272, 485, 7661, 342, 272, 372, 769, 1547, 1818, 63, 1412, 423, 3223, 9, 199, 199, 3, 199, 3, 199, 3, 199, 199, 318, 485, 7661, 837, 272, 327, 1104, 367, 10358, 1314, 1172, 9158, 272, 367, 299, 315, 769, 1547, 1818, 63, 1412, 423, 3223, 304, 267, 340, 299, 423, 12207, 14, 6843, 342, 365, 440, 488, 26, 288, 485, 1818, 63, 1412, 423, 3223, 14, 14394, 8, 80, 9, 199, 199, 3, 199, 3, 710, 658, 3498, 64, 1021, 199, 3, 199, 199, 533, 7132, 8, 785, 304, 272, 1449, 272, 7132, 2251, 2954, 10679, 626, 365, 1255, 315, 282, 7396, 2112, 339, 710, 1021, 365, 376, 279, 643, 1785, 370, 658, 12562, 14, 4436, 64, 272, 1449, 272, 485, 7942, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1572, 29, 403, 12, 1347, 29, 403, 12, 536, 29, 403, 12, 1249, 16729, 2074, 16420, 267, 702, 1572, 365, 488, 12, 283, 923, 1423, 1471, 506, 488, 367, 3063, 7, 267, 2338, 275, 2163, 1547, 1818, 63, 1412, 423, 5337, 9, 267, 291, 423, 5582, 275, 485, 1818, 63, 1412, 423, 5582, 435, 334, 835, 4258, 267, 291, 423, 1178, 498, 275, 485, 1818, 63, 1412, 423, 1178, 498, 267, 291, 423, 10824, 530, 275, 485, 1818, 63, 1412, 423, 10824, 530, 267, 291, 423, 11567, 275, 485, 1818, 63, 1412, 423, 11567, 267, 291, 423, 1708, 63, 3150, 275, 747, 14, 17829, 342, 267, 291, 423, 12207, 275, 488, 267, 291, 423, 1375, 275, 1347, 267, 291, 423, 589, 275, 2008, 8, 589, 9, 267, 291, 423, 958, 275, 1211, 8, 958, 9, 267, 291, 423, 354, 275, 536, 503, 730, 8, 277, 2843, 354, 363, 435, 10791, 435, 971, 2151, 29010, 904, 8, 495, 8, 73, 9, 367, 284, 315, 291, 423, 5582, 9, 267, 485, 68, 26896, 14, 525, 8, 277, 9, 339, 347, 1255, 8, 277, 304, 267, 1449, 267, 9075, 370, 506, 1255, 315, 1007, 13, 1412, 27, 883, 506, 10087, 315, 1007, 13, 533, 267, 1449, 267, 340, 291, 423, 1375, 26, 288, 291, 423, 1375, 2031, 277, 423, 589, 12, 1011, 277, 423, 958, 9, 339, 347, 1343, 8, 277, 304, 267, 1449, 267, 7707, 1982, 2112, 267, 1449, 267, 702, 291, 423, 12207, 365, 488, 12, 283, 11250, 1343, 282, 2112, 13373, 7, 267, 702, 291, 423, 1708, 63, 3150, 508, 747, 14, 17829, 1062, 971, 2049, 283, 2425, 1454, 1343, 282, 2112, 909, 2737, 701, 1453, 2112, 7, 267, 702, 440, 485, 1818, 63, 1412, 423, 10824, 530, 12, 971, 2049, 283, 10824, 530, 10358, 787, 440, 4370, 370, 1172, 4978, 7, 267, 485, 7661, 342, 267, 340, 291, 423, 7942, 365, 440, 488, 26, 288, 13995, 275, 291, 423, 7942, 267, 587, 26, 288, 687, 1275, 11796, 316, 492, 13995, 267, 291, 423, 12207, 275, 13995, 8, 277, 9, 267, 485, 1818, 63, 1412, 423, 3223, 14, 525, 8, 277, 9, 339, 347, 15095, 8, 277, 304, 267, 1449, 267, 20429, 323, 2112, 27, 16178, 15522, 16718, 4673, 503, 4440, 20429, 323, 3498, 342, 267, 1449, 267, 291, 423, 12207,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
iain-peddie/well-behaved-python
tests/WellBehavedPythonTests/Discovery/ModuleExaminerTests.py
1
3114
#!/usr/bin/env python3 # Copyright 2013 Iain Peddie inr314159@hotmail.com # # This file is part of WellBehavedPython # # WellBehavedPython 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. # # WellBehavedPython 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 WellBehavedPython. If not, see <http://www.gnu.org/licenses/>. from WellBehavedPython.api import * from WellBehavedPython.Engine.TestCase import TestCase from WellBehavedPython.Discovery.ModuleExaminer import ModuleExaminer class ModuleExaminerTests(TestCase): def test_examiner_can_find__only_class_in_simple_module(self): # Where examiner = ModuleExaminer('WellBehavedPythonTests.Samples.SampleModule'); # When classes = examiner.listAllClasses() # The classes have been imported # Then from ..Samples import SampleModule expect(classes).toEqual([SampleModule.SampleTests]) def test_examiner_can_find_all_classes_in_complex_module(self): # Where examiner = ModuleExaminer('WellBehavedPythonTests.Samples.SampleComplexModule'); # When classes = examiner.listAllClasses() # The classes have been imported # Then from ..Samples import SampleComplexModule expect(classes).toContain(SampleComplexModule.SampleFirstTests) expect(classes).toContain(SampleComplexModule.SampleSecondTests) expect(classes).toContain(SampleComplexModule.StandaloneClass) def test_examiner_can_find_all_modules(self): # Where examiner = ModuleExaminer('WellBehavedPythonTests.Samples'); # When modules = examiner.listAllModules(); # Then from ..Samples import SampleModule from ..Samples import SampleComplexModule expect(modules).toContain('WellBehavedPythonTests.Samples.SampleModule'); expect(modules).toContain('WellBehavedPythonTests.Samples.SampleComplexModule'); def test_examiner_is_not_recursive_for_modules(self): # Where examiner = ModuleExaminer('WellBehavedPythonTests'); # When modules = examiner.listAllModules(); # Then expect(modules).toContain('WellBehavedPythonTests.BackwardsCompatibilityTests'); expect(modules).Not.toContain('WellBehavedPythonTests.Discovery.Samples.SampleModule'); def test_examining_can_find_subpackages(self): # Where examiner = ModuleExaminer('WellBehavedPythonTests') # When packages = examiner.listAllPackages() # Then expect(packages).toContain('WellBehavedPythonTests.Discovery')
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1898, 6171, 473, 1581, 510, 379, 15130, 315, 82, 8988, 9327, 32, 8885, 1198, 14, 957, 199, 3, 221, 199, 3, 259, 961, 570, 365, 1777, 402, 644, 1697, 3655, 72, 4292, 4718, 199, 3, 199, 3, 259, 644, 1697, 3655, 72, 4292, 4718, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 644, 1697, 3655, 72, 4292, 4718, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 644, 1697, 3655, 72, 4292, 4718, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 1246, 492, 627, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 8524, 14, 1746, 492, 7640, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 2825, 6913, 14, 2377, 920, 455, 16187, 492, 5673, 920, 455, 16187, 199, 199, 533, 5673, 920, 455, 16187, 2925, 8, 1746, 304, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 363, 2118, 63, 533, 63, 262, 63, 4129, 63, 578, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 2377, 11339, 398, 327, 3979, 267, 3992, 275, 15735, 16187, 14, 513, 2422, 15711, 342, 267, 327, 710, 3992, 1172, 2757, 8439, 398, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 2377, 267, 4282, 8, 2888, 680, 475, 591, 779, 8176, 2377, 14, 8176, 2925, 566, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 63, 452, 63, 2888, 63, 262, 63, 5254, 63, 578, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 14500, 2377, 11339, 398, 327, 3979, 267, 3992, 275, 15735, 16187, 14, 513, 2422, 15711, 342, 267, 327, 710, 3992, 1172, 2757, 8439, 398, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 14500, 2377, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 8176, 7147, 2925, 9, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 8176, 11906, 2925, 9, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 18736, 10636, 2543, 9, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 63, 452, 63, 3112, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 11339, 398, 327, 3979, 267, 4621, 275, 15735, 16187, 14, 513, 2422, 17981, 7303, 2728, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 2377, 267, 687, 2508, 27665, 492, 15227, 14500, 2377, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 2377, 11339, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 14500, 2377, 11339, 339, 347, 511, 63, 15425, 16187, 63, 374, 63, 1397, 63, 9931, 63, 509, 63, 3112, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 11339, 398, 327, 3979, 267, 4621, 275, 15735, 16187, 14, 513, 2422, 17981, 7303, 2728, 327, 9442, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 4540, 4751, 2404, 5880, 2925, 11339, 267, 4282, 8, 3112, 680, 1763, 14, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 2825, 6913, 14, 27665, 14, 8176, 2377, 11339, 339, 347, 511, 63, 15425, 7969, 63, 2425, 63, 1623, 63, 954, 5154, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 358, 398, 327, 3979, 267, 6117, 275, 15735, 16187, 14, 513, 2422, 25135, 342, 398, 327, 9442, 267, 4282, 8, 5154, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 2825, 6913, 358, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1898, 6171, 473, 1581, 510, 379, 15130, 315, 82, 8988, 9327, 32, 8885, 1198, 14, 957, 199, 3, 221, 199, 3, 259, 961, 570, 365, 1777, 402, 644, 1697, 3655, 72, 4292, 4718, 199, 3, 199, 3, 259, 644, 1697, 3655, 72, 4292, 4718, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 644, 1697, 3655, 72, 4292, 4718, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 644, 1697, 3655, 72, 4292, 4718, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 1246, 492, 627, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 8524, 14, 1746, 492, 7640, 199, 504, 644, 1697, 3655, 72, 4292, 4718, 14, 2825, 6913, 14, 2377, 920, 455, 16187, 492, 5673, 920, 455, 16187, 199, 199, 533, 5673, 920, 455, 16187, 2925, 8, 1746, 304, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 363, 2118, 63, 533, 63, 262, 63, 4129, 63, 578, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 2377, 11339, 398, 327, 3979, 267, 3992, 275, 15735, 16187, 14, 513, 2422, 15711, 342, 267, 327, 710, 3992, 1172, 2757, 8439, 398, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 2377, 267, 4282, 8, 2888, 680, 475, 591, 779, 8176, 2377, 14, 8176, 2925, 566, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 63, 452, 63, 2888, 63, 262, 63, 5254, 63, 578, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 14500, 2377, 11339, 398, 327, 3979, 267, 3992, 275, 15735, 16187, 14, 513, 2422, 15711, 342, 267, 327, 710, 3992, 1172, 2757, 8439, 398, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 14500, 2377, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 8176, 7147, 2925, 9, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 8176, 11906, 2925, 9, 267, 4282, 8, 2888, 680, 475, 31266, 8, 8176, 14500, 2377, 14, 18736, 10636, 2543, 9, 339, 347, 511, 63, 15425, 16187, 63, 2425, 63, 1623, 63, 452, 63, 3112, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 11339, 398, 327, 3979, 267, 4621, 275, 15735, 16187, 14, 513, 2422, 17981, 7303, 2728, 327, 9442, 267, 687, 2508, 27665, 492, 15227, 2377, 267, 687, 2508, 27665, 492, 15227, 14500, 2377, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 2377, 11339, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 27665, 14, 8176, 14500, 2377, 11339, 339, 347, 511, 63, 15425, 16187, 63, 374, 63, 1397, 63, 9931, 63, 509, 63, 3112, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 11339, 398, 327, 3979, 267, 4621, 275, 15735, 16187, 14, 513, 2422, 17981, 7303, 2728, 327, 9442, 267, 4282, 8, 3112, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 4540, 4751, 2404, 5880, 2925, 11339, 267, 4282, 8, 3112, 680, 1763, 14, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 2825, 6913, 14, 27665, 14, 8176, 2377, 11339, 339, 347, 511, 63, 15425, 7969, 63, 2425, 63, 1623, 63, 954, 5154, 8, 277, 304, 267, 327, 17685, 267, 15735, 16187, 275, 5673, 920, 455, 16187, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 358, 398, 327, 3979, 267, 6117, 275, 15735, 16187, 14, 513, 2422, 25135, 342, 398, 327, 9442, 267, 4282, 8, 5154, 680, 475, 31266, 360, 55, 1697, 3655, 72, 4292, 4718, 2925, 14, 2825, 6913, 358, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
HBehrens/feedsanitizer
django/utils/autoreload.py
71
4279
# Autoreloading launcher. # Borrowed from Peter Hunt and the CherryPy project (http://www.cherrypy.org). # Some taken from Ian Bicking's Paste (http://pythonpaste.org/). # # Portions copyright (c) 2004, CherryPy Team (team@cherrypy.org) # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the CherryPy Team nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os, sys, time try: import thread except ImportError: import dummy_thread as thread # This import does nothing, but it's necessary to avoid some race conditions # in the threading module. See http://code.djangoproject.com/ticket/2330 . try: import threading except ImportError: pass RUN_RELOADER = True _mtimes = {} _win = (sys.platform == "win32") def code_changed(): global _mtimes, _win for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())): if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if not os.path.exists(filename): continue # File might be in an egg, so it can't be reloaded. stat = os.stat(filename) mtime = stat.st_mtime if _win: mtime -= stat.st_ctime if filename not in _mtimes: _mtimes[filename] = mtime continue if mtime != _mtimes[filename]: _mtimes = {} return True return False def reloader_thread(): while RUN_RELOADER: if code_changed(): sys.exit(3) # force reload time.sleep(1) def restart_with_reloader(): while True: args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv if sys.platform == "win32": args = ['"%s"' % arg for arg in args] new_environ = os.environ.copy() new_environ["RUN_MAIN"] = 'true' exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ) if exit_code != 3: return exit_code def python_reloader(main_func, args, kwargs): if os.environ.get("RUN_MAIN") == "true": thread.start_new_thread(main_func, args, kwargs) try: reloader_thread() except KeyboardInterrupt: pass else: try: sys.exit(restart_with_reloader()) except KeyboardInterrupt: pass def jython_reloader(main_func, args, kwargs): from _systemrestart import SystemRestart thread.start_new_thread(main_func, args) while True: if code_changed(): raise SystemRestart time.sleep(1) def main(main_func, args=None, kwargs=None): if args is None: args = () if kwargs is None: kwargs = {} if sys.platform.startswith('java'): reloader = jython_reloader else: reloader = python_reloader reloader(main_func, args, kwargs)
mit
[ 3, 27722, 720, 8786, 28757, 14, 199, 3, 699, 19598, 379, 687, 22912, 869, 638, 436, 314, 30992, 27794, 2199, 334, 1014, 921, 1544, 14, 23438, 14, 1308, 680, 199, 3, 6601, 9394, 687, 473, 290, 699, 2000, 316, 1159, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 15, 680, 199, 3, 199, 3, 20825, 4248, 334, 67, 9, 8353, 12, 30992, 27794, 11682, 334, 5969, 32, 23438, 14, 1308, 9, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 755, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 30992, 27794, 11682, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 755, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 755, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 12, 984, 12, 900, 199, 199, 893, 26, 272, 492, 2462, 199, 2590, 3545, 26, 272, 492, 7283, 63, 2671, 465, 2462, 199, 199, 3, 961, 492, 1630, 6548, 12, 1325, 652, 1159, 5784, 370, 5126, 2005, 21209, 3704, 199, 3, 315, 314, 5796, 859, 14, 1666, 1455, 921, 600, 14, 14013, 14, 957, 15, 9201, 15, 10034, 16, 1275, 199, 893, 26, 272, 492, 5796, 199, 2590, 3545, 26, 272, 986, 421, 199, 9390, 63, 907, 7405, 540, 275, 715, 199, 199, 63, 77, 4508, 275, 1052, 199, 63, 2676, 275, 334, 1274, 14, 3246, 508, 298, 2676, 708, 531, 199, 199, 318, 1233, 63, 2489, 837, 272, 2288, 485, 77, 4508, 12, 485, 2676, 272, 367, 1788, 315, 2457, 8, 2734, 373, 26, 373, 12, 2341, 8, 2734, 333, 26, 2519, 8, 77, 12, 4396, 493, 13915, 488, 395, 984, 14, 3112, 14, 1459, 28256, 267, 340, 1788, 14, 4130, 9520, 11357, 531, 503, 1788, 14, 4130, 9520, 22345, 2349, 288, 1788, 275, 1788, 4439, 17, 61, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 1980, 327, 3814, 5594, 506, 315, 376, 11393, 12, 880, 652, 883, 1133, 506, 31848, 14, 267, 5672, 275, 747, 14, 3736, 8, 1501, 9, 267, 15005, 275, 5672, 14, 270, 63, 8180, 267, 340, 485, 2676, 26, 288, 15005, 4862, 5672, 14, 270, 63, 20691, 267, 340, 1788, 440, 315, 485, 77, 4508, 26, 288, 485, 77, 4508, 59, 1501, 61, 275, 15005, 288, 1980, 267, 340, 15005, 1137, 485, 77, 4508, 59, 1501, 2189, 288, 485, 77, 4508, 275, 1052, 288, 372, 715, 272, 372, 756, 199, 199, 318, 295, 3422, 63, 2671, 837, 272, 1830, 21277, 63, 907, 7405, 540, 26, 267, 340, 1233, 63, 2489, 837, 288, 984, 14, 2224, 8, 19, 9, 327, 3542, 13101, 267, 900, 14, 4532, 8, 17, 9, 199, 199, 318, 11004, 63, 1045, 63, 264, 3422, 837, 272, 1830, 715, 26, 267, 1249, 275, 359, 1274, 14, 5904, 61, 435, 11573, 55, 5, 83, 7, 450, 312, 367, 312, 315, 984, 14, 4050, 1419, 61, 435, 984, 14, 3020, 267, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 288, 1249, 275, 788, 6808, 83, 4507, 450, 1680, 367, 1680, 315, 1249, 61, 267, 892, 63, 2314, 275, 747, 14, 2314, 14, 1574, 342, 267, 892, 63, 2314, 905, 9390, 63, 5848, 937, 275, 283, 2052, 7, 267, 4458, 63, 600, 275, 747, 14, 10212, 432, 8, 736, 14, 48, 63, 12458, 12, 984, 14, 5904, 12, 1249, 12, 892, 63, 2314, 9, 267, 340, 4458, 63, 600, 1137, 650, 26, 288, 372, 4458, 63, 600, 199, 199, 318, 2366, 63, 264, 3422, 8, 973, 63, 1532, 12, 1249, 12, 2074, 304, 272, 340, 747, 14, 2314, 14, 362, 480, 9390, 63, 5848, 531, 508, 298, 2052, 582, 267, 2462, 14, 928, 63, 1222, 63, 2671, 8, 973, 63, 1532, 12, 1249, 12, 2074, 9, 267, 862, 26, 288, 295, 3422, 63, 2671, 342, 267, 871, 13483, 26, 288, 986, 272, 587, 26, 267, 862, 26, 288, 984, 14, 2224, 8, 10506, 63, 1045, 63, 264, 3422, 1012, 267, 871, 13483, 26, 288, 986, 199, 199, 318, 1335, 11361, 63, 264, 3422, 8, 973, 63, 1532, 12, 1249, 12, 2074, 304, 272, 687, 485, 2253, 10506, 492, 6187, 25493, 272, 2462, 14, 928, 63, 1222, 63, 2671, 8, 973, 63, 1532, 12, 1249, 9, 272, 1830, 715, 26, 267, 340, 1233, 63, 2489, 837, 288, 746, 6187, 25493, 267, 900, 14, 4532, 8, 17, 9, 421, 199, 318, 2446, 8, 973, 63, 1532, 12, 1249, 29, 403, 12, 2074, 29, 403, 304, 272, 340, 1249, 365, 488, 26, 267, 1249, 275, 6248, 272, 340, 2074, 365, 488, 26, 267, 2074, 275, 1052, 272, 340, 984, 14, 3246, 14, 2460, 360, 6138, 735, 267, 295 ]
[ 27722, 720, 8786, 28757, 14, 199, 3, 699, 19598, 379, 687, 22912, 869, 638, 436, 314, 30992, 27794, 2199, 334, 1014, 921, 1544, 14, 23438, 14, 1308, 680, 199, 3, 6601, 9394, 687, 473, 290, 699, 2000, 316, 1159, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 15, 680, 199, 3, 199, 3, 20825, 4248, 334, 67, 9, 8353, 12, 30992, 27794, 11682, 334, 5969, 32, 23438, 14, 1308, 9, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 755, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 30992, 27794, 11682, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 755, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 755, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 12, 984, 12, 900, 199, 199, 893, 26, 272, 492, 2462, 199, 2590, 3545, 26, 272, 492, 7283, 63, 2671, 465, 2462, 199, 199, 3, 961, 492, 1630, 6548, 12, 1325, 652, 1159, 5784, 370, 5126, 2005, 21209, 3704, 199, 3, 315, 314, 5796, 859, 14, 1666, 1455, 921, 600, 14, 14013, 14, 957, 15, 9201, 15, 10034, 16, 1275, 199, 893, 26, 272, 492, 5796, 199, 2590, 3545, 26, 272, 986, 421, 199, 9390, 63, 907, 7405, 540, 275, 715, 199, 199, 63, 77, 4508, 275, 1052, 199, 63, 2676, 275, 334, 1274, 14, 3246, 508, 298, 2676, 708, 531, 199, 199, 318, 1233, 63, 2489, 837, 272, 2288, 485, 77, 4508, 12, 485, 2676, 272, 367, 1788, 315, 2457, 8, 2734, 373, 26, 373, 12, 2341, 8, 2734, 333, 26, 2519, 8, 77, 12, 4396, 493, 13915, 488, 395, 984, 14, 3112, 14, 1459, 28256, 267, 340, 1788, 14, 4130, 9520, 11357, 531, 503, 1788, 14, 4130, 9520, 22345, 2349, 288, 1788, 275, 1788, 4439, 17, 61, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 1980, 327, 3814, 5594, 506, 315, 376, 11393, 12, 880, 652, 883, 1133, 506, 31848, 14, 267, 5672, 275, 747, 14, 3736, 8, 1501, 9, 267, 15005, 275, 5672, 14, 270, 63, 8180, 267, 340, 485, 2676, 26, 288, 15005, 4862, 5672, 14, 270, 63, 20691, 267, 340, 1788, 440, 315, 485, 77, 4508, 26, 288, 485, 77, 4508, 59, 1501, 61, 275, 15005, 288, 1980, 267, 340, 15005, 1137, 485, 77, 4508, 59, 1501, 2189, 288, 485, 77, 4508, 275, 1052, 288, 372, 715, 272, 372, 756, 199, 199, 318, 295, 3422, 63, 2671, 837, 272, 1830, 21277, 63, 907, 7405, 540, 26, 267, 340, 1233, 63, 2489, 837, 288, 984, 14, 2224, 8, 19, 9, 327, 3542, 13101, 267, 900, 14, 4532, 8, 17, 9, 199, 199, 318, 11004, 63, 1045, 63, 264, 3422, 837, 272, 1830, 715, 26, 267, 1249, 275, 359, 1274, 14, 5904, 61, 435, 11573, 55, 5, 83, 7, 450, 312, 367, 312, 315, 984, 14, 4050, 1419, 61, 435, 984, 14, 3020, 267, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 288, 1249, 275, 788, 6808, 83, 4507, 450, 1680, 367, 1680, 315, 1249, 61, 267, 892, 63, 2314, 275, 747, 14, 2314, 14, 1574, 342, 267, 892, 63, 2314, 905, 9390, 63, 5848, 937, 275, 283, 2052, 7, 267, 4458, 63, 600, 275, 747, 14, 10212, 432, 8, 736, 14, 48, 63, 12458, 12, 984, 14, 5904, 12, 1249, 12, 892, 63, 2314, 9, 267, 340, 4458, 63, 600, 1137, 650, 26, 288, 372, 4458, 63, 600, 199, 199, 318, 2366, 63, 264, 3422, 8, 973, 63, 1532, 12, 1249, 12, 2074, 304, 272, 340, 747, 14, 2314, 14, 362, 480, 9390, 63, 5848, 531, 508, 298, 2052, 582, 267, 2462, 14, 928, 63, 1222, 63, 2671, 8, 973, 63, 1532, 12, 1249, 12, 2074, 9, 267, 862, 26, 288, 295, 3422, 63, 2671, 342, 267, 871, 13483, 26, 288, 986, 272, 587, 26, 267, 862, 26, 288, 984, 14, 2224, 8, 10506, 63, 1045, 63, 264, 3422, 1012, 267, 871, 13483, 26, 288, 986, 199, 199, 318, 1335, 11361, 63, 264, 3422, 8, 973, 63, 1532, 12, 1249, 12, 2074, 304, 272, 687, 485, 2253, 10506, 492, 6187, 25493, 272, 2462, 14, 928, 63, 1222, 63, 2671, 8, 973, 63, 1532, 12, 1249, 9, 272, 1830, 715, 26, 267, 340, 1233, 63, 2489, 837, 288, 746, 6187, 25493, 267, 900, 14, 4532, 8, 17, 9, 421, 199, 318, 2446, 8, 973, 63, 1532, 12, 1249, 29, 403, 12, 2074, 29, 403, 304, 272, 340, 1249, 365, 488, 26, 267, 1249, 275, 6248, 272, 340, 2074, 365, 488, 26, 267, 2074, 275, 1052, 272, 340, 984, 14, 3246, 14, 2460, 360, 6138, 735, 267, 295, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MapofLife/MOL
app/mapreduce/lib/pipeline/handlers.py
65
1049
#!/usr/bin/env python # # Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Web request dispatcher for the Google App Engine Pipeline API. In a separate file from the core pipeline module to break circular dependencies. """ import logging from google.appengine.ext import webapp from google.appengine.ext.webapp import util as webapp_util import pipeline _APP = webapp.WSGIApplication(pipeline.create_handlers_map(), debug=True) def _main(): webapp_util.run_wsgi_app(_APP) if __name__ == '__main__': _main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7129, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 5926, 1056, 17475, 367, 314, 4475, 4693, 12580, 19090, 3261, 14, 199, 199, 607, 282, 7396, 570, 687, 314, 6170, 7679, 859, 370, 2059, 15032, 5124, 14, 199, 624, 199, 199, 646, 2050, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 24812, 199, 504, 6233, 14, 15358, 14, 832, 14, 22632, 492, 4884, 465, 24812, 63, 1974, 199, 199, 646, 7679, 421, 199, 63, 7121, 275, 24812, 14, 16828, 5039, 8, 7379, 14, 981, 63, 5586, 63, 1130, 1062, 3105, 29, 549, 9, 421, 199, 318, 485, 973, 837, 523, 24812, 63, 1974, 14, 1065, 63, 6508, 63, 571, 1547, 7121, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 485, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7129, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 5926, 1056, 17475, 367, 314, 4475, 4693, 12580, 19090, 3261, 14, 199, 199, 607, 282, 7396, 570, 687, 314, 6170, 7679, 859, 370, 2059, 15032, 5124, 14, 199, 624, 199, 199, 646, 2050, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 24812, 199, 504, 6233, 14, 15358, 14, 832, 14, 22632, 492, 4884, 465, 24812, 63, 1974, 199, 199, 646, 7679, 421, 199, 63, 7121, 275, 24812, 14, 16828, 5039, 8, 7379, 14, 981, 63, 5586, 63, 1130, 1062, 3105, 29, 549, 9, 421, 199, 318, 485, 973, 837, 523, 24812, 63, 1974, 14, 1065, 63, 6508, 63, 571, 1547, 7121, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 485, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from django import http from django.core.urlresolvers import reverse from django.utils.datastructures import SortedDict from mox import IsA from openstack_dashboard import api from openstack_dashboard.test import helpers as test class InstanceViewTest(test.BaseAdminViewTests): @test.create_stubs({api.nova: ('flavor_list', 'server_list',), api.keystone: ('tenant_list',)}) def test_index(self): servers = self.servers.list() flavors = self.flavors.list() tenants = self.tenants.list() api.keystone.tenant_list(IsA(http.HttpRequest), admin=True).\ AndReturn(tenants) api.nova.server_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(servers) api.nova.flavor_list(IsA(http.HttpRequest)).AndReturn(flavors) self.mox.ReplayAll() res = self.client.get(reverse('horizon:admin:instances:index')) self.assertTemplateUsed(res, 'admin/instances/index.html') instances = res.context['table'].data self.assertItemsEqual(instances, servers) @test.create_stubs({api.nova: ('flavor_list', 'flavor_get', 'server_list',), api.keystone: ('tenant_list',)}) def test_index_flavor_list_exception(self): servers = self.servers.list() tenants = self.tenants.list() flavors = self.flavors.list() full_flavors = SortedDict([(f.id, f) for f in flavors]) api.nova.server_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(servers) api.nova.flavor_list(IsA(http.HttpRequest)). \ AndRaise(self.exceptions.nova) api.keystone.tenant_list(IsA(http.HttpRequest), admin=True).\ AndReturn(tenants) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ AndReturn(full_flavors[server.flavor["id"]]) self.mox.ReplayAll() res = self.client.get(reverse('horizon:admin:instances:index')) self.assertTemplateUsed(res, 'admin/instances/index.html') instances = res.context['table'].data self.assertItemsEqual(instances, servers) @test.create_stubs({api.nova: ('flavor_list', 'flavor_get', 'server_list',), api.keystone: ('tenant_list',)}) def test_index_flavor_get_exception(self): servers = self.servers.list() flavors = self.flavors.list() tenants = self.tenants.list() max_id = max([int(flavor.id) for flavor in flavors]) for server in servers: max_id += 1 server.flavor["id"] = max_id api.nova.server_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(servers) api.nova.flavor_list(IsA(http.HttpRequest)). \ AndReturn(flavors) api.keystone.tenant_list(IsA(http.HttpRequest), admin=True).\ AndReturn(tenants) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ AndRaise(self.exceptions.nova) self.mox.ReplayAll() res = self.client.get(reverse('horizon:admin:instances:index')) instances = res.context['table'].data self.assertTemplateUsed(res, 'admin/instances/index.html') self.assertMessageCount(res, error=len(servers)) self.assertItemsEqual(instances, servers) @test.create_stubs({api.nova: ('server_list',)}) def test_index_server_list_exception(self): api.nova.server_list(IsA(http.HttpRequest), all_tenants=True).AndRaise(self.exceptions.nova) self.mox.ReplayAll() res = self.client.get(reverse('horizon:admin:instances:index')) self.assertTemplateUsed(res, 'admin/instances/index.html') self.assertEqual(len(res.context['instances_table'].data), 0) @test.create_stubs({api: ('server_get', 'flavor_get',), api.keystone: ('tenant_get',)}) def test_ajax_loading_instances(self): server = self.servers.first() flavor = self.flavors.list()[0] tenant = self.tenants.list()[0] api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server) api.flavor_get(IsA(http.HttpRequest), server.flavor['id']).AndReturn(flavor) api.keystone.tenant_get(IsA(http.HttpRequest), server.tenant_id, admin=True).AndReturn(tenant) self.mox.ReplayAll() url = reverse('horizon:admin:instances:index') + \ "?action=row_update&table=instances&obj_id=" + server.id res = self.client.get(url, {}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertTemplateUsed(res, "horizon/common/_data_table_row.html") self.assertContains(res, "test_tenant", 1, 200) self.assertContains(res, "instance-host", 1, 200) self.assertContains(res, "server_1", 1, 200) self.assertContains(res, "10.0.0.1", 1, 200) self.assertContains(res, "512MB RAM | 1 VCPU | 0 Disk", 1, 200) self.assertContains(res, "Active", 1, 200) self.assertContains(res, "Running", 1, 200)
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 199, 504, 18610, 492, 29719, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 421, 199, 533, 10066, 2768, 774, 8, 396, 14, 1563, 4880, 2768, 2925, 304, 272, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 8572, 8, 18664, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 6081, 63, 362, 297, 2511, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 63, 6081, 63, 513, 63, 1971, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 2615, 63, 18664, 275, 27432, 2141, 7694, 70, 14, 344, 12, 289, 9, 367, 289, 315, 23547, 566, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 971, 1169, 6061, 18111, 8, 277, 14, 3924, 14, 6765, 9, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 367, 1654, 315, 8037, 26, 288, 2986, 14, 6765, 14, 6081, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 1654, 14, 6081, 905, 344, 29126, 971, 1816, 6061, 1767, 8, 2861, 63, 18664, 59, 1000, 14, 6081, 905, 344, 937, 566, 398, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 6081, 63, 362, 297, 2511, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 63, 6081, 63, 362, 63, 1971, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 1390, 63, 344, 275, 1390, 779, 442, 8, 6081, 14, 344, 9, 367, 8541, 315, 23547, 566, 267, 367, 1654, 315, 8037, 26, 288, 1390, 63, 344, 847, 413, 288, 1654, 14, 6081, 905, 344, 937, 275, 1390, 63, 344, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 971, 1169, 6061, 1767, 8, 18664, 9, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 367, 1654, 315, 8037, 26, 288, 2986, 14, 6765, 14, 6081, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 1654, 14, 6081, 905, 344, 29126, 971, 1816, 6061, 18111, 8, 277, 14, 3924, 14, 6765, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 291, 14, 479, 2209, 2353, 8, 470, 12, 1125, 29, 552, 8, 5871, 430, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 199, 504, 18610, 492, 29719, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 421, 199, 533, 10066, 2768, 774, 8, 396, 14, 1563, 4880, 2768, 2925, 304, 272, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 8572, 8, 18664, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 6081, 63, 362, 297, 2511, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 63, 6081, 63, 513, 63, 1971, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 2615, 63, 18664, 275, 27432, 2141, 7694, 70, 14, 344, 12, 289, 9, 367, 289, 315, 23547, 566, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 971, 1169, 6061, 18111, 8, 277, 14, 3924, 14, 6765, 9, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 367, 1654, 315, 8037, 26, 288, 2986, 14, 6765, 14, 6081, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 1654, 14, 6081, 905, 344, 29126, 971, 1816, 6061, 1767, 8, 2861, 63, 18664, 59, 1000, 14, 6081, 905, 344, 937, 566, 398, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 6765, 26, 661, 6081, 63, 513, 297, 283, 6081, 63, 362, 297, 2511, 283, 1000, 63, 513, 5529, 717, 2986, 14, 19143, 26, 661, 4647, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 63, 6081, 63, 362, 63, 1971, 8, 277, 304, 267, 8037, 275, 291, 14, 5871, 14, 513, 342, 267, 23547, 275, 291, 14, 18664, 14, 513, 342, 267, 16685, 2285, 275, 291, 14, 25021, 14, 513, 342, 267, 1390, 63, 344, 275, 1390, 779, 442, 8, 6081, 14, 344, 9, 367, 8541, 315, 23547, 566, 267, 367, 1654, 315, 8037, 26, 288, 1390, 63, 344, 847, 413, 288, 1654, 14, 6081, 905, 344, 937, 275, 1390, 63, 344, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 2490, 1006, 63, 25021, 29, 549, 680, 8572, 8, 5871, 9, 267, 2986, 14, 6765, 14, 6081, 63, 513, 8, 14104, 8, 1014, 14, 10441, 4992, 971, 1169, 6061, 1767, 8, 18664, 9, 267, 2986, 14, 19143, 14, 4647, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 4628, 29, 549, 12013, 639, 6061, 1767, 8, 25021, 9, 267, 367, 1654, 315, 8037, 26, 288, 2986, 14, 6765, 14, 6081, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 1654, 14, 6081, 905, 344, 29126, 971, 1816, 6061, 18111, 8, 277, 14, 3924, 14, 6765, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 2113, 26, 5990, 26, 1080, 1333, 267, 4454, 275, 522, 14, 1100, 459, 1224, 2278, 576, 267, 291, 14, 19661, 8, 470, 12, 283, 2113, 15, 5990, 15, 1080, 14, 1360, 358, 267, 291, 14, 479, 2209, 2353, 8, 470, 12, 1125, 29, 552, 8, 5871, 430, 267, 291, 14, 19673, 8, 5990, 12, 8037, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
40223226/2015cd_midterm
static/Brython3.1.1-20150328-091302/Lib/urllib/parse.py
735
35170
"""Parse (absolute and relative) URLs. urlparse module is based upon the following RFC specifications. RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding and L. Masinter, January 2005. RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter and L.Masinter, December 1999. RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T. Berners-Lee, R. Fielding, and L. Masinter, August 1998. RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998. RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M. McCahill, December 1994 RFC 3986 is considered the current standard and any future changes to urlparse module should conform with it. The urlparse module is currently not entirely compliant with this RFC due to defacto scenarios for parsing, and for backward compatibility purposes, some parsing quirks from older RFCs are retained. The testcases in test_urlparse.py provides a good indicator of parsing behavior. """ import re import sys import collections __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", "urlsplit", "urlunsplit", "urlencode", "parse_qs", "parse_qsl", "quote", "quote_plus", "quote_from_bytes", "unquote", "unquote_plus", "unquote_to_bytes"] # A classification of schemes ('' means apply by default) uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap', 'wais', 'file', 'https', 'shttp', 'mms', 'prospero', 'rtsp', 'rtspu', '', 'sftp', 'svn', 'svn+ssh'] uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet', 'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', 'mms', '', 'sftp', 'tel'] # These are not actually used anymore, but should stay for backwards # compatibility. (They are undocumented, but have a public-looking name.) non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms', 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', 'https', 'shttp', 'snews', 'file', 'prospero', ''] # Characters valid in scheme names scheme_chars = ('abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '0123456789' '+-.') # XXX: Consider replacing with functools.lru_cache MAX_CACHE_SIZE = 20 _parse_cache = {} def clear_cache(): """Clear the parse cache and the quoters cache.""" _parse_cache.clear() _safe_quoters.clear() # Helpers for bytes handling # For 3.2, we deliberately require applications that # handle improperly quoted URLs to do their own # decoding and encoding. If valid use cases are # presented, we may relax this by using latin-1 # decoding internally for 3.3 _implicit_encoding = 'ascii' _implicit_errors = 'strict' def _noop(obj): return obj def _encode_result(obj, encoding=_implicit_encoding, errors=_implicit_errors): return obj.encode(encoding, errors) def _decode_args(args, encoding=_implicit_encoding, errors=_implicit_errors): return tuple(x.decode(encoding, errors) if x else '' for x in args) def _coerce_args(*args): # Invokes decode if necessary to create str args # and returns the coerced inputs along with # an appropriate result coercion function # - noop for str inputs # - encoding function otherwise str_input = isinstance(args[0], str) for arg in args[1:]: # We special-case the empty string to support the # "scheme=''" default argument to some functions if arg and isinstance(arg, str) != str_input: raise TypeError("Cannot mix str and non-str arguments") if str_input: return args + (_noop,) return _decode_args(args) + (_encode_result,) # Result objects are more helpful than simple tuples class _ResultMixinStr(object): """Standard approach to encoding parsed results from str to bytes""" __slots__ = () def encode(self, encoding='ascii', errors='strict'): return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self)) class _ResultMixinBytes(object): """Standard approach to decoding parsed results from bytes to str""" __slots__ = () def decode(self, encoding='ascii', errors='strict'): return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self)) class _NetlocResultMixinBase(object): """Shared methods for the parsed result objects containing a netloc element""" __slots__ = () @property def username(self): return self._userinfo[0] @property def password(self): return self._userinfo[1] @property def hostname(self): hostname = self._hostinfo[0] if not hostname: hostname = None elif hostname is not None: hostname = hostname.lower() return hostname @property def port(self): port = self._hostinfo[1] if port is not None: port = int(port, 10) # Return None on an illegal port if not ( 0 <= port <= 65535): return None return port class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr): __slots__ = () @property def _userinfo(self): netloc = self.netloc userinfo, have_info, hostinfo = netloc.rpartition('@') if have_info: username, have_password, password = userinfo.partition(':') if not have_password: password = None else: username = password = None return username, password @property def _hostinfo(self): netloc = self.netloc _, _, hostinfo = netloc.rpartition('@') _, have_open_br, bracketed = hostinfo.partition('[') if have_open_br: hostname, _, port = bracketed.partition(']') _, have_port, port = port.partition(':') else: hostname, have_port, port = hostinfo.partition(':') if not have_port: port = None return hostname, port class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes): __slots__ = () @property def _userinfo(self): netloc = self.netloc userinfo, have_info, hostinfo = netloc.rpartition(b'@') if have_info: username, have_password, password = userinfo.partition(b':') if not have_password: password = None else: username = password = None return username, password @property def _hostinfo(self): netloc = self.netloc _, _, hostinfo = netloc.rpartition(b'@') _, have_open_br, bracketed = hostinfo.partition(b'[') if have_open_br: hostname, _, port = bracketed.partition(b']') _, have_port, port = port.partition(b':') else: hostname, have_port, port = hostinfo.partition(b':') if not have_port: port = None return hostname, port from collections import namedtuple _DefragResultBase = namedtuple('DefragResult', 'url fragment') _SplitResultBase = namedtuple('SplitResult', 'scheme netloc path query fragment') _ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment') # For backwards compatibility, alias _NetlocResultMixinStr # ResultBase is no longer part of the documented API, but it is # retained since deprecating it isn't worth the hassle ResultBase = _NetlocResultMixinStr # Structured result objects for string data class DefragResult(_DefragResultBase, _ResultMixinStr): __slots__ = () def geturl(self): if self.fragment: return self.url + '#' + self.fragment else: return self.url class SplitResult(_SplitResultBase, _NetlocResultMixinStr): __slots__ = () def geturl(self): return urlunsplit(self) class ParseResult(_ParseResultBase, _NetlocResultMixinStr): __slots__ = () def geturl(self): return urlunparse(self) # Structured result objects for bytes data class DefragResultBytes(_DefragResultBase, _ResultMixinBytes): __slots__ = () def geturl(self): if self.fragment: return self.url + b'#' + self.fragment else: return self.url class SplitResultBytes(_SplitResultBase, _NetlocResultMixinBytes): __slots__ = () def geturl(self): return urlunsplit(self) class ParseResultBytes(_ParseResultBase, _NetlocResultMixinBytes): __slots__ = () def geturl(self): return urlunparse(self) # Set up the encode/decode result pairs def _fix_result_transcoding(): _result_pairs = ( (DefragResult, DefragResultBytes), (SplitResult, SplitResultBytes), (ParseResult, ParseResultBytes), ) for _decoded, _encoded in _result_pairs: _decoded._encoded_counterpart = _encoded _encoded._decoded_counterpart = _decoded _fix_result_transcoding() del _fix_result_transcoding def urlparse(url, scheme='', allow_fragments=True): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" url, scheme, _coerce_result = _coerce_args(url, scheme) splitresult = urlsplit(url, scheme, allow_fragments) scheme, netloc, url, query, fragment = splitresult if scheme in uses_params and ';' in url: url, params = _splitparams(url) else: params = '' result = ParseResult(scheme, netloc, url, params, query, fragment) return _coerce_result(result) def _splitparams(url): if '/' in url: i = url.find(';', url.rfind('/')) if i < 0: return url, '' else: i = url.find(';') return url[:i], url[i+1:] def _splitnetloc(url, start=0): delim = len(url) # position of end of domain part of url, default is end for c in '/?#': # look for delimiters; the order is NOT important wdelim = url.find(c, start) # find first of this delim if wdelim >= 0: # if found delim = min(delim, wdelim) # use earliest delim position return url[start:delim], url[delim:] # return (domain, rest) def urlsplit(url, scheme='', allow_fragments=True): """Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment> Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" url, scheme, _coerce_result = _coerce_args(url, scheme) allow_fragments = bool(allow_fragments) key = url, scheme, allow_fragments, type(url), type(scheme) cached = _parse_cache.get(key, None) if cached: return _coerce_result(cached) if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = query = fragment = '' i = url.find(':') if i > 0: if url[:i] == 'http': # optimize the common case scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': netloc, url = _splitnetloc(url, 2) if (('[' in netloc and ']' not in netloc) or (']' in netloc and '[' not in netloc)): raise ValueError("Invalid IPv6 URL") if allow_fragments and '#' in url: url, fragment = url.split('#', 1) if '?' in url: url, query = url.split('?', 1) v = SplitResult(scheme, netloc, url, query, fragment) _parse_cache[key] = v return _coerce_result(v) for c in url[:i]: if c not in scheme_chars: break else: # make sure "url" is not actually a port number (in which case # "scheme" is really part of the path) rest = url[i+1:] if not rest or any(c not in '0123456789' for c in rest): # not a port number scheme, url = url[:i].lower(), rest if url[:2] == '//': netloc, url = _splitnetloc(url, 2) if (('[' in netloc and ']' not in netloc) or (']' in netloc and '[' not in netloc)): raise ValueError("Invalid IPv6 URL") if allow_fragments and '#' in url: url, fragment = url.split('#', 1) if '?' in url: url, query = url.split('?', 1) v = SplitResult(scheme, netloc, url, query, fragment) _parse_cache[key] = v return _coerce_result(v) def urlunparse(components): """Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).""" scheme, netloc, url, params, query, fragment, _coerce_result = ( _coerce_args(*components)) if params: url = "%s;%s" % (url, params) return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment))) def urlunsplit(components): """Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The data argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).""" scheme, netloc, url, query, fragment, _coerce_result = ( _coerce_args(*components)) if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'): if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url if scheme: url = scheme + ':' + url if query: url = url + '?' + query if fragment: url = url + '#' + fragment return _coerce_result(url) def urljoin(base, url, allow_fragments=True): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" if not base: return url if not url: return base base, url, _coerce_result = _coerce_args(base, url) bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_fragments) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_fragments) if scheme != bscheme or scheme not in uses_relative: return _coerce_result(url) if scheme in uses_netloc: if netloc: return _coerce_result(urlunparse((scheme, netloc, path, params, query, fragment))) netloc = bnetloc if path[:1] == '/': return _coerce_result(urlunparse((scheme, netloc, path, params, query, fragment))) if not path and not params: path = bpath params = bparams if not query: query = bquery return _coerce_result(urlunparse((scheme, netloc, path, params, query, fragment))) segments = bpath.split('/')[:-1] + path.split('/') # XXX The stuff below is bogus in various ways... if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if (segments[i] == '..' and segments[i-1] not in ('', '..')): del segments[i-1:i+1] break i = i+1 else: break if segments == ['', '..']: segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return _coerce_result(urlunparse((scheme, netloc, '/'.join(segments), params, query, fragment))) def urldefrag(url): """Removes any existing fragment from URL. Returns a tuple of the defragmented URL and the fragment. If the URL contained no fragments, the second element is the empty string. """ url, _coerce_result = _coerce_args(url) if '#' in url: s, n, p, a, q, frag = urlparse(url) defrag = urlunparse((s, n, p, a, q, '')) else: frag = '' defrag = url return _coerce_result(DefragResult(defrag, frag)) _hexdig = '0123456789ABCDEFabcdef' _hextobyte = {(a + b).encode(): bytes([int(a + b, 16)]) for a in _hexdig for b in _hexdig} def unquote_to_bytes(string): """unquote_to_bytes('abc%20def') -> b'abc def'.""" # Note: strings are encoded as UTF-8. This is only an issue if it contains # unescaped non-ASCII characters, which URIs should not. if not string: # Is it a string-like object? string.split return b'' if isinstance(string, str): string = string.encode('utf-8') bits = string.split(b'%') if len(bits) == 1: return string res = [bits[0]] append = res.append for item in bits[1:]: try: append(_hextobyte[item[:2]]) append(item[2:]) except KeyError: append(b'%') append(item) return b''.join(res) _asciire = re.compile('([\x00-\x7f]+)') def unquote(string, encoding='utf-8', errors='replace'): """Replace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. By default, percent-encoded sequences are decoded with UTF-8, and invalid sequences are replaced by a placeholder character. unquote('abc%20def') -> 'abc def'. """ if '%' not in string: string.split return string if encoding is None: encoding = 'utf-8' if errors is None: errors = 'replace' bits = _asciire.split(string) res = [bits[0]] append = res.append for i in range(1, len(bits), 2): append(unquote_to_bytes(bits[i]).decode(encoding, errors)) append(bits[i + 1]) return ''.join(res) def parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace'): """Parse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. encoding and errors: specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. """ parsed_result = {} pairs = parse_qsl(qs, keep_blank_values, strict_parsing, encoding=encoding, errors=errors) for name, value in pairs: if name in parsed_result: parsed_result[name].append(value) else: parsed_result[name] = [value] return parsed_result def parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace'): """Parse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. encoding and errors: specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. Returns a list, as G-d intended. """ qs, _coerce_result = _coerce_args(qs) pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')] r = [] for name_value in pairs: if not name_value and not strict_parsing: continue nv = name_value.split('=', 1) if len(nv) != 2: if strict_parsing: raise ValueError("bad query field: %r" % (name_value,)) # Handle case of a control-name with no equal sign if keep_blank_values: nv.append('') else: continue if len(nv[1]) or keep_blank_values: name = nv[0].replace('+', ' ') name = unquote(name, encoding=encoding, errors=errors) name = _coerce_result(name) value = nv[1].replace('+', ' ') value = unquote(value, encoding=encoding, errors=errors) value = _coerce_result(value) r.append((name, value)) return r def unquote_plus(string, encoding='utf-8', errors='replace'): """Like unquote(), but also replace plus signs by spaces, as required for unquoting HTML form values. unquote_plus('%7e/abc+def') -> '~/abc def' """ string = string.replace('+', ' ') return unquote(string, encoding, errors) _ALWAYS_SAFE = frozenset(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ' b'abcdefghijklmnopqrstuvwxyz' b'0123456789' b'_.-') _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE) _safe_quoters = {} class Quoter(collections.defaultdict): """A mapping from bytes (in range(0,256)) to strings. String values are percent-encoded byte values, unless the key < 128, and in the "safe" set (either the specified safe set, or default set). """ # Keeps a cache internally, using defaultdict, for efficiency (lookups # of cached keys don't call Python code at all). def __init__(self, safe): """safe: bytes object.""" self.safe = _ALWAYS_SAFE.union(safe) def __repr__(self): # Without this, will just display as a defaultdict return "<Quoter %r>" % dict(self) def __missing__(self, b): # Handle a cache miss. Store quoted string in cache and return. res = chr(b) if b in self.safe else '%{:02X}'.format(b) self[b] = res return res def quote(string, safe='/', encoding=None, errors=None): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. string and safe may be either str or bytes objects. encoding must not be specified if string is a str. The optional encoding and errors parameters specify how to deal with non-ASCII characters, as accepted by the str.encode method. By default, encoding='utf-8' (characters are encoded with UTF-8), and errors='strict' (unsupported characters raise a UnicodeEncodeError). """ if isinstance(string, str): if not string: return string if encoding is None: encoding = 'utf-8' if errors is None: errors = 'strict' string = string.encode(encoding, errors) else: if encoding is not None: raise TypeError("quote() doesn't support 'encoding' for bytes") if errors is not None: raise TypeError("quote() doesn't support 'errors' for bytes") return quote_from_bytes(string, safe) def quote_plus(string, safe='', encoding=None, errors=None): """Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'. """ # Check if ' ' in string, where string may either be a str or bytes. If # there are no spaces, the regular quote will produce the right answer. if ((isinstance(string, str) and ' ' not in string) or (isinstance(string, bytes) and b' ' not in string)): return quote(string, safe, encoding, errors) if isinstance(safe, str): space = ' ' else: space = b' ' string = quote(string, safe + space, encoding, errors) return string.replace(' ', '+') def quote_from_bytes(bs, safe='/'): """Like quote(), but accepts a bytes object rather than a str, and does not perform string-to-bytes encoding. It always returns an ASCII string. quote_from_bytes(b'abc def\x3f') -> 'abc%20def%3f' """ if not isinstance(bs, (bytes, bytearray)): raise TypeError("quote_from_bytes() expected bytes") if not bs: return '' if isinstance(safe, str): # Normalize 'safe' by converting to bytes and removing non-ASCII chars safe = safe.encode('ascii', 'ignore') else: safe = bytes([c for c in safe if c < 128]) if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe): return bs.decode() try: quoter = _safe_quoters[safe] except KeyError: _safe_quoters[safe] = quoter = Quoter(safe).__getitem__ return ''.join([quoter(char) for char in bs]) def urlencode(query, doseq=False, safe='', encoding=None, errors=None): """Encode a sequence of two-element tuples or dictionary into a URL query string. If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. If the query arg is a sequence of two-element tuples, the order of the parameters in the output will match the order of parameters in the input. The query arg may be either a string or a bytes type. When query arg is a string, the safe, encoding and error parameters are sent the quote_plus for encoding. """ if hasattr(query, "items"): query = query.items() else: # It's a bother at times that strings and string-like objects are # sequences. try: # non-sequence items should not work with len() # non-empty strings will fail this if len(query) and not isinstance(query[0], tuple): raise TypeError # Zero-length sequences of all types will get here and succeed, # but that's a minor nit. Since the original implementation # allowed empty dicts that type of behavior probably should be # preserved for consistency except TypeError: ty, va, tb = sys.exc_info() raise TypeError("not a valid non-string sequence " "or mapping object").with_traceback(tb) l = [] if not doseq: for k, v in query: if isinstance(k, bytes): k = quote_plus(k, safe) else: k = quote_plus(str(k), safe, encoding, errors) if isinstance(v, bytes): v = quote_plus(v, safe) else: v = quote_plus(str(v), safe, encoding, errors) l.append(k + '=' + v) else: for k, v in query: if isinstance(k, bytes): k = quote_plus(k, safe) else: k = quote_plus(str(k), safe, encoding, errors) if isinstance(v, bytes): v = quote_plus(v, safe) l.append(k + '=' + v) elif isinstance(v, str): v = quote_plus(v, safe, encoding, errors) l.append(k + '=' + v) else: try: # Is this a sufficient test for sequence-ness? x = len(v) except TypeError: # not a sequence v = quote_plus(str(v), safe, encoding, errors) l.append(k + '=' + v) else: # loop over the sequence for elt in v: if isinstance(elt, bytes): elt = quote_plus(elt, safe) else: elt = quote_plus(str(elt), safe, encoding, errors) l.append(k + '=' + elt) return '&'.join(l) # Utilities to parse URLs (most of these return None for missing parts): # unwrap('<URL:type://host/path>') --> 'type://host/path' # splittype('type:opaquestring') --> 'type', 'opaquestring' # splithost('//host[:port]/path') --> 'host[:port]', '/path' # splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]' # splitpasswd('user:passwd') -> 'user', 'passwd' # splitport('host:port') --> 'host', 'port' # splitquery('/path?query') --> '/path', 'query' # splittag('/path#tag') --> '/path', 'tag' # splitattr('/path;attr1=value1;attr2=value2;...') -> # '/path', ['attr1=value1', 'attr2=value2', ...] # splitvalue('attr=value') --> 'attr', 'value' # urllib.parse.unquote('abc%20def') -> 'abc def' # quote('abc def') -> 'abc%20def') def to_bytes(url): """to_bytes(u"URL") --> 'URL'.""" # Most URL schemes require ASCII. If that changes, the conversion # can be relaxed. # XXX get rid of to_bytes() if isinstance(url, str): try: url = url.encode("ASCII").decode() except UnicodeError: raise UnicodeError("URL " + repr(url) + " contains non-ASCII characters") return url def unwrap(url): """unwrap('<URL:type://host/path>') --> 'type://host/path'.""" url = str(url).strip() if url[:1] == '<' and url[-1:] == '>': url = url[1:-1].strip() if url[:4] == 'URL:': url = url[4:].strip() return url _typeprog = None def splittype(url): """splittype('type:opaquestring') --> 'type', 'opaquestring'.""" global _typeprog if _typeprog is None: import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) if match: scheme = match.group(1) return scheme.lower(), url[len(scheme) + 1:] return None, url _hostprog = None def splithost(url): """splithost('//host[:port]/path') --> 'host[:port]', '/path'.""" global _hostprog if _hostprog is None: import re _hostprog = re.compile('^//([^/?]*)(.*)$') match = _hostprog.match(url) if match: host_port = match.group(1) path = match.group(2) if path and not path.startswith('/'): path = '/' + path return host_port, path return None, url _userprog = None def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^(.*)@(.*)$') match = _userprog.match(host) if match: return match.group(1, 2) return None, host _passwdprog = None def splitpasswd(user): """splitpasswd('user:passwd') -> 'user', 'passwd'.""" global _passwdprog if _passwdprog is None: import re _passwdprog = re.compile('^([^:]*):(.*)$',re.S) match = _passwdprog.match(user) if match: return match.group(1, 2) return user, None # splittag('/path#tag') --> '/path', 'tag' _portprog = None def splitport(host): """splitport('host:port') --> 'host', 'port'.""" global _portprog if _portprog is None: import re _portprog = re.compile('^(.*):([0-9]+)$') match = _portprog.match(host) if match: return match.group(1, 2) return host, None _nportprog = None def splitnport(host, defport=-1): """Split host and port, returning numeric port. Return given default port if no ':' found; defaults to -1. Return numerical port if a valid number are found after ':'. Return None if ':' but not a valid number.""" global _nportprog if _nportprog is None: import re _nportprog = re.compile('^(.*):(.*)$') match = _nportprog.match(host) if match: host, port = match.group(1, 2) try: if not port: raise ValueError("no digits") nport = int(port) except ValueError: nport = None return host, nport return host, defport _queryprog = None def splitquery(url): """splitquery('/path?query') --> '/path', 'query'.""" global _queryprog if _queryprog is None: import re _queryprog = re.compile('^(.*)\?([^?]*)$') match = _queryprog.match(url) if match: return match.group(1, 2) return url, None _tagprog = None def splittag(url): """splittag('/path#tag') --> '/path', 'tag'.""" global _tagprog if _tagprog is None: import re _tagprog = re.compile('^(.*)#([^#]*)$') match = _tagprog.match(url) if match: return match.group(1, 2) return url, None def splitattr(url): """splitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].""" words = url.split(';') return words[0], words[1:] _valueprog = None def splitvalue(attr): """splitvalue('attr=value') --> 'attr', 'value'.""" global _valueprog if _valueprog is None: import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr) if match: return match.group(1, 2) return attr, None
gpl-3.0
[ 624, 4003, 334, 6116, 436, 3847, 9, 10867, 14, 199, 199, 10290, 859, 365, 4079, 12188, 314, 2569, 7329, 28754, 14, 199, 199, 14468, 10551, 1184, 334, 18472, 1272, 304, 298, 12421, 7337, 473, 8577, 2, 701, 377, 14, 23207, 8715, 13, 44, 1024, 12, 820, 14, 5024, 316, 199, 460, 491, 14, 221, 603, 305, 1058, 12, 17474, 20527, 11811, 14, 199, 199, 14468, 8087, 708, 520, 298, 3484, 367, 18271, 6509, 22, 2654, 4357, 315, 2851, 1159, 701, 820, 14, 40, 262, 848, 12, 699, 14, 16034, 897, 351, 199, 460, 491, 14, 45, 305, 1058, 12, 1487, 26381, 21300, 14, 199, 199, 14468, 499, 13443, 26, 221, 298, 12421, 7337, 473, 8577, 334, 7639, 9, 582, 8307, 18377, 701, 377, 14, 199, 24947, 8715, 13, 44, 1024, 12, 820, 14, 5024, 316, 12, 436, 491, 14, 603, 305, 1058, 12, 25298, 833, 19960, 14, 199, 199, 14468, 499, 10997, 26, 298, 1918, 6016, 475, 2851, 5687, 401, 701, 510, 14, 40, 1997, 1237, 2360, 491, 603, 305, 1058, 12, 1603, 14, 3107, 65, 2676, 10728, 12, 1603, 21797, 19960, 14, 199, 199, 14468, 413, 11292, 26, 298, 15277, 1910, 8241, 7337, 6263, 2750, 401, 701, 820, 14, 5024, 316, 12, 738, 35, 473, 6310, 1132, 12, 1603, 11474, 199, 7155, 21, 14, 199, 199, 14468, 5557, 1703, 26, 298, 12421, 7337, 6263, 2750, 334, 2632, 2924, 701, 377, 14, 23207, 8715, 13, 44, 1024, 12, 491, 14, 603, 305, 1058, 12, 603, 14, 199, 45, 67, 3630, 72, 778, 12, 1487, 26381, 9013, 20, 199, 199, 14468, 10551, 1184, 365, 8652, 314, 1453, 4465, 436, 1263, 6466, 4493, 370, 199, 10290, 859, 1077, 26449, 543, 652, 14, 221, 710, 7097, 859, 365, 199, 19767, 440, 21926, 1013, 22676, 543, 642, 7329, 7037, 370, 347, 2442, 79, 199, 32225, 367, 6057, 12, 436, 367, 13388, 7163, 12901, 12, 2005, 199, 11059, 2173, 723, 6080, 687, 12731, 7329, 83, 787, 30403, 14, 710, 511, 9403, 315, 199, 396, 63, 10290, 14, 647, 6571, 282, 6954, 16385, 402, 6057, 5953, 14, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 10290, 401, 298, 633, 18185, 401, 298, 17755, 401, 298, 633, 318, 2527, 401, 1779, 298, 29491, 401, 298, 633, 30038, 401, 298, 10738, 401, 298, 1122, 63, 6177, 401, 1779, 298, 1122, 63, 26714, 401, 298, 3513, 401, 298, 3513, 63, 6666, 401, 298, 3513, 63, 504, 63, 2394, 401, 1779, 298, 12240, 401, 298, 12240, 63, 6666, 401, 298, 12240, 63, 475, 63, 2394, 937, 199, 199, 3, 437, 12505, 402, 21149, 661, 7, 4910, 4838, 701, 849, 9, 199, 5589, 63, 6188, 275, 788, 8915, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 78, 15893, 297, 283, 15311, 297, 326, 283, 758, 374, 297, 283, 493, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 596, 83, 297, 326, 283, 496, 83, 529, 79, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 3260, 283, 25032, 297, 326, 283, 6836, 297, 283, 6836, 11, 5510, 418, 199, 5589, 63, 12652, 275, 788, 8915, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 78, 15893, 297, 283, 31085, 297, 2049, 283, 15311, 297, 283, 758, 374, 297, 283, 493, 297, 283, 596, 83, 297, 283, 2859, 297, 283, 83, 1014, 297, 2049, 283, 83, 13224, 297, 283, 496, 83, 529, 79, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 27152, 297, 3260, 2049, 283, 6836, 297, 283, 6836, 11, 5510, 297, 283, 25032, 297, 283, 19591, 297, 283, 3187, 297, 283, 3187, 11, 5510, 418, 199, 5589, 63, 1162, 275, 788, 8915, 297, 283, 28738, 297, 283, 496, 83, 529, 79, 297, 283, 1014, 297, 283, 15311, 297, 2049, 283, 2859, 297, 283, 83, 1014, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 17839, 297, 283, 338, 1190, 297, 2049, 283, 596, 83, 297, 3260, 283, 25032, 297, 283, 14146, 418, 199, 199, 3, 5723, 787, 440, 5965, 1202, 20827, 12, 1325, 1077, 25578, 367, 8552, 199, 3, 7163, 14, 221, 334, 1918, 89, 787, 625, 29383, 12, 1325, 1172, 282, 4575, 13, 11660, 316, 536, 4959, 199, 2865, 63, 72, 16437, 275, 788, 71, 411, 2523, 297, 283, 28738, 297, 283, 26206, 297, 283, 13224, 297, 490, 283, 31085, 297, 283, 758, 374, 297, 283, 15311, 297, 283, 83, 13224, 297, 283, 17839, 297, 283, 338, 1190, 418, 199, 5589, 63, 1131, 275, 788, 1014, 297, 283, 758, 374, 297, 283, 15311, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 596, 83, 297, 1598, 283, 71, 411, 2523, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 17839, 297, 283, 338, 1190, 297, 28696, 199, 5589, 63, 7677, 275, 788, 8915, 297, 283, 28738, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 13224, 297, 326, 283, 78, 15893, 297, 283, 758, 374, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 83, 13224, 297, 326, 283, 493, 297, 283, 496, 83, 529, 79, 297, 28696, 199, 199, 3, 6659, 7421, 1686, 315, 5687, 1561, 199, 5512, 63, 6574, 275, 661, 23459, 7, 355, 283, 28114, 7, 355, 283, 11371, 7, 355, 6681, 13, 2659, 199, 199, 3, 5787, 26, 24413, 15810, 543, 9143, 14, 25003, 63, 1637, 199, 4283, 63, 8677, 63, 4305, 275, 3388, 199, 63, 1122, 63, 1637, 275, 1052, 199, 199, 318, 5436, 63, 1637, 837, 272, 408, 9721, 314, 2198, 2581, 436, 314, 28419, 878, 2581, 1041, 272, 485, 1122, 63, 1637, 14, 3584, 342, 272, 485, 3489, 63, 14209, 878, 14, 3584, 342, 421, 199, 3, 11642, 83, 367, 2783, 7252, 199, 3, 2104, 650, 14, 18, 12, 781, 9122, 605, 13824, 4409, 13103, 626, 199, 3, 2429, 1742, 10567, 10999, 10867, 370, 886, 3932, 5705, 199, 3, 15952, 436, 2644, 14, 982, 1686, 675, 5560, 787, 199, 3, 26568, 12, 781, 1443, 13773, 88, 642, 701, 1808, 16899, 13, 17, 199, 3, 15952, 14448, 367, 650, 14, 19, 199, 63, 11886, 63, 2991, 275, 283, 4371, 7, 199, 63, 11886, 63, 2550, 275, 283, 4768, 7, 199, 199, 318, 485 ]
[ 4003, 334, 6116, 436, 3847, 9, 10867, 14, 199, 199, 10290, 859, 365, 4079, 12188, 314, 2569, 7329, 28754, 14, 199, 199, 14468, 10551, 1184, 334, 18472, 1272, 304, 298, 12421, 7337, 473, 8577, 2, 701, 377, 14, 23207, 8715, 13, 44, 1024, 12, 820, 14, 5024, 316, 199, 460, 491, 14, 221, 603, 305, 1058, 12, 17474, 20527, 11811, 14, 199, 199, 14468, 8087, 708, 520, 298, 3484, 367, 18271, 6509, 22, 2654, 4357, 315, 2851, 1159, 701, 820, 14, 40, 262, 848, 12, 699, 14, 16034, 897, 351, 199, 460, 491, 14, 45, 305, 1058, 12, 1487, 26381, 21300, 14, 199, 199, 14468, 499, 13443, 26, 221, 298, 12421, 7337, 473, 8577, 334, 7639, 9, 582, 8307, 18377, 701, 377, 14, 199, 24947, 8715, 13, 44, 1024, 12, 820, 14, 5024, 316, 12, 436, 491, 14, 603, 305, 1058, 12, 25298, 833, 19960, 14, 199, 199, 14468, 499, 10997, 26, 298, 1918, 6016, 475, 2851, 5687, 401, 701, 510, 14, 40, 1997, 1237, 2360, 491, 603, 305, 1058, 12, 1603, 14, 3107, 65, 2676, 10728, 12, 1603, 21797, 19960, 14, 199, 199, 14468, 413, 11292, 26, 298, 15277, 1910, 8241, 7337, 6263, 2750, 401, 701, 820, 14, 5024, 316, 12, 738, 35, 473, 6310, 1132, 12, 1603, 11474, 199, 7155, 21, 14, 199, 199, 14468, 5557, 1703, 26, 298, 12421, 7337, 6263, 2750, 334, 2632, 2924, 701, 377, 14, 23207, 8715, 13, 44, 1024, 12, 491, 14, 603, 305, 1058, 12, 603, 14, 199, 45, 67, 3630, 72, 778, 12, 1487, 26381, 9013, 20, 199, 199, 14468, 10551, 1184, 365, 8652, 314, 1453, 4465, 436, 1263, 6466, 4493, 370, 199, 10290, 859, 1077, 26449, 543, 652, 14, 221, 710, 7097, 859, 365, 199, 19767, 440, 21926, 1013, 22676, 543, 642, 7329, 7037, 370, 347, 2442, 79, 199, 32225, 367, 6057, 12, 436, 367, 13388, 7163, 12901, 12, 2005, 199, 11059, 2173, 723, 6080, 687, 12731, 7329, 83, 787, 30403, 14, 710, 511, 9403, 315, 199, 396, 63, 10290, 14, 647, 6571, 282, 6954, 16385, 402, 6057, 5953, 14, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 10290, 401, 298, 633, 18185, 401, 298, 17755, 401, 298, 633, 318, 2527, 401, 1779, 298, 29491, 401, 298, 633, 30038, 401, 298, 10738, 401, 298, 1122, 63, 6177, 401, 1779, 298, 1122, 63, 26714, 401, 298, 3513, 401, 298, 3513, 63, 6666, 401, 298, 3513, 63, 504, 63, 2394, 401, 1779, 298, 12240, 401, 298, 12240, 63, 6666, 401, 298, 12240, 63, 475, 63, 2394, 937, 199, 199, 3, 437, 12505, 402, 21149, 661, 7, 4910, 4838, 701, 849, 9, 199, 5589, 63, 6188, 275, 788, 8915, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 78, 15893, 297, 283, 15311, 297, 326, 283, 758, 374, 297, 283, 493, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 596, 83, 297, 326, 283, 496, 83, 529, 79, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 3260, 283, 25032, 297, 326, 283, 6836, 297, 283, 6836, 11, 5510, 418, 199, 5589, 63, 12652, 275, 788, 8915, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 78, 15893, 297, 283, 31085, 297, 2049, 283, 15311, 297, 283, 758, 374, 297, 283, 493, 297, 283, 596, 83, 297, 283, 2859, 297, 283, 83, 1014, 297, 2049, 283, 83, 13224, 297, 283, 496, 83, 529, 79, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 27152, 297, 3260, 2049, 283, 6836, 297, 283, 6836, 11, 5510, 297, 283, 25032, 297, 283, 19591, 297, 283, 3187, 297, 283, 3187, 11, 5510, 418, 199, 5589, 63, 1162, 275, 788, 8915, 297, 283, 28738, 297, 283, 496, 83, 529, 79, 297, 283, 1014, 297, 283, 15311, 297, 2049, 283, 2859, 297, 283, 83, 1014, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 17839, 297, 283, 338, 1190, 297, 2049, 283, 596, 83, 297, 3260, 283, 25032, 297, 283, 14146, 418, 199, 199, 3, 5723, 787, 440, 5965, 1202, 20827, 12, 1325, 1077, 25578, 367, 8552, 199, 3, 7163, 14, 221, 334, 1918, 89, 787, 625, 29383, 12, 1325, 1172, 282, 4575, 13, 11660, 316, 536, 4959, 199, 2865, 63, 72, 16437, 275, 788, 71, 411, 2523, 297, 283, 28738, 297, 283, 26206, 297, 283, 13224, 297, 490, 283, 31085, 297, 283, 758, 374, 297, 283, 15311, 297, 283, 83, 13224, 297, 283, 17839, 297, 283, 338, 1190, 418, 199, 5589, 63, 1131, 275, 788, 1014, 297, 283, 758, 374, 297, 283, 15311, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 596, 83, 297, 1598, 283, 71, 411, 2523, 297, 283, 2591, 681, 297, 283, 2591, 681, 85, 297, 283, 17839, 297, 283, 338, 1190, 297, 28696, 199, 5589, 63, 7677, 275, 788, 8915, 297, 283, 28738, 297, 283, 1014, 297, 283, 71, 411, 2523, 297, 283, 13224, 297, 326, 283, 78, 15893, 297, 283, 758, 374, 297, 283, 2859, 297, 283, 83, 1014, 297, 283, 83, 13224, 297, 326, 283, 493, 297, 283, 496, 83, 529, 79, 297, 28696, 199, 199, 3, 6659, 7421, 1686, 315, 5687, 1561, 199, 5512, 63, 6574, 275, 661, 23459, 7, 355, 283, 28114, 7, 355, 283, 11371, 7, 355, 6681, 13, 2659, 199, 199, 3, 5787, 26, 24413, 15810, 543, 9143, 14, 25003, 63, 1637, 199, 4283, 63, 8677, 63, 4305, 275, 3388, 199, 63, 1122, 63, 1637, 275, 1052, 199, 199, 318, 5436, 63, 1637, 837, 272, 408, 9721, 314, 2198, 2581, 436, 314, 28419, 878, 2581, 1041, 272, 485, 1122, 63, 1637, 14, 3584, 342, 272, 485, 3489, 63, 14209, 878, 14, 3584, 342, 421, 199, 3, 11642, 83, 367, 2783, 7252, 199, 3, 2104, 650, 14, 18, 12, 781, 9122, 605, 13824, 4409, 13103, 626, 199, 3, 2429, 1742, 10567, 10999, 10867, 370, 886, 3932, 5705,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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 ]
mrquim/repository.mrquim
plugin.video.Rising.Tides/commonresolvers.py
186
31372
# -*- coding: utf-8 -*- ''' Genesis Add-on Copyright (C) 2014 lambda This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import urllib,urllib2,re,os,xbmc,xbmcgui,xbmcaddon,xbmcvfs try: import CommonFunctions as common except: import commonfunctionsdummy as common try: import json except: import simplejson as json def get(url): print url pz = premiumize(url) if not pz == None: return pz rd = realdebrid(url) if not rd == None: return rd try: u = None import urlparse u = urlparse.urlparse(url).netloc u = u.replace('www.', '') print 'common resolver',u except: pass if u == 'vk.com': url = vk(url) elif u == 'docs.google.com': url = googledocs(url) elif u == 'youtube.com': url = youtube(url) elif u == 'videomega.tv': url = videomega(url) elif u == 'movreel.com': url = movreel(url) elif u == 'billionuploads.com': url = billionuploads(url) elif u == 'v-vids.com': url = v_vids(url) elif u == 'vidbull.com': url = vidbull(url) elif u == '180upload.com': url = _180upload(url) elif u == 'hugefiles.net': url = hugefiles(url) elif u == 'filecloud.io': url = filecloud(url) elif u == 'uploadrocket.net': url = uploadrocket(url) elif u == 'kingfiles.net': url = kingfiles(url) elif u == 'streamin.to': url = streamin(url) elif u == 'grifthost.com': url = grifthost(url) elif u == 'ishared.eu': url = ishared(url) elif u == 'cloudyvideos.com': url = cloudyvideos(url) elif u == 'mrfile.me': url = mrfile(url) elif u == 'datemule.com': url = datemule(url) elif u == 'vimeo.com': url = vimeo(url) elif u == 'odnoklassniki.ru': url = odnoklassniki(url) elif u == 'videoapi.my.mail.ru': url = mailru(url) elif u == 'my.mail.ru': url = mailru(url) elif u == 'mail.ru': url = mailru(url) else: try: import urlresolver host = urlresolver.HostedMediaFile(url) if host: resolver = urlresolver.resolve(url) else: return url if not resolver.startswith('http://'): return if not resolver == url: return resolver except: pass return url class getUrl(object): def __init__(self, url, close=True, proxy=None, post=None, mobile=False, referer=None, cookie=None, output='', timeout='10'): if not proxy == None: proxy_handler = urllib2.ProxyHandler({'http':'%s' % (proxy)}) opener = urllib2.build_opener(proxy_handler, urllib2.HTTPHandler) opener = urllib2.install_opener(opener) if output == 'cookie' or not close == True: import cookielib cookie_handler = urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar()) opener = urllib2.build_opener(cookie_handler, urllib2.HTTPBasicAuthHandler(), urllib2.HTTPHandler()) opener = urllib2.install_opener(opener) if not post == None: request = urllib2.Request(url, post) else: request = urllib2.Request(url,None) if mobile == True: request.add_header('User-Agent', 'Mozilla/5.0 (iPhone; CPU; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7') else: request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0') if not referer == None: request.add_header('Referer', referer) if not cookie == None: request.add_header('cookie', cookie) response = urllib2.urlopen(request, timeout=int(timeout)) if output == 'cookie': result = str(response.headers.get('Set-Cookie')) elif output == 'geturl': result = response.geturl() else: result = response.read() if close == True: response.close() self.result = result def cloudflare(url): try: import urlparse,cookielib class NoRedirection(urllib2.HTTPErrorProcessor): def http_response(self, request, response): return response def parseJSString(s): try: offset=1 if s[0]=='+' else 0 val = int(eval(s.replace('!+[]','1').replace('!![]','1').replace('[]','0').replace('(','str(')[offset:])) return val except: pass agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0' cj = cookielib.CookieJar() opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-Agent', agent)] response = opener.open(url) result = response.read() jschl = re.compile('name="jschl_vc" value="(.+?)"/>').findall(result)[0] init = re.compile('setTimeout\(function\(\){\s*.*?.*:(.*?)};').findall(result)[0] builder = re.compile(r"challenge-form\'\);\s*(.*)a.v").findall(result)[0] decryptVal = parseJSString(init) lines = builder.split(';') for line in lines: if len(line)>0 and '=' in line: sections=line.split('=') line_val = parseJSString(sections[1]) decryptVal = int(eval(str(decryptVal)+sections[0][-1]+str(line_val))) answer = decryptVal + len(urlparse.urlparse(url).netloc) query = '%s/cdn-cgi/l/chk_jschl?jschl_vc=%s&jschl_answer=%s' % (url, jschl, answer) opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-Agent', agent)] response = opener.open(query) cookie = str(response.headers.get('Set-Cookie')) response.close() return cookie except: return def jsunpack(script): def __itoa(num, radix): result = "" while num > 0: result = "0123456789abcdefghijklmnopqrstuvwxyz"[num % radix] + result num /= radix return result def __unpack(p, a, c, k, e, d): while (c > 1): c = c -1 if (k[c]): p = re.sub('\\b' + str(__itoa(c, a)) +'\\b', k[c], p) return p aSplit = script.split(";',") p = str(aSplit[0]) aSplit = aSplit[1].split(",") a = int(aSplit[0]) c = int(aSplit[1]) k = aSplit[2].split(".")[0].replace("'", '').split('|') e = '' d = '' sUnpacked = str(__unpack(p, a, c, k, e, d)) return sUnpacked.replace('\\', '') def captcha(data): try: captcha = {} def get_response(response): try: dataPath = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo("profile")) i = os.path.join(dataPath.decode("utf-8"),'img') f = xbmcvfs.File(i, 'w') f.write(getUrl(response).result) f.close() f = xbmcgui.ControlImage(450,5,375,115, i) d = xbmcgui.WindowDialog() d.addControl(f) xbmcvfs.delete(i) d.show() xbmc.sleep(3000) t = 'Type the letters in the image' c = common.getUserInput(t, '') d.close() return c except: return solvemedia = common.parseDOM(data, "iframe", ret="src") solvemedia = [i for i in solvemedia if 'api.solvemedia.com' in i] if len(solvemedia) > 0: url = solvemedia[0] result = getUrl(url).result challenge = common.parseDOM(result, "input", ret="value", attrs = { "id": "adcopy_challenge" })[0] response = common.parseDOM(result, "iframe", ret="src") response += common.parseDOM(result, "img", ret="src") response = [i for i in response if '/papi/media' in i][0] response = 'http://api.solvemedia.com' + response response = get_response(response) captcha.update({'adcopy_challenge': challenge, 'adcopy_response': response}) return captcha recaptcha = [] if data.startswith('http://www.google.com'): recaptcha += [data] recaptcha += common.parseDOM(data, "script", ret="src", attrs = { "type": "text/javascript" }) recaptcha = [i for i in recaptcha if 'http://www.google.com' in i] if len(recaptcha) > 0: url = recaptcha[0] result = getUrl(url).result challenge = re.compile("challenge\s+:\s+'(.+?)'").findall(result)[0] response = 'http://www.google.com/recaptcha/api/image?c=' + challenge response = get_response(response) captcha.update({'recaptcha_challenge_field': challenge, 'recaptcha_challenge': challenge, 'recaptcha_response_field': response, 'recaptcha_response': response}) return captcha numeric = re.compile("left:(\d+)px;padding-top:\d+px;'>&#(.+?);<").findall(data) if len(numeric) > 0: result = sorted(numeric, key=lambda ltr: int(ltr[0])) response = ''.join(str(int(num[1])-48) for num in result) captcha.update({'code': response}) return captcha except: return captcha def vk(url): try: url = url.replace('http://', 'https://') result = getUrl(url).result u = re.compile('url(720|540|480)=(.+?)&').findall(result) url = [] try: url += [[{'quality': 'HD', 'url': i[1]} for i in u if i[0] == '720'][0]] except: pass try: url += [[{'quality': 'SD', 'url': i[1]} for i in u if i[0] == '540'][0]] except: pass try: url += [[{'quality': 'SD', 'url': i[1]} for i in u if i[0] == '480'][0]] except: pass if url == []: return return url except: return def google(url): try: if any(x in url for x in ['&itag=37&', '&itag=137&', '&itag=299&', '&itag=96&', '&itag=248&', '&itag=303&', '&itag=46&']): quality = '1080p' elif any(x in url for x in ['&itag=22&', '&itag=84&', '&itag=136&', '&itag=298&', '&itag=120&', '&itag=95&', '&itag=247&', '&itag=302&', '&itag=45&', '&itag=102&']): quality = 'HD' else: raise Exception() url = [{'quality': quality, 'url': url}] return url except: return def googledocs(url): try: url = url.split('/preview', 1)[0] result = getUrl(url).result result = re.compile('"fmt_stream_map",(".+?")').findall(result)[0] result = json.loads(result) u = [i.split('|')[-1] for i in result.split(',')] url = [] try: url += [[{'quality': '1080p', 'url': i} for i in u if any(x in i for x in ['&itag=37&', '&itag=137&', '&itag=299&', '&itag=96&', '&itag=248&', '&itag=303&', '&itag=46&'])][0]] except: pass try: url += [[{'quality': 'HD', 'url': i} for i in u if any(x in i for x in ['&itag=22&', '&itag=84&', '&itag=136&', '&itag=298&', '&itag=120&', '&itag=95&', '&itag=247&', '&itag=302&', '&itag=45&', '&itag=102&'])][0]] except: pass if url == []: return return url except: return def youtube(url): try: id = url.split("?v=")[-1].split("/")[-1].split("?")[0].split("&")[0] result = getUrl('http://gdata.youtube.com/feeds/api/videos/%s?v=2' % id).result state, reason = None, None try: state = common.parseDOM(result, "yt:state", ret="name")[0] except: pass try: reason = common.parseDOM(result, "yt:state", ret="reasonCode")[0] except: pass if state == 'deleted' or state == 'rejected' or state == 'failed' or reason == 'requesterRegion' : return url = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % id return url except: return def premiumize(url): try: user = xbmcaddon.Addon().getSetting("premiumize_user") password = xbmcaddon.Addon().getSetting("premiumize_password") if (user == '' or password == ''): raise Exception() url = 'https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink&params[login]=%s&params[pass]=%s&params[link]=%s' % (user, password, url) result = getUrl(url, close=False).result url = json.loads(result)['result']['location'] return url except: return def premiumize_hosts(): try: user = xbmcaddon.Addon().getSetting("premiumize_user") password = xbmcaddon.Addon().getSetting("premiumize_password") if (user == '' or password == ''): raise Exception() pz = getUrl('https://api.premiumize.me/pm-api/v1.php?method=hosterlist&params[login]=%s&params[pass]=%s' % (user, password)).result pz = json.loads(pz)['result']['hosterlist'] pz = [i.rsplit('.' ,1)[0].lower() for i in pz] return pz except: return def realdebrid(url): try: user = xbmcaddon.Addon().getSetting("realdedrid_user") password = xbmcaddon.Addon().getSetting("realdedrid_password") if (user == '' or password == ''): raise Exception() login_data = urllib.urlencode({'user' : user, 'pass' : password}) login_link = 'https://real-debrid.com/ajax/login.php?%s' % login_data result = getUrl(login_link, close=False).result result = json.loads(result) error = result['error'] if not error == 0: raise Exception() url = 'https://real-debrid.com/ajax/unrestrict.php?link=%s' % url url = url.replace('filefactory.com/stream/', 'filefactory.com/file/') result = getUrl(url).result result = json.loads(result) url = result['generated_links'][0][-1] return url except: return def realdebrid_hosts(): try: rd = getUrl('https://real-debrid.com/api/hosters.php').result rd = json.loads('[%s]' % rd) rd = [i.rsplit('.' ,1)[0].lower() for i in rd] return rd except: return def videomega(url): try: url = url.replace('/?ref=', '/iframe.php?ref=') result = getUrl(url).result url = re.compile('document.write.unescape."(.+?)"').findall(result)[0] url = urllib.unquote_plus(url) url = re.compile('file: "(.+?)"').findall(url)[0] return url except: return def movreel(url): try: user = xbmcaddon.Addon().getSetting("movreel_user") password = xbmcaddon.Addon().getSetting("movreel_password") login = 'http://movreel.com/login.html' post = {'op': 'login', 'login': user, 'password': password, 'redirect': url} post = urllib.urlencode(post) result = getUrl(url, close=False).result result += getUrl(login, post=post, close=False).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[-1] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': '', 'method_premium': ''}) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = re.compile('(<a .+?</a>)').findall(result) url = [i for i in url if 'Download Link' in i][-1] url = common.parseDOM(url, "a", ret="href")[0] return url except: return def billionuploads(url): try: import cookielib cj = cookielib.CookieJar() agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0' base = 'http://billionuploads.com' class NoRedirection(urllib2.HTTPErrorProcessor): def http_response(self, request, response): return response opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-Agent', agent)] response = opener.open(base) response = opener.open(base) result = response.read() z = [] decoded = re.compile('(?i)var z="";var b="([^"]+?)"').findall(result)[0] for i in range(len(decoded)/2): z.append(int(decoded[i*2:i*2+2],16)) decoded = ''.join(map(unichr, z)) incapurl = re.compile('(?i)"GET","(/_Incapsula_Resource[^"]+?)"').findall(decoded)[0] incapurl = base + incapurl response = opener.open(incapurl) response = opener.open(url) result = response.read() post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[0] enc_input = re.compile('decodeURIComponent\("(.+?)"\)').findall(result) if enc_input: f += urllib2.unquote(enc_input[0]) extra = re.compile("append\(\$\(document.createElement\('input'\)\).attr\('type','hidden'\).attr\('name','(.*?)'\).val\((.*?)\)").findall(result) for i, k in extra: try: k = re.compile('<textarea[^>]*?source="self"[^>]*?>([^<]*?)<').findall(result)[0].strip("'") post.update({i: k}) except: pass k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'submit_btn': ''}) k = re.findall('\'input\[name="([^"]+?)"\]\'\)\.remove\(\)', result) for i in k: del post[i] post = urllib.urlencode(post) response = opener.open(url, post) result = response.read() response.close() def custom_range(start, end, step): while start <= end: yield start start += step def checkwmv(e): s = "" i=[] u=[[65,91],[97,123],[48,58],[43,44],[47,48]] for z in range(0, len(u)): for n in range(u[z][0],u[z][1]): i.append(chr(n)) t = {} for n in range(0, 64): t[i[n]]=n for n in custom_range(0, len(e), 72): a=0 h=e[n:n+72] c=0 for l in range(0, len(h)): f = t.get(h[l], 'undefined') if f == 'undefined': continue a = (a<<6) + f c = c + 6 while c >= 8: c = c - 8 s = s + chr( (a >> c) % 256 ) return s try: url = common.parseDOM(result, "input", ret="value", attrs = { "id": "dl" })[0] url = url.split('GvaZu')[1] url = checkwmv(url) url = checkwmv(url) return url except: pass try: url = common.parseDOM(result, "source", ret="src")[0] return url except: pass except: return def v_vids(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': '', 'method_premium': ''}) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = common.parseDOM(result, "a", ret="href", attrs = { "id": "downloadbutton" })[0] return url except: return def vidbull(url): try: result = getUrl(url, mobile=True).result url = common.parseDOM(result, "source", ret="src", attrs = { "type": "video.+?" })[0] return url except: return def _180upload(url): try: u = re.compile('//.+?/([\w]+)').findall(url)[0] u = 'http://180upload.com/embed-%s.html' % u result = getUrl(u).result post = {} f = common.parseDOM(result, "form", attrs = { "id": "captchaForm" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post = urllib.urlencode(post) result = getUrl(u, post=post).result result = re.compile('id="player_code".*?(eval.*?\)\)\))').findall(result)[0] result = jsunpack(result) u = re.compile('name="src"0="([^"]+)"/>').findall(result)[0] return u except: pass try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update(captcha(result)) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = common.parseDOM(result, "a", ret="href", attrs = { "id": "lnk_download" })[0] return url except: return def hugefiles(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "action": "" }) k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': 'Free Download'}) post.update(captcha(result)) post = urllib.urlencode(post) result = getUrl(url, post=post).result post = {} f = common.parseDOM(result, "Form", attrs = { "action": "" }) k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': 'Free Download'}) post = urllib.urlencode(post) u = getUrl(url, output='geturl', post=post).result if not url == u: return u except: return def filecloud(url): try: result = getUrl(url, close=False).result result = getUrl('http://filecloud.io/download.html').result url = re.compile("__requestUrl\s+=\s+'(.+?)'").findall(result)[0] ukey = re.compile("'ukey'\s+:\s+'(.+?)'").findall(result)[0] __ab1 = re.compile("__ab1\s+=\s+(\d+);").findall(result)[0] ctype = re.compile("'ctype'\s+:\s+'(.+?)'").findall(result)[0] challenge = re.compile("__recaptcha_public\s+=\s+'(.+?)'").findall(result)[0] challenge = 'http://www.google.com/recaptcha/api/challenge?k=' + challenge post = {'ukey': ukey, '__ab1': str(__ab1), 'ctype': ctype} post.update(captcha(challenge)) post = urllib.urlencode(post) result = getUrl(url, post=post).result result = getUrl('http://filecloud.io/download.html').result url = common.parseDOM(result, "a", ret="href", attrs = { "id": "downloadBtn" })[0] return url except: return def uploadrocket(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "freeorpremium" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': 'Free Download'}) post = urllib.urlencode(post) result = getUrl(url, post=post).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update(captcha(result)) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = common.parseDOM(result, "a", ret="href", attrs = { "onclick": "window[.]open.+?" })[0] return url except: return def kingfiles(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "action": "" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': ' '}) post = urllib.urlencode(post) result = getUrl(url, post=post).result post = {} f = common.parseDOM(result, "Form", attrs = { "action": "" })[0] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': ' '}) post.update(captcha(result)) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = re.compile("var download_url = '(.+?)'").findall(result)[0] return url except: return def streamin(url): try: url = url.replace('streamin.to/', 'streamin.to/embed-') if not url.endswith('.html'): url = url + '.html' result = getUrl(url, mobile=True).result url = re.compile("file:'(.+?)'").findall(result)[0] return url except: return def grifthost(url): try: url = url.replace('/embed-', '/').split('-')[0] url = re.compile('//.+?/([\w]+)').findall(url)[0] url = 'http://grifthost.com/embed-%s.html' % url result = getUrl(url).result try: post = {} f = common.parseDOM(result, "Form", attrs = { "method": "POST" })[0] f = f.replace('"submit"', '"hidden"') k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post = urllib.urlencode(post) result = getUrl(url, post=post).result except: pass result = re.compile('(eval.*?\)\)\))').findall(result)[0] result = jsunpack(result) url = re.compile("file:'(.+?)'").findall(result)[0] return url except: return def ishared(url): try: result = getUrl(url).result url = re.compile('path:"(.+?)"').findall(result)[0] return url except: return def cloudyvideos(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[-1] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': '', 'method_premium': ''}) post = urllib.urlencode(post) import time request = urllib2.Request(url, post) for i in range(0, 4): try: response = urllib2.urlopen(request, timeout=5) result = response.read() response.close() btn = common.parseDOM(result, "input", ret="value", attrs = { "class": "graybt.+?" })[0] url = re.compile('href=[\'|\"](.+?)[\'|\"]><input.+?class=[\'|\"]graybt.+?[\'|\"]').findall(result)[0] return url except: time.sleep(1) except: return def mrfile(url): try: result = getUrl(url).result post = {} f = common.parseDOM(result, "Form", attrs = { "name": "F1" })[-1] k = common.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" }) for i in k: post.update({i: common.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]}) post.update({'method_free': '', 'method_premium': ''}) post = urllib.urlencode(post) result = getUrl(url, post=post).result url = re.compile('(<a\s+href=.+?>Download\s+.+?</a>)').findall(result)[-1] url = common.parseDOM(url, "a", ret="href")[0] return url except: return def datemule(url): try: url += '&mode=html5' result = getUrl(url).result url = re.compile('file:\s+"(.+?)"').findall(result)[0] return url except: return def vimeo(url): try: url = [i for i in url.split('/') if i.isdigit()][-1] url = 'http://player.vimeo.com/video/%s/config' % url result = getUrl(url).result result = json.loads(result) u = result['request']['files']['h264'] url = None try: url = u['hd']['url'] except: pass try: url = u['sd']['url'] except: pass return url except: return def odnoklassniki(url): try: url = [i for i in url.split('/') if i.isdigit()][-1] url = 'http://www.odnoklassniki.ru/dk?cmd=videoPlayerMetadata&mid=%s' % url result = getUrl(url).result result = json.loads(result) a = "&start=0|User-Agent=%s" % urllib.quote_plus('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36') u = result['videos'] url = [] try: url += [[{'quality': 'HD', 'url': i['url'] + a} for i in u if i['name'] == 'hd'][0]] except: pass try: url += [[{'quality': 'SD', 'url': i['url'] + a} for i in u if i['name'] == 'sd'][0]] except: pass if url == []: return return url except: return def mailru(url): try: url = url.replace('/my.mail.ru/video/', '/api.video.mail.ru/videos/embed/') url = url.replace('/videoapi.my.mail.ru/', '/api.video.mail.ru/') result = getUrl(url).result url = re.compile('metadataUrl":"(.+?)"').findall(result)[0] cookie = getUrl(url, output='cookie').result h = "|Cookie=%s" % urllib.quote(cookie) result = getUrl(url).result result = json.loads(result) result = result['videos'] url = [] url += [{'quality': '1080p', 'url': i['url'] + h} for i in result if i['key'] == '1080p'] url += [{'quality': 'HD', 'url': i['url'] + h} for i in result if i['key'] == '720p'] url += [{'quality': 'SD', 'url': i['url'] + h} for i in result if not (i['key'] == '1080p' or i ['key'] == '720p')] if url == []: return return url except: return
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 272, 598, 6349, 2316, 2654, 13, 265, 272, 1898, 334, 35, 9, 6927, 2400, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 646, 4011, 12, 4078, 18, 12, 264, 12, 736, 12, 21382, 12, 21382, 5885, 12, 21382, 9291, 12, 1774, 77, 5107, 2319, 199, 199, 893, 26, 272, 492, 13964, 13967, 465, 2863, 199, 2590, 26, 272, 492, 2863, 1593, 3893, 3323, 465, 2863, 199, 893, 26, 272, 492, 2022, 199, 2590, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 664, 8, 633, 304, 272, 870, 1166, 272, 299, 90, 275, 876, 23481, 794, 8, 633, 9, 272, 340, 440, 299, 90, 508, 488, 26, 372, 299, 90, 272, 11517, 275, 3363, 271, 14601, 8, 633, 9, 272, 340, 440, 11517, 508, 488, 26, 372, 11517, 339, 862, 26, 267, 399, 275, 488, 267, 492, 7097, 267, 399, 275, 7097, 14, 10290, 8, 633, 680, 12652, 267, 399, 275, 399, 14, 1814, 360, 1544, 3130, 4074, 267, 870, 283, 2330, 15611, 297, 85, 272, 871, 26, 267, 986, 339, 340, 399, 508, 283, 21405, 14, 957, 356, 1166, 275, 373, 75, 8, 633, 9, 272, 916, 399, 508, 283, 4757, 14, 3098, 14, 957, 356, 1166, 275, 2621, 974, 1146, 14851, 8, 633, 9, 272, 916, 399, 508, 283, 9788, 14, 957, 356, 1166, 275, 22378, 8, 633, 9, 272, 916, 399, 508, 283, 5624, 23524, 14, 6993, 356, 1166, 275, 1321, 271, 23524, 8, 633, 9, 272, 916, 399, 508, 283, 14469, 264, 352, 14, 957, 356, 1166, 275, 26524, 264, 352, 8, 633, 9, 272, 916, 399, 508, 283, 66, 8148, 265, 21725, 14, 957, 356, 1166, 275, 330, 8148, 265, 21725, 8, 633, 9, 272, 916, 399, 508, 283, 86, 13, 86, 1580, 14, 957, 356, 1166, 275, 373, 63, 86, 1580, 8, 633, 9, 272, 916, 399, 508, 283, 5017, 66, 979, 14, 957, 356, 1166, 275, 27767, 66, 979, 8, 633, 9, 272, 916, 399, 508, 283, 7663, 5064, 14, 957, 356, 1166, 275, 485, 7663, 5064, 8, 633, 9, 272, 916, 399, 508, 283, 29947, 1725, 14, 846, 356, 1166, 275, 27791, 1725, 8, 633, 9, 272, 916, 399, 508, 283, 493, 4091, 14, 2308, 356, 1166, 275, 570, 4091, 8, 633, 9, 272, 916, 399, 508, 283, 5064, 293, 2284, 14, 846, 356, 1166, 275, 5802, 293, 2284, 8, 633, 9, 272, 916, 399, 508, 283, 17443, 1725, 14, 846, 356, 1166, 275, 1022, 316, 1725, 8, 633, 9, 272, 916, 399, 508, 283, 1745, 262, 14, 475, 356, 1166, 275, 2547, 262, 8, 633, 9, 272, 916, 399, 508, 283, 7928, 70, 15157, 14, 957, 356, 1166, 275, 486, 20546, 15157, 8, 633, 9, 272, 916, 399, 508, 283, 374, 10068, 14, 16913, 356, 1166, 275, 365, 10068, 8, 633, 9, 272, 916, 399, 508, 283, 4091, 89, 11418, 14, 957, 356, 1166, 275, 8002, 89, 11418, 8, 633, 9, 272, 916, 399, 508, 283, 13118, 493, 14, 278, 356, 1166, 275, 333, 23830, 8, 633, 9, 272, 916, 399, 508, 283, 602, 77, 443, 14, 957, 356, 1166, 275, 1434, 77, 443, 8, 633, 9, 272, 916, 399, 508, 283, 433, 278, 79, 14, 957, 356, 1166, 275, 373, 1036, 79, 8, 633, 9, 272, 916, 399, 508, 283, 364, 78, 745, 4297, 78, 11545, 14, 6558, 356, 1166, 275, 312, 4272, 745, 4297, 78, 11545, 8, 633, 9, 272, 916, 399, 508, 283, 3722, 1246, 14, 1662, 14, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 272, 916, 399, 508, 283, 1662, 14, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 272, 916, 399, 508, 283, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 339, 587, 26, 267, 862, 26, 288, 492, 1166, 7717, 288, 1591, 275, 1166, 7717, 14, 40, 17849, 11398, 1173, 8, 633, 9, 288, 340, 1591, 26, 15611, 275, 1166, 7717, 14, 6983, 8, 633, 9, 288, 587, 26, 372, 1166, 288, 340, 440, 15611, 14, 2460, 360, 1014, 921, 735, 372, 288, 340, 440, 15611, 508, 1166, 26, 372, 15611, 267, 871, 26, 288, 986, 339, 372, 1166, 421, 199, 533, 29937, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1166, 12, 4002, 29, 549, 12, 4566, 29, 403, 12, 2963, 29, 403, 12, 21305, 29, 797, 12, 25104, 29, 403, 12, 5494, 29, 403, 12, 1072, 4581, 2653, 534, 709, 735, 267, 340, 440, 4566, 508, 488, 26, 288, 4566, 63, 2232, 275, 4011, 18, 14, 4936, 2461, 3252, 1014, 5242, 5, 83, 7, 450, 334, 3280, 11466, 288, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 8, 3280, 63, 2232, 12, 4011, 18, 14, 2856, 2461, 9, 288, 16088, 275, 4011, 18, 14, 3174, 63, 11637, 8, 11637, 9, 267, 340, 1072, 508, 283, 5306, 7, 503, 440, 4002, 508, 715, 26, 288, 492, 26234, 288, 5494, 63, 2232, 275, 4011, 18, 14, 2856, 7810, 10438, 8, 5306, 773, 14, 20145, 48, 21315, 1012, 288, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 8, 5306, 63, 2232, 12, 4011, 18, 14, 2856, 6845, 21547, 1062, 4011, 18, 14, 2856, 2461, 1012, 288, 16088, 275, 4011, 18, 14, 3174, 63, 11637, 8, 11637, 9, 267, 340, 440, 2963, 508, 488, 26, 288, 1056, 275, 4011, 18, 14, 2017, 8, 633, 12, 2963, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 272, 598, 6349, 2316, 2654, 13, 265, 272, 1898, 334, 35, 9, 6927, 2400, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 646, 4011, 12, 4078, 18, 12, 264, 12, 736, 12, 21382, 12, 21382, 5885, 12, 21382, 9291, 12, 1774, 77, 5107, 2319, 199, 199, 893, 26, 272, 492, 13964, 13967, 465, 2863, 199, 2590, 26, 272, 492, 2863, 1593, 3893, 3323, 465, 2863, 199, 893, 26, 272, 492, 2022, 199, 2590, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 664, 8, 633, 304, 272, 870, 1166, 272, 299, 90, 275, 876, 23481, 794, 8, 633, 9, 272, 340, 440, 299, 90, 508, 488, 26, 372, 299, 90, 272, 11517, 275, 3363, 271, 14601, 8, 633, 9, 272, 340, 440, 11517, 508, 488, 26, 372, 11517, 339, 862, 26, 267, 399, 275, 488, 267, 492, 7097, 267, 399, 275, 7097, 14, 10290, 8, 633, 680, 12652, 267, 399, 275, 399, 14, 1814, 360, 1544, 3130, 4074, 267, 870, 283, 2330, 15611, 297, 85, 272, 871, 26, 267, 986, 339, 340, 399, 508, 283, 21405, 14, 957, 356, 1166, 275, 373, 75, 8, 633, 9, 272, 916, 399, 508, 283, 4757, 14, 3098, 14, 957, 356, 1166, 275, 2621, 974, 1146, 14851, 8, 633, 9, 272, 916, 399, 508, 283, 9788, 14, 957, 356, 1166, 275, 22378, 8, 633, 9, 272, 916, 399, 508, 283, 5624, 23524, 14, 6993, 356, 1166, 275, 1321, 271, 23524, 8, 633, 9, 272, 916, 399, 508, 283, 14469, 264, 352, 14, 957, 356, 1166, 275, 26524, 264, 352, 8, 633, 9, 272, 916, 399, 508, 283, 66, 8148, 265, 21725, 14, 957, 356, 1166, 275, 330, 8148, 265, 21725, 8, 633, 9, 272, 916, 399, 508, 283, 86, 13, 86, 1580, 14, 957, 356, 1166, 275, 373, 63, 86, 1580, 8, 633, 9, 272, 916, 399, 508, 283, 5017, 66, 979, 14, 957, 356, 1166, 275, 27767, 66, 979, 8, 633, 9, 272, 916, 399, 508, 283, 7663, 5064, 14, 957, 356, 1166, 275, 485, 7663, 5064, 8, 633, 9, 272, 916, 399, 508, 283, 29947, 1725, 14, 846, 356, 1166, 275, 27791, 1725, 8, 633, 9, 272, 916, 399, 508, 283, 493, 4091, 14, 2308, 356, 1166, 275, 570, 4091, 8, 633, 9, 272, 916, 399, 508, 283, 5064, 293, 2284, 14, 846, 356, 1166, 275, 5802, 293, 2284, 8, 633, 9, 272, 916, 399, 508, 283, 17443, 1725, 14, 846, 356, 1166, 275, 1022, 316, 1725, 8, 633, 9, 272, 916, 399, 508, 283, 1745, 262, 14, 475, 356, 1166, 275, 2547, 262, 8, 633, 9, 272, 916, 399, 508, 283, 7928, 70, 15157, 14, 957, 356, 1166, 275, 486, 20546, 15157, 8, 633, 9, 272, 916, 399, 508, 283, 374, 10068, 14, 16913, 356, 1166, 275, 365, 10068, 8, 633, 9, 272, 916, 399, 508, 283, 4091, 89, 11418, 14, 957, 356, 1166, 275, 8002, 89, 11418, 8, 633, 9, 272, 916, 399, 508, 283, 13118, 493, 14, 278, 356, 1166, 275, 333, 23830, 8, 633, 9, 272, 916, 399, 508, 283, 602, 77, 443, 14, 957, 356, 1166, 275, 1434, 77, 443, 8, 633, 9, 272, 916, 399, 508, 283, 433, 278, 79, 14, 957, 356, 1166, 275, 373, 1036, 79, 8, 633, 9, 272, 916, 399, 508, 283, 364, 78, 745, 4297, 78, 11545, 14, 6558, 356, 1166, 275, 312, 4272, 745, 4297, 78, 11545, 8, 633, 9, 272, 916, 399, 508, 283, 3722, 1246, 14, 1662, 14, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 272, 916, 399, 508, 283, 1662, 14, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 272, 916, 399, 508, 283, 1198, 14, 6558, 356, 1166, 275, 6016, 6558, 8, 633, 9, 339, 587, 26, 267, 862, 26, 288, 492, 1166, 7717, 288, 1591, 275, 1166, 7717, 14, 40, 17849, 11398, 1173, 8, 633, 9, 288, 340, 1591, 26, 15611, 275, 1166, 7717, 14, 6983, 8, 633, 9, 288, 587, 26, 372, 1166, 288, 340, 440, 15611, 14, 2460, 360, 1014, 921, 735, 372, 288, 340, 440, 15611, 508, 1166, 26, 372, 15611, 267, 871, 26, 288, 986, 339, 372, 1166, 421, 199, 533, 29937, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1166, 12, 4002, 29, 549, 12, 4566, 29, 403, 12, 2963, 29, 403, 12, 21305, 29, 797, 12, 25104, 29, 403, 12, 5494, 29, 403, 12, 1072, 4581, 2653, 534, 709, 735, 267, 340, 440, 4566, 508, 488, 26, 288, 4566, 63, 2232, 275, 4011, 18, 14, 4936, 2461, 3252, 1014, 5242, 5, 83, 7, 450, 334, 3280, 11466, 288, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 8, 3280, 63, 2232, 12, 4011, 18, 14, 2856, 2461, 9, 288, 16088, 275, 4011, 18, 14, 3174, 63, 11637, 8, 11637, 9, 267, 340, 1072, 508, 283, 5306, 7, 503, 440, 4002, 508, 715, 26, 288, 492, 26234, 288, 5494, 63, 2232, 275, 4011, 18, 14, 2856, 7810, 10438, 8, 5306, 773, 14, 20145, 48, 21315, 1012, 288, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 8, 5306, 63, 2232, 12, 4011, 18, 14, 2856, 6845, 21547, 1062, 4011, 18, 14, 2856, 2461, 1012, 288, 16088, 275, 4011, 18, 14, 3174, 63, 11637, 8, 11637, 9, 267, 340, 440, 2963, 508, 488, 26, 288, 1056, 275, 4011, 18, 14, 2017, 8, 633, 12, 2963, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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, 1, 1, 1 ]
danielneis/osf.io
website/addons/osfstorage/views.py
10
8711
from __future__ import unicode_literals import httplib import logging from modularodm import Q from modularodm.storage.base import KeyExistsException from flask import request from framework.auth import Auth from framework.exceptions import HTTPError from framework.auth.decorators import must_be_signed from website.models import User from website.project.decorators import ( must_not_be_registration, must_have_addon, must_have_permission ) from website.util import rubeus from website.project.model import has_anonymous_link, Tag from website.files import models from website.files import exceptions from website.addons.osfstorage import utils from website.addons.osfstorage import decorators from website.addons.osfstorage import settings as osf_storage_settings logger = logging.getLogger(__name__) def osf_storage_root(node_settings, auth, **kwargs): """Build HGrid JSON for root node. Note: include node URLs for client-side URL creation for uploaded files. """ node = node_settings.owner root = rubeus.build_addon_root( node_settings=node_settings, name='', permissions=auth, user=auth.user, nodeUrl=node.url, nodeApiUrl=node.api_url, ) return [root] def make_error(code, message_short=None, message_long=None): data = {} if message_short: data['message_short'] = message_short if message_long: data['message_long'] = message_long return HTTPError(code, data=data) @must_be_signed @must_have_addon('osfstorage', 'node') def osfstorage_update_metadata(node_addon, payload, **kwargs): try: version_id = payload['version'] metadata = payload['metadata'] except KeyError: raise HTTPError(httplib.BAD_REQUEST) version = models.FileVersion.load(version_id) if version is None: raise HTTPError(httplib.NOT_FOUND) version.update_metadata(metadata) return {'status': 'success'} @must_be_signed @decorators.autoload_filenode(must_be='file') def osfstorage_get_revisions(file_node, node_addon, payload, **kwargs): is_anon = has_anonymous_link(node_addon.owner, Auth(private_key=request.args.get('view_only'))) # Return revisions in descending order return { 'revisions': [ utils.serialize_revision(node_addon.owner, file_node, version, index=len(file_node.versions) - idx - 1, anon=is_anon) for idx, version in enumerate(reversed(file_node.versions)) ] } @decorators.waterbutler_opt_hook def osfstorage_copy_hook(source, destination, name=None, **kwargs): return source.copy_under(destination, name=name).serialize(), httplib.CREATED @decorators.waterbutler_opt_hook def osfstorage_move_hook(source, destination, name=None, **kwargs): try: return source.move_under(destination, name=name).serialize(), httplib.OK except exceptions.FileNodeCheckedOutError: raise HTTPError(httplib.METHOD_NOT_ALLOWED, data={ 'message_long': 'Cannot move file as it is checked out.' }) @must_be_signed @decorators.autoload_filenode(default_root=True) def osfstorage_get_lineage(file_node, node_addon, **kwargs): #TODO Profile list(models.OsfStorageFolder.find(Q('node', 'eq', node_addon.owner))) lineage = [] while file_node: lineage.append(file_node.serialize()) file_node = file_node.parent return {'data': lineage} @must_be_signed @decorators.autoload_filenode(default_root=True) def osfstorage_get_metadata(file_node, **kwargs): try: # TODO This should change to version as its internal it can be changed anytime version = int(request.args.get('revision')) except (ValueError, TypeError): # If its not a number version = None return file_node.serialize(version=version, include_full=True) @must_be_signed @decorators.autoload_filenode(must_be='folder') def osfstorage_get_children(file_node, **kwargs): return [ child.serialize() for child in file_node.children ] @must_be_signed @must_not_be_registration @decorators.autoload_filenode(must_be='folder') def osfstorage_create_child(file_node, payload, node_addon, **kwargs): parent = file_node # Just for clarity name = payload.get('name') user = User.load(payload.get('user')) is_folder = payload.get('kind') == 'folder' if not (name or user) or '/' in name: raise HTTPError(httplib.BAD_REQUEST) try: if is_folder: created, file_node = True, parent.append_folder(name) else: created, file_node = True, parent.append_file(name) except KeyExistsException: created, file_node = False, parent.find_child_by_name(name, kind=int(not is_folder)) if not created and is_folder: raise HTTPError(httplib.CONFLICT, data={ 'message': 'Cannot create folder "{name}" because a file or folder already exists at path "{path}"'.format( name=file_node.name, path=file_node.materialized_path, ) }) if not is_folder: try: if file_node.checkout is None or file_node.checkout._id == user._id: version = file_node.create_version( user, dict(payload['settings'], **dict( payload['worker'], **{ 'object': payload['metadata']['name'], 'service': payload['metadata']['provider'], }) ), dict(payload['metadata'], **payload['hashes']) ) version_id = version._id archive_exists = version.archive is not None else: raise HTTPError(httplib.FORBIDDEN, data={ 'message_long': 'File cannot be updated due to checkout status.' }) except KeyError: raise HTTPError(httplib.BAD_REQUEST) else: version_id = None archive_exists = False return { 'status': 'success', 'archive': not archive_exists, # Should waterbutler also archive this file 'data': file_node.serialize(), 'version': version_id, }, httplib.CREATED if created else httplib.OK @must_be_signed @must_not_be_registration @decorators.autoload_filenode() def osfstorage_delete(file_node, payload, node_addon, **kwargs): auth = Auth(User.load(payload['user'])) #TODO Auth check? if not auth: raise HTTPError(httplib.BAD_REQUEST) if file_node == node_addon.get_root(): raise HTTPError(httplib.BAD_REQUEST) try: file_node.delete() except exceptions.FileNodeCheckedOutError: raise HTTPError(httplib.FORBIDDEN) return {'status': 'success'} @must_be_signed @decorators.autoload_filenode(must_be='file') def osfstorage_download(file_node, payload, node_addon, **kwargs): if not request.args.get('version'): version_id = None else: try: version_id = int(request.args['version']) except ValueError: raise make_error(httplib.BAD_REQUEST, 'Version must be an integer if not specified') version = file_node.get_version(version_id, required=True) if request.args.get('mode') not in ('render', ): utils.update_analytics(node_addon.owner, file_node._id, int(version.identifier) - 1) return { 'data': { 'name': file_node.name, 'path': version.location_hash, }, 'settings': { osf_storage_settings.WATERBUTLER_RESOURCE: version.location[osf_storage_settings.WATERBUTLER_RESOURCE], }, } @must_have_permission('write') @decorators.autoload_filenode(must_be='file') def osfstorage_add_tag(file_node, **kwargs): data = request.get_json() print data tag = data['tag'] if tag not in file_node.tags and not file_node.node.is_registration: new_tag = Tag.load(tag) if not new_tag: new_tag = Tag(_id=tag) new_tag.save() file_node.tags.append(new_tag) file_node.save() return {'status': 'success'}, httplib.OK return {'status': 'failure'}, httplib.BAD_REQUEST @must_have_permission('write') @decorators.autoload_filenode(must_be='file') def osfstorage_remove_tag(file_node, **kwargs): data = request.get_json() tag = data['tag'] tag = Tag.load(tag) if tag and tag in file_node.tags and not file_node.node.is_registration: file_node.tags.remove(tag) file_node.save() return {'status': 'success'}, httplib.OK return {'status': 'failure'}, httplib.BAD_REQUEST
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 8809, 199, 646, 2050, 199, 199, 504, 3413, 2238, 364, 77, 492, 1413, 199, 504, 3413, 2238, 364, 77, 14, 3494, 14, 1095, 492, 2606, 7965, 1726, 199, 199, 504, 7209, 492, 1056, 199, 199, 504, 10059, 14, 1178, 492, 3590, 199, 504, 10059, 14, 3924, 492, 15050, 199, 504, 10059, 14, 1178, 14, 11582, 492, 1471, 63, 1235, 63, 1737, 199, 199, 504, 10691, 14, 992, 492, 2876, 199, 504, 10691, 14, 1715, 14, 11582, 492, 334, 272, 1471, 63, 1397, 63, 1235, 63, 8054, 12, 1471, 63, 7804, 63, 9291, 12, 1471, 63, 7804, 63, 5693, 199, 9, 199, 504, 10691, 14, 1974, 492, 519, 3375, 527, 199, 504, 10691, 14, 1715, 14, 1238, 492, 965, 63, 12628, 63, 1073, 12, 8053, 199, 199, 504, 10691, 14, 1725, 492, 1709, 199, 504, 10691, 14, 1725, 492, 4967, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 3778, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 20419, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 2202, 465, 747, 70, 63, 3494, 63, 1751, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 747, 70, 63, 3494, 63, 1231, 8, 932, 63, 1751, 12, 1790, 12, 1011, 958, 304, 272, 408, 3425, 869, 7900, 4840, 367, 1738, 1031, 14, 3390, 26, 2387, 1031, 10867, 367, 1890, 13, 2441, 272, 2851, 7143, 367, 14238, 1584, 14, 272, 408, 272, 1031, 275, 1031, 63, 1751, 14, 4597, 272, 1738, 275, 519, 3375, 527, 14, 1506, 63, 9291, 63, 1231, 8, 267, 1031, 63, 1751, 29, 932, 63, 1751, 12, 267, 536, 4581, 267, 3443, 29, 1178, 12, 267, 922, 29, 1178, 14, 751, 12, 267, 1031, 6417, 29, 932, 14, 633, 12, 267, 1031, 7394, 6417, 29, 932, 14, 1246, 63, 633, 12, 272, 776, 272, 372, 359, 1231, 61, 421, 199, 318, 1852, 63, 705, 8, 600, 12, 1245, 63, 3612, 29, 403, 12, 1245, 63, 2809, 29, 403, 304, 272, 666, 275, 1052, 272, 340, 1245, 63, 3612, 26, 267, 666, 459, 1188, 63, 3612, 418, 275, 1245, 63, 3612, 272, 340, 1245, 63, 2809, 26, 267, 666, 459, 1188, 63, 2809, 418, 275, 1245, 63, 2809, 272, 372, 15050, 8, 600, 12, 666, 29, 576, 9, 421, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 7790, 63, 7804, 63, 9291, 360, 20923, 3494, 297, 283, 932, 358, 199, 318, 747, 70, 3494, 63, 873, 63, 2343, 8, 932, 63, 9291, 12, 4886, 12, 1011, 958, 304, 272, 862, 26, 267, 1015, 63, 344, 275, 4886, 459, 1023, 418, 267, 3341, 275, 4886, 459, 2343, 418, 272, 871, 4067, 26, 267, 746, 15050, 8, 12942, 14, 9439, 63, 6780, 9, 339, 1015, 275, 1709, 14, 1173, 3353, 14, 912, 8, 1023, 63, 344, 9, 339, 340, 1015, 365, 488, 26, 267, 746, 15050, 8, 12942, 14, 4609, 63, 13945, 9, 339, 1015, 14, 873, 63, 2343, 8, 2343, 9, 339, 372, 791, 1205, 356, 283, 3742, 936, 199, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 7790, 63, 1235, 534, 493, 358, 199, 318, 747, 70, 3494, 63, 362, 63, 23449, 8, 493, 63, 932, 12, 1031, 63, 9291, 12, 4886, 12, 1011, 958, 304, 272, 365, 63, 21009, 275, 965, 63, 12628, 63, 1073, 8, 932, 63, 9291, 14, 4597, 12, 3590, 8, 4239, 63, 498, 29, 1069, 14, 589, 14, 362, 360, 1345, 63, 2118, 7058, 339, 327, 1432, 22164, 315, 27524, 1865, 272, 372, 469, 267, 283, 23449, 356, 359, 288, 3778, 14, 3549, 63, 5792, 8, 932, 63, 9291, 14, 4597, 12, 570, 63, 932, 12, 1015, 12, 1478, 29, 552, 8, 493, 63, 932, 14, 6234, 9, 446, 4280, 446, 413, 12, 24757, 29, 374, 63, 21009, 9, 288, 367, 4280, 12, 1015, 315, 3874, 8, 13501, 8, 493, 63, 932, 14, 6234, 430, 267, 1622, 272, 789, 421, 199, 32, 11582, 14, 87, 323, 4848, 337, 1435, 63, 2992, 63, 3664, 199, 318, 747, 70, 3494, 63, 1574, 63, 3664, 8, 1365, 12, 5724, 12, 536, 29, 403, 12, 1011, 958, 304, 272, 372, 1350, 14, 1574, 63, 7138, 8, 6881, 12, 536, 29, 354, 680, 3549, 1062, 8809, 14, 26561, 421, 199, 32, 11582, 14, 87, 323, 4848, 337, 1435, 63, 2992, 63, 3664, 199, 318, 747, 70, 3494, 63, 1185, 63, 3664, 8, 1365, 12, 5724, 12, 536, 29, 403, 12, 1011, 958, 304, 272, 862, 26, 267, 372, 1350, 14, 1185, 63, 7138, 8, 6881, 12, 536, 29, 354, 680, 3549, 1062, 8809, 14, 3593, 272, 871, 4967, 14, 1173, 1716, 14627, 2204, 547, 26, 267, 746, 15050, 8, 12942, 14, 9977, 63, 4609, 63, 17350, 12, 666, 3126, 288, 283, 1188, 63, 2809, 356, 283, 6612, 4057, 570, 465, 652, 365, 7923, 734, 3530, 267, 3828, 199, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 885, 63, 1231, 29, 549, 9, 199, 318, 747, 70, 3494, 63, 362, 63, 604, 474, 8, 493, 63, 932, 12, 1031, 63, 9291, 12, 1011, 958, 304, 272, 327, 11768, 14386, 272, 769, 8, 992, 14, 47, 7646, 6408, 7850, 14, 1623, 8, 49, 360, 932, 297, 283, 4077, 297, 1031, 63, 9291, 14, 4597, 1724, 339, 1004, 474, 275, 942, 339, 1830, 570, 63, 932, 26, 267, 1004, 474, 14, 740, 8, 493, 63, 932, 14, 3549, 1012, 267, 570, 63, 932, 275, 570, 63, 932, 14, 1708, 339, 372, 791, 576, 356, 1004, 474, 93, 421, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 885, 63, 1231, 29, 549, 9, 199, 318, 747, 70, 3494, 63, 362, 63, 2343, 8, 493, 63, 932, 12, 1011, 958, 304, 272, 862, 26, 267, 327, 3254, 961, 1077, 1570, 370, 1015, 465, 2399, 5007, 652, 883, 506, 2896, 1263, 521, 267, 1015, 275, 1109, 8, 1069, 14, 589, 14, 362, 360, 5792, 1333, 272, 871, 334, 3393, 12, 3146, 304, 221, 327, 982, 2399, 440, 282, 1329, 267, 1015, 275, 488, 272, 372, 570 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 8809, 199, 646, 2050, 199, 199, 504, 3413, 2238, 364, 77, 492, 1413, 199, 504, 3413, 2238, 364, 77, 14, 3494, 14, 1095, 492, 2606, 7965, 1726, 199, 199, 504, 7209, 492, 1056, 199, 199, 504, 10059, 14, 1178, 492, 3590, 199, 504, 10059, 14, 3924, 492, 15050, 199, 504, 10059, 14, 1178, 14, 11582, 492, 1471, 63, 1235, 63, 1737, 199, 199, 504, 10691, 14, 992, 492, 2876, 199, 504, 10691, 14, 1715, 14, 11582, 492, 334, 272, 1471, 63, 1397, 63, 1235, 63, 8054, 12, 1471, 63, 7804, 63, 9291, 12, 1471, 63, 7804, 63, 5693, 199, 9, 199, 504, 10691, 14, 1974, 492, 519, 3375, 527, 199, 504, 10691, 14, 1715, 14, 1238, 492, 965, 63, 12628, 63, 1073, 12, 8053, 199, 199, 504, 10691, 14, 1725, 492, 1709, 199, 504, 10691, 14, 1725, 492, 4967, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 3778, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 20419, 199, 504, 10691, 14, 10788, 14, 20923, 3494, 492, 2202, 465, 747, 70, 63, 3494, 63, 1751, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 747, 70, 63, 3494, 63, 1231, 8, 932, 63, 1751, 12, 1790, 12, 1011, 958, 304, 272, 408, 3425, 869, 7900, 4840, 367, 1738, 1031, 14, 3390, 26, 2387, 1031, 10867, 367, 1890, 13, 2441, 272, 2851, 7143, 367, 14238, 1584, 14, 272, 408, 272, 1031, 275, 1031, 63, 1751, 14, 4597, 272, 1738, 275, 519, 3375, 527, 14, 1506, 63, 9291, 63, 1231, 8, 267, 1031, 63, 1751, 29, 932, 63, 1751, 12, 267, 536, 4581, 267, 3443, 29, 1178, 12, 267, 922, 29, 1178, 14, 751, 12, 267, 1031, 6417, 29, 932, 14, 633, 12, 267, 1031, 7394, 6417, 29, 932, 14, 1246, 63, 633, 12, 272, 776, 272, 372, 359, 1231, 61, 421, 199, 318, 1852, 63, 705, 8, 600, 12, 1245, 63, 3612, 29, 403, 12, 1245, 63, 2809, 29, 403, 304, 272, 666, 275, 1052, 272, 340, 1245, 63, 3612, 26, 267, 666, 459, 1188, 63, 3612, 418, 275, 1245, 63, 3612, 272, 340, 1245, 63, 2809, 26, 267, 666, 459, 1188, 63, 2809, 418, 275, 1245, 63, 2809, 272, 372, 15050, 8, 600, 12, 666, 29, 576, 9, 421, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 7790, 63, 7804, 63, 9291, 360, 20923, 3494, 297, 283, 932, 358, 199, 318, 747, 70, 3494, 63, 873, 63, 2343, 8, 932, 63, 9291, 12, 4886, 12, 1011, 958, 304, 272, 862, 26, 267, 1015, 63, 344, 275, 4886, 459, 1023, 418, 267, 3341, 275, 4886, 459, 2343, 418, 272, 871, 4067, 26, 267, 746, 15050, 8, 12942, 14, 9439, 63, 6780, 9, 339, 1015, 275, 1709, 14, 1173, 3353, 14, 912, 8, 1023, 63, 344, 9, 339, 340, 1015, 365, 488, 26, 267, 746, 15050, 8, 12942, 14, 4609, 63, 13945, 9, 339, 1015, 14, 873, 63, 2343, 8, 2343, 9, 339, 372, 791, 1205, 356, 283, 3742, 936, 199, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 7790, 63, 1235, 534, 493, 358, 199, 318, 747, 70, 3494, 63, 362, 63, 23449, 8, 493, 63, 932, 12, 1031, 63, 9291, 12, 4886, 12, 1011, 958, 304, 272, 365, 63, 21009, 275, 965, 63, 12628, 63, 1073, 8, 932, 63, 9291, 14, 4597, 12, 3590, 8, 4239, 63, 498, 29, 1069, 14, 589, 14, 362, 360, 1345, 63, 2118, 7058, 339, 327, 1432, 22164, 315, 27524, 1865, 272, 372, 469, 267, 283, 23449, 356, 359, 288, 3778, 14, 3549, 63, 5792, 8, 932, 63, 9291, 14, 4597, 12, 570, 63, 932, 12, 1015, 12, 1478, 29, 552, 8, 493, 63, 932, 14, 6234, 9, 446, 4280, 446, 413, 12, 24757, 29, 374, 63, 21009, 9, 288, 367, 4280, 12, 1015, 315, 3874, 8, 13501, 8, 493, 63, 932, 14, 6234, 430, 267, 1622, 272, 789, 421, 199, 32, 11582, 14, 87, 323, 4848, 337, 1435, 63, 2992, 63, 3664, 199, 318, 747, 70, 3494, 63, 1574, 63, 3664, 8, 1365, 12, 5724, 12, 536, 29, 403, 12, 1011, 958, 304, 272, 372, 1350, 14, 1574, 63, 7138, 8, 6881, 12, 536, 29, 354, 680, 3549, 1062, 8809, 14, 26561, 421, 199, 32, 11582, 14, 87, 323, 4848, 337, 1435, 63, 2992, 63, 3664, 199, 318, 747, 70, 3494, 63, 1185, 63, 3664, 8, 1365, 12, 5724, 12, 536, 29, 403, 12, 1011, 958, 304, 272, 862, 26, 267, 372, 1350, 14, 1185, 63, 7138, 8, 6881, 12, 536, 29, 354, 680, 3549, 1062, 8809, 14, 3593, 272, 871, 4967, 14, 1173, 1716, 14627, 2204, 547, 26, 267, 746, 15050, 8, 12942, 14, 9977, 63, 4609, 63, 17350, 12, 666, 3126, 288, 283, 1188, 63, 2809, 356, 283, 6612, 4057, 570, 465, 652, 365, 7923, 734, 3530, 267, 3828, 199, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 885, 63, 1231, 29, 549, 9, 199, 318, 747, 70, 3494, 63, 362, 63, 604, 474, 8, 493, 63, 932, 12, 1031, 63, 9291, 12, 1011, 958, 304, 272, 327, 11768, 14386, 272, 769, 8, 992, 14, 47, 7646, 6408, 7850, 14, 1623, 8, 49, 360, 932, 297, 283, 4077, 297, 1031, 63, 9291, 14, 4597, 1724, 339, 1004, 474, 275, 942, 339, 1830, 570, 63, 932, 26, 267, 1004, 474, 14, 740, 8, 493, 63, 932, 14, 3549, 1012, 267, 570, 63, 932, 275, 570, 63, 932, 14, 1708, 339, 372, 791, 576, 356, 1004, 474, 93, 421, 199, 32, 7790, 63, 1235, 63, 1737, 199, 32, 11582, 14, 2495, 912, 63, 493, 932, 8, 885, 63, 1231, 29, 549, 9, 199, 318, 747, 70, 3494, 63, 362, 63, 2343, 8, 493, 63, 932, 12, 1011, 958, 304, 272, 862, 26, 267, 327, 3254, 961, 1077, 1570, 370, 1015, 465, 2399, 5007, 652, 883, 506, 2896, 1263, 521, 267, 1015, 275, 1109, 8, 1069, 14, 589, 14, 362, 360, 5792, 1333, 272, 871, 334, 3393, 12, 3146, 304, 221, 327, 982, 2399, 440, 282, 1329, 267, 1015, 275, 488, 272, 372, 570, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hainm/MSMs
code/sandbox/tica_kde_svm.py
3
2319
from sklearn.covariance import EllipticEnvelope import sklearn.neighbors from sklearn.svm import OneClassSVM import os from msmbuilder import example_datasets, cluster, msm, featurizer, lumping, utils, dataset, decomposition sysname = os.path.split(os.getcwd())[-1] dt = 0.25 tica_lagtime = 400 regularization_string = "_012" X0 = dataset.dataset("./tica/tica%d%s.h5" % (tica_lagtime, regularization_string)) slicer = featurizer.FirstSlicer(2) X = slicer.transform(X0) Xf0 = np.concatenate(X) Xf = Xf0[::50] hexbin(Xf0[:, 0], Xf0[:, 1], bins='log') svm = OneClassSVM(nu=0.15) svm.fit(Xf) y = svm.predict(Xf) plot(Xf[y==1][:, 0], Xf[y==1][:, 1], 'kx') plot(Xf[y==-1][:, 0], Xf[y==-1][:, 1], 'wx') clusterer = cluster.GMM(n_components=3) yi = map(lambda x: svm.predict(x), X) from msmbuilder.cluster import MultiSequenceClusterMixin, BaseEstimator from sklearn.svm import OneClassSVM class OneClassSVMTrimmer(MultiSequenceClusterMixin, OneClassSVM, BaseEstimator): def partial_transform(self, traj): """Featurize an MD trajectory into a vector space. Parameters ---------- traj : mdtraj.Trajectory A molecular dynamics trajectory to featurize. Returns ------- features : np.ndarray, dtype=float, shape=(n_samples, n_features) A featurized trajectory is a 2D array of shape `(length_of_trajectory x n_features)` where each `features[i]` vector is computed by applying the featurization function to the `i`th snapshot of the input trajectory. See Also -------- transform : simultaneously featurize a collection of MD trajectories """ pass def transform(self, traj_list, y=None): """Featurize a several trajectories. Parameters ---------- traj_list : list(mdtraj.Trajectory) Trajectories to be featurized. Returns ------- features : list(np.ndarray), length = len(traj_list) The featurized trajectories. features[i] is the featurized version of traj_list[i] and has shape (n_samples_i, n_features) """ return [self.partial_transform(traj) for traj in traj_list] trimmer = OneClassSVMTrimmer() trimmer.fit(X[0:10])
gpl-2.0
[ 504, 6357, 14, 15024, 492, 27761, 764, 28278, 199, 646, 6357, 14, 11113, 199, 504, 6357, 14, 16820, 492, 7309, 2543, 29389, 199, 646, 747, 199, 504, 333, 3300, 5649, 492, 2893, 63, 12281, 12, 4350, 12, 333, 3300, 12, 13953, 300, 1793, 12, 634, 1220, 316, 12, 3778, 12, 4789, 12, 22706, 199, 199, 1274, 354, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 9458, 1012, 1988, 17, 61, 199, 3583, 275, 378, 14, 821, 199, 15922, 63, 1823, 521, 275, 8290, 199, 18948, 63, 875, 275, 2668, 11533, 2, 199, 199, 56, 16, 275, 4789, 14, 5214, 28615, 15922, 15, 15922, 5, 68, 5, 83, 14, 72, 21, 2, 450, 334, 15922, 63, 1823, 521, 12, 21095, 63, 875, 430, 199, 199, 83, 27975, 275, 13953, 300, 1793, 14, 7147, 51, 27975, 8, 18, 9, 199, 56, 275, 308, 27975, 14, 4711, 8, 56, 16, 9, 199, 199, 56, 70, 16, 275, 980, 14, 13433, 8, 56, 9, 199, 56, 70, 275, 1323, 70, 16, 10345, 1400, 61, 4388, 199, 4097, 1393, 8, 56, 70, 16, 3981, 378, 467, 1323, 70, 16, 3981, 413, 467, 13341, 534, 793, 358, 199, 199, 16820, 275, 7309, 2543, 29389, 8, 4850, 29, 16, 14, 1046, 9, 199, 16820, 14, 3269, 8, 56, 70, 9, 421, 199, 89, 275, 23044, 14, 6892, 8, 56, 70, 9, 199, 199, 2798, 8, 56, 70, 59, 89, 389, 17, 61, 3981, 378, 467, 1323, 70, 59, 89, 389, 17, 61, 3981, 413, 467, 283, 75, 88, 358, 199, 2798, 8, 56, 70, 59, 89, 389, 13, 17, 61, 3981, 378, 467, 1323, 70, 59, 89, 389, 13, 17, 61, 3981, 413, 467, 283, 6323, 358, 199, 199, 429, 527, 266, 3859, 275, 4350, 14, 39, 3218, 8, 78, 63, 4608, 29, 19, 9, 421, 199, 21643, 275, 2341, 8, 2734, 671, 26, 23044, 14, 6892, 8, 88, 395, 1323, 9, 421, 199, 504, 333, 3300, 5649, 14, 4201, 492, 6879, 5826, 9581, 4256, 12, 3523, 13183, 199, 504, 6357, 14, 16820, 492, 7309, 2543, 29389, 199, 199, 533, 7309, 2543, 4985, 5747, 31898, 2626, 8, 3947, 5826, 9581, 4256, 12, 7309, 2543, 29389, 12, 3523, 13183, 304, 272, 347, 7417, 63, 4711, 8, 277, 12, 1468, 74, 304, 267, 408, 24927, 300, 794, 376, 15830, 30595, 1901, 282, 5477, 4601, 14, 398, 3897, 267, 4143, 267, 1468, 74, 520, 6128, 22788, 14, 2437, 17928, 288, 437, 1303, 10251, 2238, 31388, 2932, 30595, 370, 13953, 300, 794, 14, 398, 1803, 267, 5514, 267, 4534, 520, 980, 14, 8237, 12, 2152, 29, 1609, 12, 2215, 2687, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 437, 13953, 300, 1759, 30595, 365, 282, 499, 36, 1625, 402, 2215, 288, 16918, 1267, 63, 1618, 63, 30575, 671, 302, 63, 3179, 12544, 2382, 1924, 658, 3179, 59, 73, 16090, 288, 5477, 365, 9235, 701, 18876, 314, 13953, 300, 2072, 805, 288, 370, 314, 658, 73, 64, 273, 5740, 402, 314, 1324, 30595, 14, 398, 1666, 6121, 267, 3001, 267, 5793, 520, 27008, 590, 13953, 300, 794, 282, 3245, 402, 15830, 1468, 963, 6112, 267, 408, 267, 986, 339, 347, 5793, 8, 277, 12, 1468, 74, 63, 513, 12, 612, 29, 403, 304, 267, 408, 24927, 300, 794, 282, 9978, 1468, 963, 6112, 14, 398, 3897, 267, 4143, 267, 1468, 74, 63, 513, 520, 769, 8, 1064, 22788, 14, 2437, 17928, 9, 288, 12643, 963, 6112, 370, 506, 13953, 300, 1759, 14, 398, 1803, 267, 5514, 267, 4534, 520, 769, 8, 1590, 14, 8237, 395, 2582, 275, 822, 8, 22788, 63, 513, 9, 288, 710, 13953, 300, 1759, 1468, 963, 6112, 14, 221, 4534, 59, 73, 61, 365, 314, 13953, 300, 1759, 288, 1015, 402, 1468, 74, 63, 513, 59, 73, 61, 436, 965, 2215, 288, 334, 78, 63, 3356, 63, 73, 12, 302, 63, 3179, 9, 267, 408, 267, 372, 359, 277, 14, 6672, 63, 4711, 8, 22788, 9, 367, 1468, 74, 315, 1468, 74, 63, 513, 61, 421, 199, 12263, 2626, 275, 7309, 2543, 4985, 5747, 31898, 2626, 342, 199, 12263, 2626, 14, 3269, 8, 56, 59, 16, 26, 709, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6357, 14, 15024, 492, 27761, 764, 28278, 199, 646, 6357, 14, 11113, 199, 504, 6357, 14, 16820, 492, 7309, 2543, 29389, 199, 646, 747, 199, 504, 333, 3300, 5649, 492, 2893, 63, 12281, 12, 4350, 12, 333, 3300, 12, 13953, 300, 1793, 12, 634, 1220, 316, 12, 3778, 12, 4789, 12, 22706, 199, 199, 1274, 354, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 9458, 1012, 1988, 17, 61, 199, 3583, 275, 378, 14, 821, 199, 15922, 63, 1823, 521, 275, 8290, 199, 18948, 63, 875, 275, 2668, 11533, 2, 199, 199, 56, 16, 275, 4789, 14, 5214, 28615, 15922, 15, 15922, 5, 68, 5, 83, 14, 72, 21, 2, 450, 334, 15922, 63, 1823, 521, 12, 21095, 63, 875, 430, 199, 199, 83, 27975, 275, 13953, 300, 1793, 14, 7147, 51, 27975, 8, 18, 9, 199, 56, 275, 308, 27975, 14, 4711, 8, 56, 16, 9, 199, 199, 56, 70, 16, 275, 980, 14, 13433, 8, 56, 9, 199, 56, 70, 275, 1323, 70, 16, 10345, 1400, 61, 4388, 199, 4097, 1393, 8, 56, 70, 16, 3981, 378, 467, 1323, 70, 16, 3981, 413, 467, 13341, 534, 793, 358, 199, 199, 16820, 275, 7309, 2543, 29389, 8, 4850, 29, 16, 14, 1046, 9, 199, 16820, 14, 3269, 8, 56, 70, 9, 421, 199, 89, 275, 23044, 14, 6892, 8, 56, 70, 9, 199, 199, 2798, 8, 56, 70, 59, 89, 389, 17, 61, 3981, 378, 467, 1323, 70, 59, 89, 389, 17, 61, 3981, 413, 467, 283, 75, 88, 358, 199, 2798, 8, 56, 70, 59, 89, 389, 13, 17, 61, 3981, 378, 467, 1323, 70, 59, 89, 389, 13, 17, 61, 3981, 413, 467, 283, 6323, 358, 199, 199, 429, 527, 266, 3859, 275, 4350, 14, 39, 3218, 8, 78, 63, 4608, 29, 19, 9, 421, 199, 21643, 275, 2341, 8, 2734, 671, 26, 23044, 14, 6892, 8, 88, 395, 1323, 9, 421, 199, 504, 333, 3300, 5649, 14, 4201, 492, 6879, 5826, 9581, 4256, 12, 3523, 13183, 199, 504, 6357, 14, 16820, 492, 7309, 2543, 29389, 199, 199, 533, 7309, 2543, 4985, 5747, 31898, 2626, 8, 3947, 5826, 9581, 4256, 12, 7309, 2543, 29389, 12, 3523, 13183, 304, 272, 347, 7417, 63, 4711, 8, 277, 12, 1468, 74, 304, 267, 408, 24927, 300, 794, 376, 15830, 30595, 1901, 282, 5477, 4601, 14, 398, 3897, 267, 4143, 267, 1468, 74, 520, 6128, 22788, 14, 2437, 17928, 288, 437, 1303, 10251, 2238, 31388, 2932, 30595, 370, 13953, 300, 794, 14, 398, 1803, 267, 5514, 267, 4534, 520, 980, 14, 8237, 12, 2152, 29, 1609, 12, 2215, 2687, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 437, 13953, 300, 1759, 30595, 365, 282, 499, 36, 1625, 402, 2215, 288, 16918, 1267, 63, 1618, 63, 30575, 671, 302, 63, 3179, 12544, 2382, 1924, 658, 3179, 59, 73, 16090, 288, 5477, 365, 9235, 701, 18876, 314, 13953, 300, 2072, 805, 288, 370, 314, 658, 73, 64, 273, 5740, 402, 314, 1324, 30595, 14, 398, 1666, 6121, 267, 3001, 267, 5793, 520, 27008, 590, 13953, 300, 794, 282, 3245, 402, 15830, 1468, 963, 6112, 267, 408, 267, 986, 339, 347, 5793, 8, 277, 12, 1468, 74, 63, 513, 12, 612, 29, 403, 304, 267, 408, 24927, 300, 794, 282, 9978, 1468, 963, 6112, 14, 398, 3897, 267, 4143, 267, 1468, 74, 63, 513, 520, 769, 8, 1064, 22788, 14, 2437, 17928, 9, 288, 12643, 963, 6112, 370, 506, 13953, 300, 1759, 14, 398, 1803, 267, 5514, 267, 4534, 520, 769, 8, 1590, 14, 8237, 395, 2582, 275, 822, 8, 22788, 63, 513, 9, 288, 710, 13953, 300, 1759, 1468, 963, 6112, 14, 221, 4534, 59, 73, 61, 365, 314, 13953, 300, 1759, 288, 1015, 402, 1468, 74, 63, 513, 59, 73, 61, 436, 965, 2215, 288, 334, 78, 63, 3356, 63, 73, 12, 302, 63, 3179, 9, 267, 408, 267, 372, 359, 277, 14, 6672, 63, 4711, 8, 22788, 9, 367, 1468, 74, 315, 1468, 74, 63, 513, 61, 421, 199, 12263, 2626, 275, 7309, 2543, 4985, 5747, 31898, 2626, 342, 199, 12263, 2626, 14, 3269, 8, 56, 59, 16, 26, 709, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
dariemp/odoo
addons/survey/wizard/__init__.py
385
1026
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import survey_email_compose_message
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, 259, 1898, 334, 35, 9, 8353, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16576, 63, 2123, 63, 12607, 63, 1188, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 259, 1898, 334, 35, 9, 8353, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16576, 63, 2123, 63, 12607, 63, 1188, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
QualiSystems/Azure-Shell
package/cloudshell/cp/azure/domain/common/vm_details_provider.py
1
5896
from azure.mgmt.compute.models import StorageAccountTypes from cloudshell.cp.core.models import VmDetailsProperty, VmDetailsData, VmDetailsNetworkInterface from cloudshell.cp.azure.domain.vm_management.operations.deploy_operation import get_ip_from_interface_name class VmDetailsProvider(object): def __init__(self, network_service, resource_id_parser): """ :param cloudshell.cp.azure.domain.services.network_service.NetworkService network_service: :param AzureResourceIdParser resource_id_parser: :return: """ self.network_service = network_service self.resource_id_parser = resource_id_parser def create(self, instance, is_market_place, logger, network_client, group_name): """ :param group_name: :param network_client: :param instance: azure.mgmt.compute.models.VirtualMachine :param is_market_place: bool :param logging.Logger logger: :return: """ vm_instance_data = None vm_network_data = None if is_market_place: vm_instance_data = self._get_vm_instance_data_for_market_place(instance) vm_network_data = self._get_vm_network_data(instance, network_client, group_name, logger) logger.info("VM {} was created via market place.".format(instance.name)) else: vm_instance_data = self._get_vm_instance_data_for_custom_image(instance) vm_network_data = self._get_vm_network_data(instance, network_client, group_name, logger) logger.info("VM {} was created via custom image.".format(instance.name)) return VmDetailsData(vmInstanceData=vm_instance_data, vmNetworkData=vm_network_data) @staticmethod def _get_vm_instance_data_for_market_place(instance): data = [ VmDetailsProperty(key='Image Publisher',value= instance.storage_profile.image_reference.publisher), VmDetailsProperty(key='Image Offer',value= instance.storage_profile.image_reference.offer), VmDetailsProperty(key='Image SKU',value= instance.storage_profile.image_reference.sku), VmDetailsProperty(key='VM Size',value= instance.hardware_profile.vm_size), VmDetailsProperty(key='Operating System',value= instance.storage_profile.os_disk.os_type.name), VmDetailsProperty(key='Disk Type',value= 'HDD' if instance.storage_profile.os_disk.managed_disk.storage_account_type == StorageAccountTypes.standard_lrs else 'SSD') ] return data def _get_vm_instance_data_for_custom_image(self, instance): image_name = self.resource_id_parser.get_image_name(resource_id=instance.storage_profile.image_reference.id) resource_group = self.resource_id_parser.get_resource_group_name(resource_id=instance.storage_profile.image_reference.id) data = [ VmDetailsProperty(key='Image',value= image_name), VmDetailsProperty(key='Image Resource Group',value= resource_group), VmDetailsProperty(key='VM Size',value= instance.hardware_profile.vm_size), VmDetailsProperty(key='Operating System',value= instance.storage_profile.os_disk.os_type.name), VmDetailsProperty(key='Disk Type',value= 'HDD' if instance.storage_profile.os_disk.managed_disk.storage_account_type == StorageAccountTypes.standard_lrs else 'SSD') ] return data def _get_vm_network_data(self, instance, network_client, group_name, logger): network_interface_objects = [] for network_interface in instance.network_profile.network_interfaces: nic_name = self.resource_id_parser.get_name_from_resource_id(network_interface.id) nic = network_client.network_interfaces.get(group_name, nic_name) ip_configuration = nic.ip_configurations[0] private_ip = ip_configuration.private_ip_address public_ip = '' network_data = [VmDetailsProperty(key="IP", value=ip_configuration.private_ip_address)] subnet_name = ip_configuration.subnet.id.split('/')[-1] current_interface = VmDetailsNetworkInterface(interfaceId=nic.resource_guid, networkId=subnet_name, isPrimary=nic.primary, networkData=network_data, privateIpAddress=private_ip, publicIpAddress=public_ip) if ip_configuration.public_ip_address: public_ip_name = get_ip_from_interface_name(nic_name) public_ip_object = self.network_service.get_public_ip(network_client=network_client, group_name=group_name, ip_name=public_ip_name) public_ip = public_ip_object.ip_address network_data.append(VmDetailsProperty(key="Public IP", value=public_ip)) network_data.append( VmDetailsProperty(key="Public IP Type", value=public_ip_object.public_ip_allocation_method)) # logger.info("VM {} was created with public IP '{}'.".format(instance.name, # ip_configuration.public_ip_address.ip_address)) logger.info("VM {} was created with public IP '{}'.".format(instance.name, public_ip)) network_data.append(VmDetailsProperty(key="MAC Address", value=nic.mac_address)) network_interface_objects.append(current_interface) return network_interface_objects
apache-2.0
[ 504, 13601, 14, 9752, 14, 3357, 14, 992, 492, 10533, 6009, 4100, 199, 504, 8002, 5641, 14, 1850, 14, 1018, 14, 992, 492, 812, 77, 11347, 3697, 12, 812, 77, 11347, 1451, 12, 812, 77, 11347, 4491, 4267, 199, 199, 504, 8002, 5641, 14, 1850, 14, 9078, 14, 2261, 14, 2611, 63, 8110, 14, 8170, 14, 11060, 63, 5735, 492, 664, 63, 711, 63, 504, 63, 3266, 63, 354, 421, 199, 533, 812, 77, 11347, 6663, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2784, 63, 1364, 12, 2073, 63, 344, 63, 2087, 304, 267, 408, 267, 520, 635, 8002, 5641, 14, 1850, 14, 9078, 14, 2261, 14, 5950, 14, 1200, 63, 1364, 14, 4491, 3167, 2784, 63, 1364, 26, 267, 520, 635, 15474, 4031, 1304, 2842, 2073, 63, 344, 63, 2087, 26, 267, 520, 1107, 26, 267, 408, 267, 291, 14, 1200, 63, 1364, 275, 2784, 63, 1364, 267, 291, 14, 1927, 63, 344, 63, 2087, 275, 2073, 63, 344, 63, 2087, 339, 347, 1218, 8, 277, 12, 1256, 12, 365, 63, 22270, 63, 2778, 12, 2512, 12, 2784, 63, 1258, 12, 1572, 63, 354, 304, 267, 408, 267, 520, 635, 1572, 63, 354, 26, 267, 520, 635, 2784, 63, 1258, 26, 267, 520, 635, 1256, 26, 13601, 14, 9752, 14, 3357, 14, 992, 14, 29863, 267, 520, 635, 365, 63, 22270, 63, 2778, 26, 2155, 267, 520, 635, 2050, 14, 4455, 2512, 26, 267, 520, 1107, 26, 267, 408, 267, 4169, 63, 842, 63, 576, 275, 488, 267, 4169, 63, 1200, 63, 576, 275, 488, 398, 340, 365, 63, 22270, 63, 2778, 26, 288, 4169, 63, 842, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 22270, 63, 2778, 8, 842, 9, 288, 4169, 63, 1200, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 1200, 63, 576, 8, 842, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 9, 288, 2512, 14, 815, 480, 6849, 1052, 1990, 2737, 4799, 26584, 4192, 15848, 908, 8, 842, 14, 354, 430, 267, 587, 26, 288, 4169, 63, 842, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 4229, 63, 1569, 8, 842, 9, 288, 4169, 63, 1200, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 1200, 63, 576, 8, 842, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 9, 288, 2512, 14, 815, 480, 6849, 1052, 1990, 2737, 4799, 3537, 1834, 15848, 908, 8, 842, 14, 354, 430, 398, 372, 812, 77, 11347, 1451, 8, 2611, 3244, 1451, 29, 2611, 63, 842, 63, 576, 12, 4169, 4491, 1451, 29, 2611, 63, 1200, 63, 576, 9, 339, 768, 4639, 272, 347, 485, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 22270, 63, 2778, 8, 842, 304, 267, 666, 275, 359, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 19952, 281, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 12789, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 593, 1260, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 12786, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 20062, 53, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 27772, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 6849, 14579, 297, 585, 29, 1256, 14, 16529, 63, 2913, 14, 2611, 63, 890, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 23699, 6187, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 736, 63, 466, 14, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 10690, 2434, 297, 585, 29, 2574, 283, 40, 5745, 7, 340, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 11122, 63, 4032, 14, 3494, 63, 2048, 63, 466, 508, 10533, 6009, 4100, 14, 6807, 63, 76, 2393, 587, 283, 2300, 36, 358, 267, 1622, 267, 372, 666, 339, 347, 485, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 4229, 63, 1569, 8, 277, 12, 1256, 304, 267, 1834, 63, 354, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 1569, 63, 354, 8, 1927, 63, 344, 29, 842, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 344, 9, 267, 2073, 63, 923, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 1927, 63, 923, 63, 354, 8, 1927, 63, 344, 29, 842, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 344, 9, 398, 666, 275, 359, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 297, 585, 29, 1834, 63, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 7337, 5611, 297, 585, 29, 2073, 63, 923, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 6849, 14579, 297, 585, 29, 1256, 14, 16529, 63, 2913, 14, 2611, 63, 890, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 23699, 6187, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 736, 63, 466, 14, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 10690, 2434, 297, 585, 29, 2574, 283, 40, 5745, 7, 340, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 11122, 63, 4032, 14, 3494, 63, 2048, 63, 466, 508, 10533, 6009, 4100, 14, 6807, 63, 76, 2393, 587, 283, 2300, 36, 358, 267, 1622, 267, 372, 666, 339, 347, 485, 362, 63, 2611, 63, 1200, 63, 576, 8, 277, 12, 1256, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 304, 398, 2784, 63, 3266, 63, 1462, 275, 942, 267, 367, 2784, 63, 3266, 315, 1256, 14, 1200, 63, 2913, 14, 1200, 63, 7436, 26, 288, 14304, 63, 354, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 354, 63, 504, 63, 1927, 63, 344, 8, 1200, 63, 3266, 14, 344, 9, 953, 14304, 275, 2784, 63, 1258, 14, 1200, 63, 7436, 14, 362, 8, 923, 63, 354, 12, 14304, 63, 354, 9, 953, 3384, 63, 4758, 275, 14304, 14, 711, 63, 10057, 59, 16, 61, 953, 5726, 63, 711, 275, 3384, 63, 4758, 14, 4239, 63, 711, 63, 1562, 288, 4575 ]
[ 13601, 14, 9752, 14, 3357, 14, 992, 492, 10533, 6009, 4100, 199, 504, 8002, 5641, 14, 1850, 14, 1018, 14, 992, 492, 812, 77, 11347, 3697, 12, 812, 77, 11347, 1451, 12, 812, 77, 11347, 4491, 4267, 199, 199, 504, 8002, 5641, 14, 1850, 14, 9078, 14, 2261, 14, 2611, 63, 8110, 14, 8170, 14, 11060, 63, 5735, 492, 664, 63, 711, 63, 504, 63, 3266, 63, 354, 421, 199, 533, 812, 77, 11347, 6663, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2784, 63, 1364, 12, 2073, 63, 344, 63, 2087, 304, 267, 408, 267, 520, 635, 8002, 5641, 14, 1850, 14, 9078, 14, 2261, 14, 5950, 14, 1200, 63, 1364, 14, 4491, 3167, 2784, 63, 1364, 26, 267, 520, 635, 15474, 4031, 1304, 2842, 2073, 63, 344, 63, 2087, 26, 267, 520, 1107, 26, 267, 408, 267, 291, 14, 1200, 63, 1364, 275, 2784, 63, 1364, 267, 291, 14, 1927, 63, 344, 63, 2087, 275, 2073, 63, 344, 63, 2087, 339, 347, 1218, 8, 277, 12, 1256, 12, 365, 63, 22270, 63, 2778, 12, 2512, 12, 2784, 63, 1258, 12, 1572, 63, 354, 304, 267, 408, 267, 520, 635, 1572, 63, 354, 26, 267, 520, 635, 2784, 63, 1258, 26, 267, 520, 635, 1256, 26, 13601, 14, 9752, 14, 3357, 14, 992, 14, 29863, 267, 520, 635, 365, 63, 22270, 63, 2778, 26, 2155, 267, 520, 635, 2050, 14, 4455, 2512, 26, 267, 520, 1107, 26, 267, 408, 267, 4169, 63, 842, 63, 576, 275, 488, 267, 4169, 63, 1200, 63, 576, 275, 488, 398, 340, 365, 63, 22270, 63, 2778, 26, 288, 4169, 63, 842, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 22270, 63, 2778, 8, 842, 9, 288, 4169, 63, 1200, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 1200, 63, 576, 8, 842, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 9, 288, 2512, 14, 815, 480, 6849, 1052, 1990, 2737, 4799, 26584, 4192, 15848, 908, 8, 842, 14, 354, 430, 267, 587, 26, 288, 4169, 63, 842, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 4229, 63, 1569, 8, 842, 9, 288, 4169, 63, 1200, 63, 576, 275, 291, 423, 362, 63, 2611, 63, 1200, 63, 576, 8, 842, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 9, 288, 2512, 14, 815, 480, 6849, 1052, 1990, 2737, 4799, 3537, 1834, 15848, 908, 8, 842, 14, 354, 430, 398, 372, 812, 77, 11347, 1451, 8, 2611, 3244, 1451, 29, 2611, 63, 842, 63, 576, 12, 4169, 4491, 1451, 29, 2611, 63, 1200, 63, 576, 9, 339, 768, 4639, 272, 347, 485, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 22270, 63, 2778, 8, 842, 304, 267, 666, 275, 359, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 19952, 281, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 12789, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 593, 1260, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 12786, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 20062, 53, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 27772, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 6849, 14579, 297, 585, 29, 1256, 14, 16529, 63, 2913, 14, 2611, 63, 890, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 23699, 6187, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 736, 63, 466, 14, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 10690, 2434, 297, 585, 29, 2574, 283, 40, 5745, 7, 340, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 11122, 63, 4032, 14, 3494, 63, 2048, 63, 466, 508, 10533, 6009, 4100, 14, 6807, 63, 76, 2393, 587, 283, 2300, 36, 358, 267, 1622, 267, 372, 666, 339, 347, 485, 362, 63, 2611, 63, 842, 63, 576, 63, 509, 63, 4229, 63, 1569, 8, 277, 12, 1256, 304, 267, 1834, 63, 354, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 1569, 63, 354, 8, 1927, 63, 344, 29, 842, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 344, 9, 267, 2073, 63, 923, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 1927, 63, 923, 63, 354, 8, 1927, 63, 344, 29, 842, 14, 3494, 63, 2913, 14, 1569, 63, 4443, 14, 344, 9, 398, 666, 275, 359, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 297, 585, 29, 1834, 63, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 3491, 7337, 5611, 297, 585, 29, 2073, 63, 923, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 6849, 14579, 297, 585, 29, 1256, 14, 16529, 63, 2913, 14, 2611, 63, 890, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 23699, 6187, 297, 585, 29, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 736, 63, 466, 14, 354, 395, 288, 812, 77, 11347, 3697, 8, 498, 534, 10690, 2434, 297, 585, 29, 2574, 283, 40, 5745, 7, 340, 1256, 14, 3494, 63, 2913, 14, 736, 63, 4032, 14, 11122, 63, 4032, 14, 3494, 63, 2048, 63, 466, 508, 10533, 6009, 4100, 14, 6807, 63, 76, 2393, 587, 283, 2300, 36, 358, 267, 1622, 267, 372, 666, 339, 347, 485, 362, 63, 2611, 63, 1200, 63, 576, 8, 277, 12, 1256, 12, 2784, 63, 1258, 12, 1572, 63, 354, 12, 2512, 304, 398, 2784, 63, 3266, 63, 1462, 275, 942, 267, 367, 2784, 63, 3266, 315, 1256, 14, 1200, 63, 2913, 14, 1200, 63, 7436, 26, 288, 14304, 63, 354, 275, 291, 14, 1927, 63, 344, 63, 2087, 14, 362, 63, 354, 63, 504, 63, 1927, 63, 344, 8, 1200, 63, 3266, 14, 344, 9, 953, 14304, 275, 2784, 63, 1258, 14, 1200, 63, 7436, 14, 362, 8, 923, 63, 354, 12, 14304, 63, 354, 9, 953, 3384, 63, 4758, 275, 14304, 14, 711, 63, 10057, 59, 16,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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 ]
fengjian/libinjection
src/sqlparse2c.py
3
3800
#!/usr/bin/env python # # Copyright 2012, 2013 Nick Galbreath # nickg@client9.com # BSD License -- see COPYING.txt for details # """ Converts a libinjection JSON data file to a C header (.h) file """ import sys def toc(obj): """ main routine """ print """ #ifndef LIBINJECTION_SQLI_DATA_H #define LIBINJECTION_SQLI_DATA_H #include "libinjection.h" #include "libinjection_sqli.h" typedef struct { const char *word; char type; } keyword_t; static size_t parse_money(sfilter * sf); static size_t parse_other(sfilter * sf); static size_t parse_white(sfilter * sf); static size_t parse_operator1(sfilter *sf); static size_t parse_char(sfilter *sf); static size_t parse_hash(sfilter *sf); static size_t parse_dash(sfilter *sf); static size_t parse_slash(sfilter *sf); static size_t parse_backslash(sfilter * sf); static size_t parse_operator2(sfilter *sf); static size_t parse_string(sfilter *sf); static size_t parse_word(sfilter * sf); static size_t parse_var(sfilter * sf); static size_t parse_number(sfilter * sf); static size_t parse_tick(sfilter * sf); static size_t parse_ustring(sfilter * sf); static size_t parse_qstring(sfilter * sf); static size_t parse_nqstring(sfilter * sf); static size_t parse_xstring(sfilter * sf); static size_t parse_bstring(sfilter * sf); static size_t parse_estring(sfilter * sf); static size_t parse_bword(sfilter * sf); """ # # Mapping of character to function # fnmap = { 'CHAR_WORD' : 'parse_word', 'CHAR_WHITE': 'parse_white', 'CHAR_OP1' : 'parse_operator1', 'CHAR_UNARY': 'parse_operator1', 'CHAR_OP2' : 'parse_operator2', 'CHAR_BANG' : 'parse_operator2', 'CHAR_BACK' : 'parse_backslash', 'CHAR_DASH' : 'parse_dash', 'CHAR_STR' : 'parse_string', 'CHAR_HASH' : 'parse_hash', 'CHAR_NUM' : 'parse_number', 'CHAR_SLASH': 'parse_slash', 'CHAR_SEMICOLON' : 'parse_char', 'CHAR_COMMA': 'parse_char', 'CHAR_LEFTPARENS': 'parse_char', 'CHAR_RIGHTPARENS': 'parse_char', 'CHAR_LEFTBRACE': 'parse_char', 'CHAR_RIGHTBRACE': 'parse_char', 'CHAR_VAR' : 'parse_var', 'CHAR_OTHER': 'parse_other', 'CHAR_MONEY': 'parse_money', 'CHAR_TICK' : 'parse_tick', 'CHAR_UNDERSCORE': 'parse_underscore', 'CHAR_USTRING' : 'parse_ustring', 'CHAR_QSTRING' : 'parse_qstring', 'CHAR_NQSTRING' : 'parse_nqstring', 'CHAR_XSTRING' : 'parse_xstring', 'CHAR_BSTRING' : 'parse_bstring', 'CHAR_ESTRING' : 'parse_estring', 'CHAR_BWORD' : 'parse_bword' } print print "typedef size_t (*pt2Function)(sfilter *sf);" print "static const pt2Function char_parse_map[] = {" pos = 0 for character in obj['charmap']: print " &%s, /* %d */" % (fnmap[character], pos) pos += 1 print "};" print # keywords # load them keywords = obj['keywords'] for fingerprint in list(obj[u'fingerprints']): fingerprint = '0' + fingerprint.upper() keywords[fingerprint] = 'F' needhelp = [] for key in keywords.iterkeys(): if key != key.upper(): needhelp.append(key) for key in needhelp: tmpv = keywords[key] del keywords[key] keywords[key.upper()] = tmpv print "static const keyword_t sql_keywords[] = {" for k in sorted(keywords.keys()): if len(k) > 31: sys.stderr.write("ERROR: keyword greater than 32 chars\n") sys.exit(1) print " {\"%s\", '%s'}," % (k, keywords[k]) print "};" print "static const size_t sql_keywords_sz = %d;" % (len(keywords), ) print "#endif" return 0 if __name__ == '__main__': import json sys.exit(toc(json.load(sys.stdin)))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 221, 1898, 6029, 12, 6171, 653, 2000, 598, 279, 10205, 1619, 199, 3, 221, 14900, 71, 32, 1258, 25, 14, 957, 199, 3, 221, 6289, 844, 1553, 1937, 9685, 14, 2424, 367, 2436, 199, 3, 199, 199, 624, 199, 17729, 282, 1973, 262, 8923, 4840, 666, 570, 370, 282, 445, 1406, 17048, 72, 9, 570, 199, 624, 199, 199, 646, 984, 199, 199, 318, 22021, 8, 1113, 304, 272, 408, 2446, 12981, 408, 339, 870, 408, 199, 3, 27708, 25764, 568, 5550, 1075, 63, 18445, 2673, 63, 3998, 63, 40, 199, 3, 4640, 25764, 568, 5550, 1075, 63, 18445, 2673, 63, 3998, 63, 40, 199, 199, 3, 2613, 298, 773, 262, 8923, 14, 72, 2, 199, 3, 2613, 298, 773, 262, 8923, 63, 3526, 317, 14, 72, 2, 199, 199, 9594, 2702, 469, 272, 950, 1495, 627, 1027, 27, 272, 1495, 730, 27, 199, 93, 4252, 63, 84, 27, 199, 199, 1986, 1568, 63, 84, 2198, 63, 27468, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1848, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 7510, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 3856, 17, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1560, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 2227, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 6760, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 7001, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 21509, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 3856, 18, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 875, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1027, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1391, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1955, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 8284, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 85, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 81, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 78, 81, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 88, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 66, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 69, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 66, 1027, 8, 83, 1541, 627, 13330, 2736, 199, 624, 339, 327, 272, 327, 12340, 402, 4528, 370, 805, 272, 327, 272, 4325, 1130, 275, 469, 267, 283, 5901, 63, 5172, 7, 520, 283, 1122, 63, 1027, 297, 267, 283, 5901, 63, 18817, 356, 283, 1122, 63, 7510, 297, 267, 283, 5901, 63, 1938, 17, 7, 221, 520, 283, 1122, 63, 3856, 17, 297, 199, 198, 7, 5901, 63, 31401, 356, 283, 1122, 63, 3856, 17, 297, 267, 283, 5901, 63, 1938, 18, 7, 221, 520, 283, 1122, 63, 3856, 18, 297, 199, 198, 7, 5901, 63, 34, 3986, 7, 520, 283, 1122, 63, 3856, 18, 297, 267, 283, 5901, 63, 7111, 7, 520, 283, 1122, 63, 21509, 297, 267, 283, 5901, 63, 29019, 7, 520, 283, 1122, 63, 6760, 297, 267, 283, 5901, 63, 3027, 7, 221, 520, 283, 1122, 63, 875, 297, 267, 283, 5901, 63, 14395, 7, 520, 283, 1122, 63, 2227, 297, 267, 283, 5901, 63, 7125, 7, 221, 520, 283, 1122, 63, 1955, 297, 267, 283, 5901, 63, 27192, 356, 283, 1122, 63, 7001, 297, 267, 283, 5901, 63, 899, 17233, 22670, 7, 520, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 11265, 2054, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 9894, 4014, 8456, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 12811, 4014, 8456, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 9894, 29246, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 12811, 29246, 356, 283, 1122, 63, 1560, 297, 267, 283, 5901, 63, 5568, 7, 221, 520, 283, 1122, 63, 1391, 297, 267, 283, 5901, 63, 18400, 356, 283, 1122, 63, 1848, 297, 267, 283, 5901, 63, 45, 4817, 57, 356, 283, 1122, 63, 27468, 297, 267, 283, 5901, 63, 52, 13884, 7, 520, 283, 1122, 63, 8284, 297, 267, 283, 5901, 63, 6131, 3960, 24428, 356, 283, 1122, 63, 21831, 297, 267, 283, 5901, 63, 53, 5353, 7, 257, 520, 283, 1122, 63, 85, 875, 297, 267, 283, 5901, 63, 49, 5353, 7, 257, 520, 283, 1122, 63, 81, 875, 297, 267, 283, 5901, 63, 46, 49, 5353, 7, 221, 520, 283, 1122, 63, 78, 81, 875, 297, 267, 283, 5901, 63, 56, 5353, 7, 257, 520, 283, 1122, 63, 88, 875, 297, 267, 283, 5901, 63, 34, 5353, 7, 257, 520, 283, 1122, 63, 66, 875, 297, 267, 283, 5901, 63, 29780, 7, 257, 520, 283, 1122, 63, 69, 875, 297, 267, 283, 5901, 63, 34, 5172, 7, 258, 520, 283, 1122, 63, 66, 1027, 7, 267, 789, 272, 870, 272, 870, 298, 9594, 1568, 63, 84, 19943, 541, 18, 3481, 5130, 83, 1541, 627, 7646, 27556, 272, 870, 298, 1986, 950, 10063, 18, 3481, 1495, 63, 1122, 63, 1130, 8607, 275, 2420, 272, 2086, 275, 378, 272, 367, 4528, 315, 1559, 459, 13391, 2565, 267, 870, 298, 257, 1253, 5, 83, 12, 13505, 450, 68, 627, 6687, 450, 334, 2324, 1130, 59, 10856, 467, 2086, 9, 267, 2086, 847, 413, 272, 870, 298, 93, 9426, 272, 870, 339, 327, 7681, 272, 327, 221, 2248, 3062, 272, 7681, 275, 1559, 459, 7511, 418, 339, 367, 221, 18020, 315, 769, 8, 1113, 59, 85, 7, 15077, 83, 9090, 267, 18020, 275, 283, 16, 7, 435, 18020, 14, 4142, 342, 267 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 221, 1898, 6029, 12, 6171, 653, 2000, 598, 279, 10205, 1619, 199, 3, 221, 14900, 71, 32, 1258, 25, 14, 957, 199, 3, 221, 6289, 844, 1553, 1937, 9685, 14, 2424, 367, 2436, 199, 3, 199, 199, 624, 199, 17729, 282, 1973, 262, 8923, 4840, 666, 570, 370, 282, 445, 1406, 17048, 72, 9, 570, 199, 624, 199, 199, 646, 984, 199, 199, 318, 22021, 8, 1113, 304, 272, 408, 2446, 12981, 408, 339, 870, 408, 199, 3, 27708, 25764, 568, 5550, 1075, 63, 18445, 2673, 63, 3998, 63, 40, 199, 3, 4640, 25764, 568, 5550, 1075, 63, 18445, 2673, 63, 3998, 63, 40, 199, 199, 3, 2613, 298, 773, 262, 8923, 14, 72, 2, 199, 3, 2613, 298, 773, 262, 8923, 63, 3526, 317, 14, 72, 2, 199, 199, 9594, 2702, 469, 272, 950, 1495, 627, 1027, 27, 272, 1495, 730, 27, 199, 93, 4252, 63, 84, 27, 199, 199, 1986, 1568, 63, 84, 2198, 63, 27468, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1848, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 7510, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 3856, 17, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1560, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 2227, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 6760, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 7001, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 21509, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 3856, 18, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 875, 8, 83, 1541, 627, 7646, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1027, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1391, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 1955, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 8284, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 85, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 81, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 78, 81, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 88, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 66, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 69, 875, 8, 83, 1541, 627, 13330, 2736, 199, 1986, 1568, 63, 84, 2198, 63, 66, 1027, 8, 83, 1541, 627, 13330, 2736, 199, 624, 339, 327, 272, 327, 12340, 402, 4528, 370, 805, 272, 327, 272, 4325, 1130, 275, 469, 267, 283, 5901, 63, 5172, 7, 520, 283, 1122, 63, 1027, 297, 267, 283, 5901, 63, 18817, 356, 283, 1122, 63, 7510, 297, 267, 283, 5901, 63, 1938, 17, 7, 221, 520, 283, 1122, 63, 3856, 17, 297, 199, 198, 7, 5901, 63, 31401, 356, 283, 1122, 63, 3856, 17, 297, 267, 283, 5901, 63, 1938, 18, 7, 221, 520, 283, 1122, 63, 3856, 18, 297, 199, 198, 7, 5901, 63, 34, 3986, 7, 520, 283, 1122, 63, 3856, 18, 297, 267, 283, 5901, 63, 7111, 7, 520, 283, 1122, 63, 21509, 297, 267, 283, 5901, 63, 29019, 7, 520, 283, 1122, 63, 6760, 297, 267, 283, 5901, 63, 3027, 7, 221, 520, 283, 1122, 63, 875, 297, 267, 283, 5901, 63, 14395, 7, 520, 283, 1122, 63, 2227, 297, 267, 283, 5901, 63, 7125, 7, 221, 520, 283, 1122, 63, 1955, 297, 267, 283, 5901, 63, 27192, 356, 283, 1122, 63, 7001, 297, 267, 283, 5901, 63, 899, 17233, 22670, 7, 520, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 11265, 2054, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 9894, 4014, 8456, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 12811, 4014, 8456, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 9894, 29246, 356, 283, 1122, 63, 1560, 297, 199, 198, 7, 5901, 63, 12811, 29246, 356, 283, 1122, 63, 1560, 297, 267, 283, 5901, 63, 5568, 7, 221, 520, 283, 1122, 63, 1391, 297, 267, 283, 5901, 63, 18400, 356, 283, 1122, 63, 1848, 297, 267, 283, 5901, 63, 45, 4817, 57, 356, 283, 1122, 63, 27468, 297, 267, 283, 5901, 63, 52, 13884, 7, 520, 283, 1122, 63, 8284, 297, 267, 283, 5901, 63, 6131, 3960, 24428, 356, 283, 1122, 63, 21831, 297, 267, 283, 5901, 63, 53, 5353, 7, 257, 520, 283, 1122, 63, 85, 875, 297, 267, 283, 5901, 63, 49, 5353, 7, 257, 520, 283, 1122, 63, 81, 875, 297, 267, 283, 5901, 63, 46, 49, 5353, 7, 221, 520, 283, 1122, 63, 78, 81, 875, 297, 267, 283, 5901, 63, 56, 5353, 7, 257, 520, 283, 1122, 63, 88, 875, 297, 267, 283, 5901, 63, 34, 5353, 7, 257, 520, 283, 1122, 63, 66, 875, 297, 267, 283, 5901, 63, 29780, 7, 257, 520, 283, 1122, 63, 69, 875, 297, 267, 283, 5901, 63, 34, 5172, 7, 258, 520, 283, 1122, 63, 66, 1027, 7, 267, 789, 272, 870, 272, 870, 298, 9594, 1568, 63, 84, 19943, 541, 18, 3481, 5130, 83, 1541, 627, 7646, 27556, 272, 870, 298, 1986, 950, 10063, 18, 3481, 1495, 63, 1122, 63, 1130, 8607, 275, 2420, 272, 2086, 275, 378, 272, 367, 4528, 315, 1559, 459, 13391, 2565, 267, 870, 298, 257, 1253, 5, 83, 12, 13505, 450, 68, 627, 6687, 450, 334, 2324, 1130, 59, 10856, 467, 2086, 9, 267, 2086, 847, 413, 272, 870, 298, 93, 9426, 272, 870, 339, 327, 7681, 272, 327, 221, 2248, 3062, 272, 7681, 275, 1559, 459, 7511, 418, 339, 367, 221, 18020, 315, 769, 8, 1113, 59, 85, 7, 15077, 83, 9090, 267, 18020, 275, 283, 16, 7, 435, 18020, 14, 4142, 342, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Peddle/hue
desktop/core/ext-py/cryptography-1.3.1/src/_cffi_src/openssl/hmac.py
7
2910
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function INCLUDES = """ #include <openssl/hmac.h> """ TYPES = """ typedef ... HMAC_CTX; """ FUNCTIONS = """ int Cryptography_HMAC_Init_ex(HMAC_CTX *, const void *, int, const EVP_MD *, ENGINE *); int Cryptography_HMAC_Update(HMAC_CTX *, const unsigned char *, size_t); int Cryptography_HMAC_Final(HMAC_CTX *, unsigned char *, unsigned int *); int Cryptography_HMAC_CTX_copy(HMAC_CTX *, HMAC_CTX *); HMAC_CTX *Cryptography_HMAC_CTX_new(void); void Cryptography_HMAC_CTX_free(HMAC_CTX *ctx); """ MACROS = """ """ CUSTOMIZATIONS = """ int Cryptography_HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl) { #if OPENSSL_VERSION_NUMBER >= 0x010000000 return HMAC_Init_ex(ctx, key, key_len, md, impl); #else HMAC_Init_ex(ctx, key, key_len, md, impl); return 1; #endif } int Cryptography_HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t data_len) { #if OPENSSL_VERSION_NUMBER >= 0x010000000 return HMAC_Update(ctx, data, data_len); #else HMAC_Update(ctx, data, data_len); return 1; #endif } int Cryptography_HMAC_Final(HMAC_CTX *ctx, unsigned char *digest, unsigned int *outlen) { #if OPENSSL_VERSION_NUMBER >= 0x010000000 return HMAC_Final(ctx, digest, outlen); #else HMAC_Final(ctx, digest, outlen); return 1; #endif } int Cryptography_HMAC_CTX_copy(HMAC_CTX *dst_ctx, HMAC_CTX *src_ctx) { #if OPENSSL_VERSION_NUMBER >= 0x010000000 return HMAC_CTX_copy(dst_ctx, src_ctx); #else HMAC_CTX_init(dst_ctx); if (!EVP_MD_CTX_copy_ex(&dst_ctx->i_ctx, &src_ctx->i_ctx)) { goto err; } if (!EVP_MD_CTX_copy_ex(&dst_ctx->o_ctx, &src_ctx->o_ctx)) { goto err; } if (!EVP_MD_CTX_copy_ex(&dst_ctx->md_ctx, &src_ctx->md_ctx)) { goto err; } memcpy(dst_ctx->key, src_ctx->key, HMAC_MAX_MD_CBLOCK); dst_ctx->key_length = src_ctx->key_length; dst_ctx->md = src_ctx->md; return 1; err: return 0; #endif } HMAC_CTX *Cryptography_HMAC_CTX_new(void) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) return HMAC_CTX_new(); #else /* This uses OPENSSL_zalloc in 1.1.0, which is malloc + memset */ HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_malloc(sizeof(HMAC_CTX)); memset(ctx, 0, sizeof(HMAC_CTX)); return ctx; #endif } void Cryptography_HMAC_CTX_free(HMAC_CTX *ctx) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) return HMAC_CTX_free(ctx); #else if (ctx != NULL) { HMAC_CTX_cleanup(ctx); OPENSSL_free(ctx); } #endif } """
apache-2.0
[ 3, 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 568, 29992, 275, 408, 199, 3, 2613, 665, 14837, 15, 18537, 14, 72, 30, 199, 624, 199, 199, 7893, 275, 408, 199, 9594, 2263, 29817, 63, 21524, 27, 199, 624, 199, 199, 29865, 275, 408, 199, 442, 18855, 9773, 63, 23034, 63, 9346, 63, 476, 8, 23034, 63, 21524, 9889, 950, 2309, 9889, 1109, 12, 950, 662, 14159, 63, 5127, 9889, 2892, 5070, 14331, 627, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 4152, 8, 23034, 63, 21524, 9889, 950, 7381, 1495, 9889, 1568, 63, 84, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 12776, 8, 23034, 63, 21524, 9889, 7381, 1495, 9889, 7381, 1109, 627, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 21524, 63, 1574, 8, 23034, 63, 21524, 9889, 29817, 63, 21524, 627, 2736, 199, 23034, 63, 21524, 627, 17134, 9773, 63, 23034, 63, 21524, 63, 1222, 8, 1647, 2736, 199, 1647, 18855, 9773, 63, 23034, 63, 21524, 63, 4624, 8, 23034, 63, 21524, 627, 3799, 2736, 199, 624, 199, 199, 9410, 1092, 51, 275, 408, 199, 624, 199, 199, 20519, 5357, 12969, 275, 408, 199, 442, 18855, 9773, 63, 23034, 63, 9346, 63, 476, 8, 23034, 63, 21524, 627, 3799, 12, 950, 2309, 627, 498, 12, 1109, 790, 63, 552, 12, 2892, 950, 662, 14159, 63, 5127, 627, 1064, 12, 5070, 14331, 627, 5472, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 9346, 63, 476, 8, 3799, 12, 790, 12, 790, 63, 552, 12, 6128, 12, 11512, 2736, 199, 3, 2836, 272, 29817, 63, 9346, 63, 476, 8, 3799, 12, 790, 12, 790, 63, 552, 12, 6128, 12, 11512, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 4152, 8, 23034, 63, 21524, 627, 3799, 12, 950, 7381, 1495, 627, 576, 12, 2490, 1568, 63, 84, 666, 63, 552, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 4152, 8, 3799, 12, 666, 12, 666, 63, 552, 2736, 199, 3, 2836, 272, 29817, 63, 4152, 8, 3799, 12, 666, 12, 666, 63, 552, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 12776, 8, 23034, 63, 21524, 627, 3799, 12, 7381, 1495, 627, 5671, 12, 272, 7381, 1109, 627, 548, 552, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 12776, 8, 3799, 12, 10017, 12, 734, 552, 2736, 199, 3, 2836, 272, 29817, 63, 12776, 8, 3799, 12, 10017, 12, 734, 552, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 21524, 63, 1574, 8, 23034, 63, 21524, 627, 5119, 63, 3799, 12, 29817, 63, 21524, 627, 2164, 63, 3799, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 21524, 63, 1574, 8, 5119, 63, 3799, 12, 2928, 63, 3799, 2736, 199, 3, 2836, 272, 29817, 63, 21524, 63, 826, 8, 5119, 63, 3799, 2736, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 73, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 73, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 79, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 79, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 1064, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 1064, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 562, 5466, 647, 8, 5119, 63, 3799, 5118, 498, 12, 2928, 63, 3799, 5118, 498, 12, 29817, 63, 4283, 63, 5127, 63, 35, 8475, 2736, 272, 5042, 63, 3799, 5118, 498, 63, 1267, 275, 2928, 63, 3799, 5118, 498, 63, 1267, 27, 272, 5042, 63, 3799, 5118, 1064, 275, 2928, 63, 3799, 5118, 1064, 27, 272, 372, 413, 27, 339, 2329, 26, 267, 372, 378, 27, 199, 3, 13739, 199, 93, 199, 199, 23034, 63, 21524, 627, 17134, 9773, 63, 23034, 63, 21524, 63, 1222, 8, 1647, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 4893, 5345, 44, 10883, 8546, 4037, 8, 14406, 1608, 44, 63, 4612, 63, 9190, 9, 272, 372, 29817, 63, 21524, 63, 1222, 7303, 199, 3, 2836, 272, 13505, 961, 4440, 24164, 5413, 63, 90, 9373, 315, 413, 14, 17, 14, 16, 12, 1314, 365, 333, 9373, 435, 7573, 409, 11589, 272, 29817, 63, 21524, 627, 3799, 275, 334, 23034, 63, 21524, 24104, 9935, 5413, 63, 23981, 8, 12590, 8, 23034, 63, 21524, 16674, 272, 7573, 409, 8, 3799, 12, 378, 12, 13855, 8, 23034, 63, 21524, 16674, 272, 372, 4027, 27, 199, 3, 13739, 199, 93, 4388, 199, 1647, 18855, 9773, 63, 23034, 63, 21524, 63, 4624, 8, 23034, 63, 21524, 627, 3799, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 4893, 5345, 44, 10883, 8546, 4037, 8, 14406, 1608, 44, 63, 4612, 63, 9190, 9, 272, 372, 29817, 63, 21524, 63, 4624, 8, 3799, 2736, 199, 3, 2836, 272, 340, 334, 3799, 1137, 5962, 9, 469, 267, 29817, 63, 21524, 63, 7661, 8, 3799, 2736, 267, 24164, 5413, 63, 4624, 8, 3799, 2736, 272, 789, 199, 3, 13739, 199, 93, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 568, 29992, 275, 408, 199, 3, 2613, 665, 14837, 15, 18537, 14, 72, 30, 199, 624, 199, 199, 7893, 275, 408, 199, 9594, 2263, 29817, 63, 21524, 27, 199, 624, 199, 199, 29865, 275, 408, 199, 442, 18855, 9773, 63, 23034, 63, 9346, 63, 476, 8, 23034, 63, 21524, 9889, 950, 2309, 9889, 1109, 12, 950, 662, 14159, 63, 5127, 9889, 2892, 5070, 14331, 627, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 4152, 8, 23034, 63, 21524, 9889, 950, 7381, 1495, 9889, 1568, 63, 84, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 12776, 8, 23034, 63, 21524, 9889, 7381, 1495, 9889, 7381, 1109, 627, 2736, 199, 442, 18855, 9773, 63, 23034, 63, 21524, 63, 1574, 8, 23034, 63, 21524, 9889, 29817, 63, 21524, 627, 2736, 199, 23034, 63, 21524, 627, 17134, 9773, 63, 23034, 63, 21524, 63, 1222, 8, 1647, 2736, 199, 1647, 18855, 9773, 63, 23034, 63, 21524, 63, 4624, 8, 23034, 63, 21524, 627, 3799, 2736, 199, 624, 199, 199, 9410, 1092, 51, 275, 408, 199, 624, 199, 199, 20519, 5357, 12969, 275, 408, 199, 442, 18855, 9773, 63, 23034, 63, 9346, 63, 476, 8, 23034, 63, 21524, 627, 3799, 12, 950, 2309, 627, 498, 12, 1109, 790, 63, 552, 12, 2892, 950, 662, 14159, 63, 5127, 627, 1064, 12, 5070, 14331, 627, 5472, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 9346, 63, 476, 8, 3799, 12, 790, 12, 790, 63, 552, 12, 6128, 12, 11512, 2736, 199, 3, 2836, 272, 29817, 63, 9346, 63, 476, 8, 3799, 12, 790, 12, 790, 63, 552, 12, 6128, 12, 11512, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 4152, 8, 23034, 63, 21524, 627, 3799, 12, 950, 7381, 1495, 627, 576, 12, 2490, 1568, 63, 84, 666, 63, 552, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 4152, 8, 3799, 12, 666, 12, 666, 63, 552, 2736, 199, 3, 2836, 272, 29817, 63, 4152, 8, 3799, 12, 666, 12, 666, 63, 552, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 12776, 8, 23034, 63, 21524, 627, 3799, 12, 7381, 1495, 627, 5671, 12, 272, 7381, 1109, 627, 548, 552, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 12776, 8, 3799, 12, 10017, 12, 734, 552, 2736, 199, 3, 2836, 272, 29817, 63, 12776, 8, 3799, 12, 10017, 12, 734, 552, 2736, 272, 372, 413, 27, 199, 3, 13739, 199, 93, 199, 199, 442, 18855, 9773, 63, 23034, 63, 21524, 63, 1574, 8, 23034, 63, 21524, 627, 5119, 63, 3799, 12, 29817, 63, 21524, 627, 2164, 63, 3799, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 614, 9084, 272, 372, 29817, 63, 21524, 63, 1574, 8, 5119, 63, 3799, 12, 2928, 63, 3799, 2736, 199, 3, 2836, 272, 29817, 63, 21524, 63, 826, 8, 5119, 63, 3799, 2736, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 73, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 73, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 79, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 79, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 340, 19452, 37, 14159, 63, 5127, 63, 21524, 63, 1574, 63, 476, 24168, 5119, 63, 3799, 5118, 1064, 63, 3799, 12, 1253, 2164, 63, 3799, 5118, 1064, 63, 3799, 430, 469, 267, 18878, 2329, 27, 272, 789, 272, 562, 5466, 647, 8, 5119, 63, 3799, 5118, 498, 12, 2928, 63, 3799, 5118, 498, 12, 29817, 63, 4283, 63, 5127, 63, 35, 8475, 2736, 272, 5042, 63, 3799, 5118, 498, 63, 1267, 275, 2928, 63, 3799, 5118, 498, 63, 1267, 27, 272, 5042, 63, 3799, 5118, 1064, 275, 2928, 63, 3799, 5118, 1064, 27, 272, 372, 413, 27, 339, 2329, 26, 267, 372, 378, 27, 199, 3, 13739, 199, 93, 199, 199, 23034, 63, 21524, 627, 17134, 9773, 63, 23034, 63, 21524, 63, 1222, 8, 1647, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 4893, 5345, 44, 10883, 8546, 4037, 8, 14406, 1608, 44, 63, 4612, 63, 9190, 9, 272, 372, 29817, 63, 21524, 63, 1222, 7303, 199, 3, 2836, 272, 13505, 961, 4440, 24164, 5413, 63, 90, 9373, 315, 413, 14, 17, 14, 16, 12, 1314, 365, 333, 9373, 435, 7573, 409, 11589, 272, 29817, 63, 21524, 627, 3799, 275, 334, 23034, 63, 21524, 24104, 9935, 5413, 63, 23981, 8, 12590, 8, 23034, 63, 21524, 16674, 272, 7573, 409, 8, 3799, 12, 378, 12, 13855, 8, 23034, 63, 21524, 16674, 272, 372, 4027, 27, 199, 3, 13739, 199, 93, 4388, 199, 1647, 18855, 9773, 63, 23034, 63, 21524, 63, 4624, 8, 23034, 63, 21524, 627, 3799, 9, 469, 199, 3, 692, 24164, 5413, 63, 4612, 63, 9190, 2356, 378, 88, 4893, 5345, 44, 10883, 8546, 4037, 8, 14406, 1608, 44, 63, 4612, 63, 9190, 9, 272, 372, 29817, 63, 21524, 63, 4624, 8, 3799, 2736, 199, 3, 2836, 272, 340, 334, 3799, 1137, 5962, 9, 469, 267, 29817, 63, 21524, 63, 7661, 8, 3799, 2736, 267, 24164, 5413, 63, 4624, 8, 3799, 2736, 272, 789, 199, 3, 13739, 199, 93, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Embeds standalone JavaScript snippets in C++ code. The script requires the OverridesView file from WebKit that lists the known mobile devices to be passed in as the only argument. The list of known devices will be written to a C-style string to be parsed with JSONReader. """ import optparse import os import sys import cpp_source def main(): parser = optparse.OptionParser() parser.add_option( '', '--directory', type='string', default='.', help='Path to directory where the cc/h files should be created') options, args = parser.parse_args() devices = '[' file_name = args[0] inside_list = False with open(file_name, 'r') as f: for line in f: if not inside_list: if 'WebInspector.OverridesUI._phones = [' in line or \ 'WebInspector.OverridesUI._tablets = [' in line: inside_list = True else: if line.strip() == '];': inside_list = False continue devices += line.strip() devices += ']' cpp_source.WriteSource('mobile_device_list', 'chrome/test/chromedriver/chrome', options.directory, {'kMobileDevices': devices}) if __name__ == '__main__': sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 13200, 83, 18042, 15250, 19484, 315, 445, 4176, 1233, 14, 199, 199, 1918, 2884, 5074, 314, 31144, 2768, 570, 687, 6001, 14591, 626, 5548, 314, 6040, 199, 11375, 7256, 370, 506, 3032, 315, 465, 314, 1454, 1423, 14, 710, 769, 402, 6040, 7256, 199, 14117, 506, 5313, 370, 282, 445, 13, 2487, 1059, 370, 506, 4565, 543, 4840, 5929, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 646, 7246, 63, 1365, 421, 199, 318, 2446, 837, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 8, 489, 3260, 2850, 3619, 297, 730, 534, 875, 297, 849, 534, 3130, 489, 1720, 534, 2042, 370, 2082, 2382, 314, 7429, 15, 72, 1584, 1077, 506, 2737, 358, 523, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 7256, 275, 22640, 523, 570, 63, 354, 275, 1249, 59, 16, 61, 523, 6272, 63, 513, 275, 756, 523, 543, 1551, 8, 493, 63, 354, 12, 283, 82, 358, 465, 289, 26, 272, 367, 1004, 315, 289, 26, 489, 340, 440, 6272, 63, 513, 26, 267, 340, 283, 5926, 13962, 15152, 14, 27586, 6379, 423, 838, 4548, 275, 788, 315, 1004, 503, 971, 1779, 283, 5926, 13962, 15152, 14, 27586, 6379, 423, 1224, 1086, 275, 788, 315, 1004, 26, 881, 6272, 63, 513, 275, 715, 489, 587, 26, 267, 340, 1004, 14, 1913, 342, 508, 24710, 6015, 881, 6272, 63, 513, 275, 756, 881, 1980, 267, 7256, 847, 1004, 14, 1913, 342, 819, 7256, 847, 24840, 523, 7246, 63, 1365, 14, 3534, 2980, 360, 11375, 63, 1782, 63, 513, 297, 586, 283, 9887, 15, 396, 15, 9887, 3090, 15, 9887, 297, 586, 1511, 14, 3619, 12, 791, 75, 27245, 18204, 356, 7256, 1552, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 13200, 83, 18042, 15250, 19484, 315, 445, 4176, 1233, 14, 199, 199, 1918, 2884, 5074, 314, 31144, 2768, 570, 687, 6001, 14591, 626, 5548, 314, 6040, 199, 11375, 7256, 370, 506, 3032, 315, 465, 314, 1454, 1423, 14, 710, 769, 402, 6040, 7256, 199, 14117, 506, 5313, 370, 282, 445, 13, 2487, 1059, 370, 506, 4565, 543, 4840, 5929, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 646, 7246, 63, 1365, 421, 199, 318, 2446, 837, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 8, 489, 3260, 2850, 3619, 297, 730, 534, 875, 297, 849, 534, 3130, 489, 1720, 534, 2042, 370, 2082, 2382, 314, 7429, 15, 72, 1584, 1077, 506, 2737, 358, 523, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 7256, 275, 22640, 523, 570, 63, 354, 275, 1249, 59, 16, 61, 523, 6272, 63, 513, 275, 756, 523, 543, 1551, 8, 493, 63, 354, 12, 283, 82, 358, 465, 289, 26, 272, 367, 1004, 315, 289, 26, 489, 340, 440, 6272, 63, 513, 26, 267, 340, 283, 5926, 13962, 15152, 14, 27586, 6379, 423, 838, 4548, 275, 788, 315, 1004, 503, 971, 1779, 283, 5926, 13962, 15152, 14, 27586, 6379, 423, 1224, 1086, 275, 788, 315, 1004, 26, 881, 6272, 63, 513, 275, 715, 489, 587, 26, 267, 340, 1004, 14, 1913, 342, 508, 24710, 6015, 881, 6272, 63, 513, 275, 756, 881, 1980, 267, 7256, 847, 1004, 14, 1913, 342, 819, 7256, 847, 24840, 523, 7246, 63, 1365, 14, 3534, 2980, 360, 11375, 63, 1782, 63, 513, 297, 586, 283, 9887, 15, 396, 15, 9887, 3090, 15, 9887, 297, 586, 1511, 14, 3619, 12, 791, 75, 27245, 18204, 356, 7256, 1552, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 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, 0 ]
inconvergent/differential-cloud
modules/helpers.py
1
1866
#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function def get_args(): import argparse parser = argparse.ArgumentParser() parser.add_argument( '--procs', type=int, default=4, help='number of processors.' ) parser.add_argument( '--nearl', type=float, default=0.003 ) parser.add_argument( '--midl', type=float, default=0.008 ) parser.add_argument( '--farl', type=float, default=0.05 ) parser.add_argument( '--stp', type=float, default=1.0e-7 ) parser.add_argument( '--reject', type=float, default=1.0 ) parser.add_argument( '--attract', type=float, default=0.3 ) parser.add_argument( '--nmax', type=int, default=1000000 ) parser.add_argument( '--itt', type=int, default=10000000000 ) parser.add_argument( '--vnum', type=int, default=10000000000 ) parser.add_argument( '--stat', type=int, default=100 ) parser.add_argument( '--export', type=int, default=1000 ) parser.add_argument( '--out', type=str, default='./res/res' ) parser.add_argument( '--startRad', type=float, default=0.01 ) parser.add_argument( '--startNum', type=int, default=100 ) return parser.parse_args() def make_info_str(args): s = '' for k in vars(args): s += '# ' + str(k) + ': ' + str(getattr(args,k)) + '\n' return s def print_stats(steps,dm, meta=False): from time import strftime from time import time if isinstance(meta, str): meta = ' | {:s}'.format(meta) else: meta = '' print( '{:s} | stp: {:d} sec: {:.2f} v: {:d}{:s}' .format( strftime('%d/%m/%y %H:%M:%S'), steps, time()-dm.get_start_time(), dm.get_vnum(), meta ) ) return
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 318, 664, 63, 589, 837, 819, 492, 7534, 819, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 24463, 297, 272, 730, 29, 442, 12, 272, 849, 29, 20, 12, 272, 1720, 534, 1955, 402, 21620, 3530, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 21078, 76, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 8262, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 24959, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 8662, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 15315, 76, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 1717, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 20643, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 17, 14, 16, 69, 13, 23, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 16857, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 17, 14, 16, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 292, 6908, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 19, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 78, 988, 297, 272, 730, 29, 442, 12, 272, 849, 29, 22589, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 390, 84, 297, 272, 730, 29, 442, 12, 272, 849, 29, 9943, 3273, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 86, 1507, 297, 272, 730, 29, 442, 12, 272, 849, 29, 9943, 3273, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 3736, 297, 272, 730, 29, 442, 12, 272, 849, 29, 1960, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 3790, 297, 272, 730, 29, 442, 12, 272, 849, 29, 5279, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 548, 297, 272, 730, 29, 495, 12, 272, 849, 534, 13186, 470, 15, 470, 7, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 928, 24767, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 614, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 928, 5667, 297, 272, 730, 29, 442, 12, 272, 849, 29, 1960, 523, 776, 819, 372, 1798, 14, 1122, 63, 589, 342, 199, 199, 318, 1852, 63, 815, 63, 495, 8, 589, 304, 523, 308, 275, 2125, 523, 367, 1022, 315, 6802, 8, 589, 304, 272, 308, 847, 3943, 283, 435, 620, 8, 75, 9, 435, 7596, 283, 435, 620, 8, 5675, 8, 589, 12, 75, 430, 435, 1557, 78, 7, 523, 372, 308, 421, 199, 318, 870, 63, 3200, 8, 5895, 12, 6428, 12, 3404, 29, 797, 304, 819, 687, 900, 492, 14053, 523, 687, 900, 492, 900, 819, 340, 1228, 8, 2024, 12, 620, 304, 272, 3404, 275, 283, 1204, 19850, 83, 5285, 908, 8, 2024, 9, 523, 587, 26, 272, 3404, 275, 2125, 819, 870, 8, 272, 5041, 26, 83, 93, 1204, 410, 80, 26, 19850, 68, 93, 6513, 26, 469, 14010, 18, 70, 93, 373, 26, 19850, 68, 8847, 26, 83, 6834, 489, 1275, 908, 8, 489, 14053, 3508, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 659, 489, 7124, 12, 489, 900, 22251, 6428, 14, 362, 63, 928, 63, 521, 1062, 489, 17547, 14, 362, 63, 86, 1507, 1062, 489, 3404, 272, 776, 523, 776, 819, 372, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 318, 664, 63, 589, 837, 819, 492, 7534, 819, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 24463, 297, 272, 730, 29, 442, 12, 272, 849, 29, 20, 12, 272, 1720, 534, 1955, 402, 21620, 3530, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 21078, 76, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 8262, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 24959, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 8662, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 15315, 76, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 1717, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 20643, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 17, 14, 16, 69, 13, 23, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 16857, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 17, 14, 16, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 292, 6908, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 19, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 78, 988, 297, 272, 730, 29, 442, 12, 272, 849, 29, 22589, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 390, 84, 297, 272, 730, 29, 442, 12, 272, 849, 29, 9943, 3273, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 86, 1507, 297, 272, 730, 29, 442, 12, 272, 849, 29, 9943, 3273, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 3736, 297, 272, 730, 29, 442, 12, 272, 849, 29, 1960, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 3790, 297, 272, 730, 29, 442, 12, 272, 849, 29, 5279, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 548, 297, 272, 730, 29, 495, 12, 272, 849, 534, 13186, 470, 15, 470, 7, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 928, 24767, 297, 272, 730, 29, 1609, 12, 272, 849, 29, 16, 14, 614, 523, 776, 523, 1798, 14, 525, 63, 2094, 8, 272, 2850, 928, 5667, 297, 272, 730, 29, 442, 12, 272, 849, 29, 1960, 523, 776, 819, 372, 1798, 14, 1122, 63, 589, 342, 199, 199, 318, 1852, 63, 815, 63, 495, 8, 589, 304, 523, 308, 275, 2125, 523, 367, 1022, 315, 6802, 8, 589, 304, 272, 308, 847, 3943, 283, 435, 620, 8, 75, 9, 435, 7596, 283, 435, 620, 8, 5675, 8, 589, 12, 75, 430, 435, 1557, 78, 7, 523, 372, 308, 421, 199, 318, 870, 63, 3200, 8, 5895, 12, 6428, 12, 3404, 29, 797, 304, 819, 687, 900, 492, 14053, 523, 687, 900, 492, 900, 819, 340, 1228, 8, 2024, 12, 620, 304, 272, 3404, 275, 283, 1204, 19850, 83, 5285, 908, 8, 2024, 9, 523, 587, 26, 272, 3404, 275, 2125, 819, 870, 8, 272, 5041, 26, 83, 93, 1204, 410, 80, 26, 19850, 68, 93, 6513, 26, 469, 14010, 18, 70, 93, 373, 26, 19850, 68, 8847, 26, 83, 6834, 489, 1275, 908, 8, 489, 14053, 3508, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 659, 489, 7124, 12, 489, 900, 22251, 6428, 14, 362, 63, 928, 63, 521, 1062, 489, 17547, 14, 362, 63, 86, 1507, 1062, 489, 3404, 272, 776, 523, 776, 819, 372, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
SpaceHotDog/Flask_API
test_bucketlist.py
1
3171
# test_bucketlist.py import unittest import os import json from app import create_app, db class BucketlistTestCase(unittest.TestCase): """This class represents the bucketlist test case""" def setUp(self): """Define test variables and initialize app.""" self.app = create_app(config_name="testing") self.client = self.app.test_client self.bucketlist = {'name': 'Go to Borabora for vacation'} # binds the app to the current context with self.app.app_context(): # create all tables db.create_all() def test_bucketlist_creation(self): """Test API can create a bucketlist (POST request)""" res = self.client().post('/bucketlists/', data=self.bucketlist) self.assertEqual(res.status_code, 201) self.assertIn('Go to Borabora', str(res.data)) def test_api_can_get_all_bucketlists(self): """Test API can get a bucketlist (GET request).""" res = self.client().post('/bucketlists/', data=self.bucketlist) self.assertEqual(res.status_code, 201) res = self.client().get('/bucketlists/') self.assertEqual(res.status_code, 200) self.assertIn('Go to Borabora', str(res.data)) def test_api_can_get_bucketlist_by_id(self): """Test API can get a single bucketlist by using it's id.""" rv = self.client().post('/bucketlists/', data=self.bucketlist) self.assertEqual(rv.status_code, 201) result_in_json = json.loads(rv.data.decode('utf-8').replace("'", "\"")) result = self.client().get( '/bucketlists/{}'.format(result_in_json['id'])) self.assertEqual(result.status_code, 200) self.assertIn('Go to Borabora', str(result.data)) def test_bucketlist_can_be_edited(self): """Test API can edit an existing bucketlist. (PUT request)""" rv = self.client().post( '/bucketlists/', data={'name': 'Eat, pray and love'}) self.assertEqual(rv.status_code, 201) rv = self.client().put( '/bucketlists/1', data={ "name": "Dont just eat, but also pray and love :-)" }) self.assertEqual(rv.status_code, 200) results = self.client().get('/bucketlists/1') self.assertIn('Dont just eat', str(results.data)) def test_bucketlist_deletion(self): """Test API can delete an existing bucketlist. (DELETE request).""" rv = self.client().post( '/bucketlists/', data={'name': 'Eat, pray and love'}) self.assertEqual(rv.status_code, 201) res = self.client().delete('/bucketlists/1') self.assertEqual(res.status_code, 200) # Test to see if it exists, should return a 404 result = self.client().get('/bucketlists/1') self.assertEqual(result.status_code, 404) def tearDown(self): """teardown all initialized variables.""" with self.app.app_context(): # drop all tables db.session.remove() db.drop_all() # Make the tests conveniently executable if __name__ == "__main__": unittest.main()
unlicense
[ 3, 511, 63, 4623, 513, 14, 647, 199, 199, 646, 2882, 199, 646, 747, 199, 646, 2022, 199, 504, 1145, 492, 1218, 63, 571, 12, 1592, 199, 199, 533, 31479, 513, 1746, 8, 2796, 14, 1746, 304, 272, 408, 2765, 1021, 8469, 314, 5315, 513, 511, 1930, 624, 339, 347, 3613, 8, 277, 304, 267, 408, 16213, 511, 2860, 436, 8265, 1145, 1041, 267, 291, 14, 571, 275, 1218, 63, 571, 8, 888, 63, 354, 628, 4776, 531, 267, 291, 14, 1258, 275, 291, 14, 571, 14, 396, 63, 1258, 267, 291, 14, 4623, 513, 275, 791, 354, 356, 283, 7250, 370, 699, 269, 371, 11131, 367, 28898, 425, 936, 398, 327, 5398, 83, 314, 1145, 370, 314, 1453, 1067, 267, 543, 291, 14, 571, 14, 571, 63, 1100, 837, 288, 327, 1218, 1006, 6716, 288, 1592, 14, 981, 63, 452, 342, 339, 347, 511, 63, 4623, 513, 63, 8782, 8, 277, 304, 267, 408, 774, 3261, 883, 1218, 282, 5315, 513, 334, 4030, 1056, 9471, 267, 522, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1784, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 470, 14, 576, 430, 339, 347, 511, 63, 1246, 63, 2425, 63, 362, 63, 452, 63, 4623, 6717, 8, 277, 304, 267, 408, 774, 3261, 883, 664, 282, 5315, 513, 334, 2970, 1056, 10477, 267, 522, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1784, 9, 267, 522, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 6217, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 470, 14, 576, 430, 339, 347, 511, 63, 1246, 63, 2425, 63, 362, 63, 4623, 513, 63, 991, 63, 344, 8, 277, 304, 267, 408, 774, 3261, 883, 664, 282, 2849, 5315, 513, 701, 1808, 652, 1159, 1305, 1041, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 754, 63, 262, 63, 1001, 275, 2022, 14, 3640, 8, 6310, 14, 576, 14, 2708, 360, 1624, 13, 24, 1959, 1814, 27769, 1867, 341, 430, 267, 754, 275, 291, 14, 1258, 1252, 362, 8, 288, 1994, 4623, 6717, 30837, 908, 8, 1099, 63, 262, 63, 1001, 459, 344, 5156, 267, 291, 14, 629, 8, 1099, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 1099, 14, 576, 430, 339, 347, 511, 63, 4623, 513, 63, 2425, 63, 1235, 63, 17642, 8, 277, 304, 267, 408, 774, 3261, 883, 5283, 376, 3411, 5315, 513, 14, 334, 4013, 1056, 9471, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 8, 288, 1994, 4623, 6717, 3678, 288, 666, 3713, 354, 356, 283, 37, 292, 12, 299, 803, 436, 560, 432, 3071, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 4336, 275, 291, 14, 1258, 1252, 524, 8, 288, 1994, 4623, 6717, 15, 17, 297, 288, 666, 3126, 355, 298, 354, 582, 298, 20028, 2951, 325, 292, 12, 1325, 2597, 299, 803, 436, 560, 432, 22901, 2924, 288, 3828, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1926, 9, 267, 2058, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 4080, 360, 20028, 2951, 325, 292, 297, 620, 8, 2604, 14, 576, 430, 339, 347, 511, 63, 4623, 513, 63, 14281, 8, 277, 304, 267, 408, 774, 3261, 883, 3145, 376, 3411, 5315, 513, 14, 334, 7014, 1056, 10477, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 8, 288, 1994, 4623, 6717, 3678, 288, 666, 3713, 354, 356, 283, 37, 292, 12, 299, 803, 436, 560, 432, 3071, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 522, 275, 291, 14, 1258, 1252, 1807, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1926, 9, 267, 327, 1379, 370, 1937, 340, 652, 3495, 12, 1077, 372, 282, 7901, 267, 754, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 629, 8, 1099, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 6766, 8, 277, 304, 267, 408, 15236, 1006, 10038, 2860, 1041, 267, 543, 291, 14, 571, 14, 571, 63, 1100, 837, 288, 327, 5978, 1006, 6716, 288, 1592, 14, 1730, 14, 2168, 342, 288, 1592, 14, 4824, 63, 452, 342, 199, 199, 3, 4155, 314, 2295, 22700, 590, 7286, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 511, 63, 4623, 513, 14, 647, 199, 199, 646, 2882, 199, 646, 747, 199, 646, 2022, 199, 504, 1145, 492, 1218, 63, 571, 12, 1592, 199, 199, 533, 31479, 513, 1746, 8, 2796, 14, 1746, 304, 272, 408, 2765, 1021, 8469, 314, 5315, 513, 511, 1930, 624, 339, 347, 3613, 8, 277, 304, 267, 408, 16213, 511, 2860, 436, 8265, 1145, 1041, 267, 291, 14, 571, 275, 1218, 63, 571, 8, 888, 63, 354, 628, 4776, 531, 267, 291, 14, 1258, 275, 291, 14, 571, 14, 396, 63, 1258, 267, 291, 14, 4623, 513, 275, 791, 354, 356, 283, 7250, 370, 699, 269, 371, 11131, 367, 28898, 425, 936, 398, 327, 5398, 83, 314, 1145, 370, 314, 1453, 1067, 267, 543, 291, 14, 571, 14, 571, 63, 1100, 837, 288, 327, 1218, 1006, 6716, 288, 1592, 14, 981, 63, 452, 342, 339, 347, 511, 63, 4623, 513, 63, 8782, 8, 277, 304, 267, 408, 774, 3261, 883, 1218, 282, 5315, 513, 334, 4030, 1056, 9471, 267, 522, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1784, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 470, 14, 576, 430, 339, 347, 511, 63, 1246, 63, 2425, 63, 362, 63, 452, 63, 4623, 6717, 8, 277, 304, 267, 408, 774, 3261, 883, 664, 282, 5315, 513, 334, 2970, 1056, 10477, 267, 522, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1784, 9, 267, 522, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 6217, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 470, 14, 576, 430, 339, 347, 511, 63, 1246, 63, 2425, 63, 362, 63, 4623, 513, 63, 991, 63, 344, 8, 277, 304, 267, 408, 774, 3261, 883, 664, 282, 2849, 5315, 513, 701, 1808, 652, 1159, 1305, 1041, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 2336, 4623, 6717, 3678, 666, 29, 277, 14, 4623, 513, 9, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 754, 63, 262, 63, 1001, 275, 2022, 14, 3640, 8, 6310, 14, 576, 14, 2708, 360, 1624, 13, 24, 1959, 1814, 27769, 1867, 341, 430, 267, 754, 275, 291, 14, 1258, 1252, 362, 8, 288, 1994, 4623, 6717, 30837, 908, 8, 1099, 63, 262, 63, 1001, 459, 344, 5156, 267, 291, 14, 629, 8, 1099, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 7250, 370, 699, 269, 371, 11131, 297, 620, 8, 1099, 14, 576, 430, 339, 347, 511, 63, 4623, 513, 63, 2425, 63, 1235, 63, 17642, 8, 277, 304, 267, 408, 774, 3261, 883, 5283, 376, 3411, 5315, 513, 14, 334, 4013, 1056, 9471, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 8, 288, 1994, 4623, 6717, 3678, 288, 666, 3713, 354, 356, 283, 37, 292, 12, 299, 803, 436, 560, 432, 3071, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 4336, 275, 291, 14, 1258, 1252, 524, 8, 288, 1994, 4623, 6717, 15, 17, 297, 288, 666, 3126, 355, 298, 354, 582, 298, 20028, 2951, 325, 292, 12, 1325, 2597, 299, 803, 436, 560, 432, 22901, 2924, 288, 3828, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1926, 9, 267, 2058, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 4080, 360, 20028, 2951, 325, 292, 297, 620, 8, 2604, 14, 576, 430, 339, 347, 511, 63, 4623, 513, 63, 14281, 8, 277, 304, 267, 408, 774, 3261, 883, 3145, 376, 3411, 5315, 513, 14, 334, 7014, 1056, 10477, 267, 4336, 275, 291, 14, 1258, 1252, 1932, 8, 288, 1994, 4623, 6717, 3678, 288, 666, 3713, 354, 356, 283, 37, 292, 12, 299, 803, 436, 560, 432, 3071, 267, 291, 14, 629, 8, 6310, 14, 1205, 63, 600, 12, 1784, 9, 267, 522, 275, 291, 14, 1258, 1252, 1807, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 629, 8, 470, 14, 1205, 63, 600, 12, 1926, 9, 267, 327, 1379, 370, 1937, 340, 652, 3495, 12, 1077, 372, 282, 7901, 267, 754, 275, 291, 14, 1258, 1252, 362, 2336, 4623, 6717, 15, 17, 358, 267, 291, 14, 629, 8, 1099, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 6766, 8, 277, 304, 267, 408, 15236, 1006, 10038, 2860, 1041, 267, 543, 291, 14, 571, 14, 571, 63, 1100, 837, 288, 327, 5978, 1006, 6716, 288, 1592, 14, 1730, 14, 2168, 342, 288, 1592, 14, 4824, 63, 452, 342, 199, 199, 3, 4155, 314, 2295, 22700, 590, 7286, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
fyfcauc/android_external_chromium-org
tools/telemetry/telemetry/core/util.py
23
4884
# 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 inspect import logging import os import socket import sys import time class TimeoutException(Exception): pass def GetBaseDir(): main_module = sys.modules['__main__'] if hasattr(main_module, '__file__'): return os.path.dirname(os.path.abspath(main_module.__file__)) else: return os.getcwd() def GetTelemetryDir(): return os.path.normpath(os.path.join( __file__, os.pardir, os.pardir, os.pardir)) def GetUnittestDataDir(): return os.path.join(GetTelemetryDir(), 'unittest_data') def GetChromiumSrcDir(): return os.path.normpath(os.path.join(GetTelemetryDir(), os.pardir, os.pardir)) def AddDirToPythonPath(*path_parts): path = os.path.abspath(os.path.join(*path_parts)) if os.path.isdir(path) and path not in sys.path: sys.path.append(path) def WaitFor(condition, timeout): """Waits for up to |timeout| secs for the function |condition| to return True. Polling frequency is (elapsed_time / 10), with a min of .1s and max of 5s. Returns: Result of |condition| function (if present). """ min_poll_interval = 0.1 max_poll_interval = 5 output_interval = 300 def GetConditionString(): if condition.__name__ == '<lambda>': try: return inspect.getsource(condition).strip() except IOError: pass return condition.__name__ start_time = time.time() last_output_time = start_time while True: res = condition() if res: return res now = time.time() elapsed_time = now - start_time last_output_elapsed_time = now - last_output_time if elapsed_time > timeout: raise TimeoutException('Timed out while waiting %ds for %s.' % (timeout, GetConditionString())) if last_output_elapsed_time > output_interval: logging.info('Continuing to wait %ds for %s. Elapsed: %ds.', timeout, GetConditionString(), elapsed_time) last_output_time = time.time() poll_interval = min(max(elapsed_time / 10., min_poll_interval), max_poll_interval) time.sleep(poll_interval) def FindElementAndPerformAction(tab, text, callback_code): """JavaScript snippet for finding an element with a given text on a page.""" code = """ (function() { var callback_function = """ + callback_code + """; function _findElement(element, text) { if (element.innerHTML == text) { callback_function return element; } for (var i in element.childNodes) { var found = _findElement(element.childNodes[i], text); if (found) return found; } return null; } var _element = _findElement(document, \"""" + text + """\"); return callback_function(_element); })();""" return tab.EvaluateJavaScript(code) class PortPair(object): def __init__(self, local_port, remote_port): self.local_port = local_port self.remote_port = remote_port def GetUnreservedAvailableLocalPort(): """Returns an available port on the system. WARNING: This method does not reserve the port it returns, so it may be used by something else before you get to use it. This can lead to flake. """ tmp = socket.socket() tmp.bind(('', 0)) port = tmp.getsockname()[1] tmp.close() return port def CloseConnections(tab): """Closes all TCP sockets held open by the browser.""" try: tab.ExecuteJavaScript("""window.chrome && chrome.benchmarking && chrome.benchmarking.closeConnections()""") except Exception: pass def GetBuildDirectories(): """Yields all combination of Chromium build output directories.""" build_dirs = ['build', os.path.basename(os.environ.get('CHROMIUM_OUT_DIR', 'out')), 'xcodebuild'] build_types = ['Debug', 'Debug_x64', 'Release', 'Release_x64'] for build_dir in build_dirs: for build_type in build_types: yield build_dir, build_type def FindSupportBinary(binary_name, executable=True): """Returns the path to the given binary name.""" # TODO(tonyg/dtu): This should support finding binaries in cloud storage. command = None command_mtime = 0 required_mode = os.R_OK if executable: required_mode = os.X_OK chrome_root = GetChromiumSrcDir() for build_dir, build_type in GetBuildDirectories(): candidate = os.path.join(chrome_root, build_dir, build_type, binary_name) if os.path.isfile(candidate) and os.access(candidate, required_mode): candidate_mtime = os.stat(candidate).st_mtime if candidate_mtime > command_mtime: command = candidate command_mtime = candidate_mtime return command
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, 646, 6485, 199, 646, 2050, 199, 646, 747, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 421, 199, 533, 12878, 1726, 8, 1726, 304, 523, 986, 421, 199, 318, 2372, 1563, 3567, 837, 523, 2446, 63, 578, 275, 984, 14, 3112, 13742, 973, 17501, 523, 340, 2688, 8, 973, 63, 578, 12, 2560, 493, 12168, 272, 372, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 973, 63, 578, 855, 493, 8964, 523, 587, 26, 272, 372, 747, 14, 9458, 342, 421, 199, 318, 2372, 24944, 10987, 3567, 837, 523, 372, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 489, 636, 493, 3108, 747, 14, 21386, 12, 747, 14, 21386, 12, 747, 14, 21386, 430, 421, 199, 318, 2372, 1358, 1770, 1451, 3567, 837, 523, 372, 747, 14, 515, 14, 904, 8, 1002, 24944, 10987, 3567, 1062, 283, 2796, 63, 576, 358, 421, 199, 318, 2372, 29381, 21261, 3567, 837, 523, 372, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 1002, 24944, 10987, 3567, 1062, 747, 14, 21386, 12, 747, 14, 21386, 430, 421, 199, 318, 2654, 3567, 1378, 4718, 2042, 2031, 515, 63, 4181, 304, 523, 931, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 2031, 515, 63, 4181, 430, 523, 340, 747, 14, 515, 14, 6027, 8, 515, 9, 436, 931, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 740, 8, 515, 9, 421, 199, 318, 13144, 1858, 8, 5394, 12, 2653, 304, 523, 408, 24804, 1405, 367, 1536, 370, 1204, 2593, 92, 20091, 367, 314, 805, 1204, 5394, 92, 370, 372, 715, 14, 819, 8467, 2983, 9857, 365, 334, 16691, 63, 521, 1182, 1616, 395, 543, 282, 1748, 402, 1275, 17, 83, 436, 1390, 402, 959, 83, 14, 819, 1803, 26, 272, 10695, 402, 1204, 5394, 92, 805, 334, 692, 3451, 680, 523, 408, 523, 1748, 63, 6843, 63, 4284, 275, 257, 378, 14, 17, 523, 1390, 63, 6843, 63, 4284, 275, 257, 959, 523, 1072, 63, 4284, 257, 275, 9601, 819, 347, 2372, 9558, 1558, 837, 272, 340, 5558, 855, 354, 363, 508, 2650, 2734, 30838, 489, 862, 26, 267, 372, 6485, 14, 362, 1365, 8, 5394, 680, 1913, 342, 489, 871, 5925, 26, 267, 986, 272, 372, 5558, 855, 354, 363, 819, 1343, 63, 521, 275, 900, 14, 521, 342, 523, 2061, 63, 1199, 63, 521, 275, 1343, 63, 521, 523, 1830, 715, 26, 272, 522, 275, 5558, 342, 272, 340, 522, 26, 489, 372, 522, 272, 3063, 275, 900, 14, 521, 342, 272, 14439, 63, 521, 275, 3063, 446, 1343, 63, 521, 272, 2061, 63, 1199, 63, 16691, 63, 521, 275, 3063, 446, 2061, 63, 1199, 63, 521, 272, 340, 14439, 63, 521, 690, 2653, 26, 489, 746, 12878, 1726, 360, 28682, 734, 1830, 10923, 450, 795, 367, 450, 83, 3530, 450, 2490, 334, 2593, 12, 2372, 9558, 1558, 4059, 272, 340, 2061, 63, 1199, 63, 16691, 63, 521, 690, 1072, 63, 4284, 26, 489, 2050, 14, 815, 360, 24593, 23221, 370, 3618, 450, 795, 367, 450, 83, 14, 662, 9982, 26, 450, 795, 3130, 673, 2653, 12, 2372, 9558, 1558, 1062, 14439, 63, 521, 9, 489, 2061, 63, 1199, 63, 521, 275, 900, 14, 521, 342, 272, 11271, 63, 4284, 275, 1748, 8, 988, 8, 16691, 63, 521, 1182, 1616, 2020, 1748, 63, 6843, 63, 4284, 395, 717, 1390, 63, 6843, 63, 4284, 9, 272, 900, 14, 4532, 8, 6843, 63, 4284, 9, 421, 199, 318, 6668, 2162, 3325, 20906, 3310, 8, 2902, 12, 1318, 12, 3233, 63, 600, 304, 523, 408, 21986, 17440, 367, 17196, 376, 1819, 543, 282, 1627, 1318, 641, 282, 2034, 1041, 523, 1233, 275, 408, 489, 334, 1593, 342, 469, 267, 2729, 3233, 63, 1593, 275, 408, 435, 3233, 63, 600, 435, 408, 27, 267, 805, 485, 1623, 2162, 8, 2108, 12, 1318, 9, 469, 881, 340, 334, 2108, 14, 26502, 508, 1318, 9, 469, 288, 3233, 63, 1593, 288, 372, 1819, 27, 881, 789, 881, 367, 334, 1391, 284, 315, 1819, 14, 10626, 9, 469, 288, 2729, 1911, 275, 485, 1623, 2162, 8, 2108, 14, 10626, 59, 73, 467, 1318, 2736, 288, 340, 334, 4214, 9, 1598, 372, 1911, 27, 881, 789, 881, 372, 2973, 27, 267, 789, 267, 2729, 485, 2108, 275, 485, 1623, 2162, 8, 3554, 12, 19669, 341, 435, 1318, 435, 9638, 3547, 267, 372, 3233, 63, 1593, 1547, 2108, 2736, 489, 3828, 7303, 624, 523, 372, 5174, 14, 25002, 21986, 8, 600, 9, 421, 199, 533, 10977, 12882, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2257, 63, 719, 12, 3982, 63, 719, 304, 272, 291, 14, 1832, 63, 719, 275, 2257, 63, 719, 272, 291, 14, 3846, 63, 719, 275, 3982, 63, 719, 421, 199, 318, 2372, 1358, 10421, 11464, 5339, 4313, 837, 523, 408, 3407, 376, 2808, 1844, 641, 314, 2656, 14, 819, 14750, 26, 961, 1083, 1630, 440, 32606, 314, 1844, 652, 2529, 12, 880, 652, 1443, 506, 1202, 523, 701, 6020, 587, 2544, 1265, 664, 370, 675, 652, 14, 961, 883, 12690, 370, 27510, 14, 523, 408, 523, 3529, 275, 2838, 14, 3450, 342, 523, 3529, 14, 3409, 4725, 297, 378, 430, 523, 1844, 275, 3529, 14, 27886, 3430, 17, 61, 523, 3529, 14, 1600, 342, 819, 372, 1844, 421, 199, 318, 15524, 22122, 8, 2902, 304, 523, 408, 3337, 874, 1006, 13488, 18772, 23608, 1551, 701, 314, 7042, 1041, 523, 862, 26, 272, 5174, 14, 12049, 21986, 4852, 3806, 14, 9887, 10883, 18221, 14, 11861, 316, 10883, 2490, 18221, 14, 11861, 316, 14, 1600, 22122, 342, 6141, 523, 871, 2186, 26, 272, 986, 421, 199, 318, 2372, 3425, 13752, 837, 523, 408, 22889, 83, 1006, 14665, 402, 12051, 1900, 1072, 6602, 1041, 523, 1900, 63, 3220, 275, 788, 1506, 297, 355, 747, 14, 515, 14, 4846, 8, 736, 14, 2314, 14, 362, 360, 30334, 24967, 63, 1877, 63, 3022, 297 ]
[ 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, 646, 6485, 199, 646, 2050, 199, 646, 747, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 421, 199, 533, 12878, 1726, 8, 1726, 304, 523, 986, 421, 199, 318, 2372, 1563, 3567, 837, 523, 2446, 63, 578, 275, 984, 14, 3112, 13742, 973, 17501, 523, 340, 2688, 8, 973, 63, 578, 12, 2560, 493, 12168, 272, 372, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 973, 63, 578, 855, 493, 8964, 523, 587, 26, 272, 372, 747, 14, 9458, 342, 421, 199, 318, 2372, 24944, 10987, 3567, 837, 523, 372, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 489, 636, 493, 3108, 747, 14, 21386, 12, 747, 14, 21386, 12, 747, 14, 21386, 430, 421, 199, 318, 2372, 1358, 1770, 1451, 3567, 837, 523, 372, 747, 14, 515, 14, 904, 8, 1002, 24944, 10987, 3567, 1062, 283, 2796, 63, 576, 358, 421, 199, 318, 2372, 29381, 21261, 3567, 837, 523, 372, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 1002, 24944, 10987, 3567, 1062, 747, 14, 21386, 12, 747, 14, 21386, 430, 421, 199, 318, 2654, 3567, 1378, 4718, 2042, 2031, 515, 63, 4181, 304, 523, 931, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 2031, 515, 63, 4181, 430, 523, 340, 747, 14, 515, 14, 6027, 8, 515, 9, 436, 931, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 740, 8, 515, 9, 421, 199, 318, 13144, 1858, 8, 5394, 12, 2653, 304, 523, 408, 24804, 1405, 367, 1536, 370, 1204, 2593, 92, 20091, 367, 314, 805, 1204, 5394, 92, 370, 372, 715, 14, 819, 8467, 2983, 9857, 365, 334, 16691, 63, 521, 1182, 1616, 395, 543, 282, 1748, 402, 1275, 17, 83, 436, 1390, 402, 959, 83, 14, 819, 1803, 26, 272, 10695, 402, 1204, 5394, 92, 805, 334, 692, 3451, 680, 523, 408, 523, 1748, 63, 6843, 63, 4284, 275, 257, 378, 14, 17, 523, 1390, 63, 6843, 63, 4284, 275, 257, 959, 523, 1072, 63, 4284, 257, 275, 9601, 819, 347, 2372, 9558, 1558, 837, 272, 340, 5558, 855, 354, 363, 508, 2650, 2734, 30838, 489, 862, 26, 267, 372, 6485, 14, 362, 1365, 8, 5394, 680, 1913, 342, 489, 871, 5925, 26, 267, 986, 272, 372, 5558, 855, 354, 363, 819, 1343, 63, 521, 275, 900, 14, 521, 342, 523, 2061, 63, 1199, 63, 521, 275, 1343, 63, 521, 523, 1830, 715, 26, 272, 522, 275, 5558, 342, 272, 340, 522, 26, 489, 372, 522, 272, 3063, 275, 900, 14, 521, 342, 272, 14439, 63, 521, 275, 3063, 446, 1343, 63, 521, 272, 2061, 63, 1199, 63, 16691, 63, 521, 275, 3063, 446, 2061, 63, 1199, 63, 521, 272, 340, 14439, 63, 521, 690, 2653, 26, 489, 746, 12878, 1726, 360, 28682, 734, 1830, 10923, 450, 795, 367, 450, 83, 3530, 450, 2490, 334, 2593, 12, 2372, 9558, 1558, 4059, 272, 340, 2061, 63, 1199, 63, 16691, 63, 521, 690, 1072, 63, 4284, 26, 489, 2050, 14, 815, 360, 24593, 23221, 370, 3618, 450, 795, 367, 450, 83, 14, 662, 9982, 26, 450, 795, 3130, 673, 2653, 12, 2372, 9558, 1558, 1062, 14439, 63, 521, 9, 489, 2061, 63, 1199, 63, 521, 275, 900, 14, 521, 342, 272, 11271, 63, 4284, 275, 1748, 8, 988, 8, 16691, 63, 521, 1182, 1616, 2020, 1748, 63, 6843, 63, 4284, 395, 717, 1390, 63, 6843, 63, 4284, 9, 272, 900, 14, 4532, 8, 6843, 63, 4284, 9, 421, 199, 318, 6668, 2162, 3325, 20906, 3310, 8, 2902, 12, 1318, 12, 3233, 63, 600, 304, 523, 408, 21986, 17440, 367, 17196, 376, 1819, 543, 282, 1627, 1318, 641, 282, 2034, 1041, 523, 1233, 275, 408, 489, 334, 1593, 342, 469, 267, 2729, 3233, 63, 1593, 275, 408, 435, 3233, 63, 600, 435, 408, 27, 267, 805, 485, 1623, 2162, 8, 2108, 12, 1318, 9, 469, 881, 340, 334, 2108, 14, 26502, 508, 1318, 9, 469, 288, 3233, 63, 1593, 288, 372, 1819, 27, 881, 789, 881, 367, 334, 1391, 284, 315, 1819, 14, 10626, 9, 469, 288, 2729, 1911, 275, 485, 1623, 2162, 8, 2108, 14, 10626, 59, 73, 467, 1318, 2736, 288, 340, 334, 4214, 9, 1598, 372, 1911, 27, 881, 789, 881, 372, 2973, 27, 267, 789, 267, 2729, 485, 2108, 275, 485, 1623, 2162, 8, 3554, 12, 19669, 341, 435, 1318, 435, 9638, 3547, 267, 372, 3233, 63, 1593, 1547, 2108, 2736, 489, 3828, 7303, 624, 523, 372, 5174, 14, 25002, 21986, 8, 600, 9, 421, 199, 533, 10977, 12882, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2257, 63, 719, 12, 3982, 63, 719, 304, 272, 291, 14, 1832, 63, 719, 275, 2257, 63, 719, 272, 291, 14, 3846, 63, 719, 275, 3982, 63, 719, 421, 199, 318, 2372, 1358, 10421, 11464, 5339, 4313, 837, 523, 408, 3407, 376, 2808, 1844, 641, 314, 2656, 14, 819, 14750, 26, 961, 1083, 1630, 440, 32606, 314, 1844, 652, 2529, 12, 880, 652, 1443, 506, 1202, 523, 701, 6020, 587, 2544, 1265, 664, 370, 675, 652, 14, 961, 883, 12690, 370, 27510, 14, 523, 408, 523, 3529, 275, 2838, 14, 3450, 342, 523, 3529, 14, 3409, 4725, 297, 378, 430, 523, 1844, 275, 3529, 14, 27886, 3430, 17, 61, 523, 3529, 14, 1600, 342, 819, 372, 1844, 421, 199, 318, 15524, 22122, 8, 2902, 304, 523, 408, 3337, 874, 1006, 13488, 18772, 23608, 1551, 701, 314, 7042, 1041, 523, 862, 26, 272, 5174, 14, 12049, 21986, 4852, 3806, 14, 9887, 10883, 18221, 14, 11861, 316, 10883, 2490, 18221, 14, 11861, 316, 14, 1600, 22122, 342, 6141, 523, 871, 2186, 26, 272, 986, 421, 199, 318, 2372, 3425, 13752, 837, 523, 408, 22889, 83, 1006, 14665, 402, 12051, 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 ]
apacha/OMR-Datasets
omrdatasettools/OmrDataset.py
1
11026
from enum import Enum, auto from typing import Dict class OmrDataset(Enum): """ The available OMR datasets that can be automatically downloaded with Downloader.py """ #: The Audiveris OMR dataset from https://github.com/Audiveris/omr-dataset-tools, Copyright 2017 by Hervé Bitteur under AGPL-3.0 license Audiveris = auto() #: The Baro Single Stave dataset from http://www.cvc.uab.es/people/abaro/datasets.html, Copyright 2019 Arnau Baró, Pau Riba, Jorge Calvo-Zaragoza, and Alicia Fornés under CC-BY-NC-SA 4.0 license Baro = auto() #: The Capitan dataset from http://grfia.dlsi.ua.es/, License unspecified, free for research purposes Capitan = auto() #: Custom version of the CVC-MUSCIMA dataset that contains all images in grayscale, binary and with the #: following staff-line augmentations: interrupted, kanungo, thickness-variation-v1/2, y-variation-v1/2 #: typeset-emulation and whitespeckles. (all data augmentations that could be aligned automatically). #: The grayscale images are different from the WriterIdentification dataset, in such a way, that they were aligned #: to the images from the Staff-Removal dataset. This is the recommended dataset for object detection, as the #: MUSCIMA++ annotations can be used with a variety of underlying images. #: See https://github.com/apacha/CVC-MUSCIMA to learn more. CvcMuscima_MultiConditionAligned = auto() #: The larger version of the CVC-MUSCIMA dataset for staff removal in black and white with augmentations #: from http://www.cvc.uab.es/cvcmuscima/index_database.html, #: Copyright 2012 Alicia Fornés, Anjan Dutta, Albert Gordo and Josep Lladós under CC-BY-NC-SA 4.0 license CvcMuscima_StaffRemoval = auto() #: The smaller version of the CVC-MUSCIMA dataset for writer identification in grayscale #: from http://www.cvc.uab.es/cvcmuscima/index_database.html, #: Copyright 2012 Alicia Fornés, Anjan Dutta, Albert Gordo and Josep Lladós under CC-BY-NC-SA 4.0 license CvcMuscima_WriterIdentification = auto() #: Edirom dataset. All rights reserved Edirom_Bargheer = auto() #: Edirom datasets on Freischuetz from https://freischuetz-digital.de/edition.html. All rights reserved. Edirom_FreischuetzDigital = auto() #: The Fornes Music Symbols dataset from http://www.cvc.uab.es/~afornes/, License unspecified - citation requested Fornes = auto() #: The official HOMUS dataset from http://grfia.dlsi.ua.es/homus/, License unspecified. Homus_V1 = auto() #: The improved version of the HOMUS dataset with several bugs-fixed from https://github.com/apacha/Homus Homus_V2 = auto() #: The MUSCIMA++ dataset from https://ufal.mff.cuni.cz/muscima, Copyright 2017 Jan Hajic jr. under CC-BY-NC-SA 4.0 license MuscimaPlusPlus_V1 = auto() #: The second version of the MUSCIMA++ dataset from https://github.com/OMR-Research/muscima-pp MuscimaPlusPlus_V2 = auto() #: A sub-set of the MUSCIMA++ annotations that contains bounding-box annotations for staves, staff measures and system measures. It was semi-automatically constructed from existing annotations and manually verified for correctness. The annotations are available in a plain JSON format as well as in the COCO format. MuscimaPlusPlus_MeasureAnnotations = auto() #: The OpenOMR Symbols dataset from https://sourceforge.net/projects/openomr/, Copyright 2013 by Arnaud F. Desaedeleer under GPL license OpenOmr = auto() #: The Printed Music Symbols dataset from https://github.com/apacha/PrintedMusicSymbolsDataset, Copyright 2017 by Alexander Pacha under MIT license Printed = auto() #: The Rebelo dataset (part 1) with music symbols from http://www.inescporto.pt/~arebelo/index.php, Copyright 2017 by Ana Rebelo under CC BY-SA 4.0 license Rebelo1 = auto() #: The Rebelo dataset (part 2) with music symbols from http://www.inescporto.pt/~arebelo/index.php, Copyright 2017 by Ana Rebelo under CC BY-SA 4.0 license Rebelo2 = auto() #: The DeepScore dataset (version 1) with extended vocabulary from https://tuggeluk.github.io/downloads/, License unspecified. DeepScores_V1_Extended = auto() #: The AudioLabs v1 dataset (aka. Measure Bounding Box Annotation) from https://www.audiolabs-erlangen.de/resources/MIR/2019-ISMIR-LBD-Measures, Copyright 2019 by Frank Zalkow, Angel Villar Corrales, TJ Tsai, Vlora Arifi-Müller, and Meinard Müller under CC BY-NC-SA 4.0 license AudioLabs_v1 = auto() #: The AudioLabs v2 dataset, enhanced with staves, staff measures and the original system measures. The annotations are available in csv, JSON and COCO format. AudioLabs_v2 = auto() #: The Accidentals detection dataset by Kwon-Young Choi from https://www-intuidoc.irisa.fr/en/choi_accidentals/, License unspecified. ChoiAccidentals = auto() def get_dataset_download_url(self) -> str: """ Returns the url of the selected dataset. Example usage: OmrDataset.Fornes.get_dataset_download_url() """ return self.dataset_download_urls()[self.name] def get_dataset_filename(self) -> str: """ Returns the name of the downloaded zip file of a dataset. Example usage: OmrDataset.Fornes.get_dataset_filename() """ return self.dataset_file_names()[self.name] def dataset_download_urls(self) -> Dict[str, str]: """ Returns a mapping with all URLs, mapped from their enum keys """ return { # Official URL: https://github.com/Audiveris/omr-dataset-tools/tree/master/data/input-images "Audiveris": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/AudiverisOmrDataset.zip", # Official URL: http://www.cvc.uab.es/people/abaro/datasets/MUSCIMA_ABARO.zip "Baro": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/BaroMuscima.zip", # Official URL: http://grfia.dlsi.ua.es/cm/projects/timul/databases/BimodalHandwrittenSymbols.zip "Capitan": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/BimodalHandwrittenSymbols.zip", # Official URL: http://www.cvc.uab.es/cvcmuscima/CVCMUSCIMA_WI.zip "CvcMuscima_WriterIdentification": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/CVCMUSCIMA_WI.zip", # Official URL: http://www.cvc.uab.es/cvcmuscima/CVCMUSCIMA_SR.zip "CvcMuscima_StaffRemoval": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/CVCMUSCIMA_SR.zip", # Official URL: https://github.com/apacha/CVC-MUSCIMA "CvcMuscima_MultiConditionAligned": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/CVCMUSCIMA_MCA.zip", "Edirom_Bargheer": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/Bargheer.zip", "Edirom_FreischuetzDigital": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/FreischuetzDigital.zip", # Official URL: http://www.cvc.uab.es/cvcmuscima/datasets/Music_Symbols.zip "Fornes": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/Music_Symbols.zip", # Official URL: http://grfia.dlsi.ua.es/homus/HOMUS.zip "Homus_V1": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/HOMUS.zip", # Official URL: https://github.com/apacha/Homus "Homus_V2": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/HOMUS-2.0.zip", # Official URL: https://lindat.mff.cuni.cz/repository/xmlui/bitstream/handle/11372/LRT-2372/MUSCIMA-pp_v1.0.zip?sequence=1&isAllowed=y "MuscimaPlusPlus_V1": "https://github.com/OMR-Research/muscima-pp/releases/download/v1.0/MUSCIMA-pp_v1.0.zip", # Official URL: https://github.com/OMR-Research/muscima-pp "MuscimaPlusPlus_V2": "https://github.com/OMR-Research/muscima-pp/releases/download/v2.0/MUSCIMA-pp_v2.0.zip", "MuscimaPlusPlus_Images": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/CVC_MUSCIMA_PP_Annotated-Images.zip", "MuscimaPlusPlus_MeasureAnnotations": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/MUSCIMA-pp_v1.0-measure-annotations.zip", # Official URL: https://sourceforge.net/projects/openomr/ "OpenOmr": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/OpenOMR-Dataset.zip", "Printed": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/PrintedMusicSymbolsDataset.zip", "Rebelo1": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/Rebelo-Music-Symbol-Dataset1.zip", "Rebelo2": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/Rebelo-Music-Symbol-Dataset2.zip", "DeepScores_V1_Extended": "https://repository.cloudlab.zhaw.ch/artifactory/deepscores/ds_extended.zip", # Official URL: https://www.audiolabs-erlangen.de/resources/MIR/2019-ISMIR-LBD-Measures "AudioLabs_v1": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/AudioLabs_v1.zip", "AudioLabs_v2": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/AudioLabs_v2.zip", # Official URL: https://www-intuidoc.irisa.fr/en/choi_accidentals/ "ChoiAccidentals": "https://github.com/apacha/OMR-Datasets/releases/download/datasets/choi_accidentals_dataset.zip" } def dataset_file_names(self) -> Dict[str, str]: """ Returns a map of all file_names, mapped from their enum keys """ return { "Audiveris": "AudiverisOmrDataset.zip", "Baro": "BaroMuscima.zip", "Capitan": "BimodalHandwrittenSymbols.zip", "CvcMuscima_WriterIdentification": "CVCMUSCIMA_WI.zip", "CvcMuscima_StaffRemoval": "CVCMUSCIMA_SR.zip", "CvcMuscima_MultiConditionAligned": "CVCMUSCIMA_MCA.zip", "Edirom_Bargheer": "Bargheer.zip", "Edirom_FreischuetzDigital": "FreischuetzDigital.zip", "Fornes": "Music_Symbols.zip", "Homus_V1": "HOMUS.zip", "Homus_V2": "HOMUS-2.0.zip", "MuscimaPlusPlus_V1": "MUSCIMA-pp_v1.0.zip", "MuscimaPlusPlus_V2": "MUSCIMA-pp_v2.0.zip", "MuscimaPlusPlus_Images": "CVC_MUSCIMA_PP_Annotated-Images.zip", "MuscimaPlusPlus_MeasureAnnotations": "MUSCIMA-pp_v1.0-measure-annotations.zip", "OpenOmr": "OpenOMR-Dataset.zip", "Printed": "PrintedMusicSymbolsDataset.zip", "Rebelo1": "Rebelo-Music-Symbol-Dataset1.zip", "Rebelo2": "Rebelo-Music-Symbol-Dataset2.zip", "DeepScores_V1_Extended": "ds_extended.zip", "AudioLabs_v1": "AudioLabs_v1.zip", "AudioLabs_v2": "AudioLabs_v2.zip", "ChoiAccidentals": "choi_accidentals_dataset.zip" }
mit
[ 504, 4952, 492, 11305, 12, 2599, 199, 504, 14090, 492, 7448, 421, 199, 533, 593, 13118, 9271, 8, 5081, 304, 272, 408, 267, 710, 2808, 593, 22153, 13148, 626, 883, 506, 5847, 13557, 543, 13392, 3422, 14, 647, 272, 408, 339, 6079, 710, 437, 14525, 422, 374, 593, 22153, 4789, 687, 4178, 921, 5031, 14, 957, 15, 33, 14525, 422, 374, 15, 676, 82, 13, 5214, 13, 2537, 12, 1898, 9708, 701, 18769, 86, 5741, 10199, 266, 300, 1334, 437, 12006, 13, 19, 14, 16, 4190, 272, 437, 14525, 422, 374, 275, 2599, 342, 339, 6079, 710, 12377, 79, 13050, 7083, 432, 4789, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 13562, 15, 371, 285, 79, 15, 12281, 14, 1360, 12, 1898, 20312, 1952, 3540, 85, 12377, 11980, 12, 510, 3844, 820, 1892, 65, 12, 1603, 24591, 8256, 2392, 13, 58, 285, 14315, 8076, 12, 436, 15170, 16521, 2104, 78, 5741, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 12377, 79, 275, 2599, 342, 339, 6079, 710, 22516, 390, 290, 4789, 687, 1455, 921, 2587, 329, 65, 14, 5030, 338, 14, 1458, 14, 397, 15, 12, 844, 21994, 12, 2867, 367, 295, 1733, 12901, 272, 22516, 390, 290, 275, 2599, 342, 339, 6079, 8388, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 626, 3509, 1006, 5935, 315, 21977, 3467, 12, 3366, 436, 543, 314, 272, 6079, 2569, 12622, 13, 604, 18336, 434, 1298, 26, 31366, 12, 1022, 290, 324, 1939, 12, 294, 17437, 13, 3808, 425, 13, 86, 17, 15, 18, 12, 612, 13, 3808, 425, 13, 86, 17, 15, 18, 272, 6079, 730, 409, 13, 20526, 436, 704, 4033, 321, 346, 2978, 14, 334, 452, 666, 18336, 434, 1298, 626, 4293, 506, 22569, 5847, 680, 272, 6079, 710, 21977, 3467, 5935, 787, 3365, 687, 314, 24441, 41, 24926, 4789, 12, 315, 4066, 282, 4340, 12, 626, 2985, 4898, 22569, 272, 6079, 370, 314, 5935, 687, 314, 25910, 13, 497, 14128, 4789, 14, 961, 365, 314, 14318, 4789, 367, 909, 15212, 12, 465, 314, 272, 6079, 603, 1668, 35, 1469, 33, 4176, 15538, 883, 506, 1202, 543, 282, 32246, 402, 8793, 5935, 14, 272, 6079, 1666, 4178, 921, 5031, 14, 957, 15, 65, 387, 9518, 15, 35, 9454, 13, 45, 1668, 35, 1469, 33, 370, 12537, 1655, 14, 272, 445, 6737, 45, 527, 559, 391, 63, 3947, 9558, 9497, 379, 275, 2599, 342, 339, 6079, 710, 12142, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 367, 12622, 20055, 315, 12136, 436, 10424, 543, 18336, 434, 1298, 272, 6079, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 5107, 4400, 527, 559, 391, 15, 1080, 63, 4659, 14, 1360, 12, 272, 6079, 1898, 6029, 15170, 16521, 2104, 78, 5741, 83, 12, 1626, 24418, 577, 337, 502, 12, 4580, 12504, 598, 269, 1117, 436, 1603, 3362, 80, 491, 76, 350, 11980, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 445, 6737, 45, 527, 559, 391, 63, 18963, 497, 14128, 275, 2599, 342, 339, 6079, 710, 12700, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 367, 7060, 29193, 315, 21977, 3467, 272, 6079, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 5107, 4400, 527, 559, 391, 15, 1080, 63, 4659, 14, 1360, 12, 272, 6079, 1898, 6029, 15170, 16521, 2104, 78, 5741, 83, 12, 1626, 24418, 577, 337, 502, 12, 4580, 12504, 598, 269, 1117, 436, 1603, 3362, 80, 491, 76, 350, 11980, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 445, 6737, 45, 527, 559, 391, 63, 6261, 41, 24926, 275, 2599, 342, 339, 6079, 662, 328, 417, 4789, 14, 2900, 4481, 4644, 272, 662, 328, 417, 63, 34, 1273, 426, 281, 275, 2599, 342, 339, 6079, 662, 328, 417, 13148, 641, 481, 264, 374, 335, 310, 3903, 687, 4178, 921, 20153, 374, 335, 310, 3903, 13, 25888, 14, 271, 15, 69, 1671, 14, 1360, 14, 2900, 4481, 4644, 14, 272, 662, 328, 417, 63, 38, 264, 374, 335, 310, 3903, 32660, 275, 2599, 342, 339, 6079, 710, 2104, 17775, 28919, 9916, 5515, 4356, 4789, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 22500, 65, 509, 17775, 15, 12, 844, 21994, 446, 286, 5314, 5839, 272, 2104, 17775, 275, 2599, 342, 339, 6079, 710, 25410, 869, 7474, 1668, 4789, 687, 1455, 921, 2587, 329, 65, 14, 5030, 338, 14, 1458, 14, 397, 15, 526, 77, 527, 15, 12, 844, 21994, 14, 272, 869, 676, 527, 63, 54, 17, 275, 2599, 342, 339, 6079, 710, 1742, 26429, 1015, 402, 314, 869, 7474, 1668, 4789, 543, 9978, 18227, 13, 5964, 687, 4178, 921, 5031, 14, 957, 15, 65, 387, 9518, 15, 40, 676, 527, 272, 869, 676, 527, 63, 54, 18, 275, 2599, 342, 339, 6079, 710, 603, 1668, 35, 1469, 33, 4176, 4789, 687, 4178, 921, 1286, 279, 14, 77, 556, 14, 67, 5411, 14, 16823, 15, 77, 527, 559, 391, 12, 1898, 9708, 17474, 869, 9091, 530, 1335, 82, 14, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 603, 527, 559, 391, 25800, 25800, 63, 54, 17, 275, 2599, 342, 339, 6079, 710, 3499, 1015, 402, 314, 603, 1668, 35, 1469, 33, 4176, 4789, 687, 4178, 921, 5031, 14, 957, 15, 7474, 50, 13, 497, 1733, 15, 77, 527, 559, 391, 13, 802, 272, 603, 527, 559, 391, 25800, 25800, 63, 54, 18, 275, 2599, 342, 339, 6079, 437, 1007, 13, 409, 402, 314, 603, 1668, 35, 1469, 33, 4176, 15538, 626, 3509, 16842, 13, 1977, 15538, 367, 410, 7047, 12, 12622, 17616, 1482, 436, 2656, 17616, 1482, 14, 2779, 1990, 18734, 13, 2495, 17174, 14701, 687, 3411, 15538, 436, 10250, 16317, 367, 29102, 14, 710, 15538, 787, 2808, 315, 282, 8971, 4840, 1475, 465, 5521, 465, 315, 314, 5099, 1439, 1475, 14, 272, 603, 527, 559, 391, 25800, 25800, 63, 18611, 21761, 1298, 275, 2599, 342, 339, 6079, 710, 3232, 7474, 50, 5515, 4356, 4789, 687, 4178, 921, 22943, 14, 846, 15, 6776, 15, 1490, 676 ]
[ 4952, 492, 11305, 12, 2599, 199, 504, 14090, 492, 7448, 421, 199, 533, 593, 13118, 9271, 8, 5081, 304, 272, 408, 267, 710, 2808, 593, 22153, 13148, 626, 883, 506, 5847, 13557, 543, 13392, 3422, 14, 647, 272, 408, 339, 6079, 710, 437, 14525, 422, 374, 593, 22153, 4789, 687, 4178, 921, 5031, 14, 957, 15, 33, 14525, 422, 374, 15, 676, 82, 13, 5214, 13, 2537, 12, 1898, 9708, 701, 18769, 86, 5741, 10199, 266, 300, 1334, 437, 12006, 13, 19, 14, 16, 4190, 272, 437, 14525, 422, 374, 275, 2599, 342, 339, 6079, 710, 12377, 79, 13050, 7083, 432, 4789, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 13562, 15, 371, 285, 79, 15, 12281, 14, 1360, 12, 1898, 20312, 1952, 3540, 85, 12377, 11980, 12, 510, 3844, 820, 1892, 65, 12, 1603, 24591, 8256, 2392, 13, 58, 285, 14315, 8076, 12, 436, 15170, 16521, 2104, 78, 5741, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 12377, 79, 275, 2599, 342, 339, 6079, 710, 22516, 390, 290, 4789, 687, 1455, 921, 2587, 329, 65, 14, 5030, 338, 14, 1458, 14, 397, 15, 12, 844, 21994, 12, 2867, 367, 295, 1733, 12901, 272, 22516, 390, 290, 275, 2599, 342, 339, 6079, 8388, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 626, 3509, 1006, 5935, 315, 21977, 3467, 12, 3366, 436, 543, 314, 272, 6079, 2569, 12622, 13, 604, 18336, 434, 1298, 26, 31366, 12, 1022, 290, 324, 1939, 12, 294, 17437, 13, 3808, 425, 13, 86, 17, 15, 18, 12, 612, 13, 3808, 425, 13, 86, 17, 15, 18, 272, 6079, 730, 409, 13, 20526, 436, 704, 4033, 321, 346, 2978, 14, 334, 452, 666, 18336, 434, 1298, 626, 4293, 506, 22569, 5847, 680, 272, 6079, 710, 21977, 3467, 5935, 787, 3365, 687, 314, 24441, 41, 24926, 4789, 12, 315, 4066, 282, 4340, 12, 626, 2985, 4898, 22569, 272, 6079, 370, 314, 5935, 687, 314, 25910, 13, 497, 14128, 4789, 14, 961, 365, 314, 14318, 4789, 367, 909, 15212, 12, 465, 314, 272, 6079, 603, 1668, 35, 1469, 33, 4176, 15538, 883, 506, 1202, 543, 282, 32246, 402, 8793, 5935, 14, 272, 6079, 1666, 4178, 921, 5031, 14, 957, 15, 65, 387, 9518, 15, 35, 9454, 13, 45, 1668, 35, 1469, 33, 370, 12537, 1655, 14, 272, 445, 6737, 45, 527, 559, 391, 63, 3947, 9558, 9497, 379, 275, 2599, 342, 339, 6079, 710, 12142, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 367, 12622, 20055, 315, 12136, 436, 10424, 543, 18336, 434, 1298, 272, 6079, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 5107, 4400, 527, 559, 391, 15, 1080, 63, 4659, 14, 1360, 12, 272, 6079, 1898, 6029, 15170, 16521, 2104, 78, 5741, 83, 12, 1626, 24418, 577, 337, 502, 12, 4580, 12504, 598, 269, 1117, 436, 1603, 3362, 80, 491, 76, 350, 11980, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 445, 6737, 45, 527, 559, 391, 63, 18963, 497, 14128, 275, 2599, 342, 339, 6079, 710, 12700, 1015, 402, 314, 445, 9454, 13, 45, 1668, 35, 1469, 33, 4789, 367, 7060, 29193, 315, 21977, 3467, 272, 6079, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 15, 5107, 4400, 527, 559, 391, 15, 1080, 63, 4659, 14, 1360, 12, 272, 6079, 1898, 6029, 15170, 16521, 2104, 78, 5741, 83, 12, 1626, 24418, 577, 337, 502, 12, 4580, 12504, 598, 269, 1117, 436, 1603, 3362, 80, 491, 76, 350, 11980, 83, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 445, 6737, 45, 527, 559, 391, 63, 6261, 41, 24926, 275, 2599, 342, 339, 6079, 662, 328, 417, 4789, 14, 2900, 4481, 4644, 272, 662, 328, 417, 63, 34, 1273, 426, 281, 275, 2599, 342, 339, 6079, 662, 328, 417, 13148, 641, 481, 264, 374, 335, 310, 3903, 687, 4178, 921, 20153, 374, 335, 310, 3903, 13, 25888, 14, 271, 15, 69, 1671, 14, 1360, 14, 2900, 4481, 4644, 14, 272, 662, 328, 417, 63, 38, 264, 374, 335, 310, 3903, 32660, 275, 2599, 342, 339, 6079, 710, 2104, 17775, 28919, 9916, 5515, 4356, 4789, 687, 1455, 921, 1544, 14, 5107, 67, 14, 8231, 14, 397, 22500, 65, 509, 17775, 15, 12, 844, 21994, 446, 286, 5314, 5839, 272, 2104, 17775, 275, 2599, 342, 339, 6079, 710, 25410, 869, 7474, 1668, 4789, 687, 1455, 921, 2587, 329, 65, 14, 5030, 338, 14, 1458, 14, 397, 15, 526, 77, 527, 15, 12, 844, 21994, 14, 272, 869, 676, 527, 63, 54, 17, 275, 2599, 342, 339, 6079, 710, 1742, 26429, 1015, 402, 314, 869, 7474, 1668, 4789, 543, 9978, 18227, 13, 5964, 687, 4178, 921, 5031, 14, 957, 15, 65, 387, 9518, 15, 40, 676, 527, 272, 869, 676, 527, 63, 54, 18, 275, 2599, 342, 339, 6079, 710, 603, 1668, 35, 1469, 33, 4176, 4789, 687, 4178, 921, 1286, 279, 14, 77, 556, 14, 67, 5411, 14, 16823, 15, 77, 527, 559, 391, 12, 1898, 9708, 17474, 869, 9091, 530, 1335, 82, 14, 1334, 17586, 13, 8285, 13, 6389, 13, 4251, 841, 14, 16, 4190, 272, 603, 527, 559, 391, 25800, 25800, 63, 54, 17, 275, 2599, 342, 339, 6079, 710, 3499, 1015, 402, 314, 603, 1668, 35, 1469, 33, 4176, 4789, 687, 4178, 921, 5031, 14, 957, 15, 7474, 50, 13, 497, 1733, 15, 77, 527, 559, 391, 13, 802, 272, 603, 527, 559, 391, 25800, 25800, 63, 54, 18, 275, 2599, 342, 339, 6079, 437, 1007, 13, 409, 402, 314, 603, 1668, 35, 1469, 33, 4176, 15538, 626, 3509, 16842, 13, 1977, 15538, 367, 410, 7047, 12, 12622, 17616, 1482, 436, 2656, 17616, 1482, 14, 2779, 1990, 18734, 13, 2495, 17174, 14701, 687, 3411, 15538, 436, 10250, 16317, 367, 29102, 14, 710, 15538, 787, 2808, 315, 282, 8971, 4840, 1475, 465, 5521, 465, 315, 314, 5099, 1439, 1475, 14, 272, 603, 527, 559, 391, 25800, 25800, 63, 18611, 21761, 1298, 275, 2599, 342, 339, 6079, 710, 3232, 7474, 50, 5515, 4356, 4789, 687, 4178, 921, 22943, 14, 846, 15, 6776, 15, 1490, 676, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hastexo/edx-platform
lms/djangoapps/course_api/blocks/transformers/tests/test_milestones.py
7
8893
""" Tests for ProctoredExamTransformer. """ import ddt from milestones.tests.utils import MilestonesTestCaseMixin from mock import Mock, patch from nose.plugins.attrib import attr from gating import api as lms_gating_api from lms.djangoapps.course_blocks.transformers.tests.helpers import CourseStructureTestCase from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers from openedx.core.lib.gating import api as gating_api from student.tests.factories import CourseEnrollmentFactory from ...api import get_course_blocks from ..milestones import MilestonesAndSpecialExamsTransformer @attr(shard=3) @ddt.ddt @patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True}) class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseMixin): """ Test behavior of ProctoredExamTransformer """ TRANSFORMER_CLASS_TO_TEST = MilestonesAndSpecialExamsTransformer def setUp(self): """ Setup course structure and create user for split test transformer test. """ super(MilestonesTransformerTestCase, self).setUp() # Build course. self.course_hierarchy = self.get_course_hierarchy() self.blocks = self.build_course(self.course_hierarchy) self.course = self.blocks['course'] # Enroll user in course. CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id, is_active=True) self.transformers = BlockStructureTransformers([self.TRANSFORMER_CLASS_TO_TEST(False)]) def setup_gated_section(self, gated_block, gating_block): """ Test helper to create a gating requirement. Args: gated_block: The block that should be inaccessible until gating_block is completed gating_block: The block that must be completed before access is granted """ gating_api.add_prerequisite(self.course.id, unicode(gating_block.location)) gating_api.set_required_content(self.course.id, gated_block.location, gating_block.location, 100) ALL_BLOCKS = ( 'course', 'A', 'B', 'C', 'ProctoredExam', 'D', 'E', 'PracticeExam', 'F', 'G', 'H', 'I', 'TimedExam', 'J', 'K' ) # The special exams (proctored, practice, timed) are not visible to # students via the Courses API. ALL_BLOCKS_EXCEPT_SPECIAL = ('course', 'A', 'B', 'C', 'H', 'I') def get_course_hierarchy(self): """ Get a course hierarchy to test with. """ # course # / / \ \ \ # / / \ \ \ # A ProctoredExam PracticeExam H TimedExam # / \ / \ / \ | / \ # / \ / \ / \ | / \ # B C D E F G I J K # return [ { 'org': 'MilestonesTransformer', 'course': 'PE101F', 'run': 'test_run', '#type': 'course', '#ref': 'course', }, { '#type': 'sequential', '#ref': 'A', '#children': [ {'#type': 'vertical', '#ref': 'B'}, {'#type': 'vertical', '#ref': 'C'}, ], }, { '#type': 'sequential', '#ref': 'ProctoredExam', 'is_time_limited': True, 'is_proctored_enabled': True, 'is_practice_exam': False, '#children': [ {'#type': 'vertical', '#ref': 'D'}, {'#type': 'vertical', '#ref': 'E'}, ], }, { '#type': 'sequential', '#ref': 'PracticeExam', 'is_time_limited': True, 'is_proctored_enabled': True, 'is_practice_exam': True, '#children': [ {'#type': 'vertical', '#ref': 'F'}, {'#type': 'vertical', '#ref': 'G'}, ], }, { '#type': 'sequential', '#ref': 'H', '#children': [ {'#type': 'vertical', '#ref': 'I'}, ], }, { '#type': 'sequential', '#ref': 'TimedExam', 'is_time_limited': True, 'is_proctored_enabled': False, 'is_practice_exam': False, '#children': [ {'#type': 'vertical', '#ref': 'J'}, {'#type': 'vertical', '#ref': 'K'}, ], }, ] def test_special_exams_not_visible_to_non_staff(self): self.get_blocks_and_check_against_expected(self.user, self.ALL_BLOCKS_EXCEPT_SPECIAL) @ddt.data( ( 'H', 'A', ('course', 'A', 'B', 'C',) ), ( 'H', 'ProctoredExam', ('course', 'A', 'B', 'C'), ), ) @ddt.unpack def test_gated(self, gated_block_ref, gating_block_ref, expected_blocks_before_completion): """ First, checks that a student cannot see the gated block when it is gated by the gating block and no attempt has been made to complete the gating block. Then, checks that the student can see the gated block after the gating block has been completed. expected_blocks_before_completion is the set of blocks we expect to be visible to the student before the student has completed the gating block. The test data includes one special exam and one non-special block as the gating blocks. """ self.course.enable_subsection_gating = True self.setup_gated_section(self.blocks[gated_block_ref], self.blocks[gating_block_ref]) with self.assertNumQueries(8): self.get_blocks_and_check_against_expected(self.user, expected_blocks_before_completion) # clear the request cache to simulate a new request self.clear_caches() # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch('gating.api._get_subsection_percentage', Mock(return_value=100)): lms_gating_api.evaluate_prerequisite( self.course, Mock(location=self.blocks[gating_block_ref].location), self.user, ) with self.assertNumQueries(8): self.get_blocks_and_check_against_expected(self.user, self.ALL_BLOCKS_EXCEPT_SPECIAL) def test_staff_access(self): """ Ensures that staff can always access all blocks in the course, regardless of gating or proctoring. """ expected_blocks = self.ALL_BLOCKS self.setup_gated_section(self.blocks['H'], self.blocks['A']) self.get_blocks_and_check_against_expected(self.staff, expected_blocks) def test_special_exams(self): """ When the block structure transformers are set to allow users to view special exams, ensure that we can see the special exams and not any of the otherwise gated blocks. """ self.transformers = BlockStructureTransformers([self.TRANSFORMER_CLASS_TO_TEST(True)]) self.course.enable_subsection_gating = True self.setup_gated_section(self.blocks['H'], self.blocks['A']) expected_blocks = ( 'course', 'A', 'B', 'C', 'ProctoredExam', 'D', 'E', 'PracticeExam', 'F', 'G', 'TimedExam', 'J', 'K' ) self.get_blocks_and_check_against_expected(self.user, expected_blocks) # clear the request cache to simulate a new request self.clear_caches() # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch('gating.api._get_subsection_percentage', Mock(return_value=100)): lms_gating_api.evaluate_prerequisite( self.course, Mock(location=self.blocks['A'].location), self.user, ) self.get_blocks_and_check_against_expected(self.user, self.ALL_BLOCKS) def get_blocks_and_check_against_expected(self, user, expected_blocks): """ Calls the course API as the specified user and checks the output against a specified set of expected blocks. """ block_structure = get_course_blocks( user, self.course.location, self.transformers, ) self.assertEqual( set(block_structure.get_block_keys()), set(self.get_block_key_set(self.blocks, *expected_blocks)), )
agpl-3.0
[ 624, 199, 2925, 367, 2165, 319, 2908, 920, 455, 19761, 14, 199, 624, 199, 646, 366, 3583, 199, 504, 333, 24156, 14, 2219, 14, 1208, 492, 603, 24156, 1746, 4256, 199, 504, 1683, 492, 4420, 12, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 486, 1958, 492, 2986, 465, 21577, 63, 71, 1958, 63, 1246, 199, 504, 21577, 14, 16432, 14, 1972, 63, 4166, 14, 1515, 22932, 14, 2219, 14, 7546, 492, 5531, 10766, 1746, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 1515, 22932, 492, 8651, 10766, 3188, 22932, 199, 504, 22709, 14, 1018, 14, 773, 14, 71, 1958, 492, 2986, 465, 486, 1958, 63, 1246, 199, 504, 6474, 14, 2219, 14, 15406, 492, 18946, 2927, 199, 199, 504, 2263, 1246, 492, 664, 63, 1972, 63, 4166, 199, 504, 2508, 77, 24156, 492, 603, 24156, 3325, 12246, 920, 19470, 19761, 421, 199, 32, 962, 8, 10810, 29, 19, 9, 199, 32, 11138, 14, 11138, 199, 32, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 25748, 63, 1438, 1156, 51, 356, 715, 1552, 199, 533, 603, 24156, 19761, 1746, 8, 6979, 10766, 1746, 12, 603, 24156, 1746, 4256, 304, 272, 408, 272, 1379, 5953, 402, 2165, 319, 2908, 920, 455, 19761, 272, 408, 272, 9074, 5622, 3516, 540, 63, 6885, 63, 2566, 63, 2864, 275, 603, 24156, 3325, 12246, 920, 19470, 19761, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 12439, 2518, 5523, 436, 1218, 922, 367, 3715, 511, 21484, 511, 14, 267, 408, 267, 1613, 8, 45, 24156, 19761, 1746, 12, 291, 680, 5996, 342, 398, 327, 6516, 2518, 14, 267, 291, 14, 1972, 63, 14861, 275, 291, 14, 362, 63, 1972, 63, 14861, 342, 267, 291, 14, 4166, 275, 291, 14, 1506, 63, 1972, 8, 277, 14, 1972, 63, 14861, 9, 267, 291, 14, 1972, 275, 291, 14, 4166, 459, 1972, 418, 398, 327, 3447, 2827, 922, 315, 2518, 14, 267, 18946, 2927, 14, 981, 8, 751, 29, 277, 14, 751, 12, 2518, 63, 344, 29, 277, 14, 1972, 14, 344, 12, 365, 63, 2682, 29, 549, 9, 398, 291, 14, 1515, 22932, 275, 8651, 10766, 3188, 22932, 779, 277, 14, 30190, 540, 63, 6885, 63, 2566, 63, 2864, 8, 797, 3948, 339, 347, 3272, 63, 71, 972, 63, 2792, 8, 277, 12, 486, 972, 63, 1457, 12, 486, 1958, 63, 1457, 304, 267, 408, 267, 1379, 5922, 370, 1218, 282, 486, 1958, 10685, 14, 267, 3033, 26, 288, 486, 972, 63, 1457, 26, 710, 1853, 626, 1077, 506, 315, 24669, 5133, 486, 1958, 63, 1457, 365, 9709, 288, 486, 1958, 63, 1457, 26, 710, 1853, 626, 1471, 506, 9709, 2544, 2879, 365, 10009, 267, 408, 267, 486, 1958, 63, 1246, 14, 525, 63, 657, 21763, 8, 277, 14, 1972, 14, 344, 12, 2649, 8, 71, 1958, 63, 1457, 14, 1985, 430, 267, 486, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 8, 277, 14, 1972, 14, 344, 12, 486, 972, 63, 1457, 14, 1985, 12, 486, 1958, 63, 1457, 14, 1985, 12, 2948, 9, 339, 11727, 63, 8475, 51, 275, 334, 267, 283, 1972, 297, 283, 33, 297, 283, 34, 297, 283, 35, 297, 283, 919, 319, 2908, 920, 455, 297, 283, 36, 297, 283, 37, 297, 283, 48, 6457, 3548, 920, 455, 297, 283, 38, 297, 283, 39, 297, 283, 40, 297, 283, 41, 297, 283, 28682, 920, 455, 297, 283, 42, 297, 283, 43, 7, 272, 776, 339, 327, 710, 4539, 15735, 83, 334, 496, 319, 2908, 12, 24471, 12, 18590, 9, 787, 440, 8917, 370, 272, 327, 18557, 4799, 314, 445, 567, 874, 3261, 14, 272, 11727, 63, 8475, 51, 63, 11764, 63, 25748, 275, 661, 1972, 297, 283, 33, 297, 283, 34, 297, 283, 35, 297, 283, 40, 297, 283, 41, 358, 339, 347, 664, 63, 1972, 63, 14861, 8, 277, 304, 267, 408, 267, 2372, 282, 2518, 14446, 370, 511, 543, 14, 267, 408, 398, 327, 13293, 2518, 267, 327, 5185, 1182, 755, 1182, 3777, 971, 260, 971, 257, 971, 267, 327, 4519, 1182, 755, 1182, 5185, 971, 260, 971, 257, 971, 267, 327, 3322, 437, 258, 2165, 319, 2908, 920, 455, 257, 510, 6457, 3548, 920, 455, 257, 869, 221, 4703, 68, 920, 455, 267, 327, 3515, 1182, 221, 971, 258, 1182, 971, 3322, 1182, 971, 3322, 1204, 258, 1182, 221, 971, 267, 327, 260, 1182, 257, 971, 259, 1182, 257, 971, 3515, 1182, 257, 971, 3698, 1204, 259, 1182, 259, 971, 267, 327, 263, 699, 259, 445, 257, 577, 258, 662, 263, 481, 259, 598, 3698, 473, 259, 1603, 258, 1804, 267, 327, 267, 372, 359, 288, 469, 355, 283, 1308, 356, 283, 45, 24156, 19761, 297, 355, 283, 1972, 356, 283, 1510, 4893, 38, 297, 355, 283, 1065, 356, 283, 396, 63, 1065, 297, 355, 3943, 466, 356, 283, 1972, 297, 355, 3943, 1121, 356, 283, 1972, 297, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 3943, 1121, 356, 283, 33, 297, 355, 3943, 3223, 356, 359, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 34, 2267, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 35, 2267, 355, 2156, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 3943, 1121, 356, 283, 919, 319, 2908, 920, 455, 297, 355, 283, 374, 63, 521, 63, 14136, 356, 715, 12, 355, 283, 374, 63, 496, 319, 2908, 63, 3827, 356, 715, 12, 355, 283, 374, 63, 80, 6457, 3548, 63, 15425, 356, 756, 12, 355, 3943, 3223, 356, 359, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 36, 2267, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 37, 2267, 355, 2156, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 3943, 1121, 356, 283, 48, 6457, 3548, 920, 455, 297, 355, 283, 374, 63, 521, 63, 14136, 356, 715, 12, 355, 283, 374, 63, 496, 319, 2908, 63, 3827, 356, 715, 12, 355, 283, 374, 63, 80, 6457, 3548, 63, 15425, 356, 715, 12, 355, 3943, 3223, 356, 359 ]
[ 199, 2925, 367, 2165, 319, 2908, 920, 455, 19761, 14, 199, 624, 199, 646, 366, 3583, 199, 504, 333, 24156, 14, 2219, 14, 1208, 492, 603, 24156, 1746, 4256, 199, 504, 1683, 492, 4420, 12, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 486, 1958, 492, 2986, 465, 21577, 63, 71, 1958, 63, 1246, 199, 504, 21577, 14, 16432, 14, 1972, 63, 4166, 14, 1515, 22932, 14, 2219, 14, 7546, 492, 5531, 10766, 1746, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 1515, 22932, 492, 8651, 10766, 3188, 22932, 199, 504, 22709, 14, 1018, 14, 773, 14, 71, 1958, 492, 2986, 465, 486, 1958, 63, 1246, 199, 504, 6474, 14, 2219, 14, 15406, 492, 18946, 2927, 199, 199, 504, 2263, 1246, 492, 664, 63, 1972, 63, 4166, 199, 504, 2508, 77, 24156, 492, 603, 24156, 3325, 12246, 920, 19470, 19761, 421, 199, 32, 962, 8, 10810, 29, 19, 9, 199, 32, 11138, 14, 11138, 199, 32, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 25748, 63, 1438, 1156, 51, 356, 715, 1552, 199, 533, 603, 24156, 19761, 1746, 8, 6979, 10766, 1746, 12, 603, 24156, 1746, 4256, 304, 272, 408, 272, 1379, 5953, 402, 2165, 319, 2908, 920, 455, 19761, 272, 408, 272, 9074, 5622, 3516, 540, 63, 6885, 63, 2566, 63, 2864, 275, 603, 24156, 3325, 12246, 920, 19470, 19761, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 12439, 2518, 5523, 436, 1218, 922, 367, 3715, 511, 21484, 511, 14, 267, 408, 267, 1613, 8, 45, 24156, 19761, 1746, 12, 291, 680, 5996, 342, 398, 327, 6516, 2518, 14, 267, 291, 14, 1972, 63, 14861, 275, 291, 14, 362, 63, 1972, 63, 14861, 342, 267, 291, 14, 4166, 275, 291, 14, 1506, 63, 1972, 8, 277, 14, 1972, 63, 14861, 9, 267, 291, 14, 1972, 275, 291, 14, 4166, 459, 1972, 418, 398, 327, 3447, 2827, 922, 315, 2518, 14, 267, 18946, 2927, 14, 981, 8, 751, 29, 277, 14, 751, 12, 2518, 63, 344, 29, 277, 14, 1972, 14, 344, 12, 365, 63, 2682, 29, 549, 9, 398, 291, 14, 1515, 22932, 275, 8651, 10766, 3188, 22932, 779, 277, 14, 30190, 540, 63, 6885, 63, 2566, 63, 2864, 8, 797, 3948, 339, 347, 3272, 63, 71, 972, 63, 2792, 8, 277, 12, 486, 972, 63, 1457, 12, 486, 1958, 63, 1457, 304, 267, 408, 267, 1379, 5922, 370, 1218, 282, 486, 1958, 10685, 14, 267, 3033, 26, 288, 486, 972, 63, 1457, 26, 710, 1853, 626, 1077, 506, 315, 24669, 5133, 486, 1958, 63, 1457, 365, 9709, 288, 486, 1958, 63, 1457, 26, 710, 1853, 626, 1471, 506, 9709, 2544, 2879, 365, 10009, 267, 408, 267, 486, 1958, 63, 1246, 14, 525, 63, 657, 21763, 8, 277, 14, 1972, 14, 344, 12, 2649, 8, 71, 1958, 63, 1457, 14, 1985, 430, 267, 486, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 8, 277, 14, 1972, 14, 344, 12, 486, 972, 63, 1457, 14, 1985, 12, 486, 1958, 63, 1457, 14, 1985, 12, 2948, 9, 339, 11727, 63, 8475, 51, 275, 334, 267, 283, 1972, 297, 283, 33, 297, 283, 34, 297, 283, 35, 297, 283, 919, 319, 2908, 920, 455, 297, 283, 36, 297, 283, 37, 297, 283, 48, 6457, 3548, 920, 455, 297, 283, 38, 297, 283, 39, 297, 283, 40, 297, 283, 41, 297, 283, 28682, 920, 455, 297, 283, 42, 297, 283, 43, 7, 272, 776, 339, 327, 710, 4539, 15735, 83, 334, 496, 319, 2908, 12, 24471, 12, 18590, 9, 787, 440, 8917, 370, 272, 327, 18557, 4799, 314, 445, 567, 874, 3261, 14, 272, 11727, 63, 8475, 51, 63, 11764, 63, 25748, 275, 661, 1972, 297, 283, 33, 297, 283, 34, 297, 283, 35, 297, 283, 40, 297, 283, 41, 358, 339, 347, 664, 63, 1972, 63, 14861, 8, 277, 304, 267, 408, 267, 2372, 282, 2518, 14446, 370, 511, 543, 14, 267, 408, 398, 327, 13293, 2518, 267, 327, 5185, 1182, 755, 1182, 3777, 971, 260, 971, 257, 971, 267, 327, 4519, 1182, 755, 1182, 5185, 971, 260, 971, 257, 971, 267, 327, 3322, 437, 258, 2165, 319, 2908, 920, 455, 257, 510, 6457, 3548, 920, 455, 257, 869, 221, 4703, 68, 920, 455, 267, 327, 3515, 1182, 221, 971, 258, 1182, 971, 3322, 1182, 971, 3322, 1204, 258, 1182, 221, 971, 267, 327, 260, 1182, 257, 971, 259, 1182, 257, 971, 3515, 1182, 257, 971, 3698, 1204, 259, 1182, 259, 971, 267, 327, 263, 699, 259, 445, 257, 577, 258, 662, 263, 481, 259, 598, 3698, 473, 259, 1603, 258, 1804, 267, 327, 267, 372, 359, 288, 469, 355, 283, 1308, 356, 283, 45, 24156, 19761, 297, 355, 283, 1972, 356, 283, 1510, 4893, 38, 297, 355, 283, 1065, 356, 283, 396, 63, 1065, 297, 355, 3943, 466, 356, 283, 1972, 297, 355, 3943, 1121, 356, 283, 1972, 297, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 3943, 1121, 356, 283, 33, 297, 355, 3943, 3223, 356, 359, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 34, 2267, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 35, 2267, 355, 2156, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 3943, 1121, 356, 283, 919, 319, 2908, 920, 455, 297, 355, 283, 374, 63, 521, 63, 14136, 356, 715, 12, 355, 283, 374, 63, 496, 319, 2908, 63, 3827, 356, 715, 12, 355, 283, 374, 63, 80, 6457, 3548, 63, 15425, 356, 756, 12, 355, 3943, 3223, 356, 359, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 36, 2267, 490, 791, 3, 466, 356, 283, 7870, 297, 3943, 1121, 356, 283, 37, 2267, 355, 2156, 288, 1660, 288, 469, 355, 3943, 466, 356, 283, 16211, 297, 355, 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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 ]
almeidapaulopt/erpnext
erpnext/stock/__init__.py
23
1794
from __future__ import unicode_literals import frappe install_docs = [ {"doctype":"Role", "role_name":"Stock Manager", "name":"Stock Manager"}, {"doctype":"Role", "role_name":"Item Manager", "name":"Item Manager"}, {"doctype":"Role", "role_name":"Stock User", "name":"Stock User"}, {"doctype":"Role", "role_name":"Quality Manager", "name":"Quality Manager"}, {"doctype":"Item Group", "item_group_name":"All Item Groups", "is_group": 1}, {"doctype":"Item Group", "item_group_name":"Default", "parent_item_group":"All Item Groups", "is_group": 0}, ] def get_warehouse_account_map(): if not frappe.flags.warehouse_account_map or frappe.flags.in_test: warehouse_account = frappe._dict() for d in frappe.get_all('Warehouse', filters = {"is_group": 0}, fields = ["name", "account", "parent_warehouse", "company"]): if not d.account: d.account = get_warehouse_account(d.name, d.company) if d.account: d.account_currency = frappe.db.get_value('Account', d.account, 'account_currency') warehouse_account.setdefault(d.name, d) frappe.flags.warehouse_account_map = warehouse_account return frappe.flags.warehouse_account_map def get_warehouse_account(warehouse, company): lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"]) account = frappe.db.sql(""" select account from `tabWarehouse` where lft <= %s and rgt >= %s and company = %s and account is not null and ifnull(account, '') !='' order by lft desc limit 1""", (lft, rgt, company), as_list=1) account = account[0][0] if account else None if not account: account = get_company_default_inventory_account(company) return account def get_company_default_inventory_account(company): return frappe.db.get_value('Company', company, 'default_inventory_account')
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 3174, 63, 4757, 275, 359, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 17103, 13537, 401, 298, 354, 5122, 17103, 13537, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 2081, 13537, 401, 298, 354, 5122, 2081, 13537, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 17103, 2876, 401, 298, 354, 5122, 17103, 2876, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 19436, 13537, 401, 298, 354, 5122, 19436, 13537, 6018, 199, 198, 6641, 6356, 5122, 2081, 5611, 401, 298, 1053, 63, 923, 63, 354, 5122, 2422, 7020, 25031, 401, 298, 374, 63, 923, 582, 413, 1386, 199, 198, 6641, 6356, 5122, 2081, 5611, 401, 298, 1053, 63, 923, 63, 354, 5122, 2698, 401, 11083, 198, 2, 1708, 63, 1053, 63, 923, 5122, 2422, 7020, 25031, 401, 298, 374, 63, 923, 582, 378, 1386, 199, 61, 199, 199, 318, 664, 63, 12806, 63, 2048, 63, 1130, 837, 199, 198, 692, 440, 6950, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 503, 6950, 14, 2469, 14, 262, 63, 396, 26, 507, 198, 12806, 63, 2048, 275, 6950, 423, 807, 342, 2742, 198, 509, 366, 315, 6950, 14, 362, 63, 452, 360, 55, 11499, 297, 4766, 275, 2420, 374, 63, 923, 582, 378, 1386, 686, 198, 955, 275, 2097, 354, 401, 298, 2048, 401, 298, 1708, 63, 12806, 401, 298, 4627, 21473, 686, 198, 692, 440, 366, 14, 2048, 26, 1585, 198, 68, 14, 2048, 275, 664, 63, 12806, 63, 2048, 8, 68, 14, 354, 12, 366, 14, 4627, 9, 6319, 198, 692, 366, 14, 2048, 26, 1585, 198, 68, 14, 2048, 63, 4968, 275, 6950, 14, 697, 14, 362, 63, 585, 360, 6009, 297, 366, 14, 2048, 12, 283, 2048, 63, 4968, 358, 1585, 198, 12806, 63, 2048, 14, 5486, 8, 68, 14, 354, 12, 366, 9, 1585, 507, 198, 9098, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 275, 13782, 63, 2048, 199, 198, 1107, 6950, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 199, 199, 318, 664, 63, 12806, 63, 2048, 8, 12806, 12, 7233, 304, 199, 198, 32462, 12, 519, 3308, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 55, 11499, 401, 13782, 12, 2097, 32462, 401, 298, 82, 3308, 3135, 199, 198, 2048, 275, 6950, 14, 697, 14, 3009, 4852, 507, 198, 2416, 686, 198, 2048, 687, 658, 2902, 55, 11499, 64, 507, 198, 4509, 686, 198, 32462, 2695, 450, 83, 436, 519, 3308, 2356, 450, 83, 436, 7233, 275, 450, 83, 686, 198, 460, 2933, 365, 440, 2973, 436, 340, 2307, 8, 2048, 12, 4074, 8546, 19070, 507, 198, 1648, 701, 14642, 84, 4328, 2304, 413, 7208, 334, 32462, 12, 519, 3308, 12, 7233, 395, 465, 63, 513, 29, 17, 9, 421, 198, 2048, 275, 2933, 59, 16, 1527, 16, 61, 340, 2933, 587, 488, 8299, 198, 692, 440, 2933, 26, 507, 198, 2048, 275, 664, 63, 4627, 63, 885, 63, 7212, 63, 2048, 8, 4627, 9, 8299, 198, 1107, 2933, 507, 199, 318, 664, 63, 4627, 63, 885, 63, 7212, 63, 2048, 8, 4627, 304, 199, 198, 1107, 6950, 14, 697, 14, 362, 63, 585, 360, 16063, 297, 7233, 12, 283, 885, 63, 7212, 63, 2048, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 3174, 63, 4757, 275, 359, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 17103, 13537, 401, 298, 354, 5122, 17103, 13537, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 2081, 13537, 401, 298, 354, 5122, 2081, 13537, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 17103, 2876, 401, 298, 354, 5122, 17103, 2876, 6018, 199, 198, 6641, 6356, 5122, 7422, 401, 298, 3756, 63, 354, 5122, 19436, 13537, 401, 298, 354, 5122, 19436, 13537, 6018, 199, 198, 6641, 6356, 5122, 2081, 5611, 401, 298, 1053, 63, 923, 63, 354, 5122, 2422, 7020, 25031, 401, 298, 374, 63, 923, 582, 413, 1386, 199, 198, 6641, 6356, 5122, 2081, 5611, 401, 298, 1053, 63, 923, 63, 354, 5122, 2698, 401, 11083, 198, 2, 1708, 63, 1053, 63, 923, 5122, 2422, 7020, 25031, 401, 298, 374, 63, 923, 582, 378, 1386, 199, 61, 199, 199, 318, 664, 63, 12806, 63, 2048, 63, 1130, 837, 199, 198, 692, 440, 6950, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 503, 6950, 14, 2469, 14, 262, 63, 396, 26, 507, 198, 12806, 63, 2048, 275, 6950, 423, 807, 342, 2742, 198, 509, 366, 315, 6950, 14, 362, 63, 452, 360, 55, 11499, 297, 4766, 275, 2420, 374, 63, 923, 582, 378, 1386, 686, 198, 955, 275, 2097, 354, 401, 298, 2048, 401, 298, 1708, 63, 12806, 401, 298, 4627, 21473, 686, 198, 692, 440, 366, 14, 2048, 26, 1585, 198, 68, 14, 2048, 275, 664, 63, 12806, 63, 2048, 8, 68, 14, 354, 12, 366, 14, 4627, 9, 6319, 198, 692, 366, 14, 2048, 26, 1585, 198, 68, 14, 2048, 63, 4968, 275, 6950, 14, 697, 14, 362, 63, 585, 360, 6009, 297, 366, 14, 2048, 12, 283, 2048, 63, 4968, 358, 1585, 198, 12806, 63, 2048, 14, 5486, 8, 68, 14, 354, 12, 366, 9, 1585, 507, 198, 9098, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 275, 13782, 63, 2048, 199, 198, 1107, 6950, 14, 2469, 14, 12806, 63, 2048, 63, 1130, 199, 199, 318, 664, 63, 12806, 63, 2048, 8, 12806, 12, 7233, 304, 199, 198, 32462, 12, 519, 3308, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 55, 11499, 401, 13782, 12, 2097, 32462, 401, 298, 82, 3308, 3135, 199, 198, 2048, 275, 6950, 14, 697, 14, 3009, 4852, 507, 198, 2416, 686, 198, 2048, 687, 658, 2902, 55, 11499, 64, 507, 198, 4509, 686, 198, 32462, 2695, 450, 83, 436, 519, 3308, 2356, 450, 83, 436, 7233, 275, 450, 83, 686, 198, 460, 2933, 365, 440, 2973, 436, 340, 2307, 8, 2048, 12, 4074, 8546, 19070, 507, 198, 1648, 701, 14642, 84, 4328, 2304, 413, 7208, 334, 32462, 12, 519, 3308, 12, 7233, 395, 465, 63, 513, 29, 17, 9, 421, 198, 2048, 275, 2933, 59, 16, 1527, 16, 61, 340, 2933, 587, 488, 8299, 198, 692, 440, 2933, 26, 507, 198, 2048, 275, 664, 63, 4627, 63, 885, 63, 7212, 63, 2048, 8, 4627, 9, 8299, 198, 1107, 2933, 507, 199, 318, 664, 63, 4627, 63, 885, 63, 7212, 63, 2048, 8, 4627, 304, 199, 198, 1107, 6950, 14, 697, 14, 362, 63, 585, 360, 16063, 297, 7233, 12, 283, 885, 63, 7212, 63, 2048, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
james08m/PiPhona
log.py
2
1282
__author__ = 'J08M' import pickle from utilities import * # Log class class Log: def __init__(self): self.logs = ["Create log"] self.size = 1 # Add a string to the logs list def add(self, log): self.logs.append("[" + getTimeToSecondes() + "] " + log) self.size = len(self.logs) def display(self): for x in self.logs: print("[log] " + x) # Save log information in a .info file def save(self): with open('logdata.info', 'wb') as file: pickler = pickle.Pickler(file) pickler.dump(self) # save logs # Load log informations from .info file def load(self): with open('logdata.info', 'rb') as file: pickler = pickle.Unpickler(file) copy = pickler.load(); # Get saved log # Clone the log from saved one self.clone(copy) # Clone a user from another user passed by parameter def clone(self,copy): self.logs = copy.logs self.size = copy.size # If run as main ... if __name__ == '__main__': log = Log() log2 = Log() log.add("waiting...") log.add("test...") log.add("end...") log.save() log2.load() log2.display()
gpl-3.0
[ 363, 2502, 363, 275, 283, 42, 2036, 45, 7, 202, 199, 646, 5927, 202, 199, 504, 15841, 492, 627, 2999, 199, 3, 5297, 1021, 202, 199, 533, 5297, 26, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 7270, 275, 2097, 2499, 943, 937, 1039, 291, 14, 890, 275, 413, 2958, 327, 2654, 282, 1059, 370, 314, 9610, 769, 1128, 347, 1050, 8, 277, 12, 943, 304, 1039, 291, 14, 7270, 14, 740, 480, 905, 435, 664, 1366, 1378, 1513, 388, 3424, 342, 435, 32705, 298, 435, 943, 9, 1039, 291, 14, 890, 275, 822, 8, 277, 14, 7270, 9, 2958, 347, 2929, 8, 277, 304, 1039, 367, 671, 315, 291, 14, 7270, 26, 1675, 870, 10994, 793, 61, 298, 435, 671, 9, 2958, 327, 11063, 943, 2556, 315, 282, 1275, 815, 570, 1128, 347, 3354, 8, 277, 304, 1039, 543, 1551, 360, 793, 576, 14, 815, 297, 283, 6603, 358, 465, 570, 26, 1675, 3732, 1435, 275, 5927, 14, 8587, 1435, 8, 493, 9, 1675, 3732, 1435, 14, 2724, 8, 277, 9, 327, 3354, 9610, 2958, 327, 7190, 943, 315, 17308, 687, 1275, 815, 570, 1128, 347, 2248, 8, 277, 304, 1039, 543, 1551, 360, 793, 576, 14, 815, 297, 283, 4848, 358, 465, 570, 26, 1675, 3732, 1435, 275, 5927, 14, 1358, 23468, 8, 493, 9, 1675, 1331, 275, 3732, 1435, 14, 912, 7303, 327, 2372, 6290, 943, 1675, 327, 8465, 368, 314, 943, 687, 6290, 1373, 1675, 291, 14, 6311, 8, 1574, 9, 2958, 327, 8465, 368, 282, 922, 687, 4573, 922, 3032, 701, 2725, 1128, 347, 7289, 8, 277, 12, 1574, 304, 1039, 291, 14, 7270, 275, 1331, 14, 7270, 1039, 291, 14, 890, 275, 1331, 14, 890, 2999, 199, 3, 982, 1255, 465, 2446, 2263, 202, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 943, 275, 5297, 342, 1128, 943, 18, 275, 5297, 342, 1128, 943, 14, 525, 480, 14093, 12594, 1128, 943, 14, 525, 480, 396, 12594, 1128, 943, 14, 525, 480, 500, 12594, 1128, 943, 14, 2117, 342, 1128, 943, 18, 14, 912, 342, 1128, 943, 18, 14, 2918, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2502, 363, 275, 283, 42, 2036, 45, 7, 202, 199, 646, 5927, 202, 199, 504, 15841, 492, 627, 2999, 199, 3, 5297, 1021, 202, 199, 533, 5297, 26, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 7270, 275, 2097, 2499, 943, 937, 1039, 291, 14, 890, 275, 413, 2958, 327, 2654, 282, 1059, 370, 314, 9610, 769, 1128, 347, 1050, 8, 277, 12, 943, 304, 1039, 291, 14, 7270, 14, 740, 480, 905, 435, 664, 1366, 1378, 1513, 388, 3424, 342, 435, 32705, 298, 435, 943, 9, 1039, 291, 14, 890, 275, 822, 8, 277, 14, 7270, 9, 2958, 347, 2929, 8, 277, 304, 1039, 367, 671, 315, 291, 14, 7270, 26, 1675, 870, 10994, 793, 61, 298, 435, 671, 9, 2958, 327, 11063, 943, 2556, 315, 282, 1275, 815, 570, 1128, 347, 3354, 8, 277, 304, 1039, 543, 1551, 360, 793, 576, 14, 815, 297, 283, 6603, 358, 465, 570, 26, 1675, 3732, 1435, 275, 5927, 14, 8587, 1435, 8, 493, 9, 1675, 3732, 1435, 14, 2724, 8, 277, 9, 327, 3354, 9610, 2958, 327, 7190, 943, 315, 17308, 687, 1275, 815, 570, 1128, 347, 2248, 8, 277, 304, 1039, 543, 1551, 360, 793, 576, 14, 815, 297, 283, 4848, 358, 465, 570, 26, 1675, 3732, 1435, 275, 5927, 14, 1358, 23468, 8, 493, 9, 1675, 1331, 275, 3732, 1435, 14, 912, 7303, 327, 2372, 6290, 943, 1675, 327, 8465, 368, 314, 943, 687, 6290, 1373, 1675, 291, 14, 6311, 8, 1574, 9, 2958, 327, 8465, 368, 282, 922, 687, 4573, 922, 3032, 701, 2725, 1128, 347, 7289, 8, 277, 12, 1574, 304, 1039, 291, 14, 7270, 275, 1331, 14, 7270, 1039, 291, 14, 890, 275, 1331, 14, 890, 2999, 199, 3, 982, 1255, 465, 2446, 2263, 202, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 943, 275, 5297, 342, 1128, 943, 18, 275, 5297, 342, 1128, 943, 14, 525, 480, 14093, 12594, 1128, 943, 14, 525, 480, 396, 12594, 1128, 943, 14, 525, 480, 500, 12594, 1128, 943, 14, 2117, 342, 1128, 943, 18, 14, 912, 342, 1128, 943, 18, 14, 2918, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mixturemodel-flow/tensorflow
tensorflow/contrib/stat_summarizer/python/stat_summarizer_test.py
123
2884
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for StatSummarizer Python wrapper.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.core.protobuf import config_pb2 from tensorflow.python import pywrap_tensorflow from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test class StatSummarizerTest(test.TestCase): def testStatSummarizer(self): with ops.Graph().as_default() as graph: matrix1 = constant_op.constant([[3., 3.]], name=r"m1") matrix2 = constant_op.constant([[2.], [2.]], name=r"m2") product = math_ops.matmul(matrix1, matrix2, name=r"product") graph_def = graph.as_graph_def() ss = pywrap_tensorflow.NewStatSummarizer(graph_def.SerializeToString()) with self.test_session() as sess: sess.run(variables.global_variables_initializer()) for _ in range(20): run_metadata = config_pb2.RunMetadata() run_options = config_pb2.RunOptions( trace_level=config_pb2.RunOptions.FULL_TRACE) sess.run(product, options=run_options, run_metadata=run_metadata) ss.ProcessStepStatsStr(run_metadata.step_stats.SerializeToString()) output_string = ss.GetOutputString() print(output_string) # Test it recorded running the expected number of times. self.assertRegexpMatches(output_string, r"count=20") # Test that a header line got printed. self.assertRegexpMatches(output_string, r"====== .* ======") # Test that the nodes we added were analyzed. # The line for the op should contain both the op type (MatMul) # and the name of the node (product) self.assertRegexpMatches(output_string, r"MatMul.*product") self.assertRegexpMatches(output_string, r"Const.*m1") self.assertRegexpMatches(output_string, r"Const.*m2") # Test that a CDF summed to 100% self.assertRegexpMatches(output_string, r"100\.") pywrap_tensorflow.DeleteStatSummarizer(ss) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 27673, 6959, 4584, 1793, 2018, 4975, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 27673, 6959, 4584, 1793, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 11232, 6959, 4584, 1793, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 342, 465, 3343, 26, 489, 3634, 17, 275, 4413, 63, 411, 14, 4083, 4038, 19, 2020, 650, 24245, 536, 29, 82, 2, 77, 17, 531, 489, 3634, 18, 275, 4413, 63, 411, 14, 4083, 4038, 18, 8333, 359, 18, 24245, 536, 29, 82, 2, 77, 18, 531, 489, 3336, 275, 3473, 63, 1483, 14, 14465, 8, 3642, 17, 12, 3634, 18, 12, 536, 29, 82, 2, 2558, 531, 2541, 3343, 63, 318, 275, 3343, 14, 305, 63, 2180, 63, 318, 342, 489, 10110, 275, 1134, 3823, 63, 16008, 14, 4665, 11232, 6959, 4584, 1793, 8, 2180, 63, 318, 14, 9436, 1012, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 4043, 14, 1065, 8, 3669, 14, 2966, 63, 3669, 63, 6498, 1012, 398, 367, 485, 315, 1425, 8, 1165, 304, 881, 1255, 63, 2343, 275, 1101, 63, 3317, 18, 14, 2540, 5142, 342, 881, 1255, 63, 1419, 275, 1101, 63, 3317, 18, 14, 2540, 4558, 8, 1598, 3307, 63, 1896, 29, 888, 63, 3317, 18, 14, 2540, 4558, 14, 14742, 63, 20112, 9, 881, 4043, 14, 1065, 8, 2558, 12, 1511, 29, 1065, 63, 1419, 12, 1255, 63, 2343, 29, 1065, 63, 2343, 9, 8592, 10110, 14, 3498, 7801, 8257, 2848, 8, 1065, 63, 2343, 14, 2926, 63, 3200, 14, 9436, 1012, 2541, 1072, 63, 875, 275, 10110, 14, 18614, 1558, 342, 2541, 870, 8, 1199, 63, 875, 9, 2541, 327, 1379, 652, 18894, 3879, 314, 1420, 1329, 402, 5431, 14, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 835, 29, 1165, 531, 2541, 327, 1379, 626, 282, 1406, 1004, 4788, 12487, 14, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 23476, 23076, 9310, 23758, 2541, 327, 1379, 626, 314, 3380, 781, 3483, 4898, 5909, 7068, 14, 489, 327, 710, 1004, 367, 314, 1687, 1077, 1395, 3865, 314, 1687, 730, 334, 14817, 16867, 9, 489, 327, 436, 314, 536, 402, 314, 1031, 334, 2558, 9, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 14817, 16867, 2795, 2558, 531, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 6361, 2795, 77, 17, 531, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 6361, 2795, 77, 18, 531, 2541, 327, 1379, 626, 282, 445, 3888, 3089, 3594, 370, 2948, 5, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 1960, 60, 2685, 2541, 1134, 3823, 63, 16008, 14, 5392, 11232, 6959, 4584, 1793, 8, 385, 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 ]
[ 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, 2925, 367, 27673, 6959, 4584, 1793, 2018, 4975, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 27673, 6959, 4584, 1793, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 11232, 6959, 4584, 1793, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 342, 465, 3343, 26, 489, 3634, 17, 275, 4413, 63, 411, 14, 4083, 4038, 19, 2020, 650, 24245, 536, 29, 82, 2, 77, 17, 531, 489, 3634, 18, 275, 4413, 63, 411, 14, 4083, 4038, 18, 8333, 359, 18, 24245, 536, 29, 82, 2, 77, 18, 531, 489, 3336, 275, 3473, 63, 1483, 14, 14465, 8, 3642, 17, 12, 3634, 18, 12, 536, 29, 82, 2, 2558, 531, 2541, 3343, 63, 318, 275, 3343, 14, 305, 63, 2180, 63, 318, 342, 489, 10110, 275, 1134, 3823, 63, 16008, 14, 4665, 11232, 6959, 4584, 1793, 8, 2180, 63, 318, 14, 9436, 1012, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 4043, 14, 1065, 8, 3669, 14, 2966, 63, 3669, 63, 6498, 1012, 398, 367, 485, 315, 1425, 8, 1165, 304, 881, 1255, 63, 2343, 275, 1101, 63, 3317, 18, 14, 2540, 5142, 342, 881, 1255, 63, 1419, 275, 1101, 63, 3317, 18, 14, 2540, 4558, 8, 1598, 3307, 63, 1896, 29, 888, 63, 3317, 18, 14, 2540, 4558, 14, 14742, 63, 20112, 9, 881, 4043, 14, 1065, 8, 2558, 12, 1511, 29, 1065, 63, 1419, 12, 1255, 63, 2343, 29, 1065, 63, 2343, 9, 8592, 10110, 14, 3498, 7801, 8257, 2848, 8, 1065, 63, 2343, 14, 2926, 63, 3200, 14, 9436, 1012, 2541, 1072, 63, 875, 275, 10110, 14, 18614, 1558, 342, 2541, 870, 8, 1199, 63, 875, 9, 2541, 327, 1379, 652, 18894, 3879, 314, 1420, 1329, 402, 5431, 14, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 835, 29, 1165, 531, 2541, 327, 1379, 626, 282, 1406, 1004, 4788, 12487, 14, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 23476, 23076, 9310, 23758, 2541, 327, 1379, 626, 314, 3380, 781, 3483, 4898, 5909, 7068, 14, 489, 327, 710, 1004, 367, 314, 1687, 1077, 1395, 3865, 314, 1687, 730, 334, 14817, 16867, 9, 489, 327, 436, 314, 536, 402, 314, 1031, 334, 2558, 9, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 14817, 16867, 2795, 2558, 531, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 6361, 2795, 77, 17, 531, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 6361, 2795, 77, 18, 531, 2541, 327, 1379, 626, 282, 445, 3888, 3089, 3594, 370, 2948, 5, 489, 291, 14, 26672, 8, 1199, 63, 875, 12, 519, 2, 1960, 60, 2685, 2541, 1134, 3823, 63, 16008, 14, 5392, 11232, 6959, 4584, 1793, 8, 385, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
khrapovs/datastorage
datastorage/compustat.py
1
2589
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Short interest dynamics """ from __future__ import print_function, division import os import zipfile import datetime as dt import pandas as pd import matplotlib.pyplot as plt import seaborn as sns path = os.getenv("HOME") + '/Dropbox/Research/data/Compustat/data/' # __location__ = os.path.realpath(os.path.join(os.getcwd(), # os.path.dirname(__file__))) # path = os.path.join(__location__, path + 'Compustat/data/') def date_convert(string): return dt.datetime.strptime(string, '%d-%m-%Y') def import_data(): """Import data and save it to the disk. """ zf = zipfile.ZipFile(path + 'short_int.zip', 'r') name = zf.namelist()[0] short_int = pd.read_csv(zf.open(name), converters={'datadate': date_convert}) columns = {'datadate': 'date', 'SHORTINTADJ': 'short_int', 'GVKEY': 'gvkey'} short_int.rename(columns=columns, inplace=True) short_int.set_index(['gvkey', 'date'], inplace=True) short_int.sort_index(inplace=True) short_int.to_hdf(path + 'short_int.h5', key='short_int') print(short_int.head()) print(short_int.dtypes) print('Number of unique companies: ', short_int.index.get_level_values('gvkey').nunique()) print('Number of unique dates: ', short_int.index.get_level_values('date').nunique()) print('Min and Max date: ', short_int.index.get_level_values('date').min().date(), ',', short_int.index.get_level_values('date').max().date()) def load_data(): """Load data from disk and check for sanity. """ return pd.read_hdf(path + 'short_int.h5', 'short_int') def count_companies(short_int): """Plot number of companies over time. """ df = short_int.reset_index().groupby('date')['gvkey'].nunique() sns.set_context('paper') df.plot(figsize=(10, 3)) plt.show() data = df.ix[dt.date(2006, 1, 1):dt.date(2007, 6, 30)] data.plot(figsize=(10, 3)) plt.show() def mean_short_int(short_int): """Mean short interest on each date. """ df = short_int.groupby(level='date')['short_int'].mean() sns.set_context('paper') df.plot(figsize=(10, 3)) plt.show() df.ix[:dt.date(2004, 12, 31)].plot(figsize=(10, 3)) plt.show() df.ix[dt.date(2006, 1, 1):dt.date(2007, 6, 30)].plot(figsize=(10, 3)) plt.show() if __name__ == '__main__': import_data() short_int = load_data() count_companies(short_int) mean_short_int(short_int)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10039, 13518, 31388, 2932, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 646, 747, 199, 646, 10392, 199, 199, 646, 2197, 465, 4487, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 542, 371, 6161, 465, 308, 561, 199, 199, 515, 275, 747, 14, 12959, 480, 9524, 531, 435, 1994, 11070, 1977, 15, 497, 1733, 15, 576, 15, 2404, 833, 292, 15, 576, 4805, 199, 3, 636, 1985, 363, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 199, 3, 2476, 747, 14, 515, 14, 3475, 3460, 493, 29658, 199, 3, 931, 275, 747, 14, 515, 14, 904, 3460, 1985, 3108, 931, 435, 283, 2404, 833, 292, 15, 576, 6217, 421, 199, 318, 1434, 63, 3916, 8, 875, 304, 272, 372, 4487, 14, 2083, 14, 9866, 8, 875, 12, 1543, 68, 3295, 77, 3295, 57, 358, 421, 199, 318, 492, 63, 576, 837, 272, 408, 6295, 666, 436, 3354, 652, 370, 314, 4543, 14, 339, 408, 272, 20194, 275, 10392, 14, 15016, 8, 515, 435, 283, 3612, 63, 442, 14, 3065, 297, 283, 82, 358, 272, 536, 275, 20194, 14, 23841, 3430, 16, 61, 339, 3974, 63, 442, 275, 6454, 14, 739, 63, 4737, 8, 20127, 14, 1490, 8, 354, 395, 1169, 23172, 3713, 4616, 350, 323, 356, 1434, 63, 3916, 1552, 272, 4362, 275, 791, 4616, 350, 323, 356, 283, 602, 297, 2049, 283, 13003, 2919, 1554, 42, 356, 283, 3612, 63, 442, 297, 2049, 283, 14876, 3078, 356, 283, 30560, 498, 936, 272, 3974, 63, 442, 14, 8165, 8, 3406, 29, 3406, 12, 16304, 29, 549, 9, 272, 3974, 63, 442, 14, 409, 63, 1080, 2941, 30560, 498, 297, 283, 602, 995, 16304, 29, 549, 9, 272, 3974, 63, 442, 14, 3191, 63, 1080, 8, 15008, 29, 549, 9, 339, 3974, 63, 442, 14, 475, 63, 19912, 8, 515, 435, 283, 3612, 63, 442, 14, 72, 21, 297, 790, 534, 3612, 63, 442, 358, 339, 870, 8, 3612, 63, 442, 14, 2993, 1012, 272, 870, 8, 3612, 63, 442, 14, 5717, 9, 272, 870, 360, 3259, 402, 3747, 1013, 23461, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 30560, 498, 1959, 78, 3235, 1012, 272, 870, 360, 3259, 402, 3747, 10831, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 78, 3235, 1012, 272, 870, 360, 4649, 436, 8228, 1434, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 827, 1252, 602, 1062, 30048, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 988, 1252, 602, 1012, 421, 199, 318, 2248, 63, 576, 837, 272, 408, 6200, 666, 687, 4543, 436, 1104, 367, 16740, 14, 339, 408, 272, 372, 6454, 14, 739, 63, 19912, 8, 515, 435, 283, 3612, 63, 442, 14, 72, 21, 297, 283, 3612, 63, 442, 358, 421, 199, 318, 2338, 63, 863, 23461, 8, 3612, 63, 442, 304, 272, 408, 10711, 1329, 402, 1013, 23461, 1806, 900, 14, 339, 408, 272, 4051, 275, 3974, 63, 442, 14, 3958, 63, 1080, 1252, 16968, 360, 602, 24211, 30560, 498, 2278, 78, 3235, 342, 339, 308, 561, 14, 409, 63, 1100, 360, 10443, 358, 339, 4051, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 666, 275, 4051, 14, 1148, 59, 3583, 14, 602, 8, 7968, 12, 413, 12, 413, 304, 3583, 14, 602, 8, 9488, 12, 1227, 12, 4233, 1874, 272, 666, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 421, 199, 318, 4615, 63, 3612, 63, 442, 8, 3612, 63, 442, 304, 272, 408, 14825, 3974, 13518, 641, 1924, 1434, 14, 339, 408, 272, 4051, 275, 3974, 63, 442, 14, 16968, 8, 1896, 534, 602, 24211, 3612, 63, 442, 2278, 3670, 342, 339, 308, 561, 14, 409, 63, 1100, 360, 10443, 358, 339, 4051, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 4051, 14, 1148, 1491, 3583, 14, 602, 8, 15431, 12, 3144, 12, 7105, 22509, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 4051, 14, 1148, 59, 3583, 14, 602, 8, 7968, 12, 413, 12, 413, 304, 3583, 14, 602, 8, 9488, 12, 1227, 12, 4233, 22509, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 492, 63, 576, 342, 272, 3974, 63, 442, 275, 2248, 63, 576, 342, 272, 2338, 63, 863, 23461, 8, 3612, 63, 442, 9, 272, 4615, 63, 3612, 63, 442, 8, 3612, 63, 442, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10039, 13518, 31388, 2932, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 646, 747, 199, 646, 10392, 199, 199, 646, 2197, 465, 4487, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 542, 371, 6161, 465, 308, 561, 199, 199, 515, 275, 747, 14, 12959, 480, 9524, 531, 435, 1994, 11070, 1977, 15, 497, 1733, 15, 576, 15, 2404, 833, 292, 15, 576, 4805, 199, 3, 636, 1985, 363, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 199, 3, 2476, 747, 14, 515, 14, 3475, 3460, 493, 29658, 199, 3, 931, 275, 747, 14, 515, 14, 904, 3460, 1985, 3108, 931, 435, 283, 2404, 833, 292, 15, 576, 6217, 421, 199, 318, 1434, 63, 3916, 8, 875, 304, 272, 372, 4487, 14, 2083, 14, 9866, 8, 875, 12, 1543, 68, 3295, 77, 3295, 57, 358, 421, 199, 318, 492, 63, 576, 837, 272, 408, 6295, 666, 436, 3354, 652, 370, 314, 4543, 14, 339, 408, 272, 20194, 275, 10392, 14, 15016, 8, 515, 435, 283, 3612, 63, 442, 14, 3065, 297, 283, 82, 358, 272, 536, 275, 20194, 14, 23841, 3430, 16, 61, 339, 3974, 63, 442, 275, 6454, 14, 739, 63, 4737, 8, 20127, 14, 1490, 8, 354, 395, 1169, 23172, 3713, 4616, 350, 323, 356, 1434, 63, 3916, 1552, 272, 4362, 275, 791, 4616, 350, 323, 356, 283, 602, 297, 2049, 283, 13003, 2919, 1554, 42, 356, 283, 3612, 63, 442, 297, 2049, 283, 14876, 3078, 356, 283, 30560, 498, 936, 272, 3974, 63, 442, 14, 8165, 8, 3406, 29, 3406, 12, 16304, 29, 549, 9, 272, 3974, 63, 442, 14, 409, 63, 1080, 2941, 30560, 498, 297, 283, 602, 995, 16304, 29, 549, 9, 272, 3974, 63, 442, 14, 3191, 63, 1080, 8, 15008, 29, 549, 9, 339, 3974, 63, 442, 14, 475, 63, 19912, 8, 515, 435, 283, 3612, 63, 442, 14, 72, 21, 297, 790, 534, 3612, 63, 442, 358, 339, 870, 8, 3612, 63, 442, 14, 2993, 1012, 272, 870, 8, 3612, 63, 442, 14, 5717, 9, 272, 870, 360, 3259, 402, 3747, 1013, 23461, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 30560, 498, 1959, 78, 3235, 1012, 272, 870, 360, 3259, 402, 3747, 10831, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 78, 3235, 1012, 272, 870, 360, 4649, 436, 8228, 1434, 26, 1656, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 827, 1252, 602, 1062, 30048, 881, 3974, 63, 442, 14, 1080, 14, 362, 63, 1896, 63, 1459, 360, 602, 1959, 988, 1252, 602, 1012, 421, 199, 318, 2248, 63, 576, 837, 272, 408, 6200, 666, 687, 4543, 436, 1104, 367, 16740, 14, 339, 408, 272, 372, 6454, 14, 739, 63, 19912, 8, 515, 435, 283, 3612, 63, 442, 14, 72, 21, 297, 283, 3612, 63, 442, 358, 421, 199, 318, 2338, 63, 863, 23461, 8, 3612, 63, 442, 304, 272, 408, 10711, 1329, 402, 1013, 23461, 1806, 900, 14, 339, 408, 272, 4051, 275, 3974, 63, 442, 14, 3958, 63, 1080, 1252, 16968, 360, 602, 24211, 30560, 498, 2278, 78, 3235, 342, 339, 308, 561, 14, 409, 63, 1100, 360, 10443, 358, 339, 4051, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 666, 275, 4051, 14, 1148, 59, 3583, 14, 602, 8, 7968, 12, 413, 12, 413, 304, 3583, 14, 602, 8, 9488, 12, 1227, 12, 4233, 1874, 272, 666, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 421, 199, 318, 4615, 63, 3612, 63, 442, 8, 3612, 63, 442, 304, 272, 408, 14825, 3974, 13518, 641, 1924, 1434, 14, 339, 408, 272, 4051, 275, 3974, 63, 442, 14, 16968, 8, 1896, 534, 602, 24211, 3612, 63, 442, 2278, 3670, 342, 339, 308, 561, 14, 409, 63, 1100, 360, 10443, 358, 339, 4051, 14, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 4051, 14, 1148, 1491, 3583, 14, 602, 8, 15431, 12, 3144, 12, 7105, 22509, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 339, 4051, 14, 1148, 59, 3583, 14, 602, 8, 7968, 12, 413, 12, 413, 304, 3583, 14, 602, 8, 9488, 12, 1227, 12, 4233, 22509, 2798, 8, 23899, 2687, 709, 12, 650, 430, 272, 4488, 14, 2384, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 492, 63, 576, 342, 272, 3974, 63, 442, 275, 2248, 63, 576, 342, 272, 2338, 63, 863, 23461, 8, 3612, 63, 442, 9, 272, 4615, 63, 3612, 63, 442, 8, 3612, 63, 442, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sgraham/nope
third_party/colorama/src/colorama/tests/ansitowin32_test.py
5
6445
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. try: # python3 from io import StringIO except ImportError: # python2 import StringIO try: # with unittest2 installed, presumably is Python <= 2.6 from unittest2 import TestCase, main except ImportError: # without unittest2 installed, hopefully is Python > 2.6 from unittest import TestCase, main from mock import Mock, patch from .utils import platform from ..ansi import Style from ..ansitowin32 import AnsiToWin32, StreamWrapper class StreamWrapperTest(TestCase): def testIsAProxy(self): mockStream = Mock() wrapper = StreamWrapper(mockStream, None) self.assertTrue( wrapper.random_attr is mockStream.random_attr ) def testDelegatesWrite(self): mockStream = Mock() mockConverter = Mock() wrapper = StreamWrapper(mockStream, mockConverter) wrapper.write('hello') self.assertTrue(mockConverter.write.call_args, (('hello',), {})) class AnsiToWin32Test(TestCase): def testInit(self): mockStdout = object() auto = object() stream = AnsiToWin32(mockStdout, autoreset=auto) self.assertEqual(stream.wrapped, mockStdout) self.assertEqual(stream.autoreset, auto) @patch('colorama.ansitowin32.winterm', None) def testStripIsTrueOnWindows(self): with platform('windows'): stream = AnsiToWin32(None) self.assertTrue(stream.strip) def testStripIsFalseOffWindows(self): with platform('darwin'): stream = AnsiToWin32(None) self.assertFalse(stream.strip) def testWriteStripsAnsi(self): mockStdout = Mock() stream = AnsiToWin32(mockStdout) stream.wrapped = Mock() stream.write_and_convert = Mock() stream.strip = True stream.write('abc') self.assertFalse(stream.wrapped.write.called) self.assertEqual(stream.write_and_convert.call_args, (('abc',), {})) def testWriteDoesNotStripAnsi(self): mockStdout = Mock() stream = AnsiToWin32(mockStdout) stream.wrapped = Mock() stream.write_and_convert = Mock() stream.strip = False stream.convert = False stream.write('abc') self.assertFalse(stream.write_and_convert.called) self.assertEqual(stream.wrapped.write.call_args, (('abc',), {})) def assert_autoresets(self, convert, autoreset=True): stream = AnsiToWin32(Mock()) stream.convert = convert stream.reset_all = Mock() stream.autoreset = autoreset stream.winterm = Mock() stream.write('abc') self.assertEqual(stream.reset_all.called, autoreset) def testWriteAutoresets(self): self.assert_autoresets(convert=True) self.assert_autoresets(convert=False) self.assert_autoresets(convert=True, autoreset=False) self.assert_autoresets(convert=False, autoreset=False) def testWriteAndConvertWritesPlainText(self): stream = AnsiToWin32(Mock()) stream.write_and_convert( 'abc' ) self.assertEqual( stream.wrapped.write.call_args, (('abc',), {}) ) def testWriteAndConvertStripsAllValidAnsi(self): stream = AnsiToWin32(Mock()) stream.call_win32 = Mock() data = [ 'abc\033[mdef', 'abc\033[0mdef', 'abc\033[2mdef', 'abc\033[02mdef', 'abc\033[002mdef', 'abc\033[40mdef', 'abc\033[040mdef', 'abc\033[0;1mdef', 'abc\033[40;50mdef', 'abc\033[50;30;40mdef', 'abc\033[Adef', 'abc\033[0Gdef', 'abc\033[1;20;128Hdef', ] for datum in data: stream.wrapped.write.reset_mock() stream.write_and_convert( datum ) self.assertEqual( [args[0] for args in stream.wrapped.write.call_args_list], [ ('abc',), ('def',) ] ) def testWriteAndConvertSkipsEmptySnippets(self): stream = AnsiToWin32(Mock()) stream.call_win32 = Mock() stream.write_and_convert( '\033[40m\033[41m' ) self.assertFalse( stream.wrapped.write.called ) def testWriteAndConvertCallsWin32WithParamsAndCommand(self): stream = AnsiToWin32(Mock()) stream.convert = True stream.call_win32 = Mock() stream.extract_params = Mock(return_value='params') data = { 'abc\033[adef': ('a', 'params'), 'abc\033[;;bdef': ('b', 'params'), 'abc\033[0cdef': ('c', 'params'), 'abc\033[;;0;;Gdef': ('G', 'params'), 'abc\033[1;20;128Hdef': ('H', 'params'), } for datum, expected in data.items(): stream.call_win32.reset_mock() stream.write_and_convert( datum ) self.assertEqual( stream.call_win32.call_args[0], expected ) def test_reset_all_shouldnt_raise_on_closed_orig_stdout(self): stream = StringIO() converter = AnsiToWin32(stream) stream.close() converter.reset_all() def testExtractParams(self): stream = AnsiToWin32(Mock()) data = { '': (), ';;': (), '2': (2,), ';;002;;': (2,), '0;1': (0, 1), ';;003;;456;;': (3, 456), '11;22;33;44;55': (11, 22, 33, 44, 55), } for datum, expected in data.items(): self.assertEqual(stream.extract_params(datum), expected) def testCallWin32UsesLookup(self): listener = Mock() stream = AnsiToWin32(listener) stream.win32_calls = { 1: (lambda *_, **__: listener(11),), 2: (lambda *_, **__: listener(22),), 3: (lambda *_, **__: listener(33),), } stream.call_win32('m', (3, 1, 99, 2)) self.assertEqual( [a[0][0] for a in listener.call_args_list], [33, 11, 22] ) def testCallWin32DefaultsToParams0(self): mockStdout = Mock() stream = AnsiToWin32(mockStdout) stream.win32_calls = {0: (mockStdout.reset,)} stream.call_win32('m', []) self.assertTrue(mockStdout.reset.called) if __name__ == '__main__': main()
bsd-3-clause
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 893, 26, 272, 327, 2366, 19, 272, 687, 5890, 492, 5228, 199, 2590, 3545, 26, 272, 327, 2366, 18, 272, 492, 5228, 199, 199, 893, 26, 272, 327, 543, 2882, 18, 4903, 12, 25210, 453, 6665, 365, 2018, 2695, 499, 14, 22, 272, 687, 2882, 18, 492, 7640, 12, 2446, 199, 2590, 3545, 26, 272, 327, 1928, 2882, 18, 4903, 12, 3661, 5836, 365, 2018, 690, 499, 14, 22, 272, 687, 2882, 492, 7640, 12, 2446, 199, 199, 504, 1683, 492, 4420, 12, 3371, 199, 199, 504, 1275, 1208, 492, 4298, 199, 199, 504, 2508, 22204, 492, 19442, 199, 504, 2508, 22204, 475, 2676, 708, 492, 31656, 1378, 8886, 708, 12, 8271, 4590, 4388, 199, 533, 8271, 4590, 774, 8, 1746, 304, 339, 347, 511, 14104, 4936, 8, 277, 304, 267, 1683, 3296, 275, 4420, 342, 267, 4975, 275, 8271, 4590, 8, 1805, 3296, 12, 488, 9, 267, 291, 14, 1815, 8, 4975, 14, 2355, 63, 962, 365, 1683, 3296, 14, 2355, 63, 962, 776, 339, 347, 511, 3896, 71, 2335, 3534, 8, 277, 304, 267, 1683, 3296, 275, 4420, 342, 267, 1683, 11907, 275, 4420, 342, 267, 4975, 275, 8271, 4590, 8, 1805, 3296, 12, 1683, 11907, 9, 267, 4975, 14, 952, 360, 5006, 358, 267, 291, 14, 1815, 8, 1805, 11907, 14, 952, 14, 1250, 63, 589, 12, 13636, 5006, 5529, 17003, 421, 199, 533, 31656, 1378, 8886, 708, 774, 8, 1746, 304, 339, 347, 511, 9346, 8, 277, 304, 267, 1683, 26080, 275, 909, 342, 267, 2599, 275, 909, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 12, 28589, 409, 29, 2495, 9, 267, 291, 14, 629, 8, 1745, 14, 9130, 12, 1683, 26080, 9, 267, 291, 14, 629, 8, 1745, 14, 27082, 409, 12, 2599, 9, 339, 768, 2068, 360, 2326, 14541, 14, 22204, 475, 2676, 708, 14, 87, 1058, 77, 297, 488, 9, 272, 347, 511, 21332, 1831, 549, 3314, 8647, 8, 277, 304, 267, 543, 4298, 360, 8258, 735, 288, 2547, 275, 31656, 1378, 8886, 708, 8, 403, 9, 288, 291, 14, 1815, 8, 1745, 14, 1913, 9, 339, 347, 511, 21332, 1831, 797, 5195, 8647, 8, 277, 304, 267, 543, 4298, 360, 13245, 735, 288, 2547, 275, 31656, 1378, 8886, 708, 8, 403, 9, 288, 291, 14, 3334, 8, 1745, 14, 1913, 9, 2378, 347, 511, 3534, 24125, 1190, 2493, 338, 8, 277, 304, 267, 1683, 26080, 275, 4420, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 9, 267, 2547, 14, 9130, 275, 4420, 342, 267, 2547, 14, 952, 63, 460, 63, 3916, 275, 4420, 342, 267, 2547, 14, 1913, 275, 715, 398, 2547, 14, 952, 360, 3175, 358, 398, 291, 14, 3334, 8, 1745, 14, 9130, 14, 952, 14, 3527, 9, 267, 291, 14, 629, 8, 1745, 14, 952, 63, 460, 63, 3916, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 17003, 2378, 347, 511, 3534, 7193, 21332, 2493, 338, 8, 277, 304, 267, 1683, 26080, 275, 4420, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 9, 267, 2547, 14, 9130, 275, 4420, 342, 267, 2547, 14, 952, 63, 460, 63, 3916, 275, 4420, 342, 267, 2547, 14, 1913, 275, 756, 267, 2547, 14, 3916, 275, 756, 398, 2547, 14, 952, 360, 3175, 358, 2728, 291, 14, 3334, 8, 1745, 14, 952, 63, 460, 63, 3916, 14, 3527, 9, 267, 291, 14, 629, 8, 1745, 14, 9130, 14, 952, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 17003, 2378, 347, 702, 63, 27082, 2193, 8, 277, 12, 3957, 12, 28589, 409, 29, 549, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 3916, 275, 3957, 267, 2547, 14, 3958, 63, 452, 275, 4420, 342, 267, 2547, 14, 27082, 409, 275, 28589, 409, 267, 2547, 14, 87, 1058, 77, 275, 4420, 342, 398, 2547, 14, 952, 360, 3175, 358, 2728, 291, 14, 629, 8, 1745, 14, 3958, 63, 452, 14, 3527, 12, 28589, 409, 9, 339, 347, 511, 3534, 23570, 720, 2193, 8, 277, 304, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 549, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 797, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 549, 12, 28589, 409, 29, 797, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 797, 12, 28589, 409, 29, 797, 9, 339, 347, 511, 3534, 3325, 7306, 20908, 20711, 1872, 8, 277, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 952, 63, 460, 63, 3916, 8, 283, 3175, 7, 776, 267, 291, 14, 629, 8, 2547, 14, 9130, 14, 952, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 5009, 776, 339, 347, 511, 3534, 3325, 7306, 24125, 1190, 2422, 3490, 2493, 338, 8, 277, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 1250, 63, 2676, 708, 275, 4420, 342, 267, 666, 275, 359, 288, 283, 3175, 60, 8762, 59, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 18, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 996, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 7432, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 2167, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 11189, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 27, 17, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 2167, 27, 1400, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 1400, 27, 1216, 27, 2167, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 33, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 39, 318, 297, 288, 283, 3175, 60, 8762, 59, 17, 27, 1165, 27, 3933, 40, 318, 297, 267, 1622, 267, 367, 18908, 315, 666, 26, 288, 2547, 14, 9130, 14, 952, 14, 3958, 63, 1805, 342, 288, 2547, 14, 952, 63, 460, 63, 3916, 8, 18908, 776, 288, 291, 14, 629, 8, 2049, 359, 589, 59, 16, 61, 367, 1249, 315 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 893, 26, 272, 327, 2366, 19, 272, 687, 5890, 492, 5228, 199, 2590, 3545, 26, 272, 327, 2366, 18, 272, 492, 5228, 199, 199, 893, 26, 272, 327, 543, 2882, 18, 4903, 12, 25210, 453, 6665, 365, 2018, 2695, 499, 14, 22, 272, 687, 2882, 18, 492, 7640, 12, 2446, 199, 2590, 3545, 26, 272, 327, 1928, 2882, 18, 4903, 12, 3661, 5836, 365, 2018, 690, 499, 14, 22, 272, 687, 2882, 492, 7640, 12, 2446, 199, 199, 504, 1683, 492, 4420, 12, 3371, 199, 199, 504, 1275, 1208, 492, 4298, 199, 199, 504, 2508, 22204, 492, 19442, 199, 504, 2508, 22204, 475, 2676, 708, 492, 31656, 1378, 8886, 708, 12, 8271, 4590, 4388, 199, 533, 8271, 4590, 774, 8, 1746, 304, 339, 347, 511, 14104, 4936, 8, 277, 304, 267, 1683, 3296, 275, 4420, 342, 267, 4975, 275, 8271, 4590, 8, 1805, 3296, 12, 488, 9, 267, 291, 14, 1815, 8, 4975, 14, 2355, 63, 962, 365, 1683, 3296, 14, 2355, 63, 962, 776, 339, 347, 511, 3896, 71, 2335, 3534, 8, 277, 304, 267, 1683, 3296, 275, 4420, 342, 267, 1683, 11907, 275, 4420, 342, 267, 4975, 275, 8271, 4590, 8, 1805, 3296, 12, 1683, 11907, 9, 267, 4975, 14, 952, 360, 5006, 358, 267, 291, 14, 1815, 8, 1805, 11907, 14, 952, 14, 1250, 63, 589, 12, 13636, 5006, 5529, 17003, 421, 199, 533, 31656, 1378, 8886, 708, 774, 8, 1746, 304, 339, 347, 511, 9346, 8, 277, 304, 267, 1683, 26080, 275, 909, 342, 267, 2599, 275, 909, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 12, 28589, 409, 29, 2495, 9, 267, 291, 14, 629, 8, 1745, 14, 9130, 12, 1683, 26080, 9, 267, 291, 14, 629, 8, 1745, 14, 27082, 409, 12, 2599, 9, 339, 768, 2068, 360, 2326, 14541, 14, 22204, 475, 2676, 708, 14, 87, 1058, 77, 297, 488, 9, 272, 347, 511, 21332, 1831, 549, 3314, 8647, 8, 277, 304, 267, 543, 4298, 360, 8258, 735, 288, 2547, 275, 31656, 1378, 8886, 708, 8, 403, 9, 288, 291, 14, 1815, 8, 1745, 14, 1913, 9, 339, 347, 511, 21332, 1831, 797, 5195, 8647, 8, 277, 304, 267, 543, 4298, 360, 13245, 735, 288, 2547, 275, 31656, 1378, 8886, 708, 8, 403, 9, 288, 291, 14, 3334, 8, 1745, 14, 1913, 9, 2378, 347, 511, 3534, 24125, 1190, 2493, 338, 8, 277, 304, 267, 1683, 26080, 275, 4420, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 9, 267, 2547, 14, 9130, 275, 4420, 342, 267, 2547, 14, 952, 63, 460, 63, 3916, 275, 4420, 342, 267, 2547, 14, 1913, 275, 715, 398, 2547, 14, 952, 360, 3175, 358, 398, 291, 14, 3334, 8, 1745, 14, 9130, 14, 952, 14, 3527, 9, 267, 291, 14, 629, 8, 1745, 14, 952, 63, 460, 63, 3916, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 17003, 2378, 347, 511, 3534, 7193, 21332, 2493, 338, 8, 277, 304, 267, 1683, 26080, 275, 4420, 342, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 1805, 26080, 9, 267, 2547, 14, 9130, 275, 4420, 342, 267, 2547, 14, 952, 63, 460, 63, 3916, 275, 4420, 342, 267, 2547, 14, 1913, 275, 756, 267, 2547, 14, 3916, 275, 756, 398, 2547, 14, 952, 360, 3175, 358, 2728, 291, 14, 3334, 8, 1745, 14, 952, 63, 460, 63, 3916, 14, 3527, 9, 267, 291, 14, 629, 8, 1745, 14, 9130, 14, 952, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 17003, 2378, 347, 702, 63, 27082, 2193, 8, 277, 12, 3957, 12, 28589, 409, 29, 549, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 3916, 275, 3957, 267, 2547, 14, 3958, 63, 452, 275, 4420, 342, 267, 2547, 14, 27082, 409, 275, 28589, 409, 267, 2547, 14, 87, 1058, 77, 275, 4420, 342, 398, 2547, 14, 952, 360, 3175, 358, 2728, 291, 14, 629, 8, 1745, 14, 3958, 63, 452, 14, 3527, 12, 28589, 409, 9, 339, 347, 511, 3534, 23570, 720, 2193, 8, 277, 304, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 549, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 797, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 549, 12, 28589, 409, 29, 797, 9, 267, 291, 14, 479, 63, 27082, 2193, 8, 3916, 29, 797, 12, 28589, 409, 29, 797, 9, 339, 347, 511, 3534, 3325, 7306, 20908, 20711, 1872, 8, 277, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 952, 63, 460, 63, 3916, 8, 283, 3175, 7, 776, 267, 291, 14, 629, 8, 2547, 14, 9130, 14, 952, 14, 1250, 63, 589, 12, 13636, 3175, 5529, 5009, 776, 339, 347, 511, 3534, 3325, 7306, 24125, 1190, 2422, 3490, 2493, 338, 8, 277, 304, 267, 2547, 275, 31656, 1378, 8886, 708, 8, 3346, 1012, 267, 2547, 14, 1250, 63, 2676, 708, 275, 4420, 342, 267, 666, 275, 359, 288, 283, 3175, 60, 8762, 59, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 18, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 996, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 7432, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 2167, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 11189, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 27, 17, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 2167, 27, 1400, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 1400, 27, 1216, 27, 2167, 77, 318, 297, 288, 283, 3175, 60, 8762, 59, 33, 318, 297, 288, 283, 3175, 60, 8762, 59, 16, 39, 318, 297, 288, 283, 3175, 60, 8762, 59, 17, 27, 1165, 27, 3933, 40, 318, 297, 267, 1622, 267, 367, 18908, 315, 666, 26, 288, 2547, 14, 9130, 14, 952, 14, 3958, 63, 1805, 342, 288, 2547, 14, 952, 63, 460, 63, 3916, 8, 18908, 776, 288, 291, 14, 629, 8, 2049, 359, 589, 59, 16, 61, 367, 1249, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nanditav/15712-TensorFlow
tensorflow/tensorboard/backend/handler.py
14
21208
# 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. # ============================================================================== """TensorBoard server handler logic. TensorboardHandler contains all the logic for serving static files off of disk and for handling the API calls to endpoints like /tags that require information about loaded events. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import csv import functools import imghdr import mimetypes import os from six import StringIO from six.moves import BaseHTTPServer from six.moves import urllib from six.moves import xrange # pylint: disable=redefined-builtin from six.moves.urllib import parse as urlparse from tensorflow.python.platform import resource_loader from tensorflow.python.platform import tf_logging as logging from tensorflow.python.summary import event_accumulator from tensorflow.tensorboard.backend import process_graph from tensorflow.tensorboard.lib.python import http from tensorflow.tensorboard.plugins import REGISTERED_PLUGINS DATA_PREFIX = '/data' LOGDIR_ROUTE = '/logdir' RUNS_ROUTE = '/runs' PLUGIN_PREFIX = '/plugin' SCALARS_ROUTE = '/' + event_accumulator.SCALARS IMAGES_ROUTE = '/' + event_accumulator.IMAGES AUDIO_ROUTE = '/' + event_accumulator.AUDIO HISTOGRAMS_ROUTE = '/' + event_accumulator.HISTOGRAMS COMPRESSED_HISTOGRAMS_ROUTE = '/' + event_accumulator.COMPRESSED_HISTOGRAMS INDIVIDUAL_IMAGE_ROUTE = '/individualImage' INDIVIDUAL_AUDIO_ROUTE = '/individualAudio' GRAPH_ROUTE = '/' + event_accumulator.GRAPH RUN_METADATA_ROUTE = '/' + event_accumulator.RUN_METADATA TAB_ROUTES = ['', '/events', '/images', '/audio', '/graphs', '/histograms'] _IMGHDR_TO_MIMETYPE = { 'bmp': 'image/bmp', 'gif': 'image/gif', 'jpeg': 'image/jpeg', 'png': 'image/png' } _DEFAULT_IMAGE_MIMETYPE = 'application/octet-stream' def _content_type_for_image(encoded_image_string): image_type = imghdr.what(None, encoded_image_string) return _IMGHDR_TO_MIMETYPE.get(image_type, _DEFAULT_IMAGE_MIMETYPE) class _OutputFormat(object): """An enum used to list the valid output formats for API calls. Not all API calls support all formats (for example, only scalars and compressed histograms support CSV). """ JSON = 'json' CSV = 'csv' class TensorboardHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handler class for use with BaseHTTPServer.HTTPServer. This is essentially a thin wrapper around calls to an EventMultiplexer object as well as serving files off disk. """ # How many samples to include in sampling API calls by default. DEFAULT_SAMPLE_COUNT = 10 # NOTE TO MAINTAINERS: An accurate Content-Length MUST be specified on all # responses using send_header. protocol_version = 'HTTP/1.1' def __init__(self, multiplexer, logdir, *args): self._multiplexer = multiplexer self._logdir = logdir self._setup_data_handlers() BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) def _setup_data_handlers(self): self.data_handlers = { DATA_PREFIX + LOGDIR_ROUTE: self._serve_logdir, DATA_PREFIX + SCALARS_ROUTE: self._serve_scalars, DATA_PREFIX + GRAPH_ROUTE: self._serve_graph, DATA_PREFIX + RUN_METADATA_ROUTE: self._serve_run_metadata, DATA_PREFIX + HISTOGRAMS_ROUTE: self._serve_histograms, DATA_PREFIX + COMPRESSED_HISTOGRAMS_ROUTE: self._serve_compressed_histograms, DATA_PREFIX + IMAGES_ROUTE: self._serve_images, DATA_PREFIX + INDIVIDUAL_IMAGE_ROUTE: self._serve_image, DATA_PREFIX + AUDIO_ROUTE: self._serve_audio, DATA_PREFIX + INDIVIDUAL_AUDIO_ROUTE: self._serve_individual_audio, DATA_PREFIX + RUNS_ROUTE: self._serve_runs, '/app.js': self._serve_js } # Serve the routes from the registered plugins using their name as the route # prefix. For example if plugin z has two routes /a and /b, they will be # served as /data/plugin/z/a and /data/plugin/z/b. for name in REGISTERED_PLUGINS: try: plugin = REGISTERED_PLUGINS[name] plugin_handlers = plugin.get_plugin_handlers( self._multiplexer.RunPaths(), self._logdir) except Exception as e: # pylint: disable=broad-except logging.warning('Plugin %s failed. Exception: %s', name, str(e)) continue for route, handler in plugin_handlers.items(): path = DATA_PREFIX + PLUGIN_PREFIX + '/' + name + route self.data_handlers[path] = functools.partial(handler, self) def respond(self, *args, **kwargs): """Delegates to http.Respond.""" http.Respond(self, *args, **kwargs) # We use underscore_names for consistency with inherited methods. def _image_response_for_run(self, run_images, run, tag): """Builds a JSON-serializable object with information about run_images. Args: run_images: A list of event_accumulator.ImageValueEvent objects. run: The name of the run. tag: The name of the tag the images all belong to. Returns: A list of dictionaries containing the wall time, step, URL, width, and height for each image. """ response = [] for index, run_image in enumerate(run_images): response.append({ 'wall_time': run_image.wall_time, 'step': run_image.step, # We include the size so that the frontend can add that to the <img> # tag so that the page layout doesn't change when the image loads. 'width': run_image.width, 'height': run_image.height, 'query': self._query_for_individual_image(run, tag, index) }) return response def _audio_response_for_run(self, run_audio, run, tag): """Builds a JSON-serializable object with information about run_audio. Args: run_audio: A list of event_accumulator.AudioValueEvent objects. run: The name of the run. tag: The name of the tag the images all belong to. Returns: A list of dictionaries containing the wall time, step, URL, and content_type for each audio clip. """ response = [] for index, run_audio_clip in enumerate(run_audio): response.append({ 'wall_time': run_audio_clip.wall_time, 'step': run_audio_clip.step, 'content_type': run_audio_clip.content_type, 'query': self._query_for_individual_audio(run, tag, index) }) return response def _path_is_safe(self, path): """Check path is safe (stays within current directory). This is for preventing directory-traversal attacks. Args: path: The path to check for safety. Returns: True if the given path stays within the current directory, and false if it would escape to a higher directory. E.g. _path_is_safe('index.html') returns true, but _path_is_safe('../../../etc/password') returns false. """ base = os.path.abspath(os.curdir) absolute_path = os.path.abspath(path) prefix = os.path.commonprefix([base, absolute_path]) return prefix == base def _serve_logdir(self, unused_query_params): """Writes out the logdir argument with which this tensorboard was started. """ self.respond({'logdir': self._logdir}, 'application/json') def _serve_scalars(self, query_params): """Given a tag and single run, return array of ScalarEvents. Alternately, if both the tag and the run are omitted, returns JSON object where obj[run][tag] contains sample values for the given tag in the given run. Args: query_params: The query parameters as a dict. """ # TODO(cassandrax): return HTTP status code for malformed requests tag = query_params.get('tag') run = query_params.get('run') if tag is None and run is None: if query_params.get('format') == _OutputFormat.CSV: self.respond('Scalar sample values only supports JSON output', 'text/plain', 400) return sample_count = int(query_params.get('sample_count', self.DEFAULT_SAMPLE_COUNT)) values = {} for run_name, tags in self._multiplexer.Runs().items(): values[run_name] = { tag: _uniform_sample( self._multiplexer.Scalars(run_name, tag), sample_count) for tag in tags['scalars'] } else: values = self._multiplexer.Scalars(run, tag) if query_params.get('format') == _OutputFormat.CSV: string_io = StringIO() writer = csv.writer(string_io) writer.writerow(['Wall time', 'Step', 'Value']) writer.writerows(values) self.respond(string_io.getvalue(), 'text/csv') else: self.respond(values, 'application/json') def _serve_graph(self, query_params): """Given a single run, return the graph definition in json format.""" run = query_params.get('run', None) if run is None: self.respond('query parameter "run" is required', 'text/plain', 400) return try: graph = self._multiplexer.Graph(run) except ValueError: self.send_response(404) return limit_attr_size = query_params.get('limit_attr_size', None) if limit_attr_size is not None: try: limit_attr_size = int(limit_attr_size) except ValueError: self.respond('query parameter `limit_attr_size` must be integer', 'text/plain', 400) return large_attrs_key = query_params.get('large_attrs_key', None) try: process_graph.prepare_graph_for_ui(graph, limit_attr_size, large_attrs_key) except ValueError as e: self.respond(e.message, 'text/plain', 400) return self.respond(str(graph), 'text/x-protobuf') # pbtxt def _serve_run_metadata(self, query_params): """Given a tag and a TensorFlow run, return the session.run() metadata.""" tag = query_params.get('tag', None) run = query_params.get('run', None) if tag is None: self.respond('query parameter "tag" is required', 'text/plain', 400) return if run is None: self.respond('query parameter "run" is required', 'text/plain', 400) return try: run_metadata = self._multiplexer.RunMetadata(run, tag) except ValueError: self.send_response(404) return self.respond(str(run_metadata), 'text/x-protobuf') # pbtxt def _serve_histograms(self, query_params): """Given a tag and single run, return an array of histogram values.""" tag = query_params.get('tag') run = query_params.get('run') values = self._multiplexer.Histograms(run, tag) self.respond(values, 'application/json') def _serve_compressed_histograms(self, query_params): """Given a tag and single run, return an array of compressed histograms.""" tag = query_params.get('tag') run = query_params.get('run') compressed_histograms = self._multiplexer.CompressedHistograms(run, tag) if query_params.get('format') == _OutputFormat.CSV: string_io = StringIO() writer = csv.writer(string_io) # Build the headers; we have two columns for timing and two columns for # each compressed histogram bucket. headers = ['Wall time', 'Step'] if compressed_histograms: bucket_count = len(compressed_histograms[0].compressed_histogram_values) for i in xrange(bucket_count): headers += ['Edge %d basis points' % i, 'Edge %d value' % i] writer.writerow(headers) for compressed_histogram in compressed_histograms: row = [compressed_histogram.wall_time, compressed_histogram.step] for value in compressed_histogram.compressed_histogram_values: row += [value.rank_in_bps, value.value] writer.writerow(row) self.respond(string_io.getvalue(), 'text/csv') else: self.respond(compressed_histograms, 'application/json') def _serve_images(self, query_params): """Given a tag and list of runs, serve a list of images. Note that the images themselves are not sent; instead, we respond with URLs to the images. The frontend should treat these URLs as opaque and should not try to parse information about them or generate them itself, as the format may change. Args: query_params: The query parameters as a dict. """ tag = query_params.get('tag') run = query_params.get('run') images = self._multiplexer.Images(run, tag) response = self._image_response_for_run(images, run, tag) self.respond(response, 'application/json') def _serve_image(self, query_params): """Serves an individual image.""" tag = query_params.get('tag') run = query_params.get('run') index = int(query_params.get('index')) image = self._multiplexer.Images(run, tag)[index] encoded_image_string = image.encoded_image_string content_type = _content_type_for_image(encoded_image_string) self.respond(encoded_image_string, content_type) def _query_for_individual_image(self, run, tag, index): """Builds a URL for accessing the specified image. This should be kept in sync with _serve_image. Note that the URL is *not* guaranteed to always return the same image, since images may be unloaded from the reservoir as new images come in. Args: run: The name of the run. tag: The tag. index: The index of the image. Negative values are OK. Returns: A string representation of a URL that will load the index-th sampled image in the given run with the given tag. """ query_string = urllib.parse.urlencode({ 'run': run, 'tag': tag, 'index': index }) return query_string def _serve_audio(self, query_params): """Given a tag and list of runs, serve a list of audio. Note that the audio clips themselves are not sent; instead, we respond with URLs to the audio. The frontend should treat these URLs as opaque and should not try to parse information about them or generate them itself, as the format may change. Args: query_params: The query parameters as a dict. """ tag = query_params.get('tag') run = query_params.get('run') audio_list = self._multiplexer.Audio(run, tag) response = self._audio_response_for_run(audio_list, run, tag) self.respond(response, 'application/json') def _serve_individual_audio(self, query_params): """Serves an individual audio clip.""" tag = query_params.get('tag') run = query_params.get('run') index = int(query_params.get('index')) audio = self._multiplexer.Audio(run, tag)[index] self.respond(audio.encoded_audio_string, audio.content_type) def _query_for_individual_audio(self, run, tag, index): """Builds a URL for accessing the specified audio. This should be kept in sync with _serve_individual_audio. Note that the URL is *not* guaranteed to always return the same audio, since audio may be unloaded from the reservoir as new audio comes in. Args: run: The name of the run. tag: The tag. index: The index of the audio. Negative values are OK. Returns: A string representation of a URL that will load the index-th sampled audio in the given run with the given tag. """ query_string = urllib.parse.urlencode({ 'run': run, 'tag': tag, 'index': index }) return query_string def _serve_runs(self, unused_query_params): """Return a JSON object about runs and tags. Returns a mapping from runs to tagType to list of tags for that run. Returns: {runName: {images: [tag1, tag2, tag3], audio: [tag4, tag5, tag6], scalars: [tagA, tagB, tagC], histograms: [tagX, tagY, tagZ], firstEventTimestamp: 123456.789}} """ runs = self._multiplexer.Runs() for run_name, run_data in runs.items(): try: run_data['firstEventTimestamp'] = self._multiplexer.FirstEventTimestamp( run_name) except ValueError: logging.warning('Unable to get first event timestamp for run %s', run_name) run_data['firstEventTimestamp'] = None self.respond(runs, 'application/json') def _serve_index(self, unused_query_params): """Serves the index page (i.e., the tensorboard app itself).""" self._serve_static_file('/dist/index.html') def _serve_js(self, unused_query_params): """Serves the JavaScript for the index page.""" self._serve_static_file('/dist/app.js') def _serve_static_file(self, path): """Serves the static file located at the given path. Args: path: The path of the static file, relative to the tensorboard/ directory. """ # Strip off the leading forward slash. orig_path = path.lstrip('/') if not self._path_is_safe(orig_path): logging.warning('path not safe: %s', orig_path) self.respond('Naughty naughty!', 'text/plain', 400) return # Resource loader wants a path relative to //WORKSPACE/tensorflow. path = os.path.join('tensorboard', orig_path) # Open the file and read it. try: contents = resource_loader.load_resource(path) except IOError: # For compatibility with latest version of Bazel, we renamed bower # packages to use '_' rather than '-' in their package name. # This means that the directory structure is changed too. # So that all our recursive imports work, we need to modify incoming # requests to map onto the new directory structure. path = orig_path components = path.split('/') components[0] = components[0].replace('-', '_') path = ('/').join(components) # Bazel keeps all the external dependencies in //WORKSPACE/external. # and resource loader wants a path relative to //WORKSPACE/tensorflow/. path = os.path.join('../external', path) try: contents = resource_loader.load_resource(path) except IOError: logging.info('path %s not found, sending 404', path) self.respond('Not found', 'text/plain', 404) return mimetype, content_encoding = mimetypes.guess_type(path) mimetype = mimetype or 'application/octet-stream' self.respond(contents, mimetype, expires=3600, content_encoding=content_encoding) def do_GET(self): # pylint: disable=invalid-name """Handler for all get requests.""" parsed_url = urlparse.urlparse(self.path) # Remove a trailing slash, if present. clean_path = parsed_url.path if clean_path.endswith('/'): clean_path = clean_path[:-1] query_params = urlparse.parse_qs(parsed_url.query) # parse_qs returns a list of values for each key; we're only interested in # the first. for key in query_params: value_count = len(query_params[key]) if value_count != 1: self.respond( 'query parameter %s should have exactly one value, had %d' % (key, value_count), 'text/plain', 400) return query_params[key] = query_params[key][0] if clean_path in self.data_handlers: self.data_handlers[clean_path](query_params) elif clean_path in TAB_ROUTES: self._serve_index(query_params) else: self._serve_static_file(clean_path) # @Override def log_message(self, *args): """Logs message.""" # By default, BaseHTTPRequestHandler logs to stderr. logging.info(*args) # @Override def log_request(self, *args): """Does nothing.""" # This is called by BaseHTTPRequestHandler.send_response() which causes it # to log every request. We've configured http.Respond() to only log # requests with >=400 status code. pass def _uniform_sample(values, count): """Samples `count` values uniformly from `values`. Args: values: The values to sample from. count: The number of values to sample. Must be at least 2. Raises: ValueError: If `count` is not at least 2. TypeError: If `type(count) != int`. Returns: A list of values from `values`. The first and the last element will always be included. If `count > len(values)`, then all values will be returned. """ if count < 2: raise ValueError('Must sample at least 2 elements, %d requested' % count) if count >= len(values): # Copy the list in case the caller mutates it. return list(values) return [ # We divide by count - 1 to make sure we always get the first and the last # element. values[(len(values) - 1) * i // (count - 1)] for i in xrange(count) ]
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3861, 18995, 1654, 3016, 9661, 14, 199, 199, 3861, 3576, 2461, 3509, 1006, 314, 9661, 367, 22701, 2955, 1584, 2331, 402, 4543, 199, 460, 367, 7252, 314, 3261, 4882, 370, 16173, 2839, 1182, 2969, 626, 4409, 2556, 199, 10254, 6511, 4474, 14, 199, 624, 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, 7392, 199, 646, 9143, 199, 646, 3416, 3561, 5012, 199, 646, 13290, 199, 646, 747, 199, 199, 504, 3816, 492, 5228, 199, 504, 3816, 14, 4912, 492, 3523, 14938, 199, 504, 3816, 14, 4912, 492, 4011, 199, 504, 3816, 14, 4912, 492, 4945, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 504, 3228, 14, 1548, 14, 4705, 492, 1566, 63, 21417, 199, 504, 3228, 14, 3128, 3576, 14, 4620, 492, 2112, 63, 2180, 199, 504, 3228, 14, 3128, 3576, 14, 773, 14, 1548, 492, 1455, 199, 504, 3228, 14, 3128, 3576, 14, 5265, 492, 14142, 19027, 1149, 63, 16483, 10789, 421, 199, 3998, 63, 6351, 275, 1994, 576, 7, 199, 4947, 3022, 63, 1092, 4586, 275, 1994, 22222, 7, 199, 9390, 51, 63, 1092, 4586, 275, 1994, 10802, 7, 199, 19108, 63, 6351, 275, 1994, 2718, 7, 199, 17209, 689, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 17209, 689, 51, 199, 1469, 5383, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 1469, 5383, 199, 27743, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 27743, 199, 22802, 47, 10896, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 22802, 47, 10896, 51, 199, 6790, 3830, 10934, 63, 22802, 47, 10896, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 6790, 3830, 10934, 63, 22802, 47, 10896, 51, 199, 568, 1914, 5437, 13841, 63, 9438, 63, 1092, 4586, 275, 1994, 23001, 3491, 7, 199, 568, 1914, 5437, 13841, 63, 27743, 63, 1092, 4586, 275, 1994, 23001, 15484, 7, 199, 25302, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 25302, 199, 9390, 63, 8314, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 9390, 63, 8314, 199, 10129, 63, 14999, 654, 275, 18179, 1994, 4368, 297, 1994, 4782, 297, 1994, 8130, 297, 1994, 16670, 297, 1994, 72, 22137, 418, 199, 199, 63, 26246, 40, 4564, 63, 2566, 63, 45, 1469, 17509, 275, 469, 272, 283, 22308, 356, 283, 1569, 15, 22308, 297, 272, 283, 14513, 356, 283, 1569, 15, 14513, 297, 272, 283, 14230, 356, 283, 1569, 15, 14230, 297, 272, 283, 4524, 356, 283, 1569, 15, 4524, 7, 199, 93, 199, 63, 3472, 63, 9438, 63, 45, 1469, 17509, 275, 283, 3578, 15, 18162, 13, 1745, 7, 421, 199, 318, 485, 1317, 63, 466, 63, 509, 63, 1569, 8, 8167, 63, 1569, 63, 875, 304, 523, 1834, 63, 466, 275, 3416, 3561, 5012, 14, 10058, 8, 403, 12, 5737, 63, 1569, 63, 875, 9, 523, 372, 485, 26246, 40, 4564, 63, 2566, 63, 45, 1469, 17509, 14, 362, 8, 1569, 63, 466, 12, 485, 3472, 63, 9438, 63, 45, 1469, 17509, 9, 421, 199, 533, 485, 2959, 3484, 8, 785, 304, 523, 408, 2493, 4952, 1202, 370, 769, 314, 1686, 1072, 6752, 367, 3261, 4882, 14, 819, 2832, 1006, 3261, 4882, 2291, 1006, 6752, 334, 509, 2893, 12, 1454, 19945, 436, 523, 12335, 394, 22137, 2291, 14689, 680, 523, 408, 523, 4840, 275, 283, 1001, 7, 523, 14689, 275, 283, 4737, 7, 421, 199, 533, 5878, 3576, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 523, 408, 2461, 1021, 367, 675, 543, 3523, 14938, 14, 14938, 14, 819, 961, 365, 28891, 282, 30758, 4975, 6818, 4882, 370, 376, 6763, 8433, 32200, 909, 523, 465, 5521, 465, 22701, 1584, 2331, 4543, 14, 523, 408, 819, 327, 7494, 5002, 5845, 370, 2387, 315, 15877, 3261, 4882, 701, 849, 14, 523, 6186, 63, 15827, 63, 8760, 275, 1616, 819, 327, 6944, 2296, 4828, 2919, 9021, 3960, 26, 1626, 23189, 6646, 13, 4625, 18095, 506, 2013, 641, 1006, 523, 327, 10473, 9320, 1808, 3222, 63, 1291, 14, 523, 4113, 63, 1023, 275, 283, 2856, 15, 17, 14, 17, 7, 819, 347, 636, 826, 721, 277, 12, 3663, 32200, 12, 28825, 12, 627, 589, 304, 272, 291, 423, 6048, 32200, 275, 3663, 32200, 272, 291, 423, 22222, 275, 28825, 272, 291, 423, 2758, 63, 576, 63, 5586, 342, 272, 3523, 14938, 14, 1563, 23518, 855, 826, 721, 277, 12, 627, 589, 9, 819, 347, 485, 2758, 63, 576, 63, 5586, 8, 277, 304, 272, 291, 14, 576, 63, 5586, 275, 469, 267, 7126, 63, 6351, 435, 5051, 3022, 63, 1092, 4586, 26, 291, 423, 4909, 63, 22222, 12, 267, 7126, 63, 6351, 435, 12075, 748, 689, 51, 63, 1092, 4586, 26, 291, 423, 4909, 63, 4732, 4291, 12, 267, 7126, 63, 6351, 435, 21772, 21126, 63, 1092, 4586, 26, 291, 423, 4909, 63, 2180, 12, 267, 7126, 63, 6351, 435, 21277, 63, 8314, 63, 1092, 4586, 26, 291, 423, 4909, 63, 1065, 63, 2343, 12, 267, 7126, 63 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3861, 18995, 1654, 3016, 9661, 14, 199, 199, 3861, 3576, 2461, 3509, 1006, 314, 9661, 367, 22701, 2955, 1584, 2331, 402, 4543, 199, 460, 367, 7252, 314, 3261, 4882, 370, 16173, 2839, 1182, 2969, 626, 4409, 2556, 199, 10254, 6511, 4474, 14, 199, 624, 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, 7392, 199, 646, 9143, 199, 646, 3416, 3561, 5012, 199, 646, 13290, 199, 646, 747, 199, 199, 504, 3816, 492, 5228, 199, 504, 3816, 14, 4912, 492, 3523, 14938, 199, 504, 3816, 14, 4912, 492, 4011, 199, 504, 3816, 14, 4912, 492, 4945, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 504, 3228, 14, 1548, 14, 4705, 492, 1566, 63, 21417, 199, 504, 3228, 14, 3128, 3576, 14, 4620, 492, 2112, 63, 2180, 199, 504, 3228, 14, 3128, 3576, 14, 773, 14, 1548, 492, 1455, 199, 504, 3228, 14, 3128, 3576, 14, 5265, 492, 14142, 19027, 1149, 63, 16483, 10789, 421, 199, 3998, 63, 6351, 275, 1994, 576, 7, 199, 4947, 3022, 63, 1092, 4586, 275, 1994, 22222, 7, 199, 9390, 51, 63, 1092, 4586, 275, 1994, 10802, 7, 199, 19108, 63, 6351, 275, 1994, 2718, 7, 199, 17209, 689, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 17209, 689, 51, 199, 1469, 5383, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 1469, 5383, 199, 27743, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 27743, 199, 22802, 47, 10896, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 22802, 47, 10896, 51, 199, 6790, 3830, 10934, 63, 22802, 47, 10896, 51, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 6790, 3830, 10934, 63, 22802, 47, 10896, 51, 199, 568, 1914, 5437, 13841, 63, 9438, 63, 1092, 4586, 275, 1994, 23001, 3491, 7, 199, 568, 1914, 5437, 13841, 63, 27743, 63, 1092, 4586, 275, 1994, 23001, 15484, 7, 199, 25302, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 25302, 199, 9390, 63, 8314, 63, 1092, 4586, 275, 7324, 435, 1566, 63, 21417, 14, 9390, 63, 8314, 199, 10129, 63, 14999, 654, 275, 18179, 1994, 4368, 297, 1994, 4782, 297, 1994, 8130, 297, 1994, 16670, 297, 1994, 72, 22137, 418, 199, 199, 63, 26246, 40, 4564, 63, 2566, 63, 45, 1469, 17509, 275, 469, 272, 283, 22308, 356, 283, 1569, 15, 22308, 297, 272, 283, 14513, 356, 283, 1569, 15, 14513, 297, 272, 283, 14230, 356, 283, 1569, 15, 14230, 297, 272, 283, 4524, 356, 283, 1569, 15, 4524, 7, 199, 93, 199, 63, 3472, 63, 9438, 63, 45, 1469, 17509, 275, 283, 3578, 15, 18162, 13, 1745, 7, 421, 199, 318, 485, 1317, 63, 466, 63, 509, 63, 1569, 8, 8167, 63, 1569, 63, 875, 304, 523, 1834, 63, 466, 275, 3416, 3561, 5012, 14, 10058, 8, 403, 12, 5737, 63, 1569, 63, 875, 9, 523, 372, 485, 26246, 40, 4564, 63, 2566, 63, 45, 1469, 17509, 14, 362, 8, 1569, 63, 466, 12, 485, 3472, 63, 9438, 63, 45, 1469, 17509, 9, 421, 199, 533, 485, 2959, 3484, 8, 785, 304, 523, 408, 2493, 4952, 1202, 370, 769, 314, 1686, 1072, 6752, 367, 3261, 4882, 14, 819, 2832, 1006, 3261, 4882, 2291, 1006, 6752, 334, 509, 2893, 12, 1454, 19945, 436, 523, 12335, 394, 22137, 2291, 14689, 680, 523, 408, 523, 4840, 275, 283, 1001, 7, 523, 14689, 275, 283, 4737, 7, 421, 199, 533, 5878, 3576, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 523, 408, 2461, 1021, 367, 675, 543, 3523, 14938, 14, 14938, 14, 819, 961, 365, 28891, 282, 30758, 4975, 6818, 4882, 370, 376, 6763, 8433, 32200, 909, 523, 465, 5521, 465, 22701, 1584, 2331, 4543, 14, 523, 408, 819, 327, 7494, 5002, 5845, 370, 2387, 315, 15877, 3261, 4882, 701, 849, 14, 523, 6186, 63, 15827, 63, 8760, 275, 1616, 819, 327, 6944, 2296, 4828, 2919, 9021, 3960, 26, 1626, 23189, 6646, 13, 4625, 18095, 506, 2013, 641, 1006, 523, 327, 10473, 9320, 1808, 3222, 63, 1291, 14, 523, 4113, 63, 1023, 275, 283, 2856, 15, 17, 14, 17, 7, 819, 347, 636, 826, 721, 277, 12, 3663, 32200, 12, 28825, 12, 627, 589, 304, 272, 291, 423, 6048, 32200, 275, 3663, 32200, 272, 291, 423, 22222, 275, 28825, 272, 291, 423, 2758, 63, 576, 63, 5586, 342, 272, 3523, 14938, 14, 1563, 23518, 855, 826, 721, 277, 12, 627, 589, 9, 819, 347, 485, 2758, 63, 576, 63, 5586, 8, 277, 304, 272, 291, 14, 576, 63, 5586, 275, 469, 267, 7126, 63, 6351, 435, 5051, 3022, 63, 1092, 4586, 26, 291, 423, 4909, 63, 22222, 12, 267, 7126, 63, 6351, 435, 12075, 748, 689, 51, 63, 1092, 4586, 26, 291, 423, 4909, 63, 4732, 4291, 12, 267, 7126, 63, 6351, 435, 21772, 21126, 63, 1092, 4586, 26, 291, 423, 4909, 63, 2180, 12, 267, 7126, 63, 6351, 435, 21277, 63, 8314, 63, 1092, 4586, 26, 291, 423, 4909, 63, 1065, 63, 2343, 12, 267, 7126, 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,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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 ]
Yethiel/re-volt-addon
io_revolt/parameters_in.py
1
4567
""" Name: parameters_in Purpose: Importing cars using the parameters.txt file Description: Imports entire cars using the carinfo module. """ if "bpy" in locals(): import imp imp.reload(common) imp.reload(carinfo) imp.reload(prm_in) import os import bpy import bmesh from mathutils import Vector from . import common from . import carinfo from . import prm_in from .common import * def import_file(filepath, scene): """ Imports a parameters.txt file and loads car body and wheels. """ PARAMETERS[filepath] = carinfo.read_parameters(filepath) # Imports the car with all supported files import_car(scene, PARAMETERS[filepath], filepath) # Removes parameters from dict so they can be reloaded next time PARAMETERS.pop(filepath) def import_car(scene, params, filepath): body = params["model"][params["body"]["modelnum"]] body_loc = to_blender_coord(params["body"]["offset"]) wheel0loc = to_blender_coord(params["wheel"][0]["offset1"]) wheel1loc = to_blender_coord(params["wheel"][1]["offset1"]) wheel2loc = to_blender_coord(params["wheel"][2]["offset1"]) wheel3loc = to_blender_coord(params["wheel"][3]["offset1"]) folder = os.sep.join(filepath.split(os.sep)[:-1]) # Checks if the wheel models exist wheel0_modelnum = int(params["wheel"][0]["modelnum"]) if wheel0_modelnum >= 0: wheel0 = params["model"][wheel0_modelnum] if wheel0.split(os.sep)[-1] in os.listdir(folder): wheel0path = os.sep.join([folder, wheel0.split(os.sep)[-1]]) else: wheel0 = None wheel1_modelnum = int(params["wheel"][1]["modelnum"]) if wheel1_modelnum >= 0: wheel1 = params["model"][wheel1_modelnum] if wheel1.split(os.sep)[-1] in os.listdir(folder): wheel1path = os.sep.join([folder, wheel1.split(os.sep)[-1]]) else: wheel1 = None wheel2_modelnum = int(params["wheel"][2]["modelnum"]) if wheel2_modelnum >= 0: wheel2 = params["model"][wheel2_modelnum] if wheel2.split(os.sep)[-1] in os.listdir(folder): wheel2path = os.sep.join([folder, wheel2.split(os.sep)[-1]]) else: wheel2 = None wheel3_modelnum = int(params["wheel"][3]["modelnum"]) if wheel3_modelnum >= 0: wheel3 = params["model"][wheel3_modelnum] if wheel3.split(os.sep)[-1] in os.listdir(folder): wheel3path = os.sep.join([folder, wheel3.split(os.sep)[-1]]) else: wheel3 = None # Checks if the body is in the same folder if body.split(os.sep)[-1] in os.listdir(folder): bodypath = os.sep.join([folder, body.split(os.sep)[-1]]) # Creates the car body and sets the offset body_obj = prm_in.import_file(bodypath, scene) body_obj.location = body_loc # Creates the wheel objects or an empty if the wheel file is not present if wheel0: wheel = prm_in.import_file(wheel0path, scene) else: wheel = bpy.data.objects.new("wheel 0", None) scene.objects.link(wheel) wheel.empty_draw_type = "SPHERE" wheel.empty_draw_size = 0.1 wheel.location = wheel0loc wheel.parent = body_obj if wheel1: wheel = prm_in.import_file(wheel1path, scene) else: wheel = bpy.data.objects.new("wheel 1", None) scene.objects.link(wheel) wheel.empty_draw_type = "SPHERE" wheel.empty_draw_size = 0.1 wheel.location = wheel1loc wheel.parent = body_obj if wheel2: wheel = prm_in.import_file(wheel2path, scene) else: wheel = bpy.data.objects.new("wheel 2", None) scene.objects.link(wheel) wheel.empty_draw_type = "SPHERE" wheel.empty_draw_size = 0.1 wheel.location = wheel2loc wheel.parent = body_obj if wheel3: wheel = prm_in.import_file(wheel3path, scene) else: wheel = bpy.data.objects.new("wheel 3", None) scene.objects.link(wheel) wheel.empty_draw_type = "SPHERE" wheel.empty_draw_size = 0.1 wheel.location = wheel3loc wheel.parent = body_obj # Aerial representation aerial_loc = to_blender_coord(params["aerial"]["offset"]) aerial = bpy.data.objects.new( "aerial", None ) scene.objects.link(aerial) aerial.location = aerial_loc aerial.empty_draw_size = 0.1 aerial.empty_draw_type = 'PLAIN_AXES' aerial.parent = body_obj
gpl-3.0
[ 624, 202, 199, 985, 26, 259, 2633, 63, 262, 202, 199, 14959, 4070, 26, 3161, 316, 286, 4291, 1808, 314, 2633, 14, 2424, 570, 2999, 199, 5831, 26, 202, 199, 32447, 8039, 286, 4291, 1808, 314, 9590, 815, 859, 14, 2999, 199, 624, 2999, 199, 692, 298, 66, 647, 2, 315, 9480, 837, 1128, 492, 1742, 1128, 1742, 14, 9233, 8, 2330, 9, 1128, 1742, 14, 9233, 8, 7007, 815, 9, 1128, 1742, 14, 9233, 8, 2700, 77, 63, 262, 9, 2999, 199, 646, 747, 202, 199, 646, 20575, 202, 199, 646, 330, 6480, 202, 199, 504, 3473, 1208, 492, 11388, 202, 199, 504, 1275, 492, 2863, 202, 199, 504, 1275, 492, 9590, 815, 202, 199, 504, 1275, 492, 5448, 77, 63, 262, 2999, 199, 504, 1275, 2330, 492, 627, 8065, 199, 318, 492, 63, 493, 8, 7218, 12, 13856, 304, 1128, 408, 1128, 24339, 282, 2633, 14, 2424, 570, 436, 14404, 9590, 2396, 436, 28300, 14, 1128, 408, 2958, 23710, 59, 7218, 61, 275, 9590, 815, 14, 739, 63, 3214, 8, 7218, 9, 2958, 327, 24339, 314, 9590, 543, 1006, 3748, 1584, 1128, 492, 63, 7007, 8, 10436, 12, 23710, 59, 7218, 467, 9911, 9, 2958, 327, 23169, 2633, 687, 1211, 880, 2985, 883, 506, 31848, 2163, 900, 1128, 23710, 14, 1935, 8, 7218, 9, 8065, 199, 318, 492, 63, 7007, 8, 10436, 12, 1862, 12, 9911, 304, 1128, 2396, 275, 1862, 905, 1238, 9210, 1162, 905, 2030, 6611, 1238, 1507, 15261, 1128, 2396, 63, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 2030, 6611, 2743, 3135, 1128, 9989, 16, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 16, 7541, 2743, 17, 3135, 1128, 9989, 17, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 17, 7541, 2743, 17, 3135, 1128, 9989, 18, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 18, 7541, 2743, 17, 3135, 1128, 9989, 19, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 19, 7541, 2743, 17, 3135, 2958, 4922, 275, 747, 14, 4127, 14, 904, 8, 7218, 14, 1294, 8, 736, 14, 4127, 31280, 17, 566, 2958, 327, 13813, 340, 314, 9989, 1709, 2187, 1128, 9989, 16, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 16, 7541, 1238, 1507, 3135, 1128, 340, 9989, 16, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 16, 275, 1862, 905, 1238, 9210, 11798, 16, 63, 1238, 1507, 61, 1039, 340, 9989, 16, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 16, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 16, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 16, 275, 488, 2958, 9989, 17, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 17, 7541, 1238, 1507, 3135, 1128, 340, 9989, 17, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 17, 275, 1862, 905, 1238, 9210, 11798, 17, 63, 1238, 1507, 61, 1039, 340, 9989, 17, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 17, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 17, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 17, 275, 488, 2958, 9989, 18, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 18, 7541, 1238, 1507, 3135, 1128, 340, 9989, 18, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 18, 275, 1862, 905, 1238, 9210, 11798, 18, 63, 1238, 1507, 61, 1039, 340, 9989, 18, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 18, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 18, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 18, 275, 488, 2958, 9989, 19, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 19, 7541, 1238, 1507, 3135, 1128, 340, 9989, 19, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 19, 275, 1862, 905, 1238, 9210, 11798, 19, 63, 1238, 1507, 61, 1039, 340, 9989, 19, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 19, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 19, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 19, 275, 488, 2958, 327, 13813, 340, 314, 2396, 365, 315, 314, 2011, 4922, 1128, 340, 2396, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 1039, 2396, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 2396, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 2958, 327, 10560, 314, 9590, 2396, 436, 5951, 314, 3268, 1128, 2396, 63, 1113, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 2030, 515, 12, 13856, 9, 1128, 2396, 63, 1113, 14, 1985, 275, 2396, 63, 2102, 2958, 327, 10560, 314, 9989, 2251, 503, 376, 2701, 340, 314, 9989, 570, 365, 440, 3451, 1128, 340, 9989, 16, 26, 1039, 9989, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 11798, 16, 515, 12, 13856, 9, 1128, 587, 26, 1039, 9989, 275, 20575, 14, 576, 14, 1462, 14, 1222, 480, 11798, 378, 401, 488, 9, 1039, 13856, 14, 1462, 14, 1073, 8, 11798, 9, 1039, 9989, 14, 1667, 63, 5485, 63, 466, 275, 298, 5763, 5293, 2, 1039, 9989, 14, 1667, 63, 5485, 63, 890, 275, 378, 14, 17, 1128, 9989, 14, 1985, 275, 9989, 16, 2102, 1128, 9989, 14, 1708, 275, 2396, 63, 1113, 2958, 340, 9989, 17, 26, 1039, 9989, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 11798, 17, 515, 12, 13856, 9, 1128, 587, 26, 1039, 9989, 275, 20575, 14, 576, 14, 1462, 14, 1222, 480, 11798, 413, 401, 488, 9, 1039, 13856, 14, 1462, 14, 1073, 8, 11798, 9, 1039, 9989, 14, 1667, 63, 5485, 63, 466, 275, 298, 5763, 5293, 2, 1039, 9989, 14, 1667, 63, 5485, 63, 890, 275, 378, 14, 17, 1128 ]
[ 202, 199, 985, 26, 259, 2633, 63, 262, 202, 199, 14959, 4070, 26, 3161, 316, 286, 4291, 1808, 314, 2633, 14, 2424, 570, 2999, 199, 5831, 26, 202, 199, 32447, 8039, 286, 4291, 1808, 314, 9590, 815, 859, 14, 2999, 199, 624, 2999, 199, 692, 298, 66, 647, 2, 315, 9480, 837, 1128, 492, 1742, 1128, 1742, 14, 9233, 8, 2330, 9, 1128, 1742, 14, 9233, 8, 7007, 815, 9, 1128, 1742, 14, 9233, 8, 2700, 77, 63, 262, 9, 2999, 199, 646, 747, 202, 199, 646, 20575, 202, 199, 646, 330, 6480, 202, 199, 504, 3473, 1208, 492, 11388, 202, 199, 504, 1275, 492, 2863, 202, 199, 504, 1275, 492, 9590, 815, 202, 199, 504, 1275, 492, 5448, 77, 63, 262, 2999, 199, 504, 1275, 2330, 492, 627, 8065, 199, 318, 492, 63, 493, 8, 7218, 12, 13856, 304, 1128, 408, 1128, 24339, 282, 2633, 14, 2424, 570, 436, 14404, 9590, 2396, 436, 28300, 14, 1128, 408, 2958, 23710, 59, 7218, 61, 275, 9590, 815, 14, 739, 63, 3214, 8, 7218, 9, 2958, 327, 24339, 314, 9590, 543, 1006, 3748, 1584, 1128, 492, 63, 7007, 8, 10436, 12, 23710, 59, 7218, 467, 9911, 9, 2958, 327, 23169, 2633, 687, 1211, 880, 2985, 883, 506, 31848, 2163, 900, 1128, 23710, 14, 1935, 8, 7218, 9, 8065, 199, 318, 492, 63, 7007, 8, 10436, 12, 1862, 12, 9911, 304, 1128, 2396, 275, 1862, 905, 1238, 9210, 1162, 905, 2030, 6611, 1238, 1507, 15261, 1128, 2396, 63, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 2030, 6611, 2743, 3135, 1128, 9989, 16, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 16, 7541, 2743, 17, 3135, 1128, 9989, 17, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 17, 7541, 2743, 17, 3135, 1128, 9989, 18, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 18, 7541, 2743, 17, 3135, 1128, 9989, 19, 2102, 275, 370, 63, 66, 24912, 63, 7988, 8, 1162, 905, 11798, 9210, 19, 7541, 2743, 17, 3135, 2958, 4922, 275, 747, 14, 4127, 14, 904, 8, 7218, 14, 1294, 8, 736, 14, 4127, 31280, 17, 566, 2958, 327, 13813, 340, 314, 9989, 1709, 2187, 1128, 9989, 16, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 16, 7541, 1238, 1507, 3135, 1128, 340, 9989, 16, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 16, 275, 1862, 905, 1238, 9210, 11798, 16, 63, 1238, 1507, 61, 1039, 340, 9989, 16, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 16, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 16, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 16, 275, 488, 2958, 9989, 17, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 17, 7541, 1238, 1507, 3135, 1128, 340, 9989, 17, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 17, 275, 1862, 905, 1238, 9210, 11798, 17, 63, 1238, 1507, 61, 1039, 340, 9989, 17, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 17, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 17, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 17, 275, 488, 2958, 9989, 18, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 18, 7541, 1238, 1507, 3135, 1128, 340, 9989, 18, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 18, 275, 1862, 905, 1238, 9210, 11798, 18, 63, 1238, 1507, 61, 1039, 340, 9989, 18, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 18, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 18, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 18, 275, 488, 2958, 9989, 19, 63, 1238, 1507, 275, 1109, 8, 1162, 905, 11798, 9210, 19, 7541, 1238, 1507, 3135, 1128, 340, 9989, 19, 63, 1238, 1507, 2356, 378, 26, 1039, 9989, 19, 275, 1862, 905, 1238, 9210, 11798, 19, 63, 1238, 1507, 61, 1039, 340, 9989, 19, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 2628, 9989, 19, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 9989, 19, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 1128, 587, 26, 1039, 9989, 19, 275, 488, 2958, 327, 13813, 340, 314, 2396, 365, 315, 314, 2011, 4922, 1128, 340, 2396, 14, 1294, 8, 736, 14, 4127, 15786, 17, 61, 315, 747, 14, 7374, 8, 3741, 304, 1039, 2396, 515, 275, 747, 14, 4127, 14, 904, 779, 3741, 12, 2396, 14, 1294, 8, 736, 14, 4127, 15786, 17, 3934, 2958, 327, 10560, 314, 9590, 2396, 436, 5951, 314, 3268, 1128, 2396, 63, 1113, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 2030, 515, 12, 13856, 9, 1128, 2396, 63, 1113, 14, 1985, 275, 2396, 63, 2102, 2958, 327, 10560, 314, 9989, 2251, 503, 376, 2701, 340, 314, 9989, 570, 365, 440, 3451, 1128, 340, 9989, 16, 26, 1039, 9989, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 11798, 16, 515, 12, 13856, 9, 1128, 587, 26, 1039, 9989, 275, 20575, 14, 576, 14, 1462, 14, 1222, 480, 11798, 378, 401, 488, 9, 1039, 13856, 14, 1462, 14, 1073, 8, 11798, 9, 1039, 9989, 14, 1667, 63, 5485, 63, 466, 275, 298, 5763, 5293, 2, 1039, 9989, 14, 1667, 63, 5485, 63, 890, 275, 378, 14, 17, 1128, 9989, 14, 1985, 275, 9989, 16, 2102, 1128, 9989, 14, 1708, 275, 2396, 63, 1113, 2958, 340, 9989, 17, 26, 1039, 9989, 275, 5448, 77, 63, 262, 14, 646, 63, 493, 8, 11798, 17, 515, 12, 13856, 9, 1128, 587, 26, 1039, 9989, 275, 20575, 14, 576, 14, 1462, 14, 1222, 480, 11798, 413, 401, 488, 9, 1039, 13856,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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 ]
wolcomm/rptk
rptk/base.py
1
3743
# Copyright (c) 2018 Workonline Communications (Pty) Ltd. All rights reserved. # # The contents of this file are licensed under the Apache License version 2.0 # (the "License"); you may not use this file except in compliance with the # License. # # 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. """rptk base module.""" from __future__ import print_function from __future__ import unicode_literals import inspect import logging class BaseObject(object): """BaseObject class providing generic logging functionality.""" def __init__(self): """Initialise object.""" self._log = logging.getLogger(self.__module__) def __repr__(self): """Provide generic string representation.""" return "{}() object".format(self.cls_name) def __enter__(self): """Log context manager entry.""" self.log_ready_start() self.log_ready_done() return self def __exit__(self, exc_type, exc_val, exc_tb): """Log context manager exit.""" self.log_exit_start() self.log_exit_done() @property def opts(self): """Get self.opts if it exists.""" return getattr(self, "_opts", None) @property def log(self): """Get the current logger.""" return self._log @property def cls_name(self): """Get the class name of self.""" return self.__class__.__name__ @property def current_method(self): """Get the currently executing method name.""" return inspect.currentframe().f_back.f_code.co_name def log_init(self): """Log entry into the __init__ method.""" self.log.debug(msg="initialising {} instance".format(self.cls_name)) def log_init_done(self): """Log exit from an __init__ method.""" caller = inspect.currentframe().f_back.f_back.f_code.co_name if caller == '__init__': self.log.debug(msg="still initialising {} instance" .format(self.cls_name)) else: self.log.debug(msg="{} instance initialised".format(self.cls_name)) def log_method_enter(self, method=None): """Log entry into a class method.""" self.log.debug(msg="entering method {}.{}" .format(self.cls_name, method)) def log_method_exit(self, method=None): """Log exit from a class method.""" self.log.debug(msg="leaving method {}.{}" .format(self.cls_name, method)) def log_ready_start(self): """Log start of object initialisation.""" self.log.debug(msg="preparing {} for use".format(self)) def log_ready_done(self): """Log end of object initialisation.""" self.log.debug(msg="{} ready for use".format(self)) def log_exit_start(self): """Log start of object cleanup.""" self.log.debug(msg="cleaning up {}".format(self)) def log_exit_done(self): """Log end of object cleanup.""" self.log.debug(msg="finished cleaning up {}".format(self)) def raise_type_error(self, arg=None, cls=None): """Raise a TypeError with useful logging.""" msg = "argument {} ({}) not of type {}".format(arg.__name__, arg, cls) self.log.error(msg=msg) raise TypeError(msg) def raise_runtime_error(self, msg=None): """Raise a RuntimeError with useful logging.""" self.log.error(msg=msg) raise RuntimeError(msg)
apache-2.0
[ 3, 1898, 334, 67, 9, 14894, 9361, 15178, 18686, 334, 48, 369, 9, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18233, 1334, 314, 3668, 844, 1015, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 199, 3, 844, 14, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 1334, 199, 3, 314, 844, 14, 199, 624, 82, 541, 75, 1300, 859, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6485, 199, 646, 2050, 421, 199, 533, 3523, 1692, 8, 785, 304, 272, 408, 1563, 1692, 1021, 13070, 7809, 2050, 9330, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 408, 5733, 572, 909, 1041, 267, 291, 423, 793, 275, 2050, 14, 5572, 8, 277, 855, 578, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 408, 25107, 7809, 1059, 6025, 1041, 267, 372, 11491, 342, 909, 1674, 908, 8, 277, 14, 1886, 63, 354, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 408, 2445, 1067, 5256, 2397, 1041, 267, 291, 14, 793, 63, 2179, 63, 928, 342, 267, 291, 14, 793, 63, 2179, 63, 4456, 342, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 408, 2445, 1067, 5256, 4458, 1041, 267, 291, 14, 793, 63, 2224, 63, 928, 342, 267, 291, 14, 793, 63, 2224, 63, 4456, 342, 339, 768, 1829, 272, 347, 3999, 8, 277, 304, 267, 408, 1002, 291, 14, 3291, 340, 652, 3495, 1041, 267, 372, 2519, 8, 277, 12, 2668, 3291, 401, 488, 9, 339, 768, 1829, 272, 347, 943, 8, 277, 304, 267, 408, 1002, 314, 1453, 2512, 1041, 267, 372, 291, 423, 793, 339, 768, 1829, 272, 347, 843, 63, 354, 8, 277, 304, 267, 408, 1002, 314, 1021, 536, 402, 291, 1041, 267, 372, 291, 855, 533, 4914, 354, 363, 339, 768, 1829, 272, 347, 1453, 63, 765, 8, 277, 304, 267, 408, 1002, 314, 5544, 14043, 1083, 536, 1041, 267, 372, 6485, 14, 1818, 1943, 1252, 70, 63, 894, 14, 70, 63, 600, 14, 331, 63, 354, 339, 347, 943, 63, 826, 8, 277, 304, 267, 408, 2445, 2397, 1901, 314, 636, 826, 363, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 2747, 11136, 1052, 1256, 1674, 908, 8, 277, 14, 1886, 63, 354, 430, 339, 347, 943, 63, 826, 63, 4456, 8, 277, 304, 267, 408, 2445, 4458, 687, 376, 636, 826, 363, 1083, 1041, 267, 8025, 275, 6485, 14, 1818, 1943, 1252, 70, 63, 894, 14, 70, 63, 894, 14, 70, 63, 600, 14, 331, 63, 354, 267, 340, 8025, 508, 2560, 826, 3706, 288, 291, 14, 793, 14, 1757, 8, 1328, 628, 32310, 2536, 11136, 1052, 1256, 2, 3044, 1275, 908, 8, 277, 14, 1886, 63, 354, 430, 267, 587, 26, 288, 291, 14, 793, 14, 1757, 8, 1328, 32053, 1256, 2536, 9096, 1674, 908, 8, 277, 14, 1886, 63, 354, 430, 339, 347, 943, 63, 765, 63, 4200, 8, 277, 12, 1083, 29, 403, 304, 267, 408, 2445, 2397, 1901, 282, 1021, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 4200, 316, 1083, 30332, 2440, 2, 2574, 1275, 908, 8, 277, 14, 1886, 63, 354, 12, 1083, 430, 339, 347, 943, 63, 765, 63, 2224, 8, 277, 12, 1083, 29, 403, 304, 267, 408, 2445, 4458, 687, 282, 1021, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 274, 5519, 1083, 30332, 2440, 2, 2574, 1275, 908, 8, 277, 14, 1886, 63, 354, 12, 1083, 430, 339, 347, 943, 63, 2179, 63, 928, 8, 277, 304, 267, 408, 2445, 1343, 402, 909, 2536, 19914, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 657, 462, 316, 1052, 367, 675, 1674, 908, 8, 277, 430, 339, 347, 943, 63, 2179, 63, 4456, 8, 277, 304, 267, 408, 2445, 1284, 402, 909, 2536, 19914, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 32053, 10144, 367, 675, 1674, 908, 8, 277, 430, 339, 347, 943, 63, 2224, 63, 928, 8, 277, 304, 267, 408, 2445, 1343, 402, 909, 9058, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 3118, 316, 1536, 8352, 908, 8, 277, 430, 339, 347, 943, 63, 2224, 63, 4456, 8, 277, 304, 267, 408, 2445, 1284, 402, 909, 9058, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 8669, 29579, 1536, 8352, 908, 8, 277, 430, 339, 347, 746, 63, 466, 63, 705, 8, 277, 12, 1680, 29, 403, 12, 843, 29, 403, 304, 267, 408, 18111, 282, 3146, 543, 2997, 2050, 1041, 267, 1499, 275, 298, 2094, 1052, 11459, 1552, 440, 402, 730, 8352, 908, 8, 1273, 855, 354, 3108, 1680, 12, 843, 9, 267, 291, 14, 793, 14, 705, 8, 1328, 29, 1328, 9, 267, 746, 3146, 8, 1328, 9, 339, 347, 746, 63, 7726, 63, 705, 8, 277, 12, 1499, 29, 403, 304, 267, 408, 18111, 282, 6064, 543, 2997, 2050, 1041, 267, 291, 14, 793, 14, 705, 8, 1328, 29, 1328, 9, 267, 746, 6064, 8, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14894, 9361, 15178, 18686, 334, 48, 369, 9, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18233, 1334, 314, 3668, 844, 1015, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 199, 3, 844, 14, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 1334, 199, 3, 314, 844, 14, 199, 624, 82, 541, 75, 1300, 859, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6485, 199, 646, 2050, 421, 199, 533, 3523, 1692, 8, 785, 304, 272, 408, 1563, 1692, 1021, 13070, 7809, 2050, 9330, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 408, 5733, 572, 909, 1041, 267, 291, 423, 793, 275, 2050, 14, 5572, 8, 277, 855, 578, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 408, 25107, 7809, 1059, 6025, 1041, 267, 372, 11491, 342, 909, 1674, 908, 8, 277, 14, 1886, 63, 354, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 408, 2445, 1067, 5256, 2397, 1041, 267, 291, 14, 793, 63, 2179, 63, 928, 342, 267, 291, 14, 793, 63, 2179, 63, 4456, 342, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 408, 2445, 1067, 5256, 4458, 1041, 267, 291, 14, 793, 63, 2224, 63, 928, 342, 267, 291, 14, 793, 63, 2224, 63, 4456, 342, 339, 768, 1829, 272, 347, 3999, 8, 277, 304, 267, 408, 1002, 291, 14, 3291, 340, 652, 3495, 1041, 267, 372, 2519, 8, 277, 12, 2668, 3291, 401, 488, 9, 339, 768, 1829, 272, 347, 943, 8, 277, 304, 267, 408, 1002, 314, 1453, 2512, 1041, 267, 372, 291, 423, 793, 339, 768, 1829, 272, 347, 843, 63, 354, 8, 277, 304, 267, 408, 1002, 314, 1021, 536, 402, 291, 1041, 267, 372, 291, 855, 533, 4914, 354, 363, 339, 768, 1829, 272, 347, 1453, 63, 765, 8, 277, 304, 267, 408, 1002, 314, 5544, 14043, 1083, 536, 1041, 267, 372, 6485, 14, 1818, 1943, 1252, 70, 63, 894, 14, 70, 63, 600, 14, 331, 63, 354, 339, 347, 943, 63, 826, 8, 277, 304, 267, 408, 2445, 2397, 1901, 314, 636, 826, 363, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 2747, 11136, 1052, 1256, 1674, 908, 8, 277, 14, 1886, 63, 354, 430, 339, 347, 943, 63, 826, 63, 4456, 8, 277, 304, 267, 408, 2445, 4458, 687, 376, 636, 826, 363, 1083, 1041, 267, 8025, 275, 6485, 14, 1818, 1943, 1252, 70, 63, 894, 14, 70, 63, 894, 14, 70, 63, 600, 14, 331, 63, 354, 267, 340, 8025, 508, 2560, 826, 3706, 288, 291, 14, 793, 14, 1757, 8, 1328, 628, 32310, 2536, 11136, 1052, 1256, 2, 3044, 1275, 908, 8, 277, 14, 1886, 63, 354, 430, 267, 587, 26, 288, 291, 14, 793, 14, 1757, 8, 1328, 32053, 1256, 2536, 9096, 1674, 908, 8, 277, 14, 1886, 63, 354, 430, 339, 347, 943, 63, 765, 63, 4200, 8, 277, 12, 1083, 29, 403, 304, 267, 408, 2445, 2397, 1901, 282, 1021, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 4200, 316, 1083, 30332, 2440, 2, 2574, 1275, 908, 8, 277, 14, 1886, 63, 354, 12, 1083, 430, 339, 347, 943, 63, 765, 63, 2224, 8, 277, 12, 1083, 29, 403, 304, 267, 408, 2445, 4458, 687, 282, 1021, 1083, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 274, 5519, 1083, 30332, 2440, 2, 2574, 1275, 908, 8, 277, 14, 1886, 63, 354, 12, 1083, 430, 339, 347, 943, 63, 2179, 63, 928, 8, 277, 304, 267, 408, 2445, 1343, 402, 909, 2536, 19914, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 657, 462, 316, 1052, 367, 675, 1674, 908, 8, 277, 430, 339, 347, 943, 63, 2179, 63, 4456, 8, 277, 304, 267, 408, 2445, 1284, 402, 909, 2536, 19914, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 32053, 10144, 367, 675, 1674, 908, 8, 277, 430, 339, 347, 943, 63, 2224, 63, 928, 8, 277, 304, 267, 408, 2445, 1343, 402, 909, 9058, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 3118, 316, 1536, 8352, 908, 8, 277, 430, 339, 347, 943, 63, 2224, 63, 4456, 8, 277, 304, 267, 408, 2445, 1284, 402, 909, 9058, 1041, 267, 291, 14, 793, 14, 1757, 8, 1328, 628, 8669, 29579, 1536, 8352, 908, 8, 277, 430, 339, 347, 746, 63, 466, 63, 705, 8, 277, 12, 1680, 29, 403, 12, 843, 29, 403, 304, 267, 408, 18111, 282, 3146, 543, 2997, 2050, 1041, 267, 1499, 275, 298, 2094, 1052, 11459, 1552, 440, 402, 730, 8352, 908, 8, 1273, 855, 354, 3108, 1680, 12, 843, 9, 267, 291, 14, 793, 14, 705, 8, 1328, 29, 1328, 9, 267, 746, 3146, 8, 1328, 9, 339, 347, 746, 63, 7726, 63, 705, 8, 277, 12, 1499, 29, 403, 304, 267, 408, 18111, 282, 6064, 543, 2997, 2050, 1041, 267, 291, 14, 793, 14, 705, 8, 1328, 29, 1328, 9, 267, 746, 6064, 8, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
tigerneil/deepy
experiments/attention_models/first_glimpse.py
5
1691
import time import logging from deepy import TrainerConfig from deepy.dataset import MnistDataset, MiniBatches from deepy.trainers import LearningRateAnnealer from first_glimpse_model import get_network from first_glimpse_trainer import FirstGlimpseTrainer from deepy.utils import Timer logging.basicConfig(level=logging.INFO) if __name__ == '__main__': from argparse import ArgumentParser ap = ArgumentParser() ap.add_argument("--model", default="/tmp/mnist_att_params2.gz") ap.add_argument("--method", default="MOMENTUM") ap.add_argument("--learning_rate", default=0.01) ap.add_argument("--variance", default=0.03) ap.add_argument("--disable_backprop", default=False) ap.add_argument("--disable_reinforce", default=False) ap.add_argument("--random_glimpse", default=False) args = ap.parse_args() mnist = MiniBatches((MnistDataset()), batch_size=1) model_path = args.model network = get_network(model_path, std=args.variance, disable_reinforce=args.disable_reinforce, random_glimpse=args.random_glimpse) trainer_conf = TrainerConfig() trainer_conf.learning_rate = LearningRateAnnealer.learning_rate(args.learning_rate) trainer_conf.weight_l2 = 0.0001 trainer_conf.hidden_l2 = 0.0001 trainer_conf.method = args.method trainer = FirstGlimpseTrainer(network, network.layers[0], config=trainer_conf) annealer = LearningRateAnnealer(trainer, patience=5) timer = Timer() for _ in trainer.train(mnist.train_set(), mnist.valid_set(), mnist.test_set()): if annealer.invoke(): break timer.end() network.save_params(model_path) timer.report()
mit
[ 646, 900, 199, 646, 2050, 199, 199, 504, 27646, 647, 492, 16732, 281, 2028, 199, 504, 27646, 647, 14, 5214, 492, 603, 78, 631, 9271, 12, 24954, 8842, 397, 199, 504, 27646, 647, 14, 2834, 1192, 492, 29127, 6621, 2493, 685, 29706, 199, 504, 1642, 63, 71, 317, 311, 261, 63, 1238, 492, 664, 63, 1200, 199, 504, 1642, 63, 71, 317, 311, 261, 63, 2834, 281, 492, 7758, 39, 317, 311, 261, 2437, 16187, 199, 504, 27646, 647, 14, 1208, 492, 22287, 199, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7534, 492, 27615, 272, 2771, 275, 27615, 342, 272, 2771, 14, 525, 63, 2094, 6739, 1238, 401, 849, 9555, 2791, 15, 32164, 63, 6796, 63, 1162, 18, 14, 6838, 531, 272, 2771, 14, 525, 63, 2094, 6739, 765, 401, 849, 628, 2679, 4479, 2639, 531, 272, 2771, 14, 525, 63, 2094, 6739, 10546, 63, 1866, 401, 849, 29, 16, 14, 614, 9, 272, 2771, 14, 525, 63, 2094, 6739, 6221, 401, 849, 29, 16, 14, 1644, 9, 272, 2771, 14, 525, 63, 2094, 6739, 5993, 63, 31113, 401, 849, 29, 797, 9, 272, 2771, 14, 525, 63, 2094, 6739, 5993, 63, 264, 262, 3990, 401, 849, 29, 797, 9, 272, 2771, 14, 525, 63, 2094, 6739, 2355, 63, 71, 317, 311, 261, 401, 849, 29, 797, 9, 272, 1249, 275, 2771, 14, 1122, 63, 589, 342, 339, 21945, 631, 275, 24954, 8842, 397, 1332, 45, 78, 631, 9271, 4000, 3522, 63, 890, 29, 17, 9, 339, 1402, 63, 515, 275, 1249, 14, 1238, 339, 2784, 275, 664, 63, 1200, 8, 1238, 63, 515, 12, 2418, 29, 589, 14, 6221, 12, 2079, 3507, 63, 264, 262, 3990, 29, 589, 14, 5993, 63, 264, 262, 3990, 12, 2196, 63, 71, 317, 311, 261, 29, 589, 14, 2355, 63, 71, 317, 311, 261, 9, 339, 3560, 281, 63, 2190, 275, 16732, 281, 2028, 342, 272, 3560, 281, 63, 2190, 14, 10546, 63, 1866, 275, 29127, 6621, 2493, 685, 29706, 14, 10546, 63, 1866, 8, 589, 14, 10546, 63, 1866, 9, 272, 3560, 281, 63, 2190, 14, 3463, 63, 76, 18, 275, 378, 14, 4183, 272, 3560, 281, 63, 2190, 14, 5642, 63, 76, 18, 275, 378, 14, 4183, 272, 3560, 281, 63, 2190, 14, 765, 275, 1249, 14, 765, 339, 3560, 281, 275, 7758, 39, 317, 311, 261, 2437, 16187, 8, 1200, 12, 2784, 14, 4359, 59, 16, 467, 1101, 29, 2834, 281, 63, 2190, 9, 339, 376, 685, 29706, 275, 29127, 6621, 2493, 685, 29706, 8, 2834, 281, 12, 691, 280, 4894, 29, 21, 9, 339, 9715, 275, 22287, 342, 272, 367, 485, 315, 3560, 281, 14, 2834, 8, 32164, 14, 2834, 63, 409, 1062, 21945, 631, 14, 1078, 63, 409, 1062, 21945, 631, 14, 396, 63, 409, 5109, 267, 340, 376, 685, 29706, 14, 15195, 837, 288, 2059, 272, 9715, 14, 500, 342, 339, 2784, 14, 2117, 63, 1162, 8, 1238, 63, 515, 9, 339, 9715, 14, 3070, 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 ]
[ 900, 199, 646, 2050, 199, 199, 504, 27646, 647, 492, 16732, 281, 2028, 199, 504, 27646, 647, 14, 5214, 492, 603, 78, 631, 9271, 12, 24954, 8842, 397, 199, 504, 27646, 647, 14, 2834, 1192, 492, 29127, 6621, 2493, 685, 29706, 199, 504, 1642, 63, 71, 317, 311, 261, 63, 1238, 492, 664, 63, 1200, 199, 504, 1642, 63, 71, 317, 311, 261, 63, 2834, 281, 492, 7758, 39, 317, 311, 261, 2437, 16187, 199, 504, 27646, 647, 14, 1208, 492, 22287, 199, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7534, 492, 27615, 272, 2771, 275, 27615, 342, 272, 2771, 14, 525, 63, 2094, 6739, 1238, 401, 849, 9555, 2791, 15, 32164, 63, 6796, 63, 1162, 18, 14, 6838, 531, 272, 2771, 14, 525, 63, 2094, 6739, 765, 401, 849, 628, 2679, 4479, 2639, 531, 272, 2771, 14, 525, 63, 2094, 6739, 10546, 63, 1866, 401, 849, 29, 16, 14, 614, 9, 272, 2771, 14, 525, 63, 2094, 6739, 6221, 401, 849, 29, 16, 14, 1644, 9, 272, 2771, 14, 525, 63, 2094, 6739, 5993, 63, 31113, 401, 849, 29, 797, 9, 272, 2771, 14, 525, 63, 2094, 6739, 5993, 63, 264, 262, 3990, 401, 849, 29, 797, 9, 272, 2771, 14, 525, 63, 2094, 6739, 2355, 63, 71, 317, 311, 261, 401, 849, 29, 797, 9, 272, 1249, 275, 2771, 14, 1122, 63, 589, 342, 339, 21945, 631, 275, 24954, 8842, 397, 1332, 45, 78, 631, 9271, 4000, 3522, 63, 890, 29, 17, 9, 339, 1402, 63, 515, 275, 1249, 14, 1238, 339, 2784, 275, 664, 63, 1200, 8, 1238, 63, 515, 12, 2418, 29, 589, 14, 6221, 12, 2079, 3507, 63, 264, 262, 3990, 29, 589, 14, 5993, 63, 264, 262, 3990, 12, 2196, 63, 71, 317, 311, 261, 29, 589, 14, 2355, 63, 71, 317, 311, 261, 9, 339, 3560, 281, 63, 2190, 275, 16732, 281, 2028, 342, 272, 3560, 281, 63, 2190, 14, 10546, 63, 1866, 275, 29127, 6621, 2493, 685, 29706, 14, 10546, 63, 1866, 8, 589, 14, 10546, 63, 1866, 9, 272, 3560, 281, 63, 2190, 14, 3463, 63, 76, 18, 275, 378, 14, 4183, 272, 3560, 281, 63, 2190, 14, 5642, 63, 76, 18, 275, 378, 14, 4183, 272, 3560, 281, 63, 2190, 14, 765, 275, 1249, 14, 765, 339, 3560, 281, 275, 7758, 39, 317, 311, 261, 2437, 16187, 8, 1200, 12, 2784, 14, 4359, 59, 16, 467, 1101, 29, 2834, 281, 63, 2190, 9, 339, 376, 685, 29706, 275, 29127, 6621, 2493, 685, 29706, 8, 2834, 281, 12, 691, 280, 4894, 29, 21, 9, 339, 9715, 275, 22287, 342, 272, 367, 485, 315, 3560, 281, 14, 2834, 8, 32164, 14, 2834, 63, 409, 1062, 21945, 631, 14, 1078, 63, 409, 1062, 21945, 631, 14, 396, 63, 409, 5109, 267, 340, 376, 685, 29706, 14, 15195, 837, 288, 2059, 272, 9715, 14, 500, 342, 339, 2784, 14, 2117, 63, 1162, 8, 1238, 63, 515, 9, 339, 9715, 14, 3070, 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, 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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 ]
grevutiu-gabriel/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/port/__init__.py
129
1865
# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Port-specific entrypoints for the layout tests test infrastructure.""" import builders # Why is this in port? from base import Port # It's possible we don't need to export this virtual baseclass outside the module. from driver import Driver, DriverInput, DriverOutput from factory import platform_options, configuration_options
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 4313, 13, 6100, 2397, 3438, 367, 314, 7054, 2295, 511, 28890, 6976, 1041, 199, 199, 646, 27378, 221, 327, 6827, 365, 642, 315, 1844, 31, 199, 199, 504, 1300, 492, 10977, 221, 327, 2779, 1159, 3962, 781, 2793, 1133, 1929, 370, 4843, 642, 5791, 1300, 533, 9682, 314, 859, 14, 199, 504, 5253, 492, 19447, 12, 19447, 3205, 12, 19447, 2959, 199, 504, 6434, 492, 4298, 63, 1419, 12, 2897, 63, 1419, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 4313, 13, 6100, 2397, 3438, 367, 314, 7054, 2295, 511, 28890, 6976, 1041, 199, 199, 646, 27378, 221, 327, 6827, 365, 642, 315, 1844, 31, 199, 199, 504, 1300, 492, 10977, 221, 327, 2779, 1159, 3962, 781, 2793, 1133, 1929, 370, 4843, 642, 5791, 1300, 533, 9682, 314, 859, 14, 199, 504, 5253, 492, 19447, 12, 19447, 3205, 12, 19447, 2959, 199, 504, 6434, 492, 4298, 63, 1419, 12, 2897, 63, 1419, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
jusdng/odoo
openerp/tools/cache.py
226
6865
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2013 OpenERP (<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/>. # ############################################################################## # decorator makes wrappers that have the same API as their wrapped function; # this is important for the openerp.api.guess() that relies on signatures from collections import defaultdict from decorator import decorator from inspect import getargspec import logging _logger = logging.getLogger(__name__) class ormcache_counter(object): """ Statistic counters for cache entries. """ __slots__ = ['hit', 'miss', 'err'] def __init__(self): self.hit = 0 self.miss = 0 self.err = 0 @property def ratio(self): return 100.0 * self.hit / (self.hit + self.miss or 1) # statistic counters dictionary, maps (dbname, modelname, method) to counter STAT = defaultdict(ormcache_counter) class ormcache(object): """ LRU cache decorator for orm methods. """ def __init__(self, skiparg=2, size=8192, multi=None, timeout=None): self.skiparg = skiparg def __call__(self, method): self.method = method lookup = decorator(self.lookup, method) lookup.clear_cache = self.clear return lookup def lru(self, model): counter = STAT[(model.pool.db_name, model._name, self.method)] return model.pool.cache, (model._name, self.method), counter def lookup(self, method, *args, **kwargs): d, key0, counter = self.lru(args[0]) key = key0 + args[self.skiparg:] try: r = d[key] counter.hit += 1 return r except KeyError: counter.miss += 1 value = d[key] = self.method(*args, **kwargs) return value except TypeError: counter.err += 1 return self.method(*args, **kwargs) def clear(self, model, *args): """ Remove *args entry from the cache or all keys if *args is undefined """ d, key0, _ = self.lru(model) if args: _logger.warn("ormcache.clear arguments are deprecated and ignored " "(while clearing caches on (%s).%s)", model._name, self.method.__name__) d.clear_prefix(key0) model.pool._any_cache_cleared = True class ormcache_context(ormcache): def __init__(self, skiparg=2, size=8192, accepted_keys=()): super(ormcache_context,self).__init__(skiparg,size) self.accepted_keys = accepted_keys def __call__(self, method): # remember which argument is context args = getargspec(method)[0] self.context_pos = args.index('context') return super(ormcache_context, self).__call__(method) def lookup(self, method, *args, **kwargs): d, key0, counter = self.lru(args[0]) # Note. The decorator() wrapper (used in __call__ above) will resolve # arguments, and pass them positionally to lookup(). This is why context # is not passed through kwargs! if self.context_pos < len(args): context = args[self.context_pos] or {} else: context = kwargs.get('context') or {} ckey = [(k, context[k]) for k in self.accepted_keys if k in context] # Beware: do not take the context from args! key = key0 + args[self.skiparg:self.context_pos] + tuple(ckey) try: r = d[key] counter.hit += 1 return r except KeyError: counter.miss += 1 value = d[key] = self.method(*args, **kwargs) return value except TypeError: counter.err += 1 return self.method(*args, **kwargs) class ormcache_multi(ormcache): def __init__(self, skiparg=2, size=8192, multi=3): assert skiparg <= multi super(ormcache_multi, self).__init__(skiparg, size) self.multi = multi def lookup(self, method, *args, **kwargs): d, key0, counter = self.lru(args[0]) base_key = key0 + args[self.skiparg:self.multi] + args[self.multi+1:] ids = args[self.multi] result = {} missed = [] # first take what is available in the cache for i in ids: key = base_key + (i,) try: result[i] = d[key] counter.hit += 1 except Exception: counter.miss += 1 missed.append(i) if missed: # call the method for the ids that were not in the cache args = list(args) args[self.multi] = missed result.update(method(*args, **kwargs)) # store those new results back in the cache for i in missed: key = base_key + (i,) d[key] = result[i] return result class dummy_cache(object): """ Cache decorator replacement to actually do no caching. """ def __init__(self, *l, **kw): pass def __call__(self, fn): fn.clear_cache = self.clear return fn def clear(self, *l, **kw): pass def log_ormcache_stats(sig=None, frame=None): """ Log statistics of ormcache usage by database, model, and method. """ from openerp.modules.registry import RegistryManager import threading me = threading.currentThread() me_dbname = me.dbname entries = defaultdict(int) for dbname, reg in RegistryManager.registries.iteritems(): for key in reg.cache.iterkeys(): entries[(dbname,) + key[:2]] += 1 for key, count in sorted(entries.items()): dbname, model_name, method = key me.dbname = dbname stat = STAT[key] _logger.info("%6d entries, %6d hit, %6d miss, %6d err, %4.1f%% ratio, for %s.%s", count, stat.hit, stat.miss, stat.err, stat.ratio, model_name, method.__name__) me.dbname = me_dbname # For backward compatibility cache = ormcache # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 7531, 7704, 17995, 626, 1172, 314, 2011, 3261, 465, 3932, 8072, 805, 27, 199, 3, 642, 365, 11012, 367, 314, 5166, 14, 1246, 14, 11636, 342, 626, 25749, 641, 17597, 199, 504, 5055, 492, 10018, 199, 504, 7531, 492, 7531, 199, 504, 6485, 492, 664, 15644, 199, 646, 2050, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 9813, 1637, 63, 5337, 8, 785, 304, 272, 408, 7083, 19940, 21272, 367, 2581, 4811, 14, 408, 272, 636, 7257, 363, 275, 788, 12948, 297, 283, 18420, 297, 283, 1508, 418, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 12948, 275, 378, 267, 291, 14, 18420, 275, 378, 267, 291, 14, 1508, 275, 378, 339, 768, 1829, 272, 347, 10463, 8, 277, 304, 267, 372, 2948, 14, 16, 627, 291, 14, 12948, 1182, 334, 277, 14, 12948, 435, 291, 14, 18420, 503, 413, 9, 199, 199, 3, 22394, 21272, 2600, 12, 9033, 334, 13238, 12, 1402, 354, 12, 1083, 9, 370, 7055, 199, 4315, 275, 10018, 8, 1025, 1637, 63, 5337, 9, 421, 199, 533, 9813, 1637, 8, 785, 304, 272, 408, 491, 9500, 2581, 7531, 367, 9813, 3102, 14, 408, 339, 347, 636, 826, 721, 277, 12, 2386, 73, 462, 71, 29, 18, 12, 1568, 29, 31526, 12, 3510, 29, 403, 12, 2653, 29, 403, 304, 267, 291, 14, 10728, 462, 71, 275, 2386, 73, 462, 71, 339, 347, 636, 1250, 721, 277, 12, 1083, 304, 267, 291, 14, 765, 275, 1083, 267, 4237, 275, 7531, 8, 277, 14, 3892, 12, 1083, 9, 267, 4237, 14, 3584, 63, 1637, 275, 291, 14, 3584, 267, 372, 4237, 339, 347, 634, 6558, 8, 277, 12, 1402, 304, 267, 7055, 275, 13146, 7528, 1238, 14, 2293, 14, 697, 63, 354, 12, 1402, 423, 354, 12, 291, 14, 765, 1874, 267, 372, 1402, 14, 2293, 14, 1637, 12, 334, 1238, 423, 354, 12, 291, 14, 765, 395, 7055, 339, 347, 4237, 8, 277, 12, 1083, 12, 627, 589, 12, 1011, 958, 304, 267, 366, 12, 790, 16, 12, 7055, 275, 291, 14, 25003, 8, 589, 59, 16, 566, 267, 790, 275, 790, 16, 435, 1249, 59, 277, 14, 10728, 462, 71, 2938, 267, 862, 26, 288, 519, 275, 366, 59, 498, 61, 288, 7055, 14, 12948, 847, 413, 288, 372, 519, 267, 871, 4067, 26, 288, 7055, 14, 18420, 847, 413, 288, 574, 275, 366, 59, 498, 61, 275, 291, 14, 765, 2031, 589, 12, 1011, 958, 9, 288, 372, 574, 267, 871, 3146, 26, 288, 7055, 14, 1508, 847, 413, 288, 372, 291, 14, 765, 2031, 589, 12, 1011, 958, 9, 339, 347, 5436, 8, 277, 12, 1402, 12, 627, 589, 304, 267, 408, 5852, 627, 589, 2397, 687, 314, 2581, 503, 1006, 2883, 340, 627, 589, 365, 10942, 408, 267, 366, 12, 790, 16, 12, 485, 275, 291, 14, 25003, 8, 1238, 9, 267, 340, 1249, 26, 288, 485, 2921, 14, 4050, 480, 1025, 1637, 14, 3584, 2368, 787, 5906, 436, 5525, 298, 586, 7340, 6710, 5436, 316, 18014, 641, 4366, 83, 680, 5, 83, 4186, 586, 1402, 423, 354, 12, 291, 14, 765, 855, 354, 3368, 267, 366, 14, 3584, 63, 1861, 8, 498, 16, 9, 267, 1402, 14, 2293, 423, 1629, 63, 1637, 63, 2265, 2899, 275, 715, 421, 199, 533, 9813, 1637, 63, 1100, 8, 1025, 1637, 304, 272, 347, 636, 826, 721, 277, 12, 2386, 73, 462, 71, 29, 18, 12, 1568, 29, 31526, 12, 10226, 63, 1612, 23603, 267, 1613, 8, 1025, 1637, 63, 1100, 12, 277, 2843, 826, 721, 10728, 462, 71, 12, 890, 9, 267, 291, 14, 16121, 63, 1612, 275, 10226, 63, 1612, 339, 347, 636, 1250, 721, 277, 12, 1083, 304, 267, 327, 21027, 1314, 1423, 365, 1067, 267, 1249, 275, 664, 15644, 8, 765, 2788, 16, 61, 267, 291, 14, 1100, 63, 1712, 275, 1249, 14, 1080, 360, 1100, 358, 267, 372, 1613, 8, 1025, 1637, 63, 1100, 12, 291, 2843, 1250, 721, 765, 9, 339, 347, 4237, 8, 277, 12, 1083, 12, 627, 589, 12, 1011, 958, 304, 267, 366, 12, 790, 16, 12, 7055, 275, 291, 14, 25003, 8, 589, 59, 16, 566, 398, 327, 3390, 14, 710, 7531, 342, 4975, 334, 2972, 315, 636, 1250, 363, 3432, 9, 911, 7512, 267, 327, 2368, 12, 436, 986, 3062, 3421, 1183, 370, 4237, 1252, 961, 365, 10842, 1067, 267, 327, 365, 440, 3032, 4012, 2074, 1, 267, 340, 291, 14, 1100, 63, 1712, 665, 822, 8, 589, 304, 288, 1067, 275, 1249, 59, 277, 14, 1100, 63, 1712, 61, 503, 1052, 267, 587, 26, 288, 1067, 275, 2074, 14, 362, 360, 1100, 358, 503, 1052, 267, 286, 498, 275, 3842, 75, 12, 1067, 59, 75, 566, 367, 1022, 315, 291, 14, 16121, 63, 1612, 340, 1022, 315, 1067, 61, 398, 327, 699, 546, 1530, 26, 886, 440, 5452, 314, 1067, 687, 1249, 1, 267, 790, 275, 790, 16, 435 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 7531, 7704, 17995, 626, 1172, 314, 2011, 3261, 465, 3932, 8072, 805, 27, 199, 3, 642, 365, 11012, 367, 314, 5166, 14, 1246, 14, 11636, 342, 626, 25749, 641, 17597, 199, 504, 5055, 492, 10018, 199, 504, 7531, 492, 7531, 199, 504, 6485, 492, 664, 15644, 199, 646, 2050, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 9813, 1637, 63, 5337, 8, 785, 304, 272, 408, 7083, 19940, 21272, 367, 2581, 4811, 14, 408, 272, 636, 7257, 363, 275, 788, 12948, 297, 283, 18420, 297, 283, 1508, 418, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 12948, 275, 378, 267, 291, 14, 18420, 275, 378, 267, 291, 14, 1508, 275, 378, 339, 768, 1829, 272, 347, 10463, 8, 277, 304, 267, 372, 2948, 14, 16, 627, 291, 14, 12948, 1182, 334, 277, 14, 12948, 435, 291, 14, 18420, 503, 413, 9, 199, 199, 3, 22394, 21272, 2600, 12, 9033, 334, 13238, 12, 1402, 354, 12, 1083, 9, 370, 7055, 199, 4315, 275, 10018, 8, 1025, 1637, 63, 5337, 9, 421, 199, 533, 9813, 1637, 8, 785, 304, 272, 408, 491, 9500, 2581, 7531, 367, 9813, 3102, 14, 408, 339, 347, 636, 826, 721, 277, 12, 2386, 73, 462, 71, 29, 18, 12, 1568, 29, 31526, 12, 3510, 29, 403, 12, 2653, 29, 403, 304, 267, 291, 14, 10728, 462, 71, 275, 2386, 73, 462, 71, 339, 347, 636, 1250, 721, 277, 12, 1083, 304, 267, 291, 14, 765, 275, 1083, 267, 4237, 275, 7531, 8, 277, 14, 3892, 12, 1083, 9, 267, 4237, 14, 3584, 63, 1637, 275, 291, 14, 3584, 267, 372, 4237, 339, 347, 634, 6558, 8, 277, 12, 1402, 304, 267, 7055, 275, 13146, 7528, 1238, 14, 2293, 14, 697, 63, 354, 12, 1402, 423, 354, 12, 291, 14, 765, 1874, 267, 372, 1402, 14, 2293, 14, 1637, 12, 334, 1238, 423, 354, 12, 291, 14, 765, 395, 7055, 339, 347, 4237, 8, 277, 12, 1083, 12, 627, 589, 12, 1011, 958, 304, 267, 366, 12, 790, 16, 12, 7055, 275, 291, 14, 25003, 8, 589, 59, 16, 566, 267, 790, 275, 790, 16, 435, 1249, 59, 277, 14, 10728, 462, 71, 2938, 267, 862, 26, 288, 519, 275, 366, 59, 498, 61, 288, 7055, 14, 12948, 847, 413, 288, 372, 519, 267, 871, 4067, 26, 288, 7055, 14, 18420, 847, 413, 288, 574, 275, 366, 59, 498, 61, 275, 291, 14, 765, 2031, 589, 12, 1011, 958, 9, 288, 372, 574, 267, 871, 3146, 26, 288, 7055, 14, 1508, 847, 413, 288, 372, 291, 14, 765, 2031, 589, 12, 1011, 958, 9, 339, 347, 5436, 8, 277, 12, 1402, 12, 627, 589, 304, 267, 408, 5852, 627, 589, 2397, 687, 314, 2581, 503, 1006, 2883, 340, 627, 589, 365, 10942, 408, 267, 366, 12, 790, 16, 12, 485, 275, 291, 14, 25003, 8, 1238, 9, 267, 340, 1249, 26, 288, 485, 2921, 14, 4050, 480, 1025, 1637, 14, 3584, 2368, 787, 5906, 436, 5525, 298, 586, 7340, 6710, 5436, 316, 18014, 641, 4366, 83, 680, 5, 83, 4186, 586, 1402, 423, 354, 12, 291, 14, 765, 855, 354, 3368, 267, 366, 14, 3584, 63, 1861, 8, 498, 16, 9, 267, 1402, 14, 2293, 423, 1629, 63, 1637, 63, 2265, 2899, 275, 715, 421, 199, 533, 9813, 1637, 63, 1100, 8, 1025, 1637, 304, 272, 347, 636, 826, 721, 277, 12, 2386, 73, 462, 71, 29, 18, 12, 1568, 29, 31526, 12, 10226, 63, 1612, 23603, 267, 1613, 8, 1025, 1637, 63, 1100, 12, 277, 2843, 826, 721, 10728, 462, 71, 12, 890, 9, 267, 291, 14, 16121, 63, 1612, 275, 10226, 63, 1612, 339, 347, 636, 1250, 721, 277, 12, 1083, 304, 267, 327, 21027, 1314, 1423, 365, 1067, 267, 1249, 275, 664, 15644, 8, 765, 2788, 16, 61, 267, 291, 14, 1100, 63, 1712, 275, 1249, 14, 1080, 360, 1100, 358, 267, 372, 1613, 8, 1025, 1637, 63, 1100, 12, 291, 2843, 1250, 721, 765, 9, 339, 347, 4237, 8, 277, 12, 1083, 12, 627, 589, 12, 1011, 958, 304, 267, 366, 12, 790, 16, 12, 7055, 275, 291, 14, 25003, 8, 589, 59, 16, 566, 398, 327, 3390, 14, 710, 7531, 342, 4975, 334, 2972, 315, 636, 1250, 363, 3432, 9, 911, 7512, 267, 327, 2368, 12, 436, 986, 3062, 3421, 1183, 370, 4237, 1252, 961, 365, 10842, 1067, 267, 327, 365, 440, 3032, 4012, 2074, 1, 267, 340, 291, 14, 1100, 63, 1712, 665, 822, 8, 589, 304, 288, 1067, 275, 1249, 59, 277, 14, 1100, 63, 1712, 61, 503, 1052, 267, 587, 26, 288, 1067, 275, 2074, 14, 362, 360, 1100, 358, 503, 1052, 267, 286, 498, 275, 3842, 75, 12, 1067, 59, 75, 566, 367, 1022, 315, 291, 14, 16121, 63, 1612, 340, 1022, 315, 1067, 61, 398, 327, 699, 546, 1530, 26, 886, 440, 5452, 314, 1067, 687, 1249, 1, 267, 790, 275, 790, 16, 435, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eltonkent/android-quill
jni/libhpdf-2.3.0RC2/if/python/demo/raw_image_demo.py
32
3894
### ## * << Haru Free PDF Library 2.0.0 >> -- raw_image_demo.c ## * ## * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> ## * ## * Permission to use, copy, modify, distribute and sell this software ## * and its documentation for any purpose is hereby granted without fee, ## * provided that the above copyright notice appear in all copies and ## * that both that copyright notice and this permission notice appear ## * in supporting documentation. ## * It is provided "as is" without express or implied warranty. ## * ## ## port to python by Li Jun ## http://groups.google.com/group/pythoncia import os, sys from ctypes import * up=2 def setlibpath(up): import sys path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up) if path not in sys.path: sys.path.append(path) setlibpath(up) from haru import * from haru.c_func import * from haru.hpdf_errorcode import * @HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p) def error_handler (error_no, detail_no, user_data): global pdf printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no], detail_no) HPDF_Free (pdf) sys.exit(1) RAW_IMAGE_DATA=[ 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xf3, 0xf3, 0xff, 0xe0, 0xf3, 0xf3, 0xff, 0xc0, 0xf3, 0xf3, 0xff, 0x80, 0xf3, 0x33, 0xff, 0x00, 0xf3, 0x33, 0xfe, 0x00, 0xf3, 0x33, 0xfc, 0x00, 0xf8, 0x07, 0xf8, 0x00, 0xf8, 0x07, 0xf0, 0x00, 0xfc, 0xcf, 0xe0, 0x00, 0xfc, 0xcf, 0xc0, 0x00, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xf8, 0x0f, 0xe0, 0xff, 0xf0, 0x0f, 0xe0, 0xff, 0xe0, 0x0c, 0x30, 0xff, 0xc0, 0x0c, 0x30, 0xff, 0x80, 0x0f, 0xe0, 0xff, 0x00, 0x0f, 0xe0, 0xfe, 0x00, 0x0c, 0x30, 0xfc, 0x00, 0x0c, 0x30, 0xf8, 0x00, 0x0f, 0xe0, 0xf0, 0x00, 0x0f, 0xe0, 0xe0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] def main (): global pdf fname=os.path.realpath(sys.argv[0]) fname=fname[:fname.rfind('.')]+'.pdf' pdf = HPDF_New (error_handler, NULL) if (not pdf): printf ("error: cannot create PdfDoc object\n") return 1 HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL) # create default-font font = HPDF_GetFont (pdf, "Helvetica", NULL) # add a new page object. page = HPDF_AddPage (pdf) HPDF_Page_SetWidth (page, 172) HPDF_Page_SetHeight (page, 80) HPDF_Page_BeginText (page) HPDF_Page_SetFontAndSize (page, font, 20) HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70) HPDF_Page_ShowText (page, "RawImageDemo") HPDF_Page_EndText (page) # load RGB raw-image file. image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_rgb.dat", 32, 32, HPDF_CS_DEVICE_RGB) x = 20 y = 20 # Draw image to the canvas. (normal-mode with actual size.) HPDF_Page_DrawImage (page, image, x, y, 32, 32) # load GrayScale raw-image file. image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_gray.dat", 32, 32, HPDF_CS_DEVICE_GRAY) x = 70 y = 20 # Draw image to the canvas. (normal-mode with actual size.) HPDF_Page_DrawImage (page, image, x, y, 32, 32) # load GrayScale raw-image (1bit) file from memory. image = HPDF_LoadRawImageFromMem (pdf, RAW_IMAGE_DATA, 32, 32, HPDF_CS_DEVICE_GRAY, 1) x = 120 y = 20 # Draw image to the canvas. (normal-mode with actual size.) HPDF_Page_DrawImage (page, image, x, y, 32, 32) # save the document to a file HPDF_SaveToFile (pdf, fname) # clean up HPDF_Free (pdf) return 0 main()
gpl-3.0
[ 5680, 202, 199, 309, 627, 5213, 25378, 85, 2868, 15537, 11243, 499, 14, 16, 14, 16, 4331, 1553, 3066, 63, 1569, 63, 8768, 14, 67, 202, 199, 309, 627, 202, 199, 309, 627, 1898, 334, 67, 9, 21300, 13, 7968, 17415, 5812, 1804, 25264, 665, 31613, 5812, 63, 75, 25264, 32, 597, 14, 5812, 13, 526, 14, 685, 14, 11538, 30, 202, 199, 309, 627, 202, 199, 309, 627, 8779, 370, 675, 12, 1331, 12, 2811, 12, 11207, 436, 12743, 642, 2032, 202, 199, 309, 627, 436, 2399, 3794, 367, 1263, 12016, 365, 11882, 10009, 1928, 14751, 12, 202, 199, 309, 627, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 6866, 436, 202, 199, 309, 627, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 202, 199, 309, 627, 315, 21038, 3794, 14, 202, 199, 309, 627, 2779, 365, 2741, 298, 305, 365, 2, 1928, 4056, 503, 2478, 3750, 14, 202, 199, 309, 627, 202, 199, 309, 2999, 199, 309, 1844, 370, 2366, 701, 24157, 1603, 324, 202, 199, 309, 1455, 921, 2634, 14, 3098, 14, 957, 15, 923, 15, 1548, 16521, 2999, 199, 646, 747, 12, 984, 2999, 199, 504, 5577, 492, 627, 202, 199, 384, 29, 18, 202, 199, 318, 663, 773, 515, 8, 384, 304, 1128, 492, 984, 1128, 931, 29, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 59, 16, 2807, 1154, 703, 16804, 384, 9, 1128, 340, 931, 440, 315, 984, 14, 515, 26, 1039, 984, 14, 515, 14, 740, 8, 515, 9, 2999, 199, 409, 773, 515, 8, 384, 9, 2999, 199, 504, 12159, 85, 492, 627, 202, 199, 504, 12159, 85, 14, 67, 63, 1532, 492, 627, 202, 199, 504, 12159, 85, 14, 72, 5607, 63, 28857, 492, 627, 8065, 199, 32, 14036, 63, 547, 63, 2461, 8, 403, 12, 24006, 63, 17459, 12, 24006, 63, 17459, 12, 286, 63, 1647, 63, 80, 9, 202, 199, 318, 1125, 63, 2232, 334, 705, 63, 889, 12, 10093, 63, 889, 12, 922, 63, 576, 304, 1128, 2288, 11249, 1128, 870, 70, 1689, 3170, 26, 450, 83, 12, 10093, 63, 889, 2458, 85, 60, 78, 401, 1125, 63, 5506, 59, 705, 63, 889, 467, 2628, 10093, 63, 889, 9, 1128, 24006, 63, 10146, 334, 5607, 9, 1128, 984, 14, 2224, 8, 17, 9, 8065, 199, 4307, 63, 9438, 63, 3998, 1524, 1128, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 8371, 12, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 10347, 12, 1128, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 1949, 24, 12, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 1949, 16, 12, 1128, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 1845, 16, 12, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 1812, 16, 12, 1128, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 88, 1257, 12, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 3581, 12, 378, 88, 383, 12, 1128, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 8371, 12, 378, 88, 383, 12, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 10347, 12, 378, 88, 383, 12, 1128, 378, 1949, 24, 12, 378, 88, 1780, 12, 378, 1949, 24, 12, 378, 88, 383, 12, 378, 1949, 24, 12, 378, 88, 1780, 12, 378, 1949, 16, 12, 378, 88, 383, 12, 1128, 378, 10347, 12, 378, 10493, 12, 378, 1845, 16, 12, 378, 88, 383, 12, 378, 10347, 12, 378, 10493, 12, 378, 1812, 16, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 3581, 12, 378, 88, 1257, 12, 378, 88, 383, 12, 378, 3581, 12, 378, 3581, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 8371, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 3581, 12, 378, 10347, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 1949, 24, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 3581, 12, 378, 1949, 16, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 3581, 12, 378, 1845, 16, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 378, 3581, 12, 378, 1812, 16, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 1128, 378, 3581, 12, 378, 88, 1257, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 3581, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 8371, 12, 378, 88, 383, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 378, 10347, 12, 378, 88, 383, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 1128, 378, 1949, 24, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 1949, 16, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 1845, 16, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 1812, 16, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 88, 1257, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 202, 199, 61, 2999, 199, 318, 2446, 23390, 1128, 2288, 221, 11249, 2958, 6748, 29, 736, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 566, 1128, 6748, 29, 5252, 1491, 5252, 14, 14542, 7563, 2807, 1370, 5607, 7, 2958, 11249, 275, 24006, 63, 4665, 334, 705, 63, 2232, 12, 5962, 9, 1128, 340, 334, 1397, 11249, 304, 1039, 870, 70, 1689, 705, 26, 3913, 1218, 510, 1587, 3768, 909, 60, 78, 531, 1039, 372, 413, 2958, 24006, 63, 1084, 25551, 1385, 334, 5607, 12, 24006, 63, 6790, 63, 1761, 9, 2958, 327, 1218, 849, 13, 4246, 1128, 5023, 275, 24006, 63, 1002, 6986, 334, 5607, 12, 298, 40, 25911, 401, 5962, 9, 2958, 327, 1050, 282, 892, 2034, 909, 14, 1128, 2034, 275, 24006, 63, 1123 ]
[ 202, 199, 309, 627, 5213, 25378, 85, 2868, 15537, 11243, 499, 14, 16, 14, 16, 4331, 1553, 3066, 63, 1569, 63, 8768, 14, 67, 202, 199, 309, 627, 202, 199, 309, 627, 1898, 334, 67, 9, 21300, 13, 7968, 17415, 5812, 1804, 25264, 665, 31613, 5812, 63, 75, 25264, 32, 597, 14, 5812, 13, 526, 14, 685, 14, 11538, 30, 202, 199, 309, 627, 202, 199, 309, 627, 8779, 370, 675, 12, 1331, 12, 2811, 12, 11207, 436, 12743, 642, 2032, 202, 199, 309, 627, 436, 2399, 3794, 367, 1263, 12016, 365, 11882, 10009, 1928, 14751, 12, 202, 199, 309, 627, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 6866, 436, 202, 199, 309, 627, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 202, 199, 309, 627, 315, 21038, 3794, 14, 202, 199, 309, 627, 2779, 365, 2741, 298, 305, 365, 2, 1928, 4056, 503, 2478, 3750, 14, 202, 199, 309, 627, 202, 199, 309, 2999, 199, 309, 1844, 370, 2366, 701, 24157, 1603, 324, 202, 199, 309, 1455, 921, 2634, 14, 3098, 14, 957, 15, 923, 15, 1548, 16521, 2999, 199, 646, 747, 12, 984, 2999, 199, 504, 5577, 492, 627, 202, 199, 384, 29, 18, 202, 199, 318, 663, 773, 515, 8, 384, 304, 1128, 492, 984, 1128, 931, 29, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 59, 16, 2807, 1154, 703, 16804, 384, 9, 1128, 340, 931, 440, 315, 984, 14, 515, 26, 1039, 984, 14, 515, 14, 740, 8, 515, 9, 2999, 199, 409, 773, 515, 8, 384, 9, 2999, 199, 504, 12159, 85, 492, 627, 202, 199, 504, 12159, 85, 14, 67, 63, 1532, 492, 627, 202, 199, 504, 12159, 85, 14, 72, 5607, 63, 28857, 492, 627, 8065, 199, 32, 14036, 63, 547, 63, 2461, 8, 403, 12, 24006, 63, 17459, 12, 24006, 63, 17459, 12, 286, 63, 1647, 63, 80, 9, 202, 199, 318, 1125, 63, 2232, 334, 705, 63, 889, 12, 10093, 63, 889, 12, 922, 63, 576, 304, 1128, 2288, 11249, 1128, 870, 70, 1689, 3170, 26, 450, 83, 12, 10093, 63, 889, 2458, 85, 60, 78, 401, 1125, 63, 5506, 59, 705, 63, 889, 467, 2628, 10093, 63, 889, 9, 1128, 24006, 63, 10146, 334, 5607, 9, 1128, 984, 14, 2224, 8, 17, 9, 8065, 199, 4307, 63, 9438, 63, 3998, 1524, 1128, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 8371, 12, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 10347, 12, 1128, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 1949, 24, 12, 378, 3581, 12, 378, 3581, 12, 378, 3581, 12, 378, 1949, 16, 12, 1128, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 1845, 16, 12, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 1812, 16, 12, 1128, 378, 1949, 19, 12, 378, 1949, 19, 12, 378, 3581, 12, 378, 88, 1257, 12, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 3581, 12, 378, 88, 383, 12, 1128, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 8371, 12, 378, 88, 383, 12, 378, 1949, 19, 12, 378, 88, 1153, 12, 378, 10347, 12, 378, 88, 383, 12, 1128, 378, 1949, 24, 12, 378, 88, 1780, 12, 378, 1949, 24, 12, 378, 88, 383, 12, 378, 1949, 24, 12, 378, 88, 1780, 12, 378, 1949, 16, 12, 378, 88, 383, 12, 1128, 378, 10347, 12, 378, 10493, 12, 378, 1845, 16, 12, 378, 88, 383, 12, 378, 10347, 12, 378, 10493, 12, 378, 1812, 16, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 3581, 12, 378, 88, 1257, 12, 378, 88, 383, 12, 378, 3581, 12, 378, 3581, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 8371, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 3581, 12, 378, 10347, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 3581, 12, 378, 1949, 24, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 3581, 12, 378, 1949, 16, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 3581, 12, 378, 1845, 16, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 378, 3581, 12, 378, 1812, 16, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 1128, 378, 3581, 12, 378, 88, 1257, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 3581, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 8371, 12, 378, 88, 383, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 378, 10347, 12, 378, 88, 383, 12, 378, 88, 16, 67, 12, 378, 88, 1216, 12, 1128, 378, 1949, 24, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 378, 1949, 16, 12, 378, 88, 383, 12, 378, 88, 16, 70, 12, 378, 1845, 16, 12, 1128, 378, 1845, 16, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 1812, 16, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 1128, 378, 88, 1257, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 88, 383, 202, 199, 61, 2999, 199, 318, 2446, 23390, 1128, 2288, 221, 11249, 2958, 6748, 29, 736, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 566, 1128, 6748, 29, 5252, 1491, 5252, 14, 14542, 7563, 2807, 1370, 5607, 7, 2958, 11249, 275, 24006, 63, 4665, 334, 705, 63, 2232, 12, 5962, 9, 1128, 340, 334, 1397, 11249, 304, 1039, 870, 70, 1689, 705, 26, 3913, 1218, 510, 1587, 3768, 909, 60, 78, 531, 1039, 372, 413, 2958, 24006, 63, 1084, 25551, 1385, 334, 5607, 12, 24006, 63, 6790, 63, 1761, 9, 2958, 327, 1218, 849, 13, 4246, 1128, 5023, 275, 24006, 63, 1002, 6986, 334, 5607, 12, 298, 40, 25911, 401, 5962, 9, 2958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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
stylianos-kampakis/scikit-learn
sklearn/externals/joblib/logger.py
359
5135
""" Helpers for logging. This module needs much love to become useful. """ # Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org> # Copyright (c) 2008 Gael Varoquaux # License: BSD Style, 3 clauses. from __future__ import print_function import time import sys import os import shutil import logging import pprint from .disk import mkdirp def _squeeze_time(t): """Remove .1s to the time under Windows: this is the time it take to stat files. This is needed to make results similar to timings under Unix, for tests """ if sys.platform.startswith('win'): return max(0, t - .1) else: return t def format_time(t): t = _squeeze_time(t) return "%.1fs, %.1fmin" % (t, t / 60.) def short_format_time(t): t = _squeeze_time(t) if t > 60: return "%4.1fmin" % (t / 60.) else: return " %5.1fs" % (t) def pformat(obj, indent=0, depth=3): if 'numpy' in sys.modules: import numpy as np print_options = np.get_printoptions() np.set_printoptions(precision=6, threshold=64, edgeitems=1) else: print_options = None out = pprint.pformat(obj, depth=depth, indent=indent) if print_options: np.set_printoptions(**print_options) return out ############################################################################### # class `Logger` ############################################################################### class Logger(object): """ Base class for logging messages. """ def __init__(self, depth=3): """ Parameters ---------- depth: int, optional The depth of objects printed. """ self.depth = depth def warn(self, msg): logging.warn("[%s]: %s" % (self, msg)) def debug(self, msg): # XXX: This conflicts with the debug flag used in children class logging.debug("[%s]: %s" % (self, msg)) def format(self, obj, indent=0): """ Return the formated representation of the object. """ return pformat(obj, indent=indent, depth=self.depth) ############################################################################### # class `PrintTime` ############################################################################### class PrintTime(object): """ Print and log messages while keeping track of time. """ def __init__(self, logfile=None, logdir=None): if logfile is not None and logdir is not None: raise ValueError('Cannot specify both logfile and logdir') # XXX: Need argument docstring self.last_time = time.time() self.start_time = self.last_time if logdir is not None: logfile = os.path.join(logdir, 'joblib.log') self.logfile = logfile if logfile is not None: mkdirp(os.path.dirname(logfile)) if os.path.exists(logfile): # Rotate the logs for i in range(1, 9): try: shutil.move(logfile + '.%i' % i, logfile + '.%i' % (i + 1)) except: "No reason failing here" # Use a copy rather than a move, so that a process # monitoring this file does not get lost. try: shutil.copy(logfile, logfile + '.1') except: "No reason failing here" try: with open(logfile, 'w') as logfile: logfile.write('\nLogging joblib python script\n') logfile.write('\n---%s---\n' % time.ctime(self.last_time)) except: """ Multiprocessing writing to files can create race conditions. Rather fail silently than crash the computation. """ # XXX: We actually need a debug flag to disable this # silent failure. def __call__(self, msg='', total=False): """ Print the time elapsed between the last call and the current call, with an optional message. """ if not total: time_lapse = time.time() - self.last_time full_msg = "%s: %s" % (msg, format_time(time_lapse)) else: # FIXME: Too much logic duplicated time_lapse = time.time() - self.start_time full_msg = "%s: %.2fs, %.1f min" % (msg, time_lapse, time_lapse / 60) print(full_msg, file=sys.stderr) if self.logfile is not None: try: with open(self.logfile, 'a') as f: print(full_msg, file=f) except: """ Multiprocessing writing to files can create race conditions. Rather fail silently than crash the calculation. """ # XXX: We actually need a debug flag to disable this # silent failure. self.last_time = time.time()
bsd-3-clause
[ 624, 199, 4433, 83, 367, 2050, 14, 199, 199, 2765, 859, 4839, 8298, 560, 432, 370, 8649, 2997, 14, 199, 624, 199, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 6308, 2729, 79, 392, 10962, 737, 6590, 17667, 1961, 6308, 5981, 30, 199, 3, 1898, 334, 67, 9, 9079, 9647, 352, 21084, 79, 392, 10962, 199, 3, 844, 26, 6289, 19442, 12, 650, 25089, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 5145, 199, 646, 2050, 199, 646, 10933, 199, 199, 504, 1275, 4032, 492, 20366, 80, 421, 199, 318, 485, 16597, 63, 521, 8, 84, 304, 272, 408, 5587, 1275, 17, 83, 370, 314, 900, 1334, 5417, 26, 642, 365, 314, 900, 652, 5452, 370, 272, 5672, 1584, 14, 961, 365, 4346, 370, 1852, 2058, 8545, 370, 221, 27337, 1334, 272, 13074, 12, 367, 2295, 272, 408, 272, 340, 984, 14, 3246, 14, 2460, 360, 2676, 735, 267, 372, 1390, 8, 16, 12, 307, 446, 1275, 17, 9, 272, 587, 26, 267, 372, 307, 421, 199, 318, 1475, 63, 521, 8, 84, 304, 272, 307, 275, 485, 16597, 63, 521, 8, 84, 9, 272, 372, 31681, 17, 2319, 12, 10536, 17, 70, 827, 2, 450, 334, 84, 12, 307, 1182, 5212, 4959, 421, 199, 318, 3974, 63, 908, 63, 521, 8, 84, 304, 272, 307, 275, 485, 16597, 63, 521, 8, 84, 9, 272, 340, 307, 690, 5212, 26, 267, 372, 2071, 20, 14, 17, 70, 827, 2, 450, 334, 84, 1182, 5212, 4959, 272, 587, 26, 267, 372, 298, 450, 21, 14, 17, 2319, 2, 450, 334, 84, 9, 421, 199, 318, 30843, 8, 1113, 12, 4363, 29, 16, 12, 5818, 29, 19, 304, 272, 340, 283, 4714, 7, 315, 984, 14, 3112, 26, 267, 492, 2680, 465, 980, 267, 870, 63, 1419, 275, 980, 14, 362, 63, 1361, 1419, 342, 267, 980, 14, 409, 63, 1361, 1419, 8, 6833, 29, 22, 12, 8765, 29, 772, 12, 6275, 1744, 29, 17, 9, 272, 587, 26, 267, 870, 63, 1419, 275, 488, 272, 734, 275, 10933, 14, 24225, 8, 1113, 12, 5818, 29, 4631, 12, 4363, 29, 3724, 9, 272, 340, 870, 63, 1419, 26, 267, 980, 14, 409, 63, 1361, 1419, 3682, 1361, 63, 1419, 9, 272, 372, 734, 421, 199, 11490, 199, 3, 1021, 658, 4455, 64, 199, 11490, 199, 533, 15996, 8, 785, 304, 272, 408, 3523, 1021, 367, 2050, 3788, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5818, 29, 19, 304, 267, 408, 288, 3897, 288, 4143, 288, 5818, 26, 1109, 12, 2716, 355, 710, 5818, 402, 2251, 12487, 14, 267, 408, 267, 291, 14, 4631, 275, 5818, 339, 347, 7987, 8, 277, 12, 1499, 304, 267, 2050, 14, 4050, 480, 9722, 83, 2189, 450, 83, 2, 450, 334, 277, 12, 1499, 430, 339, 347, 3105, 8, 277, 12, 1499, 304, 267, 327, 5787, 26, 961, 18511, 543, 314, 3105, 3305, 1202, 315, 4978, 1021, 267, 2050, 14, 1757, 480, 9722, 83, 2189, 450, 83, 2, 450, 334, 277, 12, 1499, 430, 339, 347, 1475, 8, 277, 12, 1559, 12, 4363, 29, 16, 304, 267, 408, 1432, 314, 1824, 972, 6025, 402, 314, 909, 14, 267, 408, 267, 372, 30843, 8, 1113, 12, 4363, 29, 3724, 12, 5818, 29, 277, 14, 4631, 9, 421, 199, 11490, 199, 3, 1021, 658, 5375, 1366, 64, 199, 11490, 199, 533, 9101, 1366, 8, 785, 304, 272, 408, 9101, 436, 943, 3788, 1830, 22181, 4426, 402, 900, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 17251, 29, 403, 12, 28825, 29, 403, 304, 267, 340, 17251, 365, 440, 488, 436, 28825, 365, 440, 488, 26, 288, 746, 1722, 360, 6612, 4165, 3865, 17251, 436, 28825, 358, 267, 327, 5787, 26, 14012, 1423, 9214, 267, 291, 14, 2019, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 928, 63, 521, 275, 291, 14, 2019, 63, 521, 267, 340, 28825, 365, 440, 488, 26, 288, 17251, 275, 747, 14, 515, 14, 904, 8, 22222, 12, 283, 2423, 773, 14, 793, 358, 267, 291, 14, 12804, 275, 17251, 267, 340, 17251, 365, 440, 488, 26, 288, 20366, 80, 8, 736, 14, 515, 14, 3475, 8, 12804, 430, 288, 340, 747, 14, 515, 14, 2444, 8, 12804, 304, 355, 327, 20423, 323, 314, 9610, 355, 367, 284, 315, 1425, 8, 17, 12, 1749, 304, 490, 862, 26, 717, 5145, 14, 1185, 8, 12804, 435, 1987, 5, 73, 7, 450, 284, 12, 2511, 17251, 435, 1987, 5, 73, 7, 450, 334, 73, 435, 413, 430, 490, 871, 26, 717, 298, 1944, 4499, 18648, 2348, 2, 355, 327, 3645, 282, 1331, 7830, 2419, 282, 4057, 12, 880, 626, 282, 2112, 355, 327, 20391, 642, 570, 1630, 440, 664, 14669, 14, 355, 862, 26, 490, 5145, 14, 1574, 8, 12804, 12, 17251, 435, 1987, 17, 358, 355, 871, 26, 490, 298, 1944, 4499, 18648, 2348, 2, 288, 862, 26, 355, 543, 1551, 8, 12804, 12, 283, 87, 358, 465, 17251, 26, 490, 17251, 14, 952, 2258, 78, 14054, 3906, 773, 2366, 2884, 60, 78, 358, 490, 17251, 14, 952, 2258, 78, 2595, 5, 83, 17791, 78, 7, 450, 900, 14, 20691, 8, 277, 14, 2019, 63, 521, 430, 288, 871, 26, 355, 408, 6879, 6338, 3575, 370, 1584, 883, 1218, 21209, 490, 3704, 14, 3898, 728, 2449, 18030, 2419, 12420, 314, 490, 14009, 14, 355, 408, 355, 327, 5787, 26, 2136, 5965, 1929, 282, 3105, 3305, 370, 3507, 642, 355, 327, 10866, 5988, 14, 339, 347, 636, 1250, 721, 277, 12, 1499, 4581, 3141, 29, 797, 304, 267, 408, 9101, 314, 900, 14439, 3382, 314, 2061, 1240, 436, 314, 1453, 288, 1240, 12, 543, 376, 2716, 1245, 14, 267, 408, 267, 340, 440, 3141, 26, 288, 900, 63, 12057, 275, 900, 14, 521, 342, 446, 291, 14, 2019, 63, 521, 288, 2615, 63, 1328, 275, 2071, 83, 26, 450, 83, 2, 450, 334, 1328, 12, 1475, 63, 521, 8, 521, 63, 12057, 430, 267, 587, 26, 288, 327, 7600, 26, 22893, 8298, 9661, 21747, 288, 900, 63, 12057, 275, 900, 14, 521, 342, 446 ]
[ 199, 4433, 83, 367, 2050, 14, 199, 199, 2765, 859, 4839, 8298, 560, 432, 370, 8649, 2997, 14, 199, 624, 199, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 6308, 2729, 79, 392, 10962, 737, 6590, 17667, 1961, 6308, 5981, 30, 199, 3, 1898, 334, 67, 9, 9079, 9647, 352, 21084, 79, 392, 10962, 199, 3, 844, 26, 6289, 19442, 12, 650, 25089, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 5145, 199, 646, 2050, 199, 646, 10933, 199, 199, 504, 1275, 4032, 492, 20366, 80, 421, 199, 318, 485, 16597, 63, 521, 8, 84, 304, 272, 408, 5587, 1275, 17, 83, 370, 314, 900, 1334, 5417, 26, 642, 365, 314, 900, 652, 5452, 370, 272, 5672, 1584, 14, 961, 365, 4346, 370, 1852, 2058, 8545, 370, 221, 27337, 1334, 272, 13074, 12, 367, 2295, 272, 408, 272, 340, 984, 14, 3246, 14, 2460, 360, 2676, 735, 267, 372, 1390, 8, 16, 12, 307, 446, 1275, 17, 9, 272, 587, 26, 267, 372, 307, 421, 199, 318, 1475, 63, 521, 8, 84, 304, 272, 307, 275, 485, 16597, 63, 521, 8, 84, 9, 272, 372, 31681, 17, 2319, 12, 10536, 17, 70, 827, 2, 450, 334, 84, 12, 307, 1182, 5212, 4959, 421, 199, 318, 3974, 63, 908, 63, 521, 8, 84, 304, 272, 307, 275, 485, 16597, 63, 521, 8, 84, 9, 272, 340, 307, 690, 5212, 26, 267, 372, 2071, 20, 14, 17, 70, 827, 2, 450, 334, 84, 1182, 5212, 4959, 272, 587, 26, 267, 372, 298, 450, 21, 14, 17, 2319, 2, 450, 334, 84, 9, 421, 199, 318, 30843, 8, 1113, 12, 4363, 29, 16, 12, 5818, 29, 19, 304, 272, 340, 283, 4714, 7, 315, 984, 14, 3112, 26, 267, 492, 2680, 465, 980, 267, 870, 63, 1419, 275, 980, 14, 362, 63, 1361, 1419, 342, 267, 980, 14, 409, 63, 1361, 1419, 8, 6833, 29, 22, 12, 8765, 29, 772, 12, 6275, 1744, 29, 17, 9, 272, 587, 26, 267, 870, 63, 1419, 275, 488, 272, 734, 275, 10933, 14, 24225, 8, 1113, 12, 5818, 29, 4631, 12, 4363, 29, 3724, 9, 272, 340, 870, 63, 1419, 26, 267, 980, 14, 409, 63, 1361, 1419, 3682, 1361, 63, 1419, 9, 272, 372, 734, 421, 199, 11490, 199, 3, 1021, 658, 4455, 64, 199, 11490, 199, 533, 15996, 8, 785, 304, 272, 408, 3523, 1021, 367, 2050, 3788, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5818, 29, 19, 304, 267, 408, 288, 3897, 288, 4143, 288, 5818, 26, 1109, 12, 2716, 355, 710, 5818, 402, 2251, 12487, 14, 267, 408, 267, 291, 14, 4631, 275, 5818, 339, 347, 7987, 8, 277, 12, 1499, 304, 267, 2050, 14, 4050, 480, 9722, 83, 2189, 450, 83, 2, 450, 334, 277, 12, 1499, 430, 339, 347, 3105, 8, 277, 12, 1499, 304, 267, 327, 5787, 26, 961, 18511, 543, 314, 3105, 3305, 1202, 315, 4978, 1021, 267, 2050, 14, 1757, 480, 9722, 83, 2189, 450, 83, 2, 450, 334, 277, 12, 1499, 430, 339, 347, 1475, 8, 277, 12, 1559, 12, 4363, 29, 16, 304, 267, 408, 1432, 314, 1824, 972, 6025, 402, 314, 909, 14, 267, 408, 267, 372, 30843, 8, 1113, 12, 4363, 29, 3724, 12, 5818, 29, 277, 14, 4631, 9, 421, 199, 11490, 199, 3, 1021, 658, 5375, 1366, 64, 199, 11490, 199, 533, 9101, 1366, 8, 785, 304, 272, 408, 9101, 436, 943, 3788, 1830, 22181, 4426, 402, 900, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 17251, 29, 403, 12, 28825, 29, 403, 304, 267, 340, 17251, 365, 440, 488, 436, 28825, 365, 440, 488, 26, 288, 746, 1722, 360, 6612, 4165, 3865, 17251, 436, 28825, 358, 267, 327, 5787, 26, 14012, 1423, 9214, 267, 291, 14, 2019, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 928, 63, 521, 275, 291, 14, 2019, 63, 521, 267, 340, 28825, 365, 440, 488, 26, 288, 17251, 275, 747, 14, 515, 14, 904, 8, 22222, 12, 283, 2423, 773, 14, 793, 358, 267, 291, 14, 12804, 275, 17251, 267, 340, 17251, 365, 440, 488, 26, 288, 20366, 80, 8, 736, 14, 515, 14, 3475, 8, 12804, 430, 288, 340, 747, 14, 515, 14, 2444, 8, 12804, 304, 355, 327, 20423, 323, 314, 9610, 355, 367, 284, 315, 1425, 8, 17, 12, 1749, 304, 490, 862, 26, 717, 5145, 14, 1185, 8, 12804, 435, 1987, 5, 73, 7, 450, 284, 12, 2511, 17251, 435, 1987, 5, 73, 7, 450, 334, 73, 435, 413, 430, 490, 871, 26, 717, 298, 1944, 4499, 18648, 2348, 2, 355, 327, 3645, 282, 1331, 7830, 2419, 282, 4057, 12, 880, 626, 282, 2112, 355, 327, 20391, 642, 570, 1630, 440, 664, 14669, 14, 355, 862, 26, 490, 5145, 14, 1574, 8, 12804, 12, 17251, 435, 1987, 17, 358, 355, 871, 26, 490, 298, 1944, 4499, 18648, 2348, 2, 288, 862, 26, 355, 543, 1551, 8, 12804, 12, 283, 87, 358, 465, 17251, 26, 490, 17251, 14, 952, 2258, 78, 14054, 3906, 773, 2366, 2884, 60, 78, 358, 490, 17251, 14, 952, 2258, 78, 2595, 5, 83, 17791, 78, 7, 450, 900, 14, 20691, 8, 277, 14, 2019, 63, 521, 430, 288, 871, 26, 355, 408, 6879, 6338, 3575, 370, 1584, 883, 1218, 21209, 490, 3704, 14, 3898, 728, 2449, 18030, 2419, 12420, 314, 490, 14009, 14, 355, 408, 355, 327, 5787, 26, 2136, 5965, 1929, 282, 3105, 3305, 370, 3507, 642, 355, 327, 10866, 5988, 14, 339, 347, 636, 1250, 721, 277, 12, 1499, 4581, 3141, 29, 797, 304, 267, 408, 9101, 314, 900, 14439, 3382, 314, 2061, 1240, 436, 314, 1453, 288, 1240, 12, 543, 376, 2716, 1245, 14, 267, 408, 267, 340, 440, 3141, 26, 288, 900, 63, 12057, 275, 900, 14, 521, 342, 446, 291, 14, 2019, 63, 521, 288, 2615, 63, 1328, 275, 2071, 83, 26, 450, 83, 2, 450, 334, 1328, 12, 1475, 63, 521, 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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 ]
platinhom/DailyTools
scripts/ESES_ElementArea.py
1
3679
#! /usr/bin/env python # -*- coding: utf8 -*- # Author: Platinhom; Last Updated: 2015-09-10 # Calculate each element surface area by MS_Intersection and also match the atomic area results to the pqr file. # Usage: python ESES_ElementArea.py file.pqr # # Need: MS_Intersection (partition version) # Note: Only for PQR format input. # Custom: ESES parameters. import os,sys # Modify the ESES program parameter here. # You can modify to command line input parameter as you like probe=1.4 grid=0.2 buffer=4.0 if (__name__ == '__main__'): fname=sys.argv[1] fnamelist=os.path.splitext(fname) fxyzr=open(fnamelist[0]+".xyzr",'w') fr=open(fname) inlines=fr.readlines(); fr.close(); # All elements/types of input atoms, used in element area summary. atomtypes=[]; # Write out the corresponding xyzr file. for line in inlines: # Each atom if (line[:4]=="ATOM" or line[:6]=="HETATM"): # Atom element here tmp=line.split(); element=tmp[-1].upper(); atomtypes.append(element); # Extract x, y, z, r from pqr to xyzr file radius="%10.5f" % float(line[62:70].strip()); xcoor="%10.5f" % float(line[30:38].strip()); ycoor="%10.5f" % float(line[38:46].strip()); zcoor="%10.5f" % float(line[46:54].strip()); xyzrstr=xcoor+ycoor+zcoor+radius+"\n"; fxyzr.write(xyzrstr); fxyzr.close() # Use external ESES program to generate surface and calculate atom area ## So you have to put the ESES program in the same directory # Output a "partition_area.txt" file saving atom area #os.system('./MS_Intersection_Area '+fnamelist[0]+".xyzr "+str(probe)+" "+str(grid)+" "+str(buffer)); p=os.popen('./MS_Intersection '+fnamelist[0]+".xyzr "+str(probe)+" "+str(grid)+" "+str(buffer),'r') totalArea="0" totalVolume="0" while 1: line=p.readline(); if "area:" in line: totalArea=line.split(':')[1].split()[0] if "volume:" in line: totalVolume=line.split(':')[1].split()[0] if not line:break # Analyze output atom area file fa=open("partition_area.txt") atomareas=[];# tmp save atom area by atom number typedefault=["H","C","N","O","F","S","P","CL","BR","I"]; typeareas={"H":0.0,"C":0.0,"N":0.0,"O":0.0,"F":0.0,"S":0.0,"P":0.0,"CL":0.0,"BR":0.0,"I":0.0}; atomnum=0; for line in fa: tmp=line.split(); atomarea="%12.6f" % float(tmp[1]); atomareas.append(atomarea); atype=atomtypes[atomnum]; typeareas[atype]=typeareas.setdefault(atype,0.0)+float(tmp[1]); atomnum=atomnum+1; fa.close() # Write out pqra file saving atom area fwname=fnamelist[0]+"_area.pqra" fw=open(fwname,'w') # Write the total area for each element. ## Notice that here just write out the default elements. ## If you want all elements, use "typeused" for iteration. typeused=["H","C","N","O","F","S","P","CL","BR","I"]; for i in typeareas.iterkeys(): if i not in typeused:typeused.append(i); # For print out the atom area summary outputelearea=fnamelist[0]+" Areas: "+totalArea+" Volumes: "+totalVolume+" "; fw.write("REMARK AREAS "+totalArea+"\n"); fw.write("REMARK VOLUMES "+totalVolume+"\n"); for element in typedefault: # If you want all elements, need to comment the above line and uncomment the following line. #for element in typeused: fw.write("REMARK AREA "+"%2s"%element+" "+"%20.6f"%typeareas.get(element,0.0)+"\n"); outputelearea=outputelearea+element+": "+str(typeareas[element])+" "; print outputelearea fr=open(fname) atomnum=0; for line in fr: if (line[:4]=="ATOM" or line[:6]=="HETATM"): tmp=line.split(); element=tmp[-1].upper(); newline=line.strip('\n')+atomareas[atomnum]+"\n"; fw.write(newline); atomnum=atomnum+1; else: fw.write(line); fr.close(); fw.close() #end main
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 6529, 26, 510, 10378, 526, 77, 27, 15237, 6162, 68, 26, 6900, 13, 1643, 13, 709, 199, 199, 3, 12707, 1924, 1819, 13195, 9150, 701, 14282, 63, 29821, 436, 2597, 1336, 314, 15374, 9150, 2058, 370, 314, 299, 16596, 570, 14, 199, 3, 11028, 26, 2366, 10427, 654, 63, 2162, 11043, 14, 647, 570, 14, 80, 16596, 199, 3, 199, 3, 14012, 26, 14282, 63, 29821, 334, 5312, 1015, 9, 199, 3, 3390, 26, 5972, 367, 510, 26779, 1475, 1324, 14, 199, 3, 8388, 26, 10427, 654, 2633, 14, 199, 199, 646, 747, 12, 1274, 199, 199, 3, 22520, 314, 10427, 654, 2240, 2725, 2348, 14, 221, 199, 3, 2047, 883, 2811, 370, 1414, 1004, 1324, 2725, 465, 1265, 2839, 199, 15944, 29, 17, 14, 20, 199, 3825, 29, 16, 14, 18, 199, 2738, 29, 20, 14, 16, 199, 199, 692, 25373, 354, 363, 508, 2560, 973, 12168, 199, 198, 5252, 29, 1274, 14, 3020, 59, 17, 61, 199, 198, 5252, 513, 29, 736, 14, 515, 14, 7973, 8, 5252, 9, 199, 198, 70, 8568, 82, 29, 1490, 8, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 21891, 87, 358, 199, 198, 4391, 29, 1490, 8, 5252, 9, 199, 198, 26739, 29, 4391, 14, 9684, 7303, 199, 198, 4391, 14, 1600, 7303, 421, 198, 3, 2900, 4008, 15, 1313, 402, 1324, 14503, 12, 1202, 315, 1819, 9150, 6212, 14, 199, 198, 4188, 1313, 9811, 27, 199, 198, 3, 6990, 734, 314, 5226, 24122, 82, 570, 14, 199, 198, 509, 1004, 315, 29177, 26, 507, 198, 3, 7048, 6222, 507, 198, 692, 334, 604, 1491, 20, 61, 11800, 22479, 2, 503, 1004, 1491, 22, 61, 11800, 40, 775, 619, 45, 2349, 686, 198, 3, 18840, 1819, 2348, 686, 198, 2791, 29, 604, 14, 1294, 7303, 686, 198, 2108, 29, 2791, 1988, 17, 1055, 4142, 7303, 686, 198, 4188, 1313, 14, 740, 8, 2108, 2736, 686, 198, 3, 12892, 671, 12, 612, 12, 1315, 12, 519, 687, 299, 16596, 370, 24122, 82, 570, 686, 198, 8017, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 2789, 26, 2760, 1055, 1913, 30910, 686, 198, 88, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 1216, 26, 1703, 1055, 1913, 30910, 686, 198, 89, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 1703, 26, 2466, 1055, 1913, 30910, 686, 198, 90, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 2466, 26, 1477, 1055, 1913, 30910, 686, 198, 8568, 82, 495, 29, 88, 331, 269, 11, 89, 331, 269, 11, 90, 331, 269, 11, 8017, 25789, 78, 11436, 686, 198, 70, 8568, 82, 14, 952, 8, 8568, 82, 495, 2736, 199, 198, 70, 8568, 82, 14, 1600, 342, 8299, 198, 3, 3645, 5957, 10427, 654, 2240, 370, 3550, 13195, 436, 8671, 6222, 9150, 199, 198, 309, 2002, 1265, 1172, 370, 5324, 314, 10427, 654, 2240, 315, 314, 2011, 2082, 199, 198, 3, 7242, 282, 298, 5312, 63, 6789, 14, 2424, 2, 570, 13369, 6222, 9150, 199, 198, 3, 736, 14, 2253, 17371, 3053, 63, 29821, 63, 11043, 6681, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 7210, 495, 8, 15944, 18663, 7210, 495, 8, 3825, 18663, 7210, 495, 8, 2738, 16674, 199, 198, 80, 29, 736, 14, 12207, 17371, 3053, 63, 29821, 6681, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 7210, 495, 8, 15944, 18663, 7210, 495, 8, 3825, 18663, 7210, 495, 8, 2738, 26582, 82, 358, 199, 198, 2923, 11043, 628, 16, 2, 199, 198, 2923, 6464, 628, 16, 2, 199, 198, 6710, 413, 26, 507, 198, 604, 29, 80, 14, 6407, 7303, 507, 198, 692, 298, 6789, 5424, 315, 1004, 26, 3141, 11043, 29, 604, 14, 1294, 24050, 17, 1055, 1294, 3430, 16, 61, 507, 198, 692, 298, 2405, 5424, 315, 1004, 26, 3141, 6464, 29, 604, 14, 1294, 24050, 17, 1055, 1294, 3430, 16, 61, 507, 198, 692, 440, 1004, 26, 4785, 421, 198, 3, 14279, 806, 1072, 6222, 9150, 570, 199, 198, 667, 29, 1490, 480, 5312, 63, 6789, 14, 2424, 531, 199, 198, 11318, 391, 264, 305, 9811, 27, 3, 3529, 3354, 6222, 9150, 701, 6222, 1329, 199, 198, 466, 885, 6270, 40, 2266, 35, 2266, 46, 2266, 47, 2266, 38, 2266, 51, 2266, 48, 2266, 1981, 2266, 7184, 2266, 41, 937, 27, 199, 198, 466, 32354, 8871, 40, 582, 16, 14, 16, 4589, 35, 582, 16, 14, 16, 4589, 46, 582, 16, 14, 16, 4589, 47, 582, 16, 14, 16, 4589, 38, 582, 16, 14, 16, 4589, 51, 582, 16, 14, 16, 4589, 48, 582, 16, 14, 16, 4589, 1981, 582, 16, 14, 16, 4589, 7184, 582, 16, 14, 16, 4589, 41, 582, 16, 14, 16, 12084, 199, 198, 4188, 1507, 29, 16, 27, 199, 198, 509, 1004, 315, 1433, 26, 507, 198, 2791, 29, 604, 14, 1294, 7303, 507, 198, 11318, 391, 8273, 5961, 713, 14, 22, 70, 2, 450, 2069, 8, 2791, 59, 17, 21153, 507, 198, 11318, 391, 264, 305, 14, 740, 8, 11318, 391, 8273, 2736, 507, 198, 8588, 29, 4188, 1313, 59, 4188, 1507, 11566, 507, 198, 466, 32354, 59, 8588, 10404, 466, 32354, 14, 5486, 8, 8588, 12, 16, 14, 16, 6393, 1609, 8, 2791, 59, 17, 21153, 507, 198, 4188, 1507, 29, 4188, 1507, 11, 17, 27, 199, 198, 667, 14, 1600, 342, 8299, 198, 3, 6990, 734, 29158, 345, 570, 13369, 6222, 9150, 199, 198, 8835, 354, 29, 5252, 513, 59, 16, 2807, 2, 63, 6789, 14, 26295, 345, 2, 199, 198, 8835, 29, 1490, 8, 8835, 354, 2584, 87, 358, 8299, 198, 3, 6990, 314, 3141, 9150, 367, 1924, 1819, 14, 199, 198, 309, 3091, 3548, 626, 2348, 2951, 2218, 734, 314, 849, 4008, 14, 199, 198, 309, 982, 1265, 2934, 1006, 4008, 12, 675, 298, 466, 2972, 2, 367, 8494, 14, 199, 198, 466, 2972, 6270, 40, 2266, 35, 2266, 46, 2266, 47, 2266, 38, 2266, 51, 2266, 48, 2266, 1981, 2266, 7184, 2266, 41, 937, 27, 199, 198, 509, 284, 315, 730, 32354, 14, 16007, 837, 507 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 6529, 26, 510, 10378, 526, 77, 27, 15237, 6162, 68, 26, 6900, 13, 1643, 13, 709, 199, 199, 3, 12707, 1924, 1819, 13195, 9150, 701, 14282, 63, 29821, 436, 2597, 1336, 314, 15374, 9150, 2058, 370, 314, 299, 16596, 570, 14, 199, 3, 11028, 26, 2366, 10427, 654, 63, 2162, 11043, 14, 647, 570, 14, 80, 16596, 199, 3, 199, 3, 14012, 26, 14282, 63, 29821, 334, 5312, 1015, 9, 199, 3, 3390, 26, 5972, 367, 510, 26779, 1475, 1324, 14, 199, 3, 8388, 26, 10427, 654, 2633, 14, 199, 199, 646, 747, 12, 1274, 199, 199, 3, 22520, 314, 10427, 654, 2240, 2725, 2348, 14, 221, 199, 3, 2047, 883, 2811, 370, 1414, 1004, 1324, 2725, 465, 1265, 2839, 199, 15944, 29, 17, 14, 20, 199, 3825, 29, 16, 14, 18, 199, 2738, 29, 20, 14, 16, 199, 199, 692, 25373, 354, 363, 508, 2560, 973, 12168, 199, 198, 5252, 29, 1274, 14, 3020, 59, 17, 61, 199, 198, 5252, 513, 29, 736, 14, 515, 14, 7973, 8, 5252, 9, 199, 198, 70, 8568, 82, 29, 1490, 8, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 21891, 87, 358, 199, 198, 4391, 29, 1490, 8, 5252, 9, 199, 198, 26739, 29, 4391, 14, 9684, 7303, 199, 198, 4391, 14, 1600, 7303, 421, 198, 3, 2900, 4008, 15, 1313, 402, 1324, 14503, 12, 1202, 315, 1819, 9150, 6212, 14, 199, 198, 4188, 1313, 9811, 27, 199, 198, 3, 6990, 734, 314, 5226, 24122, 82, 570, 14, 199, 198, 509, 1004, 315, 29177, 26, 507, 198, 3, 7048, 6222, 507, 198, 692, 334, 604, 1491, 20, 61, 11800, 22479, 2, 503, 1004, 1491, 22, 61, 11800, 40, 775, 619, 45, 2349, 686, 198, 3, 18840, 1819, 2348, 686, 198, 2791, 29, 604, 14, 1294, 7303, 686, 198, 2108, 29, 2791, 1988, 17, 1055, 4142, 7303, 686, 198, 4188, 1313, 14, 740, 8, 2108, 2736, 686, 198, 3, 12892, 671, 12, 612, 12, 1315, 12, 519, 687, 299, 16596, 370, 24122, 82, 570, 686, 198, 8017, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 2789, 26, 2760, 1055, 1913, 30910, 686, 198, 88, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 1216, 26, 1703, 1055, 1913, 30910, 686, 198, 89, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 1703, 26, 2466, 1055, 1913, 30910, 686, 198, 90, 331, 269, 5961, 709, 14, 21, 70, 2, 450, 2069, 8, 604, 59, 2466, 26, 1477, 1055, 1913, 30910, 686, 198, 8568, 82, 495, 29, 88, 331, 269, 11, 89, 331, 269, 11, 90, 331, 269, 11, 8017, 25789, 78, 11436, 686, 198, 70, 8568, 82, 14, 952, 8, 8568, 82, 495, 2736, 199, 198, 70, 8568, 82, 14, 1600, 342, 8299, 198, 3, 3645, 5957, 10427, 654, 2240, 370, 3550, 13195, 436, 8671, 6222, 9150, 199, 198, 309, 2002, 1265, 1172, 370, 5324, 314, 10427, 654, 2240, 315, 314, 2011, 2082, 199, 198, 3, 7242, 282, 298, 5312, 63, 6789, 14, 2424, 2, 570, 13369, 6222, 9150, 199, 198, 3, 736, 14, 2253, 17371, 3053, 63, 29821, 63, 11043, 6681, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 7210, 495, 8, 15944, 18663, 7210, 495, 8, 3825, 18663, 7210, 495, 8, 2738, 16674, 199, 198, 80, 29, 736, 14, 12207, 17371, 3053, 63, 29821, 6681, 5252, 513, 59, 16, 2807, 1674, 8568, 82, 7210, 495, 8, 15944, 18663, 7210, 495, 8, 3825, 18663, 7210, 495, 8, 2738, 26582, 82, 358, 199, 198, 2923, 11043, 628, 16, 2, 199, 198, 2923, 6464, 628, 16, 2, 199, 198, 6710, 413, 26, 507, 198, 604, 29, 80, 14, 6407, 7303, 507, 198, 692, 298, 6789, 5424, 315, 1004, 26, 3141, 11043, 29, 604, 14, 1294, 24050, 17, 1055, 1294, 3430, 16, 61, 507, 198, 692, 298, 2405, 5424, 315, 1004, 26, 3141, 6464, 29, 604, 14, 1294, 24050, 17, 1055, 1294, 3430, 16, 61, 507, 198, 692, 440, 1004, 26, 4785, 421, 198, 3, 14279, 806, 1072, 6222, 9150, 570, 199, 198, 667, 29, 1490, 480, 5312, 63, 6789, 14, 2424, 531, 199, 198, 11318, 391, 264, 305, 9811, 27, 3, 3529, 3354, 6222, 9150, 701, 6222, 1329, 199, 198, 466, 885, 6270, 40, 2266, 35, 2266, 46, 2266, 47, 2266, 38, 2266, 51, 2266, 48, 2266, 1981, 2266, 7184, 2266, 41, 937, 27, 199, 198, 466, 32354, 8871, 40, 582, 16, 14, 16, 4589, 35, 582, 16, 14, 16, 4589, 46, 582, 16, 14, 16, 4589, 47, 582, 16, 14, 16, 4589, 38, 582, 16, 14, 16, 4589, 51, 582, 16, 14, 16, 4589, 48, 582, 16, 14, 16, 4589, 1981, 582, 16, 14, 16, 4589, 7184, 582, 16, 14, 16, 4589, 41, 582, 16, 14, 16, 12084, 199, 198, 4188, 1507, 29, 16, 27, 199, 198, 509, 1004, 315, 1433, 26, 507, 198, 2791, 29, 604, 14, 1294, 7303, 507, 198, 11318, 391, 8273, 5961, 713, 14, 22, 70, 2, 450, 2069, 8, 2791, 59, 17, 21153, 507, 198, 11318, 391, 264, 305, 14, 740, 8, 11318, 391, 8273, 2736, 507, 198, 8588, 29, 4188, 1313, 59, 4188, 1507, 11566, 507, 198, 466, 32354, 59, 8588, 10404, 466, 32354, 14, 5486, 8, 8588, 12, 16, 14, 16, 6393, 1609, 8, 2791, 59, 17, 21153, 507, 198, 4188, 1507, 29, 4188, 1507, 11, 17, 27, 199, 198, 667, 14, 1600, 342, 8299, 198, 3, 6990, 734, 29158, 345, 570, 13369, 6222, 9150, 199, 198, 8835, 354, 29, 5252, 513, 59, 16, 2807, 2, 63, 6789, 14, 26295, 345, 2, 199, 198, 8835, 29, 1490, 8, 8835, 354, 2584, 87, 358, 8299, 198, 3, 6990, 314, 3141, 9150, 367, 1924, 1819, 14, 199, 198, 309, 3091, 3548, 626, 2348, 2951, 2218, 734, 314, 849, 4008, 14, 199, 198, 309, 982, 1265, 2934, 1006, 4008, 12, 675, 298, 466, 2972, 2, 367, 8494, 14, 199, 198, 466, 2972, 6270, 40, 2266, 35, 2266, 46, 2266, 47, 2266, 38, 2266, 51, 2266, 48, 2266, 1981, 2266, 7184, 2266, 41, 937, 27, 199, 198, 509, 284, 315, 730, 32354, 14, 16007, 837, 507, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ea4gja/mrig
mrig/mrig.py
1
1349
#!/usr/bin/env python # # File: mrig.py # Version: 1.0 # # mrig: main program # Copyright (c) 2016 German EA4GJA # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. from mrig_config import * from gui_tkinter import * import sys import socket import os from Tkinter import Tk import multiprocessing tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcp.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) tcp.connect((REMOTE_SERVER, REMOTE_SERVER_TCP_PORT)) tcp.setblocking(1) udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) udp.bind(("", LOCAL_UDP_PORT)) udp.setblocking(0) root = Tk() gui = gui_Tkinter(root, tcp=tcp, udp=udp) root.mainloop() tcp.close() udp.close()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 3814, 26, 333, 322, 71, 14, 647, 199, 3, 3394, 26, 413, 14, 16, 199, 3, 199, 3, 333, 322, 71, 26, 2446, 2240, 199, 3, 1898, 334, 67, 9, 7800, 22261, 1237, 662, 33, 20, 39, 29849, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 257, 199, 3, 11315, 13, 10067, 12, 8217, 14, 421, 199, 504, 333, 322, 71, 63, 888, 492, 627, 199, 504, 11621, 63, 12223, 492, 627, 199, 646, 984, 199, 646, 2838, 199, 646, 747, 199, 504, 16826, 492, 12435, 199, 646, 12866, 421, 199, 8815, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 199, 8815, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 413, 9, 199, 8815, 14, 2242, 1332, 16058, 63, 6613, 12, 820, 2769, 9407, 63, 6613, 63, 9735, 63, 3657, 430, 199, 8815, 14, 409, 13091, 8, 17, 9, 199, 199, 15036, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 199, 15036, 14, 3409, 1332, 5151, 20639, 63, 17457, 63, 3657, 430, 199, 15036, 14, 409, 13091, 8, 16, 9, 199, 199, 1231, 275, 12435, 342, 199, 5885, 275, 11621, 63, 15189, 1058, 8, 1231, 12, 14719, 29, 8815, 12, 18419, 29, 15036, 9, 199, 1231, 14, 22644, 342, 199, 199, 8815, 14, 1600, 342, 199, 15036, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3814, 26, 333, 322, 71, 14, 647, 199, 3, 3394, 26, 413, 14, 16, 199, 3, 199, 3, 333, 322, 71, 26, 2446, 2240, 199, 3, 1898, 334, 67, 9, 7800, 22261, 1237, 662, 33, 20, 39, 29849, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 257, 199, 3, 11315, 13, 10067, 12, 8217, 14, 421, 199, 504, 333, 322, 71, 63, 888, 492, 627, 199, 504, 11621, 63, 12223, 492, 627, 199, 646, 984, 199, 646, 2838, 199, 646, 747, 199, 504, 16826, 492, 12435, 199, 646, 12866, 421, 199, 8815, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 199, 8815, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 413, 9, 199, 8815, 14, 2242, 1332, 16058, 63, 6613, 12, 820, 2769, 9407, 63, 6613, 63, 9735, 63, 3657, 430, 199, 8815, 14, 409, 13091, 8, 17, 9, 199, 199, 15036, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 199, 15036, 14, 3409, 1332, 5151, 20639, 63, 17457, 63, 3657, 430, 199, 15036, 14, 409, 13091, 8, 16, 9, 199, 199, 1231, 275, 12435, 342, 199, 5885, 275, 11621, 63, 15189, 1058, 8, 1231, 12, 14719, 29, 8815, 12, 18419, 29, 15036, 9, 199, 1231, 14, 22644, 342, 199, 199, 8815, 14, 1600, 342, 199, 15036, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
israeltobias/DownMedia
youtube-dl/youtube_dl/extractor/cracked.py
170
3213
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( parse_iso8601, str_to_int, ) class CrackedIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?cracked\.com/video_(?P<id>\d+)_[\da-z-]+\.html' _TESTS = [{ 'url': 'http://www.cracked.com/video_19070_if-animal-actors-got-e21-true-hollywood-stories.html', 'md5': '89b90b9824e3806ca95072c4d78f13f7', 'info_dict': { 'id': '19070', 'ext': 'mp4', 'title': 'If Animal Actors Got E! True Hollywood Stories', 'timestamp': 1404954000, 'upload_date': '20140710', } }, { # youtube embed 'url': 'http://www.cracked.com/video_19006_4-plot-holes-you-didnt-notice-in-your-favorite-movies.html', 'md5': 'ccd52866b50bde63a6ef3b35016ba8c7', 'info_dict': { 'id': 'EjI00A3rZD0', 'ext': 'mp4', 'title': "4 Plot Holes You Didn't Notice in Your Favorite Movies - The Spit Take", 'description': 'md5:c603708c718b796fe6079e2b3351ffc7', 'upload_date': '20140725', 'uploader_id': 'Cracked', 'uploader': 'Cracked', } }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) youtube_url = self._search_regex( r'<iframe[^>]+src="((?:https?:)?//www\.youtube\.com/embed/[^"]+)"', webpage, 'youtube url', default=None) if youtube_url: return self.url_result(youtube_url, 'Youtube') video_url = self._html_search_regex( [r'var\s+CK_vidSrc\s*=\s*"([^"]+)"', r'<video\s+src="([^"]+)"'], webpage, 'video URL') title = self._search_regex( [r'property="?og:title"?\s+content="([^"]+)"', r'class="?title"?>([^<]+)'], webpage, 'title') description = self._search_regex( r'name="?(?:og:)?description"?\s+content="([^"]+)"', webpage, 'description', default=None) timestamp = self._html_search_regex( r'"date"\s*:\s*"([^"]+)"', webpage, 'upload date', fatal=False) if timestamp: timestamp = parse_iso8601(timestamp[:-6]) view_count = str_to_int(self._html_search_regex( r'<span\s+class="?views"? id="?viewCounts"?>([\d,\.]+) Views</span>', webpage, 'view count', fatal=False)) comment_count = str_to_int(self._html_search_regex( r'<span\s+id="?commentCounts"?>([\d,\.]+)</span>', webpage, 'comment count', fatal=False)) m = re.search(r'_(?P<width>\d+)X(?P<height>\d+)\.mp4$', video_url) if m: width = int(m.group('width')) height = int(m.group('height')) else: width = height = None return { 'id': video_id, 'url': video_url, 'title': title, 'description': description, 'timestamp': timestamp, 'view_count': view_count, 'comment_count': comment_count, 'height': height, 'width': width, }
gpl-3.0
[ 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, 2198, 63, 4595, 15363, 12, 272, 620, 63, 475, 63, 442, 12, 199, 9, 421, 199, 533, 445, 8085, 379, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 67, 8085, 379, 4537, 957, 15, 3722, 63, 2229, 48, 28, 344, 3072, 68, 8771, 63, 7023, 983, 13, 90, 20253, 4537, 1360, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 8085, 379, 14, 957, 15, 3722, 63, 1167, 19235, 63, 692, 13, 290, 7265, 13, 32546, 13, 7808, 13, 69, 2025, 13, 2052, 13, 24588, 590, 22736, 13, 270, 6112, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 1407, 66, 2710, 66, 2905, 1194, 69, 19, 11901, 696, 29678, 2819, 67, 20, 68, 2277, 70, 969, 70, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1167, 19235, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 3917, 1626, 7265, 437, 13451, 24734, 662, 1, 715, 869, 393, 590, 22736, 1933, 6112, 297, 288, 283, 3954, 356, 4329, 12809, 1477, 1493, 12, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 709, 297, 267, 789, 272, 1660, 469, 267, 327, 22378, 6441, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 8085, 379, 14, 957, 15, 3722, 63, 1167, 8010, 63, 20, 13, 2798, 13, 31110, 13, 13297, 13, 14887, 343, 13, 20556, 13, 262, 13, 12695, 13, 23874, 13, 20888, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 30013, 2528, 13465, 66, 1400, 66, 271, 2766, 65, 22, 2829, 19, 66, 1276, 10882, 2470, 24, 67, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 37, 74, 41, 383, 33, 19, 82, 58, 36, 16, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 298, 20, 14794, 28673, 2978, 2047, 29503, 78, 1133, 3091, 3548, 315, 19519, 481, 12958, 1175, 3930, 14484, 446, 710, 8360, 390, 18146, 401, 288, 283, 1802, 356, 283, 1064, 21, 26, 67, 2259, 1401, 2036, 67, 26948, 66, 21655, 771, 16059, 25, 69, 18, 66, 1153, 2869, 26299, 23, 297, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 821, 297, 288, 283, 13671, 63, 344, 356, 283, 35, 8085, 379, 297, 288, 283, 13671, 356, 283, 35, 8085, 379, 297, 267, 789, 272, 14877, 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, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 22378, 63, 633, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 20052, 25524, 2164, 628, 17304, 26, 2859, 31, 26, 5547, 501, 1544, 4537, 9788, 4537, 957, 15, 6427, 15, 25153, 20415, 297, 288, 9248, 12, 283, 9788, 1166, 297, 849, 29, 403, 9, 267, 340, 22378, 63, 633, 26, 288, 372, 291, 14, 633, 63, 1099, 8, 9788, 63, 633, 12, 283, 57, 7715, 358, 398, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 359, 82, 7, 1391, 60, 83, 11, 2504, 63, 5017, 21261, 60, 83, 23440, 83, 12469, 15710, 20415, 297, 519, 7601, 3722, 60, 83, 11, 2164, 32391, 995, 288, 9248, 12, 283, 3722, 2851, 358, 398, 2538, 275, 291, 423, 1733, 63, 3821, 8, 288, 359, 82, 7, 1829, 628, 31, 974, 26, 1213, 2, 8995, 83, 11, 1317, 32391, 297, 519, 7, 533, 628, 31, 1213, 24327, 31204, 11896, 995, 288, 9248, 12, 283, 1213, 358, 398, 1369, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 354, 628, 31, 5169, 974, 26, 5547, 1802, 2, 8995, 83, 11, 1317, 32391, 297, 288, 9248, 12, 283, 1802, 297, 849, 29, 403, 9, 398, 4913, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 4065, 602, 3212, 83, 10, 3427, 83, 12469, 15710, 20415, 297, 9248, 12, 283, 5064, 1434, 297, 14294, 29, 797, 9, 267, 340, 4913, 26, 288, 4913, 275, 2198, 63, 4595, 15363, 8, 3954, 4439, 22, 566, 398, 2455, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 3751, 60, 83, 11, 533, 628, 31, 4196, 14863, 1305, 628, 31, 1345, 23209, 24327, 16510, 68, 4202, 14, 11896, 10935, 83, 1108, 3751, 4206, 288, 9248, 12, 283, 1345, 2338, 297, 14294, 29, 797, 430, 267, 3721, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 3751, 60, 83, 11, 344, 628, 31, 3349, 23209, 24327, 16510, 68, 4202, 14, 11896, 1108, 3751, 4206, 288, 9248, 12, 283, 3349, 2338, 297, 14294, 29, 797, 430, 398, 333, 275, 295, 14, 1733, 8, 82, 26142, 2229, 48, 28, 2063, 3072, 68, 8771, 56, 2229, 48, 28, 3333, 3072, 68, 13439, 14, 311, 20, 4268, 3991, 63, 633, 9, 267, 340, 333, 26, 288, 3462, 275, 1109, 8, 77, 14, 923, 360, 2063, 1333, 288, 4569, 275, 1109, 8, 77, 14, 923, 360, 3333, 1333, 267, 587, 26, 288, 3462, 275, 4569, 275, 488, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 3349, 63, 835, 356, 3721, 63, 835, 12, 288, 283, 3333, 356, 4569, 12, 288, 283, 2063, 356, 3462, 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 ]
[ 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, 2198, 63, 4595, 15363, 12, 272, 620, 63, 475, 63, 442, 12, 199, 9, 421, 199, 533, 445, 8085, 379, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 67, 8085, 379, 4537, 957, 15, 3722, 63, 2229, 48, 28, 344, 3072, 68, 8771, 63, 7023, 983, 13, 90, 20253, 4537, 1360, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 8085, 379, 14, 957, 15, 3722, 63, 1167, 19235, 63, 692, 13, 290, 7265, 13, 32546, 13, 7808, 13, 69, 2025, 13, 2052, 13, 24588, 590, 22736, 13, 270, 6112, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 1407, 66, 2710, 66, 2905, 1194, 69, 19, 11901, 696, 29678, 2819, 67, 20, 68, 2277, 70, 969, 70, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1167, 19235, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 3917, 1626, 7265, 437, 13451, 24734, 662, 1, 715, 869, 393, 590, 22736, 1933, 6112, 297, 288, 283, 3954, 356, 4329, 12809, 1477, 1493, 12, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 709, 297, 267, 789, 272, 1660, 469, 267, 327, 22378, 6441, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 8085, 379, 14, 957, 15, 3722, 63, 1167, 8010, 63, 20, 13, 2798, 13, 31110, 13, 13297, 13, 14887, 343, 13, 20556, 13, 262, 13, 12695, 13, 23874, 13, 20888, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 30013, 2528, 13465, 66, 1400, 66, 271, 2766, 65, 22, 2829, 19, 66, 1276, 10882, 2470, 24, 67, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 37, 74, 41, 383, 33, 19, 82, 58, 36, 16, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 298, 20, 14794, 28673, 2978, 2047, 29503, 78, 1133, 3091, 3548, 315, 19519, 481, 12958, 1175, 3930, 14484, 446, 710, 8360, 390, 18146, 401, 288, 283, 1802, 356, 283, 1064, 21, 26, 67, 2259, 1401, 2036, 67, 26948, 66, 21655, 771, 16059, 25, 69, 18, 66, 1153, 2869, 26299, 23, 297, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 821, 297, 288, 283, 13671, 63, 344, 356, 283, 35, 8085, 379, 297, 288, 283, 13671, 356, 283, 35, 8085, 379, 297, 267, 789, 272, 14877, 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, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 22378, 63, 633, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 20052, 25524, 2164, 628, 17304, 26, 2859, 31, 26, 5547, 501, 1544, 4537, 9788, 4537, 957, 15, 6427, 15, 25153, 20415, 297, 288, 9248, 12, 283, 9788, 1166, 297, 849, 29, 403, 9, 267, 340, 22378, 63, 633, 26, 288, 372, 291, 14, 633, 63, 1099, 8, 9788, 63, 633, 12, 283, 57, 7715, 358, 398, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 359, 82, 7, 1391, 60, 83, 11, 2504, 63, 5017, 21261, 60, 83, 23440, 83, 12469, 15710, 20415, 297, 519, 7601, 3722, 60, 83, 11, 2164, 32391, 995, 288, 9248, 12, 283, 3722, 2851, 358, 398, 2538, 275, 291, 423, 1733, 63, 3821, 8, 288, 359, 82, 7, 1829, 628, 31, 974, 26, 1213, 2, 8995, 83, 11, 1317, 32391, 297, 519, 7, 533, 628, 31, 1213, 24327, 31204, 11896, 995, 288, 9248, 12, 283, 1213, 358, 398, 1369, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 354, 628, 31, 5169, 974, 26, 5547, 1802, 2, 8995, 83, 11, 1317, 32391, 297, 288, 9248, 12, 283, 1802, 297, 849, 29, 403, 9, 398, 4913, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 4065, 602, 3212, 83, 10, 3427, 83, 12469, 15710, 20415, 297, 9248, 12, 283, 5064, 1434, 297, 14294, 29, 797, 9, 267, 340, 4913, 26, 288, 4913, 275, 2198, 63, 4595, 15363, 8, 3954, 4439, 22, 566, 398, 2455, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 3751, 60, 83, 11, 533, 628, 31, 4196, 14863, 1305, 628, 31, 1345, 23209, 24327, 16510, 68, 4202, 14, 11896, 10935, 83, 1108, 3751, 4206, 288, 9248, 12, 283, 1345, 2338, 297, 14294, 29, 797, 430, 267, 3721, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 3751, 60, 83, 11, 344, 628, 31, 3349, 23209, 24327, 16510, 68, 4202, 14, 11896, 1108, 3751, 4206, 288, 9248, 12, 283, 3349, 2338, 297, 14294, 29, 797, 430, 398, 333, 275, 295, 14, 1733, 8, 82, 26142, 2229, 48, 28, 2063, 3072, 68, 8771, 56, 2229, 48, 28, 3333, 3072, 68, 13439, 14, 311, 20, 4268, 3991, 63, 633, 9, 267, 340, 333, 26, 288, 3462, 275, 1109, 8, 77, 14, 923, 360, 2063, 1333, 288, 4569, 275, 1109, 8, 77, 14, 923, 360, 3333, 1333, 267, 587, 26, 288, 3462, 275, 4569, 275, 488, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 3349, 63, 835, 356, 3721, 63, 835, 12, 288, 283, 3333, 356, 4569, 12, 288, 283, 2063, 356, 3462, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
paulashford1975/clearfog-388-kernel-4.5.4
tools/perf/scripts/python/failed-syscalls-by-pid.py
1996
2233
# failed 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 failed system call totals, broken down by pid. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os import 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 * usage = "perf script -s syscall-counts-by-pid.py [comm|pid]\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_error_totals() def raw_syscalls__sys_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, common_callchain, id, ret): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return if ret < 0: try: syscalls[common_comm][common_pid][id][ret] += 1 except TypeError: syscalls[common_comm][common_pid][id][ret] = 1 def syscalls__sys_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, ret): raw_syscalls__sys_exit(**locals()) def print_error_totals(): if for_comm is not None: print "\nsyscall errors for %s:\n\n" % (for_comm), else: print "\nsyscall errors:\n\n", print "%-30s %10s\n" % ("comm [pid]", "count"), print "%-30s %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 in id_keys: print " syscall: %-16s\n" % syscall_name(id), ret_keys = syscalls[comm][pid][id].keys() for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): print " err = %-20s %10d\n" % (strerror(ret), val),
gpl-2.0
[ 3, 3405, 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, 3405, 2656, 1240, 23576, 12, 10529, 3224, 701, 4422, 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, 199, 646, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 92, 3150, 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, 705, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 2224, 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, 2330, 63, 1250, 4429, 12, 1305, 12, 2203, 304, 199, 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, 421, 198, 692, 2203, 665, 378, 26, 507, 198, 893, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 847, 413, 507, 198, 2590, 3146, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 275, 413, 199, 199, 318, 19473, 363, 1274, 63, 2224, 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, 2203, 304, 199, 198, 1773, 63, 14507, 363, 1274, 63, 2224, 3682, 9350, 1012, 199, 199, 318, 870, 63, 705, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 2552, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 2552, 3427, 78, 60, 78, 401, 339, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 11472, 298, 835, 1288, 272, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 777, 10965, 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, 315, 1305, 63, 1612, 26, 24449, 870, 298, 221, 18901, 26, 19752, 975, 83, 60, 78, 2, 450, 18901, 63, 354, 8, 344, 395, 24449, 2203, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1527, 344, 1055, 1612, 342, 24449, 367, 2203, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1527, 344, 1055, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 1871, 259, 870, 298, 259, 2329, 275, 19752, 1165, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 20395, 8, 3292, 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 ]
[ 3405, 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, 3405, 2656, 1240, 23576, 12, 10529, 3224, 701, 4422, 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, 199, 646, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 92, 3150, 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, 705, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 2224, 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, 2330, 63, 1250, 4429, 12, 1305, 12, 2203, 304, 199, 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, 421, 198, 692, 2203, 665, 378, 26, 507, 198, 893, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 847, 413, 507, 198, 2590, 3146, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 275, 413, 199, 199, 318, 19473, 363, 1274, 63, 2224, 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, 2203, 304, 199, 198, 1773, 63, 14507, 363, 1274, 63, 2224, 3682, 9350, 1012, 199, 199, 318, 870, 63, 705, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 2552, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 2552, 3427, 78, 60, 78, 401, 339, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 11472, 298, 835, 1288, 272, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 777, 10965, 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, 315, 1305, 63, 1612, 26, 24449, 870, 298, 221, 18901, 26, 19752, 975, 83, 60, 78, 2, 450, 18901, 63, 354, 8, 344, 395, 24449, 2203, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1527, 344, 1055, 1612, 342, 24449, 367, 2203, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1527, 344, 1055, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 1871, 259, 870, 298, 259, 2329, 275, 19752, 1165, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 20395, 8, 3292, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
syl20bnr/nupic
tests/integration/py2/nupic/opf/opf_description_template_test/experiments/gym/description.py
17
1447
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2014, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- """This file defines parameters for a prediction experiment.""" import os from nupic.frameworks.opf.expdescriptionhelpers import importBaseDescription # the sub-experiment configuration config = \ { 'modelParams': { 'clParams': { }, 'sensorParams': { 'encoders': { }}, 'spParams': { }, 'tpParams': { 'activationThreshold': 12}}} mod = importBaseDescription('./base.py', config) locals().update(mod.__dict__)
gpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6927, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 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, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 624, 2765, 570, 7890, 2633, 367, 282, 12044, 11805, 1041, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 283, 1238, 6007, 356, 469, 283, 429, 6007, 356, 469, 1660, 673, 283, 8956, 6007, 356, 469, 283, 9347, 83, 356, 469, 789, 1386, 673, 283, 681, 6007, 356, 469, 1660, 673, 283, 683, 6007, 356, 469, 283, 12312, 12109, 356, 3144, 4863, 93, 199, 199, 1494, 275, 492, 1563, 5831, 17371, 1095, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6927, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 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, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 624, 2765, 570, 7890, 2633, 367, 282, 12044, 11805, 1041, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 283, 1238, 6007, 356, 469, 283, 429, 6007, 356, 469, 1660, 673, 283, 8956, 6007, 356, 469, 283, 9347, 83, 356, 469, 789, 1386, 673, 283, 681, 6007, 356, 469, 1660, 673, 283, 683, 6007, 356, 469, 283, 12312, 12109, 356, 3144, 4863, 93, 199, 199, 1494, 275, 492, 1563, 5831, 17371, 1095, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dongritengfei/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/watchlist/watchlist.py
132
3393
# 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. from webkitpy.common.checkout.diff_parser import DiffParser class WatchList(object): def __init__(self): self.definitions = {} self.cc_rules = set() self.message_rules = set() def find_matching_definitions(self, diff): matching_definitions = set() patch_files = DiffParser(diff.splitlines()).files for path, diff_file in patch_files.iteritems(): for definition in self.definitions: # If a definition has already matched, there is no need to process it. if definition in matching_definitions: continue # See if the definition matches within one file. for pattern in self.definitions[definition]: if not pattern.match(path, diff_file.lines): break else: matching_definitions.add(definition) return matching_definitions def _determine_instructions(self, matching_definitions, rules): instructions = set() for rule in rules: if rule.match(matching_definitions): instructions.update(rule.instructions()) # Sort the results to make the order deterministic (for consistency and easier testing). return sorted(instructions) def determine_cc_list(self, matching_definitions): return self._determine_instructions(matching_definitions, self.cc_rules) def determine_messages(self, matching_definitions): return self._determine_instructions(matching_definitions, self.message_rules) def determine_cc_and_messages(self, diff): definitions = self.find_matching_definitions(diff) return { 'cc_list': self.determine_cc_list(definitions), 'messages': self.determine_messages(definitions), }
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, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 18007, 14, 2330, 14, 12891, 14, 3028, 63, 2087, 492, 27134, 2842, 421, 199, 533, 29075, 1296, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 15388, 275, 1052, 267, 291, 14, 2055, 63, 4423, 275, 663, 342, 267, 291, 14, 1188, 63, 4423, 275, 663, 342, 339, 347, 2342, 63, 9467, 63, 15388, 8, 277, 12, 3915, 304, 267, 4877, 63, 15388, 275, 663, 342, 267, 3371, 63, 1725, 275, 27134, 2842, 8, 3028, 14, 7644, 8801, 1725, 398, 367, 931, 12, 3915, 63, 493, 315, 3371, 63, 1725, 14, 4611, 837, 288, 367, 5492, 315, 291, 14, 15388, 26, 355, 327, 982, 282, 5492, 965, 2575, 7838, 12, 2337, 365, 949, 1929, 370, 2112, 652, 14, 355, 340, 5492, 315, 4877, 63, 15388, 26, 490, 1980, 2234, 327, 1666, 340, 314, 5492, 4450, 4453, 1373, 570, 14, 355, 367, 3851, 315, 291, 14, 15388, 59, 7463, 2189, 490, 340, 440, 3851, 14, 1431, 8, 515, 12, 3915, 63, 493, 14, 1278, 304, 717, 2059, 355, 587, 26, 490, 4877, 63, 15388, 14, 525, 8, 7463, 9, 267, 372, 4877, 63, 15388, 339, 347, 485, 22189, 63, 20718, 8, 277, 12, 4877, 63, 15388, 12, 4713, 304, 267, 15794, 275, 663, 342, 267, 367, 2332, 315, 4713, 26, 288, 340, 2332, 14, 1431, 8, 9467, 63, 15388, 304, 355, 15794, 14, 873, 8, 2200, 14, 20718, 1012, 267, 327, 16722, 314, 2058, 370, 1852, 314, 1865, 25286, 334, 509, 17754, 436, 14905, 5343, 680, 267, 372, 3355, 8, 20718, 9, 339, 347, 6705, 63, 2055, 63, 513, 8, 277, 12, 4877, 63, 15388, 304, 267, 372, 291, 423, 22189, 63, 20718, 8, 9467, 63, 15388, 12, 291, 14, 2055, 63, 4423, 9, 339, 347, 6705, 63, 3431, 8, 277, 12, 4877, 63, 15388, 304, 267, 372, 291, 423, 22189, 63, 20718, 8, 9467, 63, 15388, 12, 291, 14, 1188, 63, 4423, 9, 339, 347, 6705, 63, 2055, 63, 460, 63, 3431, 8, 277, 12, 3915, 304, 267, 10269, 275, 291, 14, 1623, 63, 9467, 63, 15388, 8, 3028, 9, 267, 372, 469, 288, 283, 2055, 63, 513, 356, 291, 14, 22189, 63, 2055, 63, 513, 8, 15388, 395, 288, 283, 3431, 356, 221, 291, 14, 22189, 63, 3431, 8, 15388, 395, 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 ]
[ 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, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 18007, 14, 2330, 14, 12891, 14, 3028, 63, 2087, 492, 27134, 2842, 421, 199, 533, 29075, 1296, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 15388, 275, 1052, 267, 291, 14, 2055, 63, 4423, 275, 663, 342, 267, 291, 14, 1188, 63, 4423, 275, 663, 342, 339, 347, 2342, 63, 9467, 63, 15388, 8, 277, 12, 3915, 304, 267, 4877, 63, 15388, 275, 663, 342, 267, 3371, 63, 1725, 275, 27134, 2842, 8, 3028, 14, 7644, 8801, 1725, 398, 367, 931, 12, 3915, 63, 493, 315, 3371, 63, 1725, 14, 4611, 837, 288, 367, 5492, 315, 291, 14, 15388, 26, 355, 327, 982, 282, 5492, 965, 2575, 7838, 12, 2337, 365, 949, 1929, 370, 2112, 652, 14, 355, 340, 5492, 315, 4877, 63, 15388, 26, 490, 1980, 2234, 327, 1666, 340, 314, 5492, 4450, 4453, 1373, 570, 14, 355, 367, 3851, 315, 291, 14, 15388, 59, 7463, 2189, 490, 340, 440, 3851, 14, 1431, 8, 515, 12, 3915, 63, 493, 14, 1278, 304, 717, 2059, 355, 587, 26, 490, 4877, 63, 15388, 14, 525, 8, 7463, 9, 267, 372, 4877, 63, 15388, 339, 347, 485, 22189, 63, 20718, 8, 277, 12, 4877, 63, 15388, 12, 4713, 304, 267, 15794, 275, 663, 342, 267, 367, 2332, 315, 4713, 26, 288, 340, 2332, 14, 1431, 8, 9467, 63, 15388, 304, 355, 15794, 14, 873, 8, 2200, 14, 20718, 1012, 267, 327, 16722, 314, 2058, 370, 1852, 314, 1865, 25286, 334, 509, 17754, 436, 14905, 5343, 680, 267, 372, 3355, 8, 20718, 9, 339, 347, 6705, 63, 2055, 63, 513, 8, 277, 12, 4877, 63, 15388, 304, 267, 372, 291, 423, 22189, 63, 20718, 8, 9467, 63, 15388, 12, 291, 14, 2055, 63, 4423, 9, 339, 347, 6705, 63, 3431, 8, 277, 12, 4877, 63, 15388, 304, 267, 372, 291, 423, 22189, 63, 20718, 8, 9467, 63, 15388, 12, 291, 14, 1188, 63, 4423, 9, 339, 347, 6705, 63, 2055, 63, 460, 63, 3431, 8, 277, 12, 3915, 304, 267, 10269, 275, 291, 14, 1623, 63, 9467, 63, 15388, 8, 3028, 9, 267, 372, 469, 288, 283, 2055, 63, 513, 356, 291, 14, 22189, 63, 2055, 63, 513, 8, 15388, 395, 288, 283, 3431, 356, 221, 291, 14, 22189, 63, 3431, 8, 15388, 395, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mattt416/neutron
neutron/tests/functional/agent/l3/test_keepalived_state_change.py
24
2853
# Copyright (c) 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os import mock from oslo_config import cfg from oslo_utils import uuidutils from neutron.agent.l3 import keepalived_state_change from neutron.tests.functional import base class TestKeepalivedStateChange(base.BaseSudoTestCase): def setUp(self): super(TestKeepalivedStateChange, self).setUp() cfg.CONF.register_opt( cfg.StrOpt('metadata_proxy_socket', default='$state_path/metadata_proxy', help=_('Location of Metadata Proxy UNIX domain ' 'socket'))) self.router_id = uuidutils.generate_uuid() self.conf_dir = self.get_default_temp_dir().path self.cidr = '169.254.128.1/24' self.interface_name = 'interface' self.monitor = keepalived_state_change.MonitorDaemon( self.get_temp_file_path('monitor.pid'), self.router_id, 1, 2, 'namespace', self.conf_dir, self.interface_name, self.cidr) mock.patch.object(self.monitor, 'notify_agent').start() self.line = '1: %s inet %s' % (self.interface_name, self.cidr) def test_parse_and_handle_event_wrong_device_completes_without_error(self): self.monitor.parse_and_handle_event( '1: wrong_device inet wrong_cidr') def _get_state(self): with open(os.path.join(self.monitor.conf_dir, 'state')) as state_file: return state_file.read() def test_parse_and_handle_event_writes_to_file(self): self.monitor.parse_and_handle_event('Deleted %s' % self.line) self.assertEqual('backup', self._get_state()) self.monitor.parse_and_handle_event(self.line) self.assertEqual('master', self._get_state()) def test_parse_and_handle_event_fails_writing_state(self): with mock.patch.object( self.monitor, 'write_state_change', side_effect=OSError): self.monitor.parse_and_handle_event(self.line) def test_parse_and_handle_event_fails_notifying_agent(self): with mock.patch.object( self.monitor, 'notify_agent', side_effect=Exception): self.monitor.parse_and_handle_event(self.line)
apache-2.0
[ 3, 1898, 334, 67, 9, 6900, 9572, 13002, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 4054, 14, 76, 19, 492, 4215, 279, 12905, 63, 929, 63, 1461, 199, 504, 8224, 14, 2219, 14, 15481, 492, 1300, 421, 199, 533, 1379, 18567, 279, 12905, 2223, 4001, 8, 1095, 14, 1563, 51, 5916, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 18567, 279, 12905, 2223, 4001, 12, 291, 680, 5996, 342, 267, 4810, 14, 3103, 14, 2683, 63, 2992, 8, 288, 4810, 14, 19340, 360, 2343, 63, 3280, 63, 3450, 297, 2432, 849, 24269, 929, 63, 515, 15, 2343, 63, 3280, 297, 2432, 1720, 12397, 6592, 402, 16160, 12373, 22242, 2881, 283, 2892, 283, 3450, 7058, 398, 291, 14, 4995, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 267, 291, 14, 2190, 63, 694, 275, 291, 14, 362, 63, 885, 63, 808, 63, 694, 1252, 515, 267, 291, 14, 10509, 275, 283, 10143, 14, 8306, 14, 3933, 14, 17, 15, 1194, 7, 267, 291, 14, 3266, 63, 354, 275, 283, 3266, 7, 267, 291, 14, 7157, 275, 4215, 279, 12905, 63, 929, 63, 1461, 14, 13189, 20555, 8, 288, 291, 14, 362, 63, 808, 63, 493, 63, 515, 360, 7157, 14, 3150, 659, 288, 291, 14, 4995, 63, 344, 12, 288, 413, 12, 288, 499, 12, 288, 283, 3251, 297, 288, 291, 14, 2190, 63, 694, 12, 288, 291, 14, 3266, 63, 354, 12, 288, 291, 14, 10509, 9, 267, 1683, 14, 2068, 14, 785, 8, 277, 14, 7157, 12, 283, 6814, 63, 4054, 1959, 928, 342, 267, 291, 14, 604, 275, 283, 17, 26, 450, 83, 259, 17260, 450, 83, 7, 450, 334, 277, 14, 3266, 63, 354, 12, 291, 14, 10509, 9, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 10603, 63, 1782, 63, 2731, 744, 63, 7395, 63, 705, 8, 277, 304, 267, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 288, 283, 17, 26, 6835, 63, 1782, 259, 17260, 6835, 63, 10509, 358, 339, 347, 485, 362, 63, 929, 8, 277, 304, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 7157, 14, 2190, 63, 694, 12, 283, 929, 1333, 465, 1174, 63, 493, 26, 288, 372, 1174, 63, 493, 14, 739, 342, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 16334, 63, 475, 63, 493, 8, 277, 304, 267, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 360, 17735, 450, 83, 7, 450, 291, 14, 604, 9, 267, 291, 14, 629, 360, 5751, 297, 291, 423, 362, 63, 929, 1012, 398, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 9, 267, 291, 14, 629, 360, 4133, 297, 291, 423, 362, 63, 929, 1012, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 15762, 63, 14827, 63, 929, 8, 277, 304, 267, 543, 1683, 14, 2068, 14, 785, 8, 355, 291, 14, 7157, 12, 283, 952, 63, 929, 63, 1461, 297, 5366, 63, 5881, 29, 16719, 304, 288, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 9, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 15762, 63, 6814, 316, 63, 4054, 8, 277, 304, 267, 543, 1683, 14, 2068, 14, 785, 8, 355, 291, 14, 7157, 12, 283, 6814, 63, 4054, 297, 5366, 63, 5881, 29, 1726, 304, 288, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 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 ]
[ 1898, 334, 67, 9, 6900, 9572, 13002, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 4054, 14, 76, 19, 492, 4215, 279, 12905, 63, 929, 63, 1461, 199, 504, 8224, 14, 2219, 14, 15481, 492, 1300, 421, 199, 533, 1379, 18567, 279, 12905, 2223, 4001, 8, 1095, 14, 1563, 51, 5916, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 18567, 279, 12905, 2223, 4001, 12, 291, 680, 5996, 342, 267, 4810, 14, 3103, 14, 2683, 63, 2992, 8, 288, 4810, 14, 19340, 360, 2343, 63, 3280, 63, 3450, 297, 2432, 849, 24269, 929, 63, 515, 15, 2343, 63, 3280, 297, 2432, 1720, 12397, 6592, 402, 16160, 12373, 22242, 2881, 283, 2892, 283, 3450, 7058, 398, 291, 14, 4995, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 267, 291, 14, 2190, 63, 694, 275, 291, 14, 362, 63, 885, 63, 808, 63, 694, 1252, 515, 267, 291, 14, 10509, 275, 283, 10143, 14, 8306, 14, 3933, 14, 17, 15, 1194, 7, 267, 291, 14, 3266, 63, 354, 275, 283, 3266, 7, 267, 291, 14, 7157, 275, 4215, 279, 12905, 63, 929, 63, 1461, 14, 13189, 20555, 8, 288, 291, 14, 362, 63, 808, 63, 493, 63, 515, 360, 7157, 14, 3150, 659, 288, 291, 14, 4995, 63, 344, 12, 288, 413, 12, 288, 499, 12, 288, 283, 3251, 297, 288, 291, 14, 2190, 63, 694, 12, 288, 291, 14, 3266, 63, 354, 12, 288, 291, 14, 10509, 9, 267, 1683, 14, 2068, 14, 785, 8, 277, 14, 7157, 12, 283, 6814, 63, 4054, 1959, 928, 342, 267, 291, 14, 604, 275, 283, 17, 26, 450, 83, 259, 17260, 450, 83, 7, 450, 334, 277, 14, 3266, 63, 354, 12, 291, 14, 10509, 9, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 10603, 63, 1782, 63, 2731, 744, 63, 7395, 63, 705, 8, 277, 304, 267, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 288, 283, 17, 26, 6835, 63, 1782, 259, 17260, 6835, 63, 10509, 358, 339, 347, 485, 362, 63, 929, 8, 277, 304, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 7157, 14, 2190, 63, 694, 12, 283, 929, 1333, 465, 1174, 63, 493, 26, 288, 372, 1174, 63, 493, 14, 739, 342, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 16334, 63, 475, 63, 493, 8, 277, 304, 267, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 360, 17735, 450, 83, 7, 450, 291, 14, 604, 9, 267, 291, 14, 629, 360, 5751, 297, 291, 423, 362, 63, 929, 1012, 398, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 9, 267, 291, 14, 629, 360, 4133, 297, 291, 423, 362, 63, 929, 1012, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 15762, 63, 14827, 63, 929, 8, 277, 304, 267, 543, 1683, 14, 2068, 14, 785, 8, 355, 291, 14, 7157, 12, 283, 952, 63, 929, 63, 1461, 297, 5366, 63, 5881, 29, 16719, 304, 288, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 9, 339, 347, 511, 63, 1122, 63, 460, 63, 2479, 63, 1430, 63, 15762, 63, 6814, 316, 63, 4054, 8, 277, 304, 267, 543, 1683, 14, 2068, 14, 785, 8, 355, 291, 14, 7157, 12, 283, 6814, 63, 4054, 297, 5366, 63, 5881, 29, 1726, 304, 288, 291, 14, 7157, 14, 1122, 63, 460, 63, 2479, 63, 1430, 8, 277, 14, 604, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
openfun/configuration
playbooks/callback_plugins/sqs.py
41
5868
# Copyright 2013 John Jarvis <john@jarv.org> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import os import sys import time import json import socket try: import boto except ImportError: boto = None else: import boto.sqs from boto.exception import NoAuthHandlerFound class CallbackModule(object): """ This Ansible callback plugin sends task events to SQS. The following vars must be set in the environment: ANSIBLE_ENABLE_SQS - enables the callback module SQS_REGION - AWS region to connect to SQS_MSG_PREFIX - Additional data that will be put on the queue (optional) The following events are put on the queue - FAILURE events - OK events - TASK events - START events """ def __init__(self): self.enable_sqs = 'ANSIBLE_ENABLE_SQS' in os.environ if not self.enable_sqs: return # make sure we got our imports if not boto: raise ImportError( "The sqs callback module requires the boto Python module, " "which is not installed or was not found." ) self.start_time = time.time() if not 'SQS_REGION' in os.environ: print 'ANSIBLE_ENABLE_SQS enabled but SQS_REGION ' \ 'not defined in environment' sys.exit(1) self.region = os.environ['SQS_REGION'] try: self.sqs = boto.sqs.connect_to_region(self.region) except NoAuthHandlerFound: print 'ANSIBLE_ENABLE_SQS enabled but cannot connect ' \ 'to AWS due invalid credentials' sys.exit(1) if not 'SQS_NAME' in os.environ: print 'ANSIBLE_ENABLE_SQS enabled but SQS_NAME not ' \ 'defined in environment' sys.exit(1) self.name = os.environ['SQS_NAME'] self.queue = self.sqs.create_queue(self.name) if 'SQS_MSG_PREFIX' in os.environ: self.prefix = os.environ['SQS_MSG_PREFIX'] else: self.prefix = '' self.last_seen_ts = {} def runner_on_failed(self, host, res, ignore_errors=False): if self.enable_sqs: if not ignore_errors: self._send_queue_message(res, 'FAILURE') def runner_on_ok(self, host, res): if self.enable_sqs: # don't send the setup results if res['invocation']['module_name'] != "setup": self._send_queue_message(res, 'OK') def playbook_on_task_start(self, name, is_conditional): if self.enable_sqs: self._send_queue_message(name, 'TASK') def playbook_on_play_start(self, pattern): if self.enable_sqs: self._send_queue_message(pattern, 'START') def playbook_on_stats(self, stats): if self.enable_sqs: d = {} delta = time.time() - self.start_time d['delta'] = delta for s in ['changed', 'failures', 'ok', 'processed', 'skipped']: d[s] = getattr(stats, s) self._send_queue_message(d, 'STATS') def _send_queue_message(self, msg, msg_type): if self.enable_sqs: from_start = time.time() - self.start_time payload = {msg_type: msg} payload['TS'] = from_start payload['PREFIX'] = self.prefix # update the last seen timestamp for # the message type self.last_seen_ts[msg_type] = time.time() if msg_type in ['OK', 'FAILURE']: # report the delta between the OK/FAILURE and # last TASK if 'TASK' in self.last_seen_ts: from_task = \ self.last_seen_ts[msg_type] - self.last_seen_ts['TASK'] payload['delta'] = from_task for output in ['stderr', 'stdout']: if output in payload[msg_type]: # only keep the last 1000 characters # of stderr and stdout # Some modules set the value of stdout or stderr to booleans in # which case the len will fail. Check to see if there is content # before trying to clip it. if payload[msg_type][output] and len(payload[msg_type][output]) > 1000: payload[msg_type][output] = "(clipping) ... " \ + payload[msg_type][output][-1000:] if 'stdout_lines' in payload[msg_type]: # only keep the last 20 or so lines to avoid payload size errors if len(payload[msg_type]['stdout_lines']) > 20: payload[msg_type]['stdout_lines'] = ['(clipping) ... '] + payload[msg_type]['stdout_lines'][-20:] while True: try: self.sqs.send_message(self.queue, json.dumps(payload)) break except socket.gaierror as e: print 'socket.gaierror will retry: ' + e time.sleep(1) except Exception as e: raise e
agpl-3.0
[ 3, 1898, 6171, 17815, 1603, 285, 5068, 665, 20216, 32, 7338, 86, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 2022, 199, 646, 2838, 199, 893, 26, 272, 492, 6055, 199, 2590, 3545, 26, 272, 6055, 275, 488, 199, 2836, 26, 272, 492, 6055, 14, 31603, 272, 687, 6055, 14, 1971, 492, 3091, 21547, 3601, 421, 199, 533, 17555, 2377, 8, 785, 304, 272, 408, 272, 961, 2622, 3233, 3589, 16178, 2120, 4474, 272, 370, 428, 23298, 14, 339, 710, 2569, 6802, 1471, 506, 663, 315, 314, 3734, 26, 267, 32271, 7187, 63, 8898, 63, 18445, 51, 446, 22741, 314, 3233, 859, 267, 428, 23298, 63, 23030, 446, 10168, 4897, 370, 4907, 370, 267, 428, 23298, 63, 9740, 63, 6351, 446, 10961, 666, 626, 911, 506, 5324, 586, 641, 314, 4126, 334, 4144, 9, 339, 710, 2569, 4474, 787, 5324, 641, 314, 4126, 267, 446, 10341, 3942, 4474, 267, 446, 9949, 4474, 267, 446, 377, 7946, 4474, 267, 446, 13910, 4474, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 4296, 63, 31603, 275, 283, 8490, 63, 8898, 63, 18445, 51, 7, 315, 747, 14, 2314, 267, 340, 440, 291, 14, 4296, 63, 31603, 26, 288, 372, 398, 327, 1852, 3238, 781, 4788, 4154, 8925, 267, 340, 440, 6055, 26, 288, 746, 3545, 8, 355, 298, 1918, 5295, 83, 3233, 859, 5074, 314, 6055, 2018, 859, 12, 298, 355, 298, 6777, 365, 440, 4903, 503, 1990, 440, 1911, 2122, 288, 776, 398, 291, 14, 928, 63, 521, 275, 900, 14, 521, 342, 398, 340, 440, 283, 18445, 51, 63, 23030, 7, 315, 747, 14, 2314, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 428, 23298, 63, 23030, 283, 971, 2116, 283, 1397, 3247, 315, 3734, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 291, 14, 4551, 275, 747, 14, 2314, 459, 18445, 51, 63, 23030, 418, 267, 862, 26, 288, 291, 14, 31603, 275, 6055, 14, 31603, 14, 2242, 63, 475, 63, 4551, 8, 277, 14, 4551, 9, 267, 871, 3091, 21547, 3601, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 3913, 4907, 283, 971, 2116, 283, 475, 10168, 7037, 3866, 6235, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 340, 440, 283, 18445, 51, 63, 2339, 7, 315, 747, 14, 2314, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 428, 23298, 63, 2339, 440, 283, 971, 2116, 283, 4037, 315, 3734, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 291, 14, 354, 275, 747, 14, 2314, 459, 18445, 51, 63, 2339, 418, 267, 291, 14, 1825, 275, 291, 14, 31603, 14, 981, 63, 1825, 8, 277, 14, 354, 9, 267, 340, 283, 18445, 51, 63, 9740, 63, 6351, 7, 315, 747, 14, 2314, 26, 288, 291, 14, 1861, 275, 747, 14, 2314, 459, 18445, 51, 63, 9740, 63, 6351, 418, 267, 587, 26, 288, 291, 14, 1861, 275, 2125, 398, 291, 14, 2019, 63, 8606, 63, 1086, 275, 1052, 339, 347, 7876, 63, 265, 63, 4892, 8, 277, 12, 1591, 12, 522, 12, 3686, 63, 2550, 29, 797, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 340, 440, 3686, 63, 2550, 26, 355, 291, 423, 2254, 63, 1825, 63, 1188, 8, 470, 12, 283, 13989, 358, 339, 347, 7876, 63, 265, 63, 745, 8, 277, 12, 1591, 12, 522, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 327, 2793, 1133, 3222, 314, 3272, 2058, 288, 340, 522, 459, 30158, 2545, 578, 63, 354, 418, 1137, 298, 2758, 582, 355, 291, 423, 2254, 63, 1825, 63, 1188, 8, 470, 12, 283, 3593, 358, 339, 347, 15695, 63, 265, 63, 1765, 63, 928, 8, 277, 12, 536, 12, 365, 63, 14353, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 354, 12, 283, 17179, 358, 339, 347, 15695, 63, 265, 63, 2802, 63, 928, 8, 277, 12, 3851, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 3401, 12, 283, 7363, 358, 339, 347, 15695, 63, 265, 63, 3200, 8, 277, 12, 5020, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 366, 275, 1052, 288, 5762, 275, 900, 14, 521, 342, 446, 291, 14, 928, 63, 521, 288, 366, 459, 3136, 418, 275, 5762, 288, 367, 308, 315, 788, 2489, 297, 283, 9968, 297, 283, 745, 297, 283, 7292, 297, 283, 11962, 2565, 355, 366, 59, 83, 61, 275, 2519, 8, 3200, 12, 308, 9, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 68, 12, 283, 19202, 358, 339, 347, 485, 2254, 63, 1825, 63, 1188, 8, 277, 12, 1499, 12, 1499, 63, 466, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 687, 63, 928, 275, 900, 14, 521, 342, 446, 291, 14, 928, 63, 521, 288, 4886, 275, 469, 1328, 63, 466, 26, 1499, 93, 288, 4886, 459, 9730, 418, 275, 687, 63, 928, 288, 4886, 459, 6351, 418, 275, 291, 14, 1861, 288, 327, 1678, 314, 2061, 6775, 4913, 367, 288, 327, 314, 1245, 730, 288, 291, 14, 2019, 63, 8606, 63, 1086 ]
[ 1898, 6171, 17815, 1603, 285, 5068, 665, 20216, 32, 7338, 86, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 2022, 199, 646, 2838, 199, 893, 26, 272, 492, 6055, 199, 2590, 3545, 26, 272, 6055, 275, 488, 199, 2836, 26, 272, 492, 6055, 14, 31603, 272, 687, 6055, 14, 1971, 492, 3091, 21547, 3601, 421, 199, 533, 17555, 2377, 8, 785, 304, 272, 408, 272, 961, 2622, 3233, 3589, 16178, 2120, 4474, 272, 370, 428, 23298, 14, 339, 710, 2569, 6802, 1471, 506, 663, 315, 314, 3734, 26, 267, 32271, 7187, 63, 8898, 63, 18445, 51, 446, 22741, 314, 3233, 859, 267, 428, 23298, 63, 23030, 446, 10168, 4897, 370, 4907, 370, 267, 428, 23298, 63, 9740, 63, 6351, 446, 10961, 666, 626, 911, 506, 5324, 586, 641, 314, 4126, 334, 4144, 9, 339, 710, 2569, 4474, 787, 5324, 641, 314, 4126, 267, 446, 10341, 3942, 4474, 267, 446, 9949, 4474, 267, 446, 377, 7946, 4474, 267, 446, 13910, 4474, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 4296, 63, 31603, 275, 283, 8490, 63, 8898, 63, 18445, 51, 7, 315, 747, 14, 2314, 267, 340, 440, 291, 14, 4296, 63, 31603, 26, 288, 372, 398, 327, 1852, 3238, 781, 4788, 4154, 8925, 267, 340, 440, 6055, 26, 288, 746, 3545, 8, 355, 298, 1918, 5295, 83, 3233, 859, 5074, 314, 6055, 2018, 859, 12, 298, 355, 298, 6777, 365, 440, 4903, 503, 1990, 440, 1911, 2122, 288, 776, 398, 291, 14, 928, 63, 521, 275, 900, 14, 521, 342, 398, 340, 440, 283, 18445, 51, 63, 23030, 7, 315, 747, 14, 2314, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 428, 23298, 63, 23030, 283, 971, 2116, 283, 1397, 3247, 315, 3734, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 291, 14, 4551, 275, 747, 14, 2314, 459, 18445, 51, 63, 23030, 418, 267, 862, 26, 288, 291, 14, 31603, 275, 6055, 14, 31603, 14, 2242, 63, 475, 63, 4551, 8, 277, 14, 4551, 9, 267, 871, 3091, 21547, 3601, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 3913, 4907, 283, 971, 2116, 283, 475, 10168, 7037, 3866, 6235, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 340, 440, 283, 18445, 51, 63, 2339, 7, 315, 747, 14, 2314, 26, 288, 870, 283, 8490, 63, 8898, 63, 18445, 51, 5223, 1325, 428, 23298, 63, 2339, 440, 283, 971, 2116, 283, 4037, 315, 3734, 7, 288, 984, 14, 2224, 8, 17, 9, 267, 291, 14, 354, 275, 747, 14, 2314, 459, 18445, 51, 63, 2339, 418, 267, 291, 14, 1825, 275, 291, 14, 31603, 14, 981, 63, 1825, 8, 277, 14, 354, 9, 267, 340, 283, 18445, 51, 63, 9740, 63, 6351, 7, 315, 747, 14, 2314, 26, 288, 291, 14, 1861, 275, 747, 14, 2314, 459, 18445, 51, 63, 9740, 63, 6351, 418, 267, 587, 26, 288, 291, 14, 1861, 275, 2125, 398, 291, 14, 2019, 63, 8606, 63, 1086, 275, 1052, 339, 347, 7876, 63, 265, 63, 4892, 8, 277, 12, 1591, 12, 522, 12, 3686, 63, 2550, 29, 797, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 340, 440, 3686, 63, 2550, 26, 355, 291, 423, 2254, 63, 1825, 63, 1188, 8, 470, 12, 283, 13989, 358, 339, 347, 7876, 63, 265, 63, 745, 8, 277, 12, 1591, 12, 522, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 327, 2793, 1133, 3222, 314, 3272, 2058, 288, 340, 522, 459, 30158, 2545, 578, 63, 354, 418, 1137, 298, 2758, 582, 355, 291, 423, 2254, 63, 1825, 63, 1188, 8, 470, 12, 283, 3593, 358, 339, 347, 15695, 63, 265, 63, 1765, 63, 928, 8, 277, 12, 536, 12, 365, 63, 14353, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 354, 12, 283, 17179, 358, 339, 347, 15695, 63, 265, 63, 2802, 63, 928, 8, 277, 12, 3851, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 3401, 12, 283, 7363, 358, 339, 347, 15695, 63, 265, 63, 3200, 8, 277, 12, 5020, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 366, 275, 1052, 288, 5762, 275, 900, 14, 521, 342, 446, 291, 14, 928, 63, 521, 288, 366, 459, 3136, 418, 275, 5762, 288, 367, 308, 315, 788, 2489, 297, 283, 9968, 297, 283, 745, 297, 283, 7292, 297, 283, 11962, 2565, 355, 366, 59, 83, 61, 275, 2519, 8, 3200, 12, 308, 9, 288, 291, 423, 2254, 63, 1825, 63, 1188, 8, 68, 12, 283, 19202, 358, 339, 347, 485, 2254, 63, 1825, 63, 1188, 8, 277, 12, 1499, 12, 1499, 63, 466, 304, 267, 340, 291, 14, 4296, 63, 31603, 26, 288, 687, 63, 928, 275, 900, 14, 521, 342, 446, 291, 14, 928, 63, 521, 288, 4886, 275, 469, 1328, 63, 466, 26, 1499, 93, 288, 4886, 459, 9730, 418, 275, 687, 63, 928, 288, 4886, 459, 6351, 418, 275, 291, 14, 1861, 288, 327, 1678, 314, 2061, 6775, 4913, 367, 288, 327, 314, 1245, 730, 288, 291, 14, 2019, 63, 8606, 63, 1086, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
nirmeshk/oh-mainline
vendor/packages/gdata/tests/gdata_tests/calendar_test.py
41
39080
#!/usr/bin/python # # Copyright (C) 2006 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. __author__ = 'api.jscudder@gmail.com (Jeff Scudder)' import unittest try: from xml.etree import ElementTree except ImportError: from elementtree import ElementTree import atom import gdata from gdata import test_data import gdata.calendar class CalendarFeedTest(unittest.TestCase): def setUp(self): self.calendar_feed = gdata.calendar.CalendarListFeedFromString( test_data.CALENDAR_FEED) def testEntryCount(self): # Assert the number of items in the feed of calendars self.assertEquals(len(self.calendar_feed.entry),2) def testToAndFromString(self): # Assert the appropriate type for each entry for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry, gdata.calendar.CalendarListEntry), 'Entry must be an instance of CalendarListEntry') # Regenerate feed from xml text new_calendar_feed = ( gdata.calendar.CalendarListFeedFromString(str(self.calendar_feed))) for an_entry in new_calendar_feed.entry: self.assert_(isinstance(an_entry, gdata.calendar.CalendarListEntry), 'Entry in regenerated feed must be an instance of CalendarListEntry') def testAuthor(self): """Tests the existence of a <atom:author> and verifies the name and email""" # Assert that each element in the feed author list is an atom.Author for an_author in self.calendar_feed.author: self.assert_(isinstance(an_author, atom.Author), "Calendar feed <atom:author> element must be an instance of " + "atom.Author: %s" % an_author) # Assert the feed author name is as expected self.assertEquals(self.calendar_feed.author[0].name.text, 'GData Ops Demo') # Assert the feed author name is as expected self.assertEquals(self.calendar_feed.author[0].email.text, 'gdata.ops.demo@gmail.com') # Assert one of the values for an entry author self.assertEquals(self.calendar_feed.entry[0].author[0].name.text, 'GData Ops Demo') self.assertEquals(self.calendar_feed.entry[0].author[0].email.text, 'gdata.ops.demo@gmail.com') def testId(self): """Tests the existence of a <atom:id> in the feed and entries and verifies the value""" # Assert the feed id exists and is an atom.Id self.assert_(isinstance(self.calendar_feed.id, atom.Id), "Calendar feed <atom:id> element must be an instance of atom.Id: %s" % ( self.calendar_feed.id)) # Assert the feed id value is as expected self.assertEquals(self.calendar_feed.id.text, 'http://www.google.com/calendar/feeds/default') # Assert that each entry has an id which is an atom.Id for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.id, atom.Id), "Calendar entry <atom:id> element must be an instance of " + "atom.Id: %s" % an_entry.id) # Assert one of the values for an id self.assertEquals(self.calendar_feed.entry[1].id.text, 'http://www.google.com/calendar/feeds/default/' + 'jnh21ovnjgfph21h32gvms2758%40group.calendar.google.com') def testPublished(self): """Tests the existence of a <atom:published> in the entries and verifies the value""" # Assert that each entry has a published value which is an atom.Published for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.published, atom.Published), "Calendar entry <atom:published> element must be an instance of " + "atom.Published: %s" % an_entry.published) # Assert one of the values for published is as expected self.assertEquals(self.calendar_feed.entry[1].published.text, '2007-03-20T22:48:57.837Z') def testUpdated(self): """Tests the existence of a <atom:updated> in the feed and the entries and verifies the value""" # Assert that the feed updated element exists and is an atom.Updated self.assert_(isinstance(self.calendar_feed.updated, atom.Updated), "Calendar feed <atom:updated> element must be an instance of " + "atom.Updated: %s" % self.calendar_feed.updated) # Assert that each entry has a updated value which is an atom.Updated for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.updated, atom.Updated), "Calendar entry <atom:updated> element must be an instance of" + "atom.Updated: %s" % an_entry.updated) # Assert the feed updated value is as expected self.assertEquals(self.calendar_feed.updated.text, '2007-03-20T22:48:57.833Z') # Assert one of the values for updated self.assertEquals(self.calendar_feed.entry[0].updated.text, '2007-03-20T22:48:52.000Z') def testTitle(self): """Tests the existence of a <atom:title> in the feed and the entries and verifies the value""" # Assert that the feed title element exists and is an atom.Title self.assert_(isinstance(self.calendar_feed.title, atom.Title), "Calendar feed <atom:title> element must be an instance of " + "atom.Title: %s" % self.calendar_feed.title) # Assert that each entry has a title value which is an atom.Title for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.title, atom.Title), "Calendar entry <atom:title> element must be an instance of " + "atom.Title: %s" % an_entry.title) # Assert the feed title value is as expected self.assertEquals(self.calendar_feed.title.text, 'GData Ops Demo\'s Calendar List') # Assert one of the values for title self.assertEquals(self.calendar_feed.entry[0].title.text, 'GData Ops Demo') def testColor(self): """Tests the existence of a <gCal:color> and verifies the value""" # Assert the color is present and is a gdata.calendar.Color for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.color, gdata.calendar.Color), "Calendar feed <gCal:color> element must be an instance of " + "gdata.calendar.Color: %s" % an_entry.color) # Assert the color value is as expected self.assertEquals(self.calendar_feed.entry[0].color.value, '#2952A3') def testAccessLevel(self): """Tests the existence of a <gCal:accesslevel> element and verifies the value""" # Assert the access_level is present and is a gdata.calendar.AccessLevel for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.access_level, gdata.calendar.AccessLevel), "Calendar feed <gCal:accesslevel> element must be an instance of " + "gdata.calendar.AccessLevel: %s" % an_entry.access_level) # Assert the access_level value is as expected self.assertEquals(self.calendar_feed.entry[0].access_level.value, 'owner') def testTimezone(self): """Tests the existence of a <gCal:timezone> element and verifies the value""" # Assert the timezone is present and is a gdata.calendar.Timezone for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.timezone, gdata.calendar.Timezone), "Calendar feed <gCal:timezone> element must be an instance of " + "gdata.calendar.Timezone: %s" % an_entry.timezone) # Assert the timezone value is as expected self.assertEquals(self.calendar_feed.entry[0].timezone.value, 'America/Los_Angeles') def testHidden(self): """Tests the existence of a <gCal:hidden> element and verifies the value""" # Assert the hidden is present and is a gdata.calendar.Hidden for an_entry in self.calendar_feed.entry: self.assert_(isinstance(an_entry.hidden, gdata.calendar.Hidden), "Calendar feed <gCal:hidden> element must be an instance of " + "gdata.calendar.Hidden: %s" % an_entry.hidden) # Assert the hidden value is as expected self.assertEquals(self.calendar_feed.entry[0].hidden.value, 'false') def testOpenSearch(self): """Tests the existence of <openSearch:startIndex>""" # Assert that the elements exist and are the appropriate type self.assert_(isinstance(self.calendar_feed.start_index, gdata.StartIndex), "Calendar feed <openSearch:startIndex> element must be an " + "instance of gdata.StartIndex: %s" % self.calendar_feed.start_index) # Assert the values for each openSearch element are as expected self.assertEquals(self.calendar_feed.start_index.text, '1') def testGenerator(self): """Tests the existence of <atom:generator> and verifies the value""" # Assert that the element exists and is of the appropriate type self.assert_(isinstance(self.calendar_feed.generator, atom.Generator), "Calendar feed <atom:generator> element must be an instance of " + "atom.Generator: %s" % self.calendar_feed.generator) # Assert the generator version, uri and text are as expected self.assertEquals(self.calendar_feed.generator.text, 'Google Calendar') self.assertEquals(self.calendar_feed.generator.version, '1.0') self.assertEquals(self.calendar_feed.generator.uri, 'http://www.google.com/calendar') def testEntryLink(self): """Makes sure entry links in the private composite feed are parsed.""" entry = gdata.calendar.CalendarEventEntryFromString( test_data.RECURRENCE_EXCEPTION_ENTRY) self.assert_(isinstance(entry.recurrence_exception, list)) self.assert_(isinstance(entry.recurrence_exception[0].entry_link, gdata.EntryLink)) self.assert_(isinstance(entry.recurrence_exception[0].entry_link.entry, gdata.calendar.CalendarEventEntry)) self.assertEquals( entry.recurrence_exception[0].entry_link.entry.author[0].name.text, 'gdata ops') def testSequence(self): entry = gdata.calendar.CalendarEventEntry( sequence=gdata.calendar.Sequence(value='1')) entry2 = gdata.calendar.CalendarEventEntryFromString(str(entry)) self.assertEqual(entry.sequence.value, entry2.sequence.value) entry = gdata.calendar.CalendarEventEntryFromString( '<entry xmlns="%s"><sequence xmlns="%s" value="7" /></entry>' % ( atom.ATOM_NAMESPACE, gdata.calendar.GCAL_NAMESPACE)) self.assertEqual(entry.sequence.value, '7') def testOriginalEntry(self): """Make sure original entry in the private composite feed are parsed.""" entry = gdata.calendar.CalendarEventEntryFromString( test_data.RECURRENCE_EXCEPTION_ENTRY) self.assertEquals( entry.recurrence_exception[0].entry_link.entry.original_event.id, 'i7lgfj69mjqjgnodklif3vbm7g') class CalendarFeedTestRegenerated(CalendarFeedTest): def setUp(self): old_calendar_feed = ( gdata.calendar.CalendarListFeedFromString(test_data.CALENDAR_FEED)) self.calendar_feed = ( gdata.calendar.CalendarListFeedFromString(str(old_calendar_feed))) tree = ElementTree.fromstring(str(old_calendar_feed)) class CalendarEventFeedTest(unittest.TestCase): def setUp(self): self.calendar_event_feed = ( gdata.calendar.CalendarEventFeedFromString( test_data.CALENDAR_FULL_EVENT_FEED)) def testEntryCount(self): # Assert the number of items in the feed of events self.assertEquals(len(self.calendar_event_feed.entry),11) def testToAndFromString(self): # Assert the appropriate type for each entry for an_entry in self.calendar_event_feed.entry: self.assert_(isinstance(an_entry, gdata.calendar.CalendarEventEntry), "Entry must be an instance of a CalendarEventEntry") # Regenerate feed from xml text new_calendar_event_feed = gdata.calendar.CalendarEventFeedFromString( str(self.calendar_event_feed)) for an_entry in new_calendar_event_feed.entry: self.assert_(isinstance(an_entry, gdata.calendar.CalendarEventEntry), "Entry in regenerated feed must be an instance of CalendarEventEntry") def testAuthor(self): """Tests the existence of a <atom:author> and verifies the name and email""" # Assert that each element in the feed author list is an atom.Author for an_author in self.calendar_event_feed.author: self.assert_(isinstance(an_author, atom.Author), "Calendar event feed <atom:author> element must be an instance of " + "atom.Author: %s" % an_author) # Assert the feed author name is as expected self.assertEquals(self.calendar_event_feed.author[0].name.text, 'GData Ops Demo') # Assert the feed author name is as expected self.assertEquals(self.calendar_event_feed.author[0].email.text, 'gdata.ops.demo@gmail.com') # Assert one of the values for an entry author self.assertEquals(self.calendar_event_feed.entry[0].author[0].name.text, 'GData Ops Demo') self.assertEquals(self.calendar_event_feed.entry[0].author[0].email.text, 'gdata.ops.demo@gmail.com') def testId(self): """Tests the existence of a <atom:id> in the feed and entries and verifies the value""" # Assert the feed id exists and is an atom.Id self.assert_(isinstance(self.calendar_event_feed.id, atom.Id), "Calendar event feed <atom:id> element must be an instance of " + "atom.Id: %s" % self.calendar_event_feed.id) # Assert the feed id value is as expected self.assertEquals(self.calendar_event_feed.id.text, 'http://www.google.com/calendar/feeds/default/private/full') # Assert that each entry has an id which is an atom.Id for an_entry in self.calendar_event_feed.entry: self.assert_(isinstance(an_entry.id, atom.Id), "Calendar event entry <atom:id> element must be an " + "instance of atom.Id: %s" % an_entry.id) # Assert one of the values for an id self.assertEquals(self.calendar_event_feed.entry[1].id.text, 'http://www.google.com/calendar/feeds/default/private/full/' + '2qt3ao5hbaq7m9igr5ak9esjo0') def testPublished(self): """Tests the existence of a <atom:published> in the entries and verifies the value""" # Assert that each entry has a published value which is an atom.Published for an_entry in self.calendar_event_feed.entry: self.assert_(isinstance(an_entry.published, atom.Published), "Calendar event entry <atom:published> element must be an instance " + "of atom.Published: %s" % an_entry.published) # Assert one of the values for published is as expected self.assertEquals(self.calendar_event_feed.entry[1].published.text, '2007-03-20T21:26:04.000Z') def testUpdated(self): """Tests the existence of a <atom:updated> in the feed and the entries and verifies the value""" # Assert that the feed updated element exists and is an atom.Updated self.assert_(isinstance(self.calendar_event_feed.updated, atom.Updated), "Calendar feed <atom:updated> element must be an instance of " + "atom.Updated: %s" % self.calendar_event_feed.updated) # Assert that each entry has a updated value which is an atom.Updated for an_entry in self.calendar_event_feed.entry: self.assert_(isinstance(an_entry.updated, atom.Updated), "Calendar event entry <atom:updated> element must be an instance " + "of atom.Updated: %s" % an_entry.updated) # Assert the feed updated value is as expected self.assertEquals(self.calendar_event_feed.updated.text, '2007-03-20T21:29:57.000Z') # Assert one of the values for updated self.assertEquals(self.calendar_event_feed.entry[3].updated.text, '2007-03-20T21:25:46.000Z') def testTitle(self): """Tests the existence of a <atom:title> in the feed and the entries and verifies the value""" # Assert that the feed title element exists and is an atom.Title self.assert_(isinstance(self.calendar_event_feed.title, atom.Title), "Calendar feed <atom:title> element must be an instance of " + "atom.Title: %s" % self.calendar_event_feed.title) # Assert that each entry has a title value which is an atom.Title for an_entry in self.calendar_event_feed.entry: self.assert_(isinstance(an_entry.title, atom.Title), "Calendar event entry <atom:title> element must be an instance of " + "atom.Title: %s" % an_entry.title) # Assert the feed title value is as expected self.assertEquals(self.calendar_event_feed.title.text, 'GData Ops Demo') # Assert one of the values for title self.assertEquals(self.calendar_event_feed.entry[0].title.text, 'test deleted') def testPostLink(self): """Tests the existence of a <atom:link> with a rel='...#post' and verifies the value""" # Assert that each link in the feed is an atom.Link for a_link in self.calendar_event_feed.link: self.assert_(isinstance(a_link, atom.Link), "Calendar event entry <atom:link> element must be an instance of " + "atom.Link: %s" % a_link) # Assert post link exists self.assert_(self.calendar_event_feed.GetPostLink() is not None) # Assert the post link value is as expected self.assertEquals(self.calendar_event_feed.GetPostLink().href, 'http://www.google.com/calendar/feeds/default/private/full') def testEditLink(self): """Tests the existence of a <atom:link> with a rel='edit' in each entry and verifies the value""" # Assert that each link in the feed is an atom.Link for a_link in self.calendar_event_feed.link: self.assert_(isinstance(a_link, atom.Link), "Calendar event entry <atom:link> element must be an instance of " + "atom.Link: %s" % a_link) # Assert edit link exists for a_entry in self.calendar_event_feed.entry: self.assert_(a_entry.GetEditLink() is not None) # Assert the edit link value is as expected self.assertEquals(self.calendar_event_feed.entry[0].GetEditLink().href, 'http://www.google.com/calendar/feeds/default/private/full/o99flmgm' + 'kfkfrr8u745ghr3100/63310109397') self.assertEquals(self.calendar_event_feed.entry[0].GetEditLink().type, 'application/atom+xml') def testOpenSearch(self): """Tests the existence of <openSearch:totalResults>, <openSearch:startIndex>, <openSearch:itemsPerPage>""" # Assert that the elements exist and are the appropriate type self.assert_(isinstance(self.calendar_event_feed.total_results, gdata.TotalResults), "Calendar event feed <openSearch:totalResults> element must be an " + "instance of gdata.TotalResults: %s" % ( self.calendar_event_feed.total_results)) self.assert_( isinstance(self.calendar_event_feed.start_index, gdata.StartIndex), "Calendar event feed <openSearch:startIndex> element must be an " + "instance of gdata.StartIndex: %s" % ( self.calendar_event_feed.start_index)) self.assert_( isinstance(self.calendar_event_feed.items_per_page, gdata.ItemsPerPage), "Calendar event feed <openSearch:itemsPerPage> element must be an " + "instance of gdata.ItemsPerPage: %s" % ( self.calendar_event_feed.items_per_page)) # Assert the values for each openSearch element are as expected self.assertEquals(self.calendar_event_feed.total_results.text, '10') self.assertEquals(self.calendar_event_feed.start_index.text, '1') self.assertEquals(self.calendar_event_feed.items_per_page.text, '25') def testGenerator(self): """Tests the existence of <atom:generator> and verifies the value""" # Assert that the element exists and is of the appropriate type self.assert_(isinstance(self.calendar_event_feed.generator, atom.Generator), "Calendar event feed <atom:generator> element must be an instance " + "of atom.Generator: %s" % self.calendar_event_feed.generator) # Assert the generator version, uri and text are as expected self.assertEquals(self.calendar_event_feed.generator.text, 'Google Calendar') self.assertEquals(self.calendar_event_feed.generator.version, '1.0') self.assertEquals(self.calendar_event_feed.generator.uri, 'http://www.google.com/calendar') def testCategory(self): """Tests the existence of <atom:category> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for a_category in self.calendar_event_feed.category: self.assert_(isinstance(a_category, atom.Category), "Calendar event feed <atom:category> element must be an instance " + "of atom.Category: %s" % a_category) self.assertEquals(a_category.scheme, 'http://schemas.google.com/g/2005#kind') self.assertEquals(a_category.term, 'http://schemas.google.com/g/2005#event') for an_event in self.calendar_event_feed.entry: for a_category in an_event.category: self.assert_(isinstance(a_category, atom.Category), "Calendar event feed entry <atom:category> element must be an " + "instance of atom.Category: %s" % a_category) self.assertEquals(a_category.scheme, 'http://schemas.google.com/g/2005#kind') self.assertEquals(a_category.term, 'http://schemas.google.com/g/2005#event') def testSendEventNotifications(self): """Test the existence of <gCal:sendEventNotifications> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for an_event in self.calendar_event_feed.entry: self.assert_(isinstance(an_event.send_event_notifications, gdata.calendar.SendEventNotifications), ("Calendar event feed entry <gCal:sendEventNotifications> element " + "must be an instance of gdata.calendar.SendEventNotifications: %s") % ( an_event.send_event_notifications,)) # Assert the <gCal:sendEventNotifications> are as expected self.assertEquals( self.calendar_event_feed.entry[0].send_event_notifications.value, 'false') self.assertEquals( self.calendar_event_feed.entry[2].send_event_notifications.value, 'true') def testQuickAdd(self): """Test the existence of <gCal:quickadd> and verifies the value""" entry = gdata.calendar.CalendarEventEntry() entry.quick_add = gdata.calendar.QuickAdd(value='true') unmarshalled_entry = entry.ToString() tag = '{%s}quickadd' % (gdata.calendar.GCAL_NAMESPACE) marshalled_entry = ElementTree.fromstring(unmarshalled_entry).find(tag) self.assert_(marshalled_entry.attrib['value'],'true') self.assert_(marshalled_entry.tag,tag) def testEventStatus(self): """Test the existence of <gd:eventStatus> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for an_event in self.calendar_event_feed.entry: self.assert_(isinstance(an_event.event_status, gdata.calendar.EventStatus), ("Calendar event feed entry <gd:eventStatus> element " + "must be an instance of gdata.calendar.EventStatus: %s") % ( an_event.event_status,)) # Assert the <gd:eventStatus> are as expected self.assertEquals( self.calendar_event_feed.entry[0].event_status.value, 'CANCELED') self.assertEquals( self.calendar_event_feed.entry[1].event_status.value, 'CONFIRMED') def testComments(self): """Tests the existence of <atom:comments> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for an_event in self.calendar_event_feed.entry: self.assert_(an_event.comments is None or isinstance(an_event.comments, gdata.calendar.Comments), ("Calendar event feed entry <gd:comments> element " + "must be an instance of gdata.calendar.Comments: %s") % ( an_event.comments,)) def testVisibility(self): """Test the existence of <gd:visibility> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for an_event in self.calendar_event_feed.entry: self.assert_(isinstance(an_event.visibility, gdata.calendar.Visibility), ("Calendar event feed entry <gd:visibility> element " + "must be an instance of gdata.calendar.Visibility: %s") % ( an_event.visibility,)) # Assert the <gd:visibility> are as expected self.assertEquals( self.calendar_event_feed.entry[0].visibility.value, 'DEFAULT') self.assertEquals( self.calendar_event_feed.entry[1].visibility.value, 'PRIVATE') self.assertEquals( self.calendar_event_feed.entry[2].visibility.value, 'PUBLIC') def testTransparency(self): """Test the existence of <gd:transparency> and verifies the value""" # Assert that the element exists and is of the appropriate type and value for an_event in self.calendar_event_feed.entry: self.assert_(isinstance(an_event.transparency, gdata.calendar.Transparency), ("Calendar event feed entry <gd:transparency> element " + "must be an instance of gdata.calendar.Transparency: %s") % ( an_event.transparency,)) # Assert the <gd:transparency> are as expected self.assertEquals( self.calendar_event_feed.entry[0].transparency.value, 'OPAQUE') self.assertEquals( self.calendar_event_feed.entry[1].transparency.value, 'OPAQUE') self.assertEquals( self.calendar_event_feed.entry[2].transparency.value, 'OPAQUE') # TODO: TEST VALUES OF VISIBILITY OTHER THAN OPAQUE def testWhere(self): """Tests the existence of a <gd:where> in the entries and verifies the value""" # Assert that each entry has a where value which is an gdata.calendar.Where for an_entry in self.calendar_event_feed.entry: for a_where in an_entry.where: self.assert_(isinstance(a_where, gdata.calendar.Where), "Calendar event entry <gd:where> element must be an instance of " + "gdata.calendar.Where: %s" % a_where) # Assert one of the values for where is as expected self.assertEquals(self.calendar_event_feed.entry[1].where[0].value_string, 'Dolores Park with Kim') def testWhenAndReminder(self): """Tests the existence of a <gd:when> and <gd:reminder> in the entries and verifies the values""" # Assert that each entry's when value is a gdata.calendar.When # Assert that each reminder is a gdata.calendar.Reminder for an_entry in self.calendar_event_feed.entry: for a_when in an_entry.when: self.assert_(isinstance(a_when, gdata.calendar.When), "Calendar event entry <gd:when> element must be an instance " + "of gdata.calendar.When: %s" % a_when) for a_reminder in a_when.reminder: self.assert_(isinstance(a_reminder, gdata.calendar.Reminder), "Calendar event entry <gd:reminder> element must be an " + "instance of gdata.calendar.Reminder: %s" % a_reminder) # Assert one of the values for when is as expected self.assertEquals(self.calendar_event_feed.entry[0].when[0].start_time, '2007-03-23T12:00:00.000-07:00') self.assertEquals(self.calendar_event_feed.entry[0].when[0].end_time, '2007-03-23T13:00:00.000-07:00') # Assert the reminder child of when is as expected self.assertEquals( self.calendar_event_feed.entry[0].when[0].reminder[0].minutes, '10') self.assertEquals( self.calendar_event_feed.entry[1].when[0].reminder[0].minutes, '20') def testBatchRequestParsing(self): batch_request = gdata.calendar.CalendarEventFeedFromString( test_data.CALENDAR_BATCH_REQUEST) self.assertEquals(len(batch_request.entry), 4) # Iterate over the batch request entries and match the operation with # the batch id. These values are hard coded to match the test data. for entry in batch_request.entry: if entry.batch_id.text == '1': self.assertEquals(entry.batch_operation.type, 'insert') if entry.batch_id.text == '2': self.assertEquals(entry.batch_operation.type, 'query') if entry.batch_id.text == '3': self.assertEquals(entry.batch_operation.type, 'update') self.assertEquals(entry.title.text, 'Event updated via batch') if entry.batch_id.text == '4': self.assertEquals(entry.batch_operation.type, 'delete') self.assertEquals(entry.id.text, 'http://www.google.com/calendar/feeds/default/' 'private/full/d8qbg9egk1n6lhsgq1sjbqffqc') self.assertEquals(entry.GetEditLink().href, 'http://www.google.com/calendar/feeds/default/' 'private/full/d8qbg9egk1n6lhsgq1sjbqffqc/' '63326018324') def testBatchResponseParsing(self): batch_response = gdata.calendar.CalendarEventFeedFromString( test_data.CALENDAR_BATCH_RESPONSE) self.assertEquals(len(batch_response.entry), 4) for entry in batch_response.entry: if entry.batch_id.text == '1': self.assertEquals(entry.batch_operation.type, 'insert') self.assertEquals(entry.batch_status.code, '201') self.assertEquals(entry.batch_status.reason, 'Created') self.assertEquals(entry.id.text, 'http://www.google.com/calendar/' 'feeds/default/private/full/' 'n9ug78gd9tv53ppn4hdjvk68ek') if entry.batch_id.text == '2': self.assertEquals(entry.batch_operation.type, 'query') if entry.batch_id.text == '3': self.assertEquals(entry.batch_operation.type, 'update') if entry.batch_id.text == '4': self.assertEquals(entry.batch_operation.type, 'delete') self.assertEquals(entry.id.text, 'http://www.google.com/calendar/' 'feeds/default/private/full/' 'd8qbg9egk1n6lhsgq1sjbqffqc') # TODO add reminder tests for absolute_time and hours/seconds (if possible) # TODO test recurrence and recurrenceexception # TODO test originalEvent class CalendarWebContentTest(unittest.TestCase): def setUp(self): self.calendar_event_feed = ( gdata.calendar.CalendarEventFeedFromString( test_data.CALENDAR_FULL_EVENT_FEED)) def testAddSimpleWebContentEventEntry(self): """Verifies that we can add a web content link to an event entry.""" title = "Al Einstein's Birthday!" href = 'http://gdata.ops.demo.googlepages.com/birthdayicon.gif' type = 'image/jpeg' url = 'http://gdata.ops.demo.googlepages.com/einstein.jpg' width = '300' height = '225' # Create a web content event event = gdata.calendar.CalendarEventEntry() web_content = gdata.calendar.WebContent(url=url, width=width, height=height) web_content_link = gdata.calendar.WebContentLink(title=title, href=href, link_type=type, web_content=web_content) event.link.append(web_content_link) # Verify the web content link exists and contains the expected data web_content_link = event.GetWebContentLink() self.assertValidWebContentLink(title, href, type, web_content_link) # Verify the web content element exists and contains the expected data web_content_element = web_content_link.web_content self.assertValidSimpleWebContent(url, width, height, web_content_element) def testAddWebContentGadgetEventEntry(self): """Verifies that we can add a web content gadget link to an event entry.""" title = "Date and Time Gadget" href = 'http://gdata.ops.demo.googlepages.com/birthdayicon.gif' url = 'http://google.com/ig/modules/datetime.xml' type = 'application/x-google-gadgets+xml' width = '300' height = '200' pref_name = 'color' pref_value = 'green' # Create a web content event event = gdata.calendar.CalendarEventEntry() web_content = gdata.calendar.WebContent(url=url, width=width, height=height) web_content.gadget_pref.append( gdata.calendar.WebContentGadgetPref(name=pref_name, value=pref_value)) web_content_link = gdata.calendar.WebContentLink(title=title, href=href, web_content=web_content, link_type=type) event.link.append(web_content_link) # Verify the web content link exists and contains the expected data web_content_link = event.GetWebContentLink() self.assertValidWebContentLink(title, href, type, web_content_link) # Verify the web content element exists and contains the expected data web_content_element = web_content_link.web_content self.assertValidWebContentGadget(url, width, height, pref_name, pref_value, web_content_element) def testFromXmlToSimpleWebContent(self): """Verifies that we can read a web content link from an event entry.""" # Expected values (from test_data.py file) title = 'World Cup' href = 'http://www.google.com/calendar/images/google-holiday.gif' type = 'image/gif' url = 'http://www.google.com/logos/worldcup06.gif' width = '276' height = '120' # Note: The tenth event entry contains web content web_content_event = self.calendar_event_feed.entry[9] # Verify the web content link exists and contains the expected data web_content_link = web_content_event.GetWebContentLink() self.assertValidWebContentLink(title, href, type, web_content_link) # Verify the web content element exists and contains the expected data web_content_element = web_content_link.web_content self.assertValidSimpleWebContent(url, width, height, web_content_element) def testFromXmlToWebContentGadget(self): """Verifies that we can read a web content link from an event entry.""" # Expected values (from test_data.py file) title = 'Date and Time Gadget' href = 'http://gdata.ops.demo.googlepages.com/birthdayicon.gif' url = 'http://google.com/ig/modules/datetime.xml' type = 'application/x-google-gadgets+xml' width = '300' height = '136' pref_name = 'color' pref_value = 'green' # Note: The eleventh event entry contains web content web_content_event = self.calendar_event_feed.entry[10] # Verify the web content link exists and contains the expected data web_content_link = web_content_event.GetWebContentLink() self.assertValidWebContentLink(title, href, type, web_content_link) # Verify the web content element exists and contains the expected data web_content_element = web_content_link.web_content self.assertValidWebContentGadget(url, width, height, pref_name, pref_value, web_content_element) def assertValidWebContentLink(self, expected_title=None, expected_href=None, expected_type=None, web_content_link=None): """Asserts that the web content link is the correct type and contains the expected values""" self.assert_(isinstance(web_content_link, gdata.calendar.WebContentLink), "Web content link element must be an " + "instance of gdata.calendar.WebContentLink: %s" % web_content_link) expected_rel = '%s/%s' % (gdata.calendar.GCAL_NAMESPACE, 'webContent') self.assertEquals(expected_rel, web_content_link.rel) self.assertEqual(expected_title, web_content_link.title) self.assertEqual(expected_href, web_content_link.href) self.assertEqual(expected_type, web_content_link.type) def assertValidSimpleWebContent(self, expected_url=None, expected_width=None, expected_height=None, web_content_element=None): """Asserts that the web content element is the correct type and contains the expected values""" self.assert_(isinstance(web_content_element, gdata.calendar.WebContent), "Calendar event entry <gCal:webContent> element must be an " + "instance of gdata.calendar.WebContent: %s" % web_content_element) self.assertEquals(expected_width, web_content_element.width) self.assertEquals(expected_height, web_content_element.height) self.assertEquals(expected_url, web_content_element.url) def assertValidWebContentGadget(self, expected_url=None, expected_width=None, expected_height=None, expected_pref_name=None, expected_pref_value=None, web_content_element=None): """Asserts that the web content element is the correct type and contains the expected values""" self.assert_(isinstance(web_content_element, gdata.calendar.WebContent), "Calendar event entry <gCal:webContent> element must be an " + "instance of gdata.calendar.WebContent: %s" % web_content_element) self.assertEquals(expected_width, web_content_element.width) self.assertEquals(expected_height, web_content_element.height) self.assertEquals(expected_url, web_content_element.url) self.assertEquals(expected_pref_name, web_content_element.gadget_pref[0].name) self.assertEquals(expected_pref_value, web_content_element.gadget_pref[0].value) def testSampleCode(self): # From http://code.google.com/apis/calendar/gadgets/event/ wc = gdata.calendar.WebContent() wc.url = 'http://www.thefreedictionary.com/_/WoD/wod-module.xml' wc.width = '300' wc.height = '136' wc.gadget_pref.append(gdata.calendar.WebContentGadgetPref(name='Days', value='1')) wc.gadget_pref.append(gdata.calendar.WebContentGadgetPref(name='Format', value='0')) wcl = gdata.calendar.WebContentLink() wcl.title = 'Word of the Day' wcl.href = 'http://www.thefreedictionary.com/favicon.ico' wcl.type = 'application/x-google-gadgets+xml' wcl.web_content = wc self.assertEqual(wcl.web_content.url, 'http://www.thefreedictionary.com/_/WoD/wod-module.xml') self.assertEqual(wcl.type, 'application/x-google-gadgets+xml') self.assertEqual(wcl.web_content.height, '136') class ExtendedPropertyTest(unittest.TestCase): def testExtendedPropertyToAndFromXml(self): ep = gdata.calendar.ExtendedProperty(name='test') ep.value = 'val' xml_string = ep.ToString() ep2 = gdata.ExtendedPropertyFromString(xml_string) self.assertEquals(ep.name, ep2.name) self.assertEquals(ep.value, ep2.value) if __name__ == '__main__': unittest.main()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 35, 9, 8315, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 363, 2502, 363, 275, 283, 1246, 14, 74, 551, 1181, 424, 32, 6799, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 2882, 199, 893, 26, 523, 687, 2748, 14, 9464, 492, 13139, 199, 2590, 3545, 26, 523, 687, 1819, 2350, 492, 13139, 199, 646, 6222, 221, 199, 646, 11006, 199, 504, 11006, 492, 511, 63, 576, 199, 646, 11006, 14, 8183, 421, 199, 533, 27779, 7658, 774, 8, 2796, 14, 1746, 304, 12244, 347, 3613, 8, 277, 304, 272, 291, 14, 8183, 63, 3871, 275, 11006, 14, 8183, 14, 18688, 1296, 7658, 7671, 8, 267, 511, 63, 576, 14, 13329, 3902, 689, 63, 18068, 9, 819, 347, 511, 3900, 2353, 8, 277, 304, 272, 327, 10716, 314, 1329, 402, 2974, 315, 314, 4733, 402, 1704, 31276, 272, 291, 14, 2947, 8, 552, 8, 277, 14, 8183, 63, 3871, 14, 2373, 395, 18, 9, 1362, 2126, 819, 347, 511, 1378, 3325, 7671, 8, 277, 304, 272, 327, 10716, 314, 5827, 730, 367, 1924, 2397, 272, 367, 376, 63, 2373, 315, 291, 14, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 12, 11006, 14, 8183, 14, 18688, 16934, 395, 23664, 283, 3900, 1471, 506, 376, 1256, 402, 27779, 16934, 358, 339, 327, 799, 4208, 4733, 687, 2748, 1318, 272, 892, 63, 8183, 63, 3871, 275, 334, 4960, 11006, 14, 8183, 14, 18688, 1296, 7658, 7671, 8, 495, 8, 277, 14, 8183, 63, 3871, 1724, 272, 367, 376, 63, 2373, 315, 892, 63, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 12, 11006, 14, 8183, 14, 18688, 16934, 395, 23664, 283, 3900, 315, 31904, 4733, 1471, 506, 376, 1256, 402, 27779, 16934, 358, 819, 347, 511, 5949, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 2502, 30, 436, 22694, 314, 536, 436, 3031, 624, 339, 327, 10716, 626, 1924, 1819, 315, 314, 4733, 4132, 769, 365, 376, 6222, 14, 5949, 272, 367, 376, 63, 2502, 315, 291, 14, 8183, 63, 3871, 14, 2502, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2502, 12, 6222, 14, 5949, 395, 23664, 298, 18688, 4733, 665, 4188, 26, 2502, 30, 1819, 1471, 506, 376, 1256, 402, 298, 435, 881, 298, 4188, 14, 5949, 26, 450, 83, 2, 450, 376, 63, 2502, 9, 339, 327, 10716, 314, 4733, 4132, 536, 365, 465, 1420, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2502, 59, 16, 1055, 354, 14, 505, 12, 283, 27413, 593, 1190, 28939, 358, 339, 327, 10716, 314, 4733, 4132, 536, 365, 465, 1420, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2502, 59, 16, 1055, 2123, 14, 505, 12, 4960, 283, 15275, 14, 1483, 14, 8768, 32, 6799, 14, 957, 358, 339, 327, 10716, 1373, 402, 314, 1338, 367, 376, 2397, 4132, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 16, 1055, 2502, 59, 16, 1055, 354, 14, 505, 12, 4960, 283, 27413, 593, 1190, 28939, 358, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 16, 1055, 2502, 59, 16, 1055, 2123, 14, 505, 12, 4960, 283, 15275, 14, 1483, 14, 8768, 32, 6799, 14, 957, 358, 819, 347, 511, 1304, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 344, 30, 315, 314, 4733, 436, 4811, 5591, 436, 22694, 314, 574, 624, 339, 327, 10716, 314, 4733, 1305, 3495, 436, 365, 376, 6222, 14, 1304, 272, 291, 14, 479, 2531, 6074, 8, 277, 14, 8183, 63, 3871, 14, 344, 12, 6222, 14, 1304, 395, 4960, 298, 18688, 4733, 665, 4188, 26, 344, 30, 1819, 1471, 506, 376, 1256, 402, 6222, 14, 1304, 26, 450, 83, 2, 450, 334, 267, 291, 14, 8183, 63, 3871, 14, 344, 430, 18407, 327, 10716, 314, 4733, 1305, 574, 365, 465, 1420, 5591, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 344, 14, 505, 12, 4960, 283, 1014, 921, 1544, 14, 3098, 14, 957, 15, 8183, 15, 11522, 15, 885, 358, 339, 327, 10716, 626, 1924, 2397, 965, 376, 1305, 1314, 365, 376, 6222, 14, 1304, 272, 367, 376, 63, 2373, 315, 291, 14, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 14, 344, 12, 6222, 14, 1304, 395, 881, 298, 18688, 2397, 665, 4188, 26, 344, 30, 1819, 1471, 506, 376, 1256, 402, 298, 435, 881, 298, 4188, 14, 1304, 26, 450, 83, 2, 450, 376, 63, 2373, 14, 344, 9, 339, 327, 10716, 1373, 402, 314, 1338, 367, 376, 1305, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 17, 1055, 344, 14, 505, 12, 4960, 283, 1014, 921, 1544, 14, 3098, 14, 957, 15, 8183, 15, 11522, 15, 885, 4805, 435, 267, 283, 24016, 72, 2025, 79, 6002, 74, 7102, 838, 2025, 72, 708, 71, 16092, 1465, 2010, 5, 2167, 923, 14, 8183, 14, 3098, 14, 957, 358, 819, 347, 511, 27862, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 8987, 30, 315, 314, 4811, 5591, 436, 22694, 314, 574, 624, 339, 327, 10716, 626, 1924, 2397, 965, 282, 3267, 574, 1314, 365, 376 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 35, 9, 8315, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 363, 2502, 363, 275, 283, 1246, 14, 74, 551, 1181, 424, 32, 6799, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 2882, 199, 893, 26, 523, 687, 2748, 14, 9464, 492, 13139, 199, 2590, 3545, 26, 523, 687, 1819, 2350, 492, 13139, 199, 646, 6222, 221, 199, 646, 11006, 199, 504, 11006, 492, 511, 63, 576, 199, 646, 11006, 14, 8183, 421, 199, 533, 27779, 7658, 774, 8, 2796, 14, 1746, 304, 12244, 347, 3613, 8, 277, 304, 272, 291, 14, 8183, 63, 3871, 275, 11006, 14, 8183, 14, 18688, 1296, 7658, 7671, 8, 267, 511, 63, 576, 14, 13329, 3902, 689, 63, 18068, 9, 819, 347, 511, 3900, 2353, 8, 277, 304, 272, 327, 10716, 314, 1329, 402, 2974, 315, 314, 4733, 402, 1704, 31276, 272, 291, 14, 2947, 8, 552, 8, 277, 14, 8183, 63, 3871, 14, 2373, 395, 18, 9, 1362, 2126, 819, 347, 511, 1378, 3325, 7671, 8, 277, 304, 272, 327, 10716, 314, 5827, 730, 367, 1924, 2397, 272, 367, 376, 63, 2373, 315, 291, 14, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 12, 11006, 14, 8183, 14, 18688, 16934, 395, 23664, 283, 3900, 1471, 506, 376, 1256, 402, 27779, 16934, 358, 339, 327, 799, 4208, 4733, 687, 2748, 1318, 272, 892, 63, 8183, 63, 3871, 275, 334, 4960, 11006, 14, 8183, 14, 18688, 1296, 7658, 7671, 8, 495, 8, 277, 14, 8183, 63, 3871, 1724, 272, 367, 376, 63, 2373, 315, 892, 63, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 12, 11006, 14, 8183, 14, 18688, 16934, 395, 23664, 283, 3900, 315, 31904, 4733, 1471, 506, 376, 1256, 402, 27779, 16934, 358, 819, 347, 511, 5949, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 2502, 30, 436, 22694, 314, 536, 436, 3031, 624, 339, 327, 10716, 626, 1924, 1819, 315, 314, 4733, 4132, 769, 365, 376, 6222, 14, 5949, 272, 367, 376, 63, 2502, 315, 291, 14, 8183, 63, 3871, 14, 2502, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2502, 12, 6222, 14, 5949, 395, 23664, 298, 18688, 4733, 665, 4188, 26, 2502, 30, 1819, 1471, 506, 376, 1256, 402, 298, 435, 881, 298, 4188, 14, 5949, 26, 450, 83, 2, 450, 376, 63, 2502, 9, 339, 327, 10716, 314, 4733, 4132, 536, 365, 465, 1420, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2502, 59, 16, 1055, 354, 14, 505, 12, 283, 27413, 593, 1190, 28939, 358, 339, 327, 10716, 314, 4733, 4132, 536, 365, 465, 1420, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2502, 59, 16, 1055, 2123, 14, 505, 12, 4960, 283, 15275, 14, 1483, 14, 8768, 32, 6799, 14, 957, 358, 339, 327, 10716, 1373, 402, 314, 1338, 367, 376, 2397, 4132, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 16, 1055, 2502, 59, 16, 1055, 354, 14, 505, 12, 4960, 283, 27413, 593, 1190, 28939, 358, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 16, 1055, 2502, 59, 16, 1055, 2123, 14, 505, 12, 4960, 283, 15275, 14, 1483, 14, 8768, 32, 6799, 14, 957, 358, 819, 347, 511, 1304, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 344, 30, 315, 314, 4733, 436, 4811, 5591, 436, 22694, 314, 574, 624, 339, 327, 10716, 314, 4733, 1305, 3495, 436, 365, 376, 6222, 14, 1304, 272, 291, 14, 479, 2531, 6074, 8, 277, 14, 8183, 63, 3871, 14, 344, 12, 6222, 14, 1304, 395, 4960, 298, 18688, 4733, 665, 4188, 26, 344, 30, 1819, 1471, 506, 376, 1256, 402, 6222, 14, 1304, 26, 450, 83, 2, 450, 334, 267, 291, 14, 8183, 63, 3871, 14, 344, 430, 18407, 327, 10716, 314, 4733, 1305, 574, 365, 465, 1420, 5591, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 344, 14, 505, 12, 4960, 283, 1014, 921, 1544, 14, 3098, 14, 957, 15, 8183, 15, 11522, 15, 885, 358, 339, 327, 10716, 626, 1924, 2397, 965, 376, 1305, 1314, 365, 376, 6222, 14, 1304, 272, 367, 376, 63, 2373, 315, 291, 14, 8183, 63, 3871, 14, 2373, 26, 489, 291, 14, 479, 2531, 6074, 8, 290, 63, 2373, 14, 344, 12, 6222, 14, 1304, 395, 881, 298, 18688, 2397, 665, 4188, 26, 344, 30, 1819, 1471, 506, 376, 1256, 402, 298, 435, 881, 298, 4188, 14, 1304, 26, 450, 83, 2, 450, 376, 63, 2373, 14, 344, 9, 339, 327, 10716, 1373, 402, 314, 1338, 367, 376, 1305, 272, 291, 14, 2947, 8, 277, 14, 8183, 63, 3871, 14, 2373, 59, 17, 1055, 344, 14, 505, 12, 4960, 283, 1014, 921, 1544, 14, 3098, 14, 957, 15, 8183, 15, 11522, 15, 885, 4805, 435, 267, 283, 24016, 72, 2025, 79, 6002, 74, 7102, 838, 2025, 72, 708, 71, 16092, 1465, 2010, 5, 2167, 923, 14, 8183, 14, 3098, 14, 957, 358, 819, 347, 511, 27862, 8, 277, 304, 272, 408, 2925, 314, 23780, 402, 282, 665, 4188, 26, 8987, 30, 315, 314, 4811, 5591, 436, 22694, 314, 574, 624, 339, 327, 10716, 626, 1924, 2397, 965, 282, 3267, 574, 1314, 365, 376, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
salomon1184/bite-project
deps/gdata-python-client/src/gdata/acl/data.py
98
1893
#!/usr/bin/python # # Copyright (C) 2009 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains the data classes of the Google Access Control List (ACL) Extension""" __author__ = 'j.s@google.com (Jeff Scudder)' import atom.core import atom.data import gdata.data import gdata.opensearch.data GACL_TEMPLATE = '{http://schemas.google.com/acl/2007}%s' class AclRole(atom.core.XmlElement): """Describes the role of an entry in an access control list.""" _qname = GACL_TEMPLATE % 'role' value = 'value' class AclAdditionalRole(atom.core.XmlElement): """Describes an additionalRole element.""" _qname = GACL_TEMPLATE % 'additionalRole' value = 'value' class AclScope(atom.core.XmlElement): """Describes the scope of an entry in an access control list.""" _qname = GACL_TEMPLATE % 'scope' type = 'type' value = 'value' class AclWithKey(atom.core.XmlElement): """Describes a key that can be used to access a document.""" _qname = GACL_TEMPLATE % 'withKey' key = 'key' role = AclRole additional_role = AclAdditionalRole class AclEntry(gdata.data.GDEntry): """Describes an entry in a feed of an access control list (ACL).""" scope = AclScope role = AclRole with_key = AclWithKey additional_role = AclAdditionalRole class AclFeed(gdata.data.GDFeed): """Describes a feed of an access control list (ACL).""" entry = [AclEntry]
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 314, 666, 3992, 402, 314, 4475, 11003, 8612, 3820, 334, 18765, 9, 13282, 624, 421, 199, 363, 2502, 363, 275, 283, 74, 14, 83, 32, 3098, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 6222, 14, 1018, 199, 646, 6222, 14, 576, 199, 646, 11006, 14, 576, 199, 646, 11006, 14, 27285, 14, 576, 421, 199, 39, 18765, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5853, 15, 9488, 22109, 83, 7, 421, 199, 533, 437, 429, 7422, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 314, 4719, 402, 376, 2397, 315, 376, 2879, 3304, 769, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 3756, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 8824, 7422, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 376, 4722, 7422, 1819, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 8460, 7422, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 7812, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 314, 4194, 402, 376, 2397, 315, 376, 2879, 3304, 769, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 2645, 7, 523, 730, 275, 283, 466, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 3007, 1197, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 282, 790, 626, 883, 506, 1202, 370, 2879, 282, 2213, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 1045, 1197, 7, 523, 790, 275, 283, 498, 7, 523, 4719, 275, 437, 429, 7422, 523, 4722, 63, 3756, 275, 437, 429, 8824, 7422, 421, 199, 533, 437, 429, 3900, 8, 15275, 14, 576, 14, 39, 1093, 3410, 304, 523, 408, 16320, 11562, 376, 2397, 315, 282, 4733, 402, 376, 2879, 3304, 769, 334, 18765, 10477, 523, 4194, 275, 437, 429, 7812, 523, 4719, 275, 437, 429, 7422, 523, 543, 63, 498, 275, 437, 429, 3007, 1197, 523, 4722, 63, 3756, 275, 437, 429, 8824, 7422, 421, 199, 533, 437, 429, 7658, 8, 15275, 14, 576, 14, 27046, 7658, 304, 523, 408, 16320, 11562, 282, 4733, 402, 376, 2879, 3304, 769, 334, 18765, 10477, 523, 2397, 275, 359, 23937, 3900, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 314, 666, 3992, 402, 314, 4475, 11003, 8612, 3820, 334, 18765, 9, 13282, 624, 421, 199, 363, 2502, 363, 275, 283, 74, 14, 83, 32, 3098, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 6222, 14, 1018, 199, 646, 6222, 14, 576, 199, 646, 11006, 14, 576, 199, 646, 11006, 14, 27285, 14, 576, 421, 199, 39, 18765, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5853, 15, 9488, 22109, 83, 7, 421, 199, 533, 437, 429, 7422, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 314, 4719, 402, 376, 2397, 315, 376, 2879, 3304, 769, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 3756, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 8824, 7422, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 376, 4722, 7422, 1819, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 8460, 7422, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 7812, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 314, 4194, 402, 376, 2397, 315, 376, 2879, 3304, 769, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 2645, 7, 523, 730, 275, 283, 466, 7, 523, 574, 275, 283, 585, 7, 421, 199, 533, 437, 429, 3007, 1197, 8, 4188, 14, 1018, 14, 26928, 304, 523, 408, 16320, 11562, 282, 790, 626, 883, 506, 1202, 370, 2879, 282, 2213, 1041, 523, 485, 12333, 275, 598, 18765, 63, 7433, 450, 283, 1045, 1197, 7, 523, 790, 275, 283, 498, 7, 523, 4719, 275, 437, 429, 7422, 523, 4722, 63, 3756, 275, 437, 429, 8824, 7422, 421, 199, 533, 437, 429, 3900, 8, 15275, 14, 576, 14, 39, 1093, 3410, 304, 523, 408, 16320, 11562, 376, 2397, 315, 282, 4733, 402, 376, 2879, 3304, 769, 334, 18765, 10477, 523, 4194, 275, 437, 429, 7812, 523, 4719, 275, 437, 429, 7422, 523, 543, 63, 498, 275, 437, 429, 3007, 1197, 523, 4722, 63, 3756, 275, 437, 429, 8824, 7422, 421, 199, 533, 437, 429, 7658, 8, 15275, 14, 576, 14, 27046, 7658, 304, 523, 408, 16320, 11562, 282, 4733, 402, 376, 2879, 3304, 769, 334, 18765, 10477, 523, 2397, 275, 359, 23937, 3900, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sunlianqiang/kbengine
kbe/src/lib/python/Lib/test/test_crashers.py
116
1210
# Tests that the crashers in the Lib/test/crashers directory actually # do crash the interpreter as expected # # If a crasher is fixed, it should be moved elsewhere in the test suite to # ensure it continues to work correctly. import unittest import glob import os.path import test.support from test.script_helper import assert_python_failure CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers") CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py") infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"] class CrasherTest(unittest.TestCase): @unittest.skip("these tests are too fragile") @test.support.cpython_only def test_crashers_crash(self): for fname in glob.glob(CRASHER_FILES): if os.path.basename(fname) in infinite_loops: continue # Some "crashers" only trigger an exception rather than a # segfault. Consider that an acceptable outcome. if test.support.verbose: print("Checking crasher:", fname) assert_python_failure(fname) def test_main(): test.support.run_unittest(CrasherTest) test.support.reap_children() if __name__ == "__main__": test_main()
lgpl-3.0
[ 3, 6496, 626, 314, 12420, 1192, 315, 314, 8003, 15, 396, 15, 14807, 1192, 2082, 5965, 199, 3, 886, 12420, 314, 12693, 465, 1420, 199, 3, 199, 3, 982, 282, 12420, 281, 365, 6317, 12, 652, 1077, 506, 12155, 25320, 315, 314, 511, 5241, 370, 199, 3, 4868, 652, 32438, 370, 1736, 6657, 14, 199, 199, 646, 2882, 199, 646, 5739, 199, 646, 747, 14, 515, 199, 646, 511, 14, 4058, 199, 504, 511, 14, 1579, 63, 3676, 492, 702, 63, 1548, 63, 5328, 199, 199, 2944, 1179, 3452, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 298, 14807, 1192, 531, 199, 2944, 1179, 3452, 63, 9472, 275, 747, 14, 515, 14, 904, 8, 2944, 1179, 3452, 63, 3022, 12, 298, 4856, 647, 531, 199, 199, 30757, 63, 22412, 275, 2097, 30757, 63, 3813, 63, 264, 14, 647, 401, 298, 78, 27352, 63, 4077, 63, 3122, 63, 807, 14, 647, 937, 199, 199, 533, 30277, 1119, 281, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 2759, 480, 29032, 2295, 787, 4634, 11101, 441, 531, 272, 768, 396, 14, 4058, 14, 67, 1548, 63, 2118, 272, 347, 511, 63, 14807, 1192, 63, 14807, 8, 277, 304, 267, 367, 6748, 315, 5739, 14, 6463, 8, 2944, 1179, 3452, 63, 9472, 304, 288, 340, 747, 14, 515, 14, 4846, 8, 5252, 9, 315, 15258, 63, 22412, 26, 355, 1980, 288, 327, 6601, 298, 14807, 1192, 2, 1454, 6804, 376, 1919, 7830, 2419, 282, 288, 327, 8812, 1879, 14, 24413, 626, 376, 14712, 15955, 14, 288, 340, 511, 14, 4058, 14, 3832, 26, 355, 870, 480, 14740, 12420, 281, 6783, 6748, 9, 288, 702, 63, 1548, 63, 5328, 8, 5252, 9, 421, 199, 318, 511, 63, 973, 837, 272, 511, 14, 4058, 14, 1065, 63, 2796, 8, 17345, 1119, 281, 774, 9, 272, 511, 14, 4058, 14, 264, 439, 63, 3223, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6496, 626, 314, 12420, 1192, 315, 314, 8003, 15, 396, 15, 14807, 1192, 2082, 5965, 199, 3, 886, 12420, 314, 12693, 465, 1420, 199, 3, 199, 3, 982, 282, 12420, 281, 365, 6317, 12, 652, 1077, 506, 12155, 25320, 315, 314, 511, 5241, 370, 199, 3, 4868, 652, 32438, 370, 1736, 6657, 14, 199, 199, 646, 2882, 199, 646, 5739, 199, 646, 747, 14, 515, 199, 646, 511, 14, 4058, 199, 504, 511, 14, 1579, 63, 3676, 492, 702, 63, 1548, 63, 5328, 199, 199, 2944, 1179, 3452, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 298, 14807, 1192, 531, 199, 2944, 1179, 3452, 63, 9472, 275, 747, 14, 515, 14, 904, 8, 2944, 1179, 3452, 63, 3022, 12, 298, 4856, 647, 531, 199, 199, 30757, 63, 22412, 275, 2097, 30757, 63, 3813, 63, 264, 14, 647, 401, 298, 78, 27352, 63, 4077, 63, 3122, 63, 807, 14, 647, 937, 199, 199, 533, 30277, 1119, 281, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 2759, 480, 29032, 2295, 787, 4634, 11101, 441, 531, 272, 768, 396, 14, 4058, 14, 67, 1548, 63, 2118, 272, 347, 511, 63, 14807, 1192, 63, 14807, 8, 277, 304, 267, 367, 6748, 315, 5739, 14, 6463, 8, 2944, 1179, 3452, 63, 9472, 304, 288, 340, 747, 14, 515, 14, 4846, 8, 5252, 9, 315, 15258, 63, 22412, 26, 355, 1980, 288, 327, 6601, 298, 14807, 1192, 2, 1454, 6804, 376, 1919, 7830, 2419, 282, 288, 327, 8812, 1879, 14, 24413, 626, 376, 14712, 15955, 14, 288, 340, 511, 14, 4058, 14, 3832, 26, 355, 870, 480, 14740, 12420, 281, 6783, 6748, 9, 288, 702, 63, 1548, 63, 5328, 8, 5252, 9, 421, 199, 318, 511, 63, 973, 837, 272, 511, 14, 4058, 14, 1065, 63, 2796, 8, 17345, 1119, 281, 774, 9, 272, 511, 14, 4058, 14, 264, 439, 63, 3223, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TuSimple/mxnet
example/sparse/matrix_factorization/data.py
14
2340
# 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 os, logging import mxnet as mx def get_movielens_data(data_dir, prefix): if not os.path.exists(os.path.join(data_dir, "ml-10M100K")): mx.test_utils.get_zip_data(data_dir, "http://files.grouplens.org/datasets/movielens/%s.zip" % prefix, prefix + ".zip") assert os.path.exists(os.path.join(data_dir, "ml-10M100K")) os.system("cd data/ml-10M100K; chmod +x allbut.pl; sh split_ratings.sh; cd -;") def get_movielens_iter(filename, batch_size): """Not particularly fast code to parse the text file and load into NDArrays. return two data iters, one for train, the other for validation. """ logging.info("Preparing data iterators for " + filename + " ... ") user = [] item = [] score = [] with open(filename, 'r') as f: num_samples = 0 for line in f: tks = line.strip().split('::') if len(tks) != 4: continue num_samples += 1 user.append((tks[0])) item.append((tks[1])) score.append((tks[2])) # convert to ndarrays user = mx.nd.array(user, dtype='int32') item = mx.nd.array(item) score = mx.nd.array(score) # prepare data iters data_train = {'user': user, 'item': item} label_train = {'score': score} iter_train = mx.io.NDArrayIter(data=data_train,label=label_train, batch_size=batch_size, shuffle=True) return mx.io.PrefetchingIter(iter_train)
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 747, 12, 2050, 199, 646, 8728, 846, 465, 8728, 199, 199, 318, 664, 63, 10888, 25057, 63, 576, 8, 576, 63, 694, 12, 2403, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 576, 63, 694, 12, 298, 757, 13, 709, 45, 1960, 43, 14150, 267, 8728, 14, 396, 63, 1208, 14, 362, 63, 3065, 63, 576, 8, 576, 63, 694, 12, 3521, 298, 1014, 921, 1725, 14, 923, 25057, 14, 1308, 15, 12281, 15, 10888, 25057, 3149, 83, 14, 3065, 2, 450, 2403, 12, 3521, 2403, 435, 3680, 3065, 531, 267, 702, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 576, 63, 694, 12, 298, 757, 13, 709, 45, 1960, 43, 2237, 267, 747, 14, 2253, 480, 2866, 666, 15, 757, 13, 709, 45, 1960, 43, 27, 30106, 435, 88, 1006, 7911, 14, 1168, 27, 1033, 3715, 63, 17565, 780, 14, 609, 27, 12829, 446, 15027, 199, 199, 318, 664, 63, 10888, 25057, 63, 1661, 8, 1501, 12, 3522, 63, 890, 304, 272, 408, 1763, 6770, 590, 7377, 1233, 370, 2198, 314, 1318, 570, 436, 2248, 1901, 27038, 29033, 14, 272, 372, 2877, 666, 284, 878, 12, 1373, 367, 3560, 12, 314, 1163, 367, 6411, 14, 272, 408, 272, 2050, 14, 815, 480, 2398, 462, 316, 666, 28241, 367, 298, 435, 1788, 435, 298, 2263, 6099, 272, 922, 275, 942, 272, 1242, 275, 942, 272, 5396, 275, 942, 272, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 267, 1967, 63, 3356, 275, 378, 267, 367, 1004, 315, 289, 26, 288, 307, 6080, 275, 1004, 14, 1913, 1252, 1294, 6176, 10993, 288, 340, 822, 8, 2663, 83, 9, 1137, 841, 26, 355, 1980, 288, 1967, 63, 3356, 847, 413, 288, 922, 14, 740, 1332, 2663, 83, 59, 16, 2459, 288, 1242, 14, 740, 1332, 2663, 83, 59, 17, 2459, 288, 5396, 14, 740, 1332, 2663, 83, 59, 18, 2459, 272, 327, 3957, 370, 302, 4460, 4814, 272, 922, 275, 8728, 14, 977, 14, 1144, 8, 751, 12, 2152, 534, 442, 708, 358, 272, 1242, 275, 8728, 14, 977, 14, 1144, 8, 1053, 9, 272, 5396, 275, 8728, 14, 977, 14, 1144, 8, 3397, 9, 272, 327, 9275, 666, 284, 878, 272, 666, 63, 2834, 275, 791, 751, 356, 922, 12, 283, 1053, 356, 1242, 93, 272, 1768, 63, 2834, 275, 791, 3397, 356, 5396, 93, 272, 2740, 63, 2834, 275, 8728, 14, 2308, 14, 8711, 3836, 3315, 8, 576, 29, 576, 63, 2834, 12, 1302, 29, 1302, 63, 2834, 12, 3521, 3522, 63, 890, 29, 2912, 63, 890, 12, 13031, 29, 549, 9, 272, 372, 8728, 14, 2308, 14, 18441, 2367, 316, 3315, 8, 1661, 63, 2834, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 747, 12, 2050, 199, 646, 8728, 846, 465, 8728, 199, 199, 318, 664, 63, 10888, 25057, 63, 576, 8, 576, 63, 694, 12, 2403, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 576, 63, 694, 12, 298, 757, 13, 709, 45, 1960, 43, 14150, 267, 8728, 14, 396, 63, 1208, 14, 362, 63, 3065, 63, 576, 8, 576, 63, 694, 12, 3521, 298, 1014, 921, 1725, 14, 923, 25057, 14, 1308, 15, 12281, 15, 10888, 25057, 3149, 83, 14, 3065, 2, 450, 2403, 12, 3521, 2403, 435, 3680, 3065, 531, 267, 702, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 576, 63, 694, 12, 298, 757, 13, 709, 45, 1960, 43, 2237, 267, 747, 14, 2253, 480, 2866, 666, 15, 757, 13, 709, 45, 1960, 43, 27, 30106, 435, 88, 1006, 7911, 14, 1168, 27, 1033, 3715, 63, 17565, 780, 14, 609, 27, 12829, 446, 15027, 199, 199, 318, 664, 63, 10888, 25057, 63, 1661, 8, 1501, 12, 3522, 63, 890, 304, 272, 408, 1763, 6770, 590, 7377, 1233, 370, 2198, 314, 1318, 570, 436, 2248, 1901, 27038, 29033, 14, 272, 372, 2877, 666, 284, 878, 12, 1373, 367, 3560, 12, 314, 1163, 367, 6411, 14, 272, 408, 272, 2050, 14, 815, 480, 2398, 462, 316, 666, 28241, 367, 298, 435, 1788, 435, 298, 2263, 6099, 272, 922, 275, 942, 272, 1242, 275, 942, 272, 5396, 275, 942, 272, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 267, 1967, 63, 3356, 275, 378, 267, 367, 1004, 315, 289, 26, 288, 307, 6080, 275, 1004, 14, 1913, 1252, 1294, 6176, 10993, 288, 340, 822, 8, 2663, 83, 9, 1137, 841, 26, 355, 1980, 288, 1967, 63, 3356, 847, 413, 288, 922, 14, 740, 1332, 2663, 83, 59, 16, 2459, 288, 1242, 14, 740, 1332, 2663, 83, 59, 17, 2459, 288, 5396, 14, 740, 1332, 2663, 83, 59, 18, 2459, 272, 327, 3957, 370, 302, 4460, 4814, 272, 922, 275, 8728, 14, 977, 14, 1144, 8, 751, 12, 2152, 534, 442, 708, 358, 272, 1242, 275, 8728, 14, 977, 14, 1144, 8, 1053, 9, 272, 5396, 275, 8728, 14, 977, 14, 1144, 8, 3397, 9, 272, 327, 9275, 666, 284, 878, 272, 666, 63, 2834, 275, 791, 751, 356, 922, 12, 283, 1053, 356, 1242, 93, 272, 1768, 63, 2834, 275, 791, 3397, 356, 5396, 93, 272, 2740, 63, 2834, 275, 8728, 14, 2308, 14, 8711, 3836, 3315, 8, 576, 29, 576, 63, 2834, 12, 1302, 29, 1302, 63, 2834, 12, 3521, 3522, 63, 890, 29, 2912, 63, 890, 12, 13031, 29, 549, 9, 272, 372, 8728, 14, 2308, 14, 18441, 2367, 316, 3315, 8, 1661, 63, 2834, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
munnerz/CouchPotatoServer
libs/CodernityDB/hash_index.py
81
33813
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2011-2013 Codernity (http://codernity.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from CodernityDB.index import (Index, IndexException, DocIdNotFound, ElemNotFound, TryReindexException, IndexPreconditionsException) import os import marshal import io import struct import shutil from CodernityDB.storage import IU_Storage, DummyStorage from CodernityDB.env import cdb_environment if cdb_environment.get('rlock_obj'): from CodernityDB import patch patch.patch_cache_rr(cdb_environment['rlock_obj']) from CodernityDB.rr_cache import cache1lvl from CodernityDB.misc import random_hex_32 try: from CodernityDB import __version__ except ImportError: from __init__ import __version__ class IU_HashIndex(Index): """ That class is for Internal Use only, if you want to use HashIndex just subclass the :py:class:`HashIndex` instead this one. That design is because main index logic should be always in database not in custom user indexes. """ def __init__(self, db_path, name, entry_line_format='<32s{key}IIcI', hash_lim=0xfffff, storage_class=None, key_format='c'): """ The index is capable to solve conflicts by `Separate chaining` :param db_path: database path :type db_path: string :param name: index name :type name: ascii string :param line_format: line format, `key_format` parameter value will replace `{key}` if present. :type line_format: string (32s{key}IIcI by default) {doc_id}{hash_key}{start}{size}{status}{next} :param hash_lim: maximum hash functon results (remember about birthday problem) count from 0 :type hash_lim: integer :param storage_class: Storage class by default it will open standard :py:class:`CodernityDB.storage.Storage` (if string has to be accesible by globals()[storage_class]) :type storage_class: class name which will be instance of CodernityDB.storage.Storage instance or None :param key_format: a index key format """ if key_format and '{key}' in entry_line_format: entry_line_format = entry_line_format.replace('{key}', key_format) super(IU_HashIndex, self).__init__(db_path, name) self.hash_lim = hash_lim if not storage_class: storage_class = IU_Storage if storage_class and not isinstance(storage_class, basestring): storage_class = storage_class.__name__ self.storage_class = storage_class self.storage = None self.bucket_line_format = "<I" self.bucket_line_size = struct.calcsize(self.bucket_line_format) self.entry_line_format = entry_line_format self.entry_line_size = struct.calcsize(self.entry_line_format) cache = cache1lvl(100) self._find_key = cache(self._find_key) self._locate_doc_id = cache(self._locate_doc_id) self.bucket_struct = struct.Struct(self.bucket_line_format) self.entry_struct = struct.Struct(self.entry_line_format) self.data_start = ( self.hash_lim + 1) * self.bucket_line_size + self._start_ind + 2 def _fix_params(self): super(IU_HashIndex, self)._fix_params() self.bucket_line_size = struct.calcsize(self.bucket_line_format) self.entry_line_size = struct.calcsize(self.entry_line_format) self.bucket_struct = struct.Struct(self.bucket_line_format) self.entry_struct = struct.Struct(self.entry_line_format) self.data_start = ( self.hash_lim + 1) * self.bucket_line_size + self._start_ind + 2 def open_index(self): if not os.path.isfile(os.path.join(self.db_path, self.name + '_buck')): raise IndexException("Doesn't exists") self.buckets = io.open( os.path.join(self.db_path, self.name + "_buck"), 'r+b', buffering=0) self._fix_params() self._open_storage() def create_index(self): if os.path.isfile(os.path.join(self.db_path, self.name + '_buck')): raise IndexException('Already exists') with io.open(os.path.join(self.db_path, self.name + "_buck"), 'w+b') as f: props = dict(name=self.name, bucket_line_format=self.bucket_line_format, entry_line_format=self.entry_line_format, hash_lim=self.hash_lim, version=self.__version__, storage_class=self.storage_class) f.write(marshal.dumps(props)) self.buckets = io.open( os.path.join(self.db_path, self.name + "_buck"), 'r+b', buffering=0) self._create_storage() def destroy(self): super(IU_HashIndex, self).destroy() self._clear_cache() def _open_storage(self): s = globals()[self.storage_class] if not self.storage: self.storage = s(self.db_path, self.name) self.storage.open() def _create_storage(self): s = globals()[self.storage_class] if not self.storage: self.storage = s(self.db_path, self.name) self.storage.create() # def close_index(self): # self.buckets.flush() # self.buckets.close() # self.storage.close() # @lfu_cache(100) def _find_key(self, key): """ Find the key position :param key: the key to find """ start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) if curr_data: location = self.bucket_struct.unpack(curr_data)[0] if not location: return None, None, 0, 0, 'u' found_at, doc_id, l_key, start, size, status, _next = self._locate_key( key, location) if status == 'd': # when first record from many is deleted while True: found_at, doc_id, l_key, start, size, status, _next = self._locate_key( key, _next) if status != 'd': break return doc_id, l_key, start, size, status else: return None, None, 0, 0, 'u' def _find_key_many(self, key, limit=1, offset=0): location = None start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) if curr_data: location = self.bucket_struct.unpack(curr_data)[0] while offset: if not location: break try: found_at, doc_id, l_key, start, size, status, _next = self._locate_key( key, location) except IndexException: break else: if status != 'd': if l_key == key: # in case of hash function conflicts offset -= 1 location = _next while limit: if not location: break try: found_at, doc_id, l_key, start, size, status, _next = self._locate_key( key, location) except IndexException: break else: if status != 'd': if l_key == key: # in case of hash function conflicts yield doc_id, start, size, status limit -= 1 location = _next def _calculate_position(self, key): return abs(hash(key) & self.hash_lim) * self.bucket_line_size + self._start_ind # TODO add cache! def _locate_key(self, key, start): """ Locate position of the key, it will iterate using `next` field in record until required key will be find. :param key: the key to locate :param start: position to start from """ location = start while True: self.buckets.seek(location) data = self.buckets.read(self.entry_line_size) # todo, maybe partial read there... try: doc_id, l_key, start, size, status, _next = self.entry_struct.unpack(data) except struct.error: raise ElemNotFound( "Not found") # not found but might be also broken if l_key == key: break else: if not _next: # not found raise ElemNotFound("Not found") else: location = _next # go to next record return location, doc_id, l_key, start, size, status, _next # @lfu_cache(100) def _locate_doc_id(self, doc_id, key, start): """ Locate position of the doc_id, it will iterate using `next` field in record until required key will be find. :param doc_id: the doc_id to locate :param key: key value :param start: position to start from """ location = start while True: self.buckets.seek(location) data = self.buckets.read(self.entry_line_size) try: l_doc_id, l_key, start, size, status, _next = self.entry_struct.unpack(data) except: raise DocIdNotFound( "Doc_id '%s' for '%s' not found" % (doc_id, key)) if l_doc_id == doc_id and l_key == key: # added for consistency break else: if not _next: # not found raise DocIdNotFound( "Doc_id '%s' for '%s' not found" % (doc_id, key)) else: location = _next # go to next record return location, doc_id, l_key, start, size, status, _next def _find_place(self, start): """ Find a place to where put the key. It will iterate using `next` field in record, until empty `next` found :param start: position to start from """ location = start while True: self.buckets.seek(location) data = self.buckets.read(self.entry_line_size) # todo, maybe partial read there... doc_id, l_key, start, size, status, _next = self.entry_struct.unpack(data) if not _next or status == 'd': return self.buckets.tell() - self.entry_line_size, doc_id, l_key, start, size, status, _next else: location = _next # go to next record def update(self, doc_id, key, u_start=0, u_size=0, u_status='o'): start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) # test if it's unique or not really unique hash if curr_data: location = self.bucket_struct.unpack(curr_data)[0] else: raise ElemNotFound("Location '%s' not found" % doc_id) found_at, _doc_id, _key, start, size, status, _next = self._locate_doc_id(doc_id, key, location) self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(doc_id, key, u_start, u_size, u_status, _next)) self.flush() self._find_key.delete(key) self._locate_doc_id.delete(doc_id) return True def insert(self, doc_id, key, start, size, status='o'): start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) # conflict occurs? if curr_data: location = self.bucket_struct.unpack(curr_data)[0] else: location = 0 if location: # last key with that hash try: found_at, _doc_id, _key, _start, _size, _status, _next = self._locate_doc_id(doc_id, key, location) except DocIdNotFound: found_at, _doc_id, _key, _start, _size, _status, _next = self._find_place(location) self.buckets.seek(0, 2) wrote_at = self.buckets.tell() self.buckets.write(self.entry_struct.pack(doc_id, key, start, size, status, _next)) # self.flush() self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(_doc_id, _key, _start, _size, _status, wrote_at)) else: self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(doc_id, key, start, size, status, _next)) self.flush() self._locate_doc_id.delete(doc_id) self._find_key.delete(_key) # self._find_key.delete(key) # self._locate_key.delete(_key) return True # raise NotImplementedError else: self.buckets.seek(0, 2) wrote_at = self.buckets.tell() # check if position is bigger than all hash entries... if wrote_at < self.data_start: self.buckets.seek(self.data_start) wrote_at = self.buckets.tell() self.buckets.write(self.entry_struct.pack(doc_id, key, start, size, status, 0)) # self.flush() self._find_key.delete(key) self.buckets.seek(start_position) self.buckets.write(self.bucket_struct.pack(wrote_at)) self.flush() return True def get(self, key): return self._find_key(self.make_key(key)) def get_many(self, key, limit=1, offset=0): return self._find_key_many(self.make_key(key), limit, offset) def all(self, limit=-1, offset=0): self.buckets.seek(self.data_start) while offset: curr_data = self.buckets.read(self.entry_line_size) if not curr_data: break try: doc_id, key, start, size, status, _next = self.entry_struct.unpack(curr_data) except IndexException: break else: if status != 'd': offset -= 1 while limit: curr_data = self.buckets.read(self.entry_line_size) if not curr_data: break try: doc_id, key, start, size, status, _next = self.entry_struct.unpack(curr_data) except IndexException: break else: if status != 'd': yield doc_id, key, start, size, status limit -= 1 def _fix_link(self, key, pos_prev, pos_next): # CHECKIT why I need that hack if pos_prev >= self.data_start: self.buckets.seek(pos_prev) data = self.buckets.read(self.entry_line_size) if data: doc_id, l_key, start, size, status, _next = self.entry_struct.unpack(data) self.buckets.seek(pos_prev) self.buckets.write(self.entry_struct.pack(doc_id, l_key, start, size, status, pos_next)) self.flush() if pos_next: self.buckets.seek(pos_next) data = self.buckets.read(self.entry_line_size) if data: doc_id, l_key, start, size, status, _next = self.entry_struct.unpack(data) self.buckets.seek(pos_next) self.buckets.write(self.entry_struct.pack(doc_id, l_key, start, size, status, _next)) self.flush() return def delete(self, doc_id, key, start=0, size=0): start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) if curr_data: location = self.bucket_struct.unpack(curr_data)[0] else: # case happens when trying to delete element with new index key in data # after adding new index to database without reindex raise TryReindexException() found_at, _doc_id, _key, start, size, status, _next = self._locate_doc_id(doc_id, key, location) self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(doc_id, key, start, size, 'd', _next)) self.flush() # self._fix_link(_key, _prev, _next) self._find_key.delete(key) self._locate_doc_id.delete(doc_id) return True def compact(self, hash_lim=None): if not hash_lim: hash_lim = self.hash_lim compact_ind = self.__class__( self.db_path, self.name + '_compact', hash_lim=hash_lim) compact_ind.create_index() gen = self.all() while True: try: doc_id, key, start, size, status = gen.next() except StopIteration: break self.storage._f.seek(start) value = self.storage._f.read(size) start_ = compact_ind.storage._f.tell() compact_ind.storage._f.write(value) compact_ind.insert(doc_id, key, start_, size, status) compact_ind.close_index() original_name = self.name # os.unlink(os.path.join(self.db_path, self.name + "_buck")) self.close_index() shutil.move(os.path.join(compact_ind.db_path, compact_ind. name + "_buck"), os.path.join(self.db_path, self.name + "_buck")) shutil.move(os.path.join(compact_ind.db_path, compact_ind. name + "_stor"), os.path.join(self.db_path, self.name + "_stor")) # self.name = original_name self.open_index() # reload... self.name = original_name self._save_params(dict(name=original_name)) self._fix_params() self._clear_cache() return True def make_key(self, key): return key def make_key_value(self, data): return '1', data def _clear_cache(self): self._find_key.clear() self._locate_doc_id.clear() def close_index(self): super(IU_HashIndex, self).close_index() self._clear_cache() class IU_UniqueHashIndex(IU_HashIndex): """ Index for *unique* keys! Designed to be a **id** index. That class is for Internal Use only, if you want to use UniqueHashIndex just subclass the :py:class:`UniqueHashIndex` instead this one. That design is because main index logic should be always in database not in custom user indexes. """ def __init__(self, db_path, name, entry_line_format="<32s8sIIcI", *args, **kwargs): if 'key' in kwargs: raise IndexPreconditionsException( "UniqueHashIndex doesn't accept key parameter'") super(IU_UniqueHashIndex, self).__init__(db_path, name, entry_line_format, *args, **kwargs) self.create_key = random_hex_32 # : set the function to create random key when no _id given # self.entry_struct=struct.Struct(entry_line_format) # @lfu_cache(100) def _find_key(self, key): """ Find the key position :param key: the key to find """ start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) if curr_data: location = self.bucket_struct.unpack(curr_data)[0] found_at, l_key, rev, start, size, status, _next = self._locate_key( key, location) return l_key, rev, start, size, status else: return None, None, 0, 0, 'u' def _find_key_many(self, *args, **kwargs): raise NotImplementedError() def _find_place(self, start, key): """ Find a place to where put the key. It will iterate using `next` field in record, until empty `next` found :param start: position to start from """ location = start while True: self.buckets.seek(location) data = self.buckets.read(self.entry_line_size) # todo, maybe partial read there... l_key, rev, start, size, status, _next = self.entry_struct.unpack( data) if l_key == key: raise IndexException("The '%s' key already exists" % key) if not _next or status == 'd': return self.buckets.tell() - self.entry_line_size, l_key, rev, start, size, status, _next else: location = _next # go to next record # @lfu_cache(100) def _locate_key(self, key, start): """ Locate position of the key, it will iterate using `next` field in record until required key will be find. :param key: the key to locate :param start: position to start from """ location = start while True: self.buckets.seek(location) data = self.buckets.read(self.entry_line_size) # todo, maybe partial read there... try: l_key, rev, start, size, status, _next = self.entry_struct.unpack(data) except struct.error: raise ElemNotFound("Location '%s' not found" % key) if l_key == key: break else: if not _next: # not found raise ElemNotFound("Location '%s' not found" % key) else: location = _next # go to next record return self.buckets.tell() - self.entry_line_size, l_key, rev, start, size, status, _next def update(self, key, rev, u_start=0, u_size=0, u_status='o'): start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) # test if it's unique or not really unique hash if curr_data: location = self.bucket_struct.unpack(curr_data)[0] else: raise ElemNotFound("Location '%s' not found" % key) found_at, _key, _rev, start, size, status, _next = self._locate_key( key, location) if u_start == 0: u_start = start if u_size == 0: u_size = size self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(key, rev, u_start, u_size, u_status, _next)) self.flush() self._find_key.delete(key) return True def insert(self, key, rev, start, size, status='o'): start_position = self._calculate_position(key) self.buckets.seek(start_position) curr_data = self.buckets.read(self.bucket_line_size) # conflict occurs? if curr_data: location = self.bucket_struct.unpack(curr_data)[0] else: location = 0 if location: # last key with that hash found_at, _key, _rev, _start, _size, _status, _next = self._find_place( location, key) self.buckets.seek(0, 2) wrote_at = self.buckets.tell() # check if position is bigger than all hash entries... if wrote_at < self.data_start: self.buckets.seek(self.data_start) wrote_at = self.buckets.tell() self.buckets.write(self.entry_struct.pack(key, rev, start, size, status, _next)) # self.flush() self.buckets.seek(found_at) self.buckets.write(self.entry_struct.pack(_key, _rev, _start, _size, _status, wrote_at)) self.flush() self._find_key.delete(_key) # self._locate_key.delete(_key) return True # raise NotImplementedError else: self.buckets.seek(0, 2) wrote_at = self.buckets.tell() # check if position is bigger than all hash entries... if wrote_at < self.data_start: self.buckets.seek(self.data_start) wrote_at = self.buckets.tell() self.buckets.write(self.entry_struct.pack(key, rev, start, size, status, 0)) # self.flush() self.buckets.seek(start_position) self.buckets.write(self.bucket_struct.pack(wrote_at)) self.flush() self._find_key.delete(key) return True def all(self, limit=-1, offset=0): self.buckets.seek(self.data_start) while offset: curr_data = self.buckets.read(self.entry_line_size) if not curr_data: break try: doc_id, rev, start, size, status, next = self.entry_struct.unpack(curr_data) except IndexException: break else: if status != 'd': offset -= 1 while limit: curr_data = self.buckets.read(self.entry_line_size) if not curr_data: break try: doc_id, rev, start, size, status, next = self.entry_struct.unpack(curr_data) except IndexException: break else: if status != 'd': yield doc_id, rev, start, size, status limit -= 1 def get_many(self, *args, **kwargs): raise NotImplementedError() def delete(self, key, start=0, size=0): self.update(key, '00000000', start, size, 'd') def make_key_value(self, data): _id = data['_id'] try: _id = bytes(data['_id']) except: raise IndexPreconditionsException( "_id must be valid string/bytes object") if len(_id) != 32: raise IndexPreconditionsException("Invalid _id lenght") del data['_id'] del data['_rev'] return _id, data def destroy(self): Index.destroy(self) self._clear_cache() def _clear_cache(self): self._find_key.clear() def insert_with_storage(self, _id, _rev, value): if value: start, size = self.storage.insert(value) else: start = 1 size = 0 return self.insert(_id, _rev, start, size) def update_with_storage(self, _id, _rev, value): if value: start, size = self.storage.insert(value) else: start = 1 size = 0 return self.update(_id, _rev, start, size) class DummyHashIndex(IU_HashIndex): def __init__(self, db_path, name, entry_line_format="<32s4sIIcI", *args, **kwargs): super(DummyHashIndex, self).__init__(db_path, name, entry_line_format, *args, **kwargs) self.create_key = random_hex_32 # : set the function to create random key when no _id given # self.entry_struct=struct.Struct(entry_line_format) def update(self, *args, **kwargs): return True def insert(self, *args, **kwargs): return True def all(self, *args, **kwargs): raise StopIteration def get(self, *args, **kwargs): raise ElemNotFound def get_many(self, *args, **kwargs): raise StopIteration def delete(self, *args, **kwargs): pass def make_key_value(self, data): return '1', {'_': 1} def destroy(self): pass def _clear_cache(self): pass def _open_storage(self): if not self.storage: self.storage = DummyStorage() self.storage.open() def _create_storage(self): if not self.storage: self.storage = DummyStorage() self.storage.create() class IU_MultiHashIndex(IU_HashIndex): """ Class that allows to index more than one key per database record. It operates very well on GET/INSERT. It's not optimized for UPDATE operations (will always readd everything) """ def __init__(self, *args, **kwargs): super(IU_MultiHashIndex, self).__init__(*args, **kwargs) def insert(self, doc_id, key, start, size, status='o'): if isinstance(key, (list, tuple)): key = set(key) elif not isinstance(key, set): key = set([key]) ins = super(IU_MultiHashIndex, self).insert for curr_key in key: ins(doc_id, curr_key, start, size, status) return True def update(self, doc_id, key, u_start, u_size, u_status='o'): if isinstance(key, (list, tuple)): key = set(key) elif not isinstance(key, set): key = set([key]) upd = super(IU_MultiHashIndex, self).update for curr_key in key: upd(doc_id, curr_key, u_start, u_size, u_status) def delete(self, doc_id, key, start=0, size=0): if isinstance(key, (list, tuple)): key = set(key) elif not isinstance(key, set): key = set([key]) delete = super(IU_MultiHashIndex, self).delete for curr_key in key: delete(doc_id, curr_key, start, size) def get(self, key): return super(IU_MultiHashIndex, self).get(key) def make_key_value(self, data): raise NotImplementedError() # classes for public use, done in this way because of # generation static files with indexes (_index directory) class HashIndex(IU_HashIndex): """ That class is designed to be used in custom indexes. """ pass class UniqueHashIndex(IU_UniqueHashIndex): """ That class is designed to be used in custom indexes. It's designed to be **id** index. """ pass class MultiHashIndex(IU_MultiHashIndex): """ That class is designed to be used in custom indexes. """
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 7760, 13, 6965, 5495, 11641, 1209, 334, 1014, 921, 2693, 78, 1209, 14, 957, 9, 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, 421, 199, 504, 5495, 11641, 1209, 2846, 14, 1080, 492, 334, 2681, 12, 3044, 5499, 1726, 12, 3044, 5454, 1304, 4667, 12, 3044, 662, 3701, 4667, 12, 3044, 7649, 497, 1080, 1726, 12, 3044, 5499, 2398, 9855, 1726, 9, 199, 199, 646, 747, 199, 646, 21985, 199, 646, 5890, 199, 646, 2702, 199, 646, 5145, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 3494, 492, 473, 53, 63, 6408, 12, 9762, 6408, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 1813, 492, 286, 697, 63, 5418, 199, 199, 692, 286, 697, 63, 5418, 14, 362, 360, 82, 831, 63, 1113, 735, 272, 687, 5495, 11641, 1209, 2846, 492, 3371, 272, 3371, 14, 2068, 63, 1637, 63, 9734, 8, 24035, 63, 5418, 459, 82, 831, 63, 1113, 1105, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 9734, 63, 1637, 492, 2581, 17, 27803, 421, 199, 504, 5495, 11641, 1209, 2846, 14, 9923, 492, 2196, 63, 4097, 63, 708, 199, 199, 893, 26, 272, 687, 5495, 11641, 1209, 2846, 492, 636, 1023, 363, 199, 2590, 3545, 26, 272, 687, 636, 826, 363, 492, 636, 1023, 363, 421, 199, 533, 473, 53, 63, 3476, 2681, 8, 2681, 304, 272, 408, 272, 10314, 1021, 365, 367, 12624, 3645, 1454, 12, 340, 1265, 2934, 370, 675, 16101, 2681, 2951, 5516, 314, 520, 647, 26, 533, 1705, 3476, 2681, 64, 3140, 642, 1373, 14, 339, 10314, 12899, 365, 2952, 2446, 1478, 9661, 1077, 506, 3544, 315, 3050, 440, 315, 3537, 922, 10507, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1592, 63, 515, 12, 536, 12, 2397, 63, 604, 63, 908, 15829, 708, 83, 91, 498, 93, 8921, 67, 41, 297, 2631, 63, 4175, 29, 16, 3581, 18190, 12, 4887, 63, 533, 29, 403, 12, 790, 63, 908, 534, 67, 735, 267, 408, 267, 710, 1478, 365, 4021, 461, 370, 14241, 18511, 701, 658, 12653, 323, 6036, 316, 64, 267, 520, 635, 1592, 63, 515, 26, 3050, 931, 267, 520, 466, 1592, 63, 515, 26, 1059, 267, 520, 635, 536, 26, 1478, 536, 267, 520, 466, 536, 26, 13294, 1059, 267, 520, 635, 1004, 63, 908, 26, 1004, 1475, 12, 658, 498, 63, 908, 64, 2725, 574, 911, 3350, 658, 91, 498, 23485, 340, 3451, 14, 267, 520, 466, 1004, 63, 908, 26, 1059, 334, 708, 83, 91, 498, 93, 8921, 67, 41, 701, 849, 9, 469, 1301, 63, 344, 8847, 2227, 63, 498, 8847, 928, 8847, 890, 8847, 1205, 8847, 2184, 93, 267, 520, 635, 2631, 63, 4175, 26, 5696, 2631, 289, 4638, 265, 2058, 334, 264, 1114, 3595, 21036, 2977, 5160, 9, 2338, 687, 378, 267, 520, 466, 2631, 63, 4175, 26, 3000, 267, 520, 635, 4887, 63, 533, 26, 10533, 1021, 701, 849, 652, 911, 1551, 4465, 520, 647, 26, 533, 1705, 3034, 11641, 1209, 2846, 14, 3494, 14, 6408, 64, 334, 692, 1059, 965, 370, 506, 1066, 301, 1164, 701, 7992, 3430, 3494, 63, 533, 566, 267, 520, 466, 4887, 63, 533, 26, 1021, 536, 1314, 911, 506, 1256, 402, 5495, 11641, 1209, 2846, 14, 3494, 14, 6408, 1256, 503, 488, 267, 520, 635, 790, 63, 908, 26, 282, 1478, 790, 1475, 267, 408, 267, 340, 790, 63, 908, 436, 5041, 498, 6834, 315, 2397, 63, 604, 63, 908, 26, 288, 2397, 63, 604, 63, 908, 275, 2397, 63, 604, 63, 908, 14, 1814, 11117, 498, 7293, 790, 63, 908, 9, 267, 1613, 8, 41, 53, 63, 3476, 2681, 12, 291, 2843, 826, 721, 697, 63, 515, 12, 536, 9, 267, 291, 14, 2227, 63, 4175, 275, 2631, 63, 4175, 267, 340, 440, 4887, 63, 533, 26, 288, 4887, 63, 533, 275, 473, 53, 63, 6408, 267, 340, 4887, 63, 533, 436, 440, 1228, 8, 3494, 63, 533, 12, 7116, 304, 288, 4887, 63, 533, 275, 4887, 63, 533, 855, 354, 363, 267, 291, 14, 3494, 63, 533, 275, 4887, 63, 533, 267, 291, 14, 3494, 275, 488, 398, 291, 14, 4623, 63, 604, 63, 908, 275, 3886, 41, 2, 267, 291, 14, 4623, 63, 604, 63, 890, 275, 2702, 14, 21691, 8, 277, 14, 4623, 63, 604, 63, 908, 9, 267, 291, 14, 2373, 63, 604, 63, 908, 275, 2397, 63, 604, 63, 908, 267, 291, 14, 2373, 63, 604, 63, 890, 275, 2702, 14, 21691, 8, 277, 14, 2373, 63, 604, 63, 908, 9, 398, 2581, 275, 2581, 17, 27803, 8, 1960, 9, 267, 291, 423, 1623, 63, 498, 275, 2581, 8, 277, 423, 1623, 63, 498, 9, 267, 291, 423, 6280, 63, 1301, 63, 344, 275, 2581, 8, 277, 423, 6280, 63, 1301, 63, 344, 9, 267, 291, 14, 4623, 63, 1820, 275, 2702, 14, 4836, 8, 277, 14, 4623, 63, 604, 63, 908, 9, 267, 291, 14, 2373, 63, 1820, 275, 2702, 14, 4836, 8, 277, 14, 2373, 63, 604, 63, 908, 9, 267, 291, 14, 576, 63, 928, 275, 334, 288, 291, 14, 2227, 63, 4175, 435, 413, 9, 627, 291, 14, 4623, 63, 604, 63, 890, 435, 291, 423, 928, 63, 688, 435, 499, 339, 347, 485, 970, 63, 1162, 8, 277, 304, 267, 1613, 8, 41, 53, 63, 3476, 2681, 12, 291, 10445, 970, 63, 1162, 342, 267, 291, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 7760, 13, 6965, 5495, 11641, 1209, 334, 1014, 921, 2693, 78, 1209, 14, 957, 9, 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, 421, 199, 504, 5495, 11641, 1209, 2846, 14, 1080, 492, 334, 2681, 12, 3044, 5499, 1726, 12, 3044, 5454, 1304, 4667, 12, 3044, 662, 3701, 4667, 12, 3044, 7649, 497, 1080, 1726, 12, 3044, 5499, 2398, 9855, 1726, 9, 199, 199, 646, 747, 199, 646, 21985, 199, 646, 5890, 199, 646, 2702, 199, 646, 5145, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 3494, 492, 473, 53, 63, 6408, 12, 9762, 6408, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 1813, 492, 286, 697, 63, 5418, 199, 199, 692, 286, 697, 63, 5418, 14, 362, 360, 82, 831, 63, 1113, 735, 272, 687, 5495, 11641, 1209, 2846, 492, 3371, 272, 3371, 14, 2068, 63, 1637, 63, 9734, 8, 24035, 63, 5418, 459, 82, 831, 63, 1113, 1105, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 9734, 63, 1637, 492, 2581, 17, 27803, 421, 199, 504, 5495, 11641, 1209, 2846, 14, 9923, 492, 2196, 63, 4097, 63, 708, 199, 199, 893, 26, 272, 687, 5495, 11641, 1209, 2846, 492, 636, 1023, 363, 199, 2590, 3545, 26, 272, 687, 636, 826, 363, 492, 636, 1023, 363, 421, 199, 533, 473, 53, 63, 3476, 2681, 8, 2681, 304, 272, 408, 272, 10314, 1021, 365, 367, 12624, 3645, 1454, 12, 340, 1265, 2934, 370, 675, 16101, 2681, 2951, 5516, 314, 520, 647, 26, 533, 1705, 3476, 2681, 64, 3140, 642, 1373, 14, 339, 10314, 12899, 365, 2952, 2446, 1478, 9661, 1077, 506, 3544, 315, 3050, 440, 315, 3537, 922, 10507, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1592, 63, 515, 12, 536, 12, 2397, 63, 604, 63, 908, 15829, 708, 83, 91, 498, 93, 8921, 67, 41, 297, 2631, 63, 4175, 29, 16, 3581, 18190, 12, 4887, 63, 533, 29, 403, 12, 790, 63, 908, 534, 67, 735, 267, 408, 267, 710, 1478, 365, 4021, 461, 370, 14241, 18511, 701, 658, 12653, 323, 6036, 316, 64, 267, 520, 635, 1592, 63, 515, 26, 3050, 931, 267, 520, 466, 1592, 63, 515, 26, 1059, 267, 520, 635, 536, 26, 1478, 536, 267, 520, 466, 536, 26, 13294, 1059, 267, 520, 635, 1004, 63, 908, 26, 1004, 1475, 12, 658, 498, 63, 908, 64, 2725, 574, 911, 3350, 658, 91, 498, 23485, 340, 3451, 14, 267, 520, 466, 1004, 63, 908, 26, 1059, 334, 708, 83, 91, 498, 93, 8921, 67, 41, 701, 849, 9, 469, 1301, 63, 344, 8847, 2227, 63, 498, 8847, 928, 8847, 890, 8847, 1205, 8847, 2184, 93, 267, 520, 635, 2631, 63, 4175, 26, 5696, 2631, 289, 4638, 265, 2058, 334, 264, 1114, 3595, 21036, 2977, 5160, 9, 2338, 687, 378, 267, 520, 466, 2631, 63, 4175, 26, 3000, 267, 520, 635, 4887, 63, 533, 26, 10533, 1021, 701, 849, 652, 911, 1551, 4465, 520, 647, 26, 533, 1705, 3034, 11641, 1209, 2846, 14, 3494, 14, 6408, 64, 334, 692, 1059, 965, 370, 506, 1066, 301, 1164, 701, 7992, 3430, 3494, 63, 533, 566, 267, 520, 466, 4887, 63, 533, 26, 1021, 536, 1314, 911, 506, 1256, 402, 5495, 11641, 1209, 2846, 14, 3494, 14, 6408, 1256, 503, 488, 267, 520, 635, 790, 63, 908, 26, 282, 1478, 790, 1475, 267, 408, 267, 340, 790, 63, 908, 436, 5041, 498, 6834, 315, 2397, 63, 604, 63, 908, 26, 288, 2397, 63, 604, 63, 908, 275, 2397, 63, 604, 63, 908, 14, 1814, 11117, 498, 7293, 790, 63, 908, 9, 267, 1613, 8, 41, 53, 63, 3476, 2681, 12, 291, 2843, 826, 721, 697, 63, 515, 12, 536, 9, 267, 291, 14, 2227, 63, 4175, 275, 2631, 63, 4175, 267, 340, 440, 4887, 63, 533, 26, 288, 4887, 63, 533, 275, 473, 53, 63, 6408, 267, 340, 4887, 63, 533, 436, 440, 1228, 8, 3494, 63, 533, 12, 7116, 304, 288, 4887, 63, 533, 275, 4887, 63, 533, 855, 354, 363, 267, 291, 14, 3494, 63, 533, 275, 4887, 63, 533, 267, 291, 14, 3494, 275, 488, 398, 291, 14, 4623, 63, 604, 63, 908, 275, 3886, 41, 2, 267, 291, 14, 4623, 63, 604, 63, 890, 275, 2702, 14, 21691, 8, 277, 14, 4623, 63, 604, 63, 908, 9, 267, 291, 14, 2373, 63, 604, 63, 908, 275, 2397, 63, 604, 63, 908, 267, 291, 14, 2373, 63, 604, 63, 890, 275, 2702, 14, 21691, 8, 277, 14, 2373, 63, 604, 63, 908, 9, 398, 2581, 275, 2581, 17, 27803, 8, 1960, 9, 267, 291, 423, 1623, 63, 498, 275, 2581, 8, 277, 423, 1623, 63, 498, 9, 267, 291, 423, 6280, 63, 1301, 63, 344, 275, 2581, 8, 277, 423, 6280, 63, 1301, 63, 344, 9, 267, 291, 14, 4623, 63, 1820, 275, 2702, 14, 4836, 8, 277, 14, 4623, 63, 604, 63, 908, 9, 267, 291, 14, 2373, 63, 1820, 275, 2702, 14, 4836, 8, 277, 14, 2373, 63, 604, 63, 908, 9, 267, 291, 14, 576, 63, 928, 275, 334, 288, 291, 14, 2227, 63, 4175, 435, 413, 9, 627, 291, 14, 4623, 63, 604, 63, 890, 435, 291, 423, 928, 63, 688, 435, 499, 339,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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 ]
csmengwan/autorest
AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/operations/availability_sets.py
5
3247
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.pipeline import ClientRawResponse from msrest.exceptions import HttpOperationError from .. import models class AvailabilitySets(object): """AvailabilitySets operations. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An objec model deserializer. """ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self.config = config def update( self, resource_group_name, avset, tags, custom_headers={}, raw=False, **operation_config): """ Updates the tags for an availability set. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param avset: The name of the storage availability set. :type avset: str :param tags: :type tags: dict :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ tags1 = models.AvailabilitySetUpdateParameters(tags=tags) # Construct URL url = '/parameterFlattening/{resourceGroupName}/{availabilitySetName}' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'availabilitySetName': self._serialize.url("avset", avset, 'str', max_length=80) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(tags1, 'AvailabilitySetUpdateParameters') # Construct and send request request = self._client.patch(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 7379, 492, 6810, 28973, 199, 504, 6605, 3911, 14, 3924, 492, 4760, 3632, 5263, 199, 199, 504, 2508, 492, 1709, 421, 199, 533, 16599, 7615, 9899, 8, 785, 304, 272, 408, 26462, 9899, 5331, 14, 339, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 1559, 825, 1402, 30237, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 398, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 398, 291, 14, 888, 275, 1101, 339, 347, 1678, 8, 288, 291, 12, 2073, 63, 923, 63, 354, 12, 2289, 409, 12, 3762, 12, 3537, 63, 2139, 10324, 3066, 29, 797, 12, 1011, 5735, 63, 888, 304, 267, 408, 267, 24663, 314, 3762, 367, 376, 14962, 663, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 2289, 409, 26, 710, 536, 402, 314, 4887, 14962, 663, 14, 267, 520, 466, 2289, 409, 26, 620, 267, 520, 635, 3762, 26, 267, 520, 466, 3762, 26, 1211, 267, 520, 635, 1211, 3537, 63, 2139, 26, 2323, 626, 911, 506, 3483, 370, 314, 1056, 267, 520, 635, 2155, 3066, 26, 2529, 314, 4125, 1177, 3180, 2441, 314, 268, 13256, 1177, 267, 520, 635, 3439, 63, 888, 26, 520, 1121, 1705, 6044, 2897, 268, 10580, 28, 25427, 26, 1419, 509, 8170, 14943, 267, 520, 4500, 26, 488, 267, 520, 4500, 26, 520, 533, 1705, 3041, 28973, 28, 25427, 14, 7379, 14, 3041, 28973, 8637, 268, 340, 3066, 29, 2052, 267, 408, 267, 3762, 17, 275, 1709, 14, 26462, 1084, 4152, 5976, 8, 2969, 29, 2969, 9, 398, 327, 9215, 2851, 267, 1166, 275, 1994, 5329, 29302, 316, 5321, 22023, 16152, 11856, 1084, 985, 6834, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 11856, 1084, 985, 356, 291, 423, 3549, 14, 633, 480, 1214, 409, 401, 2289, 409, 12, 283, 495, 297, 1390, 63, 1267, 29, 1257, 9, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 267, 1406, 63, 3214, 459, 2714, 13, 804, 418, 275, 283, 3578, 15, 1001, 27, 5960, 29, 1624, 13, 24, 7, 267, 340, 3537, 63, 2139, 26, 288, 1406, 63, 3214, 14, 873, 8, 4229, 63, 2139, 9, 398, 327, 9215, 2396, 267, 2396, 63, 1317, 275, 291, 423, 3549, 14, 2030, 8, 2969, 17, 12, 283, 26462, 1084, 4152, 5976, 358, 398, 327, 9215, 436, 3222, 1056, 267, 1056, 275, 291, 423, 1258, 14, 2068, 8, 633, 12, 1827, 63, 3214, 9, 267, 1177, 275, 291, 423, 1258, 14, 2254, 8, 288, 1056, 12, 1406, 63, 3214, 12, 2396, 63, 1317, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 1840, 2189, 288, 746, 4760, 3632, 5263, 8, 277, 423, 11143, 12, 1177, 9, 398, 340, 3066, 26, 288, 1890, 63, 1773, 63, 1310, 275, 6810, 28973, 8, 403, 12, 1177, 9, 288, 372, 1890, 63, 1773, 63, 1310, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 7379, 492, 6810, 28973, 199, 504, 6605, 3911, 14, 3924, 492, 4760, 3632, 5263, 199, 199, 504, 2508, 492, 1709, 421, 199, 533, 16599, 7615, 9899, 8, 785, 304, 272, 408, 26462, 9899, 5331, 14, 339, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 1559, 825, 1402, 30237, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 398, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 398, 291, 14, 888, 275, 1101, 339, 347, 1678, 8, 288, 291, 12, 2073, 63, 923, 63, 354, 12, 2289, 409, 12, 3762, 12, 3537, 63, 2139, 10324, 3066, 29, 797, 12, 1011, 5735, 63, 888, 304, 267, 408, 267, 24663, 314, 3762, 367, 376, 14962, 663, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 2289, 409, 26, 710, 536, 402, 314, 4887, 14962, 663, 14, 267, 520, 466, 2289, 409, 26, 620, 267, 520, 635, 3762, 26, 267, 520, 466, 3762, 26, 1211, 267, 520, 635, 1211, 3537, 63, 2139, 26, 2323, 626, 911, 506, 3483, 370, 314, 1056, 267, 520, 635, 2155, 3066, 26, 2529, 314, 4125, 1177, 3180, 2441, 314, 268, 13256, 1177, 267, 520, 635, 3439, 63, 888, 26, 520, 1121, 1705, 6044, 2897, 268, 10580, 28, 25427, 26, 1419, 509, 8170, 14943, 267, 520, 4500, 26, 488, 267, 520, 4500, 26, 520, 533, 1705, 3041, 28973, 28, 25427, 14, 7379, 14, 3041, 28973, 8637, 268, 340, 3066, 29, 2052, 267, 408, 267, 3762, 17, 275, 1709, 14, 26462, 1084, 4152, 5976, 8, 2969, 29, 2969, 9, 398, 327, 9215, 2851, 267, 1166, 275, 1994, 5329, 29302, 316, 5321, 22023, 16152, 11856, 1084, 985, 6834, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 11856, 1084, 985, 356, 291, 423, 3549, 14, 633, 480, 1214, 409, 401, 2289, 409, 12, 283, 495, 297, 1390, 63, 1267, 29, 1257, 9, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 267, 1406, 63, 3214, 459, 2714, 13, 804, 418, 275, 283, 3578, 15, 1001, 27, 5960, 29, 1624, 13, 24, 7, 267, 340, 3537, 63, 2139, 26, 288, 1406, 63, 3214, 14, 873, 8, 4229, 63, 2139, 9, 398, 327, 9215, 2396, 267, 2396, 63, 1317, 275, 291, 423, 3549, 14, 2030, 8, 2969, 17, 12, 283, 26462, 1084, 4152, 5976, 358, 398, 327, 9215, 436, 3222, 1056, 267, 1056, 275, 291, 423, 1258, 14, 2068, 8, 633, 12, 1827, 63, 3214, 9, 267, 1177, 275, 291, 423, 1258, 14, 2254, 8, 288, 1056, 12, 1406, 63, 3214, 12, 2396, 63, 1317, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 1840, 2189, 288, 746, 4760, 3632, 5263, 8, 277, 423, 11143, 12, 1177, 9, 398, 340, 3066, 26, 288, 1890, 63, 1773, 63, 1310, 275, 6810, 28973, 8, 403, 12, 1177, 9, 288, 372, 1890, 63, 1773, 63, 1310, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
girving/tensorflow
tensorflow/contrib/distributions/python/kernel_tests/vector_sinh_arcsinh_diag_test.py
25
10036
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for VectorSinhArcsinhDiag.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.contrib import distributions from tensorflow.contrib.distributions.python.ops import test_util from tensorflow.python.platform import test ds = distributions rng = np.random.RandomState(123) class VectorSinhArcsinhDiagTest(test_util.VectorDistributionTestHelpers, test.TestCase): def test_default_is_same_as_normal(self): d = 10 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(1.0) loc = rng.randn(d) with self.cached_session() as sess: norm = ds.MultivariateNormalDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, validate_args=True) sasnorm = ds.VectorSinhArcsinhDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, validate_args=True) x = rng.randn(5, d) norm_pdf, sasnorm_pdf = sess.run([norm.prob(x), sasnorm.prob(x)]) self.assertAllClose(norm_pdf, sasnorm_pdf) norm_samps, sasnorm_samps = sess.run( [norm.sample(10000, seed=0), sasnorm.sample(10000, seed=0)]) self.assertAllClose(loc, sasnorm_samps.mean(axis=0), atol=0.1) self.assertAllClose( norm_samps.mean(axis=0), sasnorm_samps.mean(axis=0), atol=0.1) self.assertAllClose( norm_samps.std(axis=0), sasnorm_samps.std(axis=0), atol=0.1) def test_passing_in_laplace_plus_defaults_is_same_as_laplace(self): d = 10 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(1.2) loc = rng.randn(d) with self.cached_session() as sess: vlap = ds.VectorLaplaceDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, validate_args=True) sasvlap = ds.VectorSinhArcsinhDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, distribution=ds.Laplace(np.float64(0.), np.float64(1.)), validate_args=True) x = rng.randn(5, d) vlap_pdf, sasvlap_pdf = sess.run([vlap.prob(x), sasvlap.prob(x)]) self.assertAllClose(vlap_pdf, sasvlap_pdf) vlap_samps, sasvlap_samps = sess.run( [vlap.sample(10000, seed=0), sasvlap.sample(10000, seed=0)]) self.assertAllClose(loc, sasvlap_samps.mean(axis=0), atol=0.1) self.assertAllClose( vlap_samps.mean(axis=0), sasvlap_samps.mean(axis=0), atol=0.1) self.assertAllClose( vlap_samps.std(axis=0), sasvlap_samps.std(axis=0), atol=0.1) def test_tailweight_small_gives_fewer_outliers_than_normal(self): d = 10 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(0.9) loc = rng.randn(d) with self.cached_session() as sess: norm = ds.MultivariateNormalDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, validate_args=True) sasnorm = ds.VectorSinhArcsinhDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, tailweight=0.1, validate_args=True) # sasnorm.pdf(x) is smaller on outliers (+-10 are outliers) x = np.float64([[-10] * d, [10] * d]) # Shape [2, 10] norm_lp, sasnorm_lp = sess.run([norm.log_prob(x), sasnorm.log_prob(x)]) np.testing.assert_array_less(sasnorm_lp, norm_lp) # 0.1% quantile and 99.9% quantile are outliers, and should be more # extreme in the normal. The 97.772% quantiles should be the same. norm_samps, sasnorm_samps = sess.run( [norm.sample(int(5e5), seed=1), sasnorm.sample(int(5e5), seed=1)]) np.testing.assert_array_less( np.percentile(norm_samps, 0.1, axis=0), np.percentile(sasnorm_samps, 0.1, axis=0)) np.testing.assert_array_less( np.percentile(sasnorm_samps, 99.9, axis=0), np.percentile(norm_samps, 99.9, axis=0)) # 100. * sp.stats.norm.cdf(2.) q = 100 * 0.97724986805182079 self.assertAllClose( np.percentile(sasnorm_samps, q, axis=0), np.percentile(norm_samps, q, axis=0), rtol=0.03) self.assertAllClose( np.percentile(sasnorm_samps, 100 - q, axis=0), np.percentile(norm_samps, 100 - q, axis=0), rtol=0.03) def test_tailweight_large_gives_more_outliers_than_normal(self): d = 10 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(1.0) loc = rng.randn(d) with self.cached_session() as sess: norm = ds.MultivariateNormalDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, validate_args=True) sasnorm = ds.VectorSinhArcsinhDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, tailweight=3., validate_args=True) # norm.pdf(x) is smaller on outliers (+-10 are outliers) x = np.float64([[-10] * d, [10] * d]) # Shape [2, 10] norm_lp, sasnorm_lp = sess.run([norm.log_prob(x), sasnorm.log_prob(x)]) np.testing.assert_array_less(norm_lp, sasnorm_lp) # 0.1% quantile and 99.9% quantile are outliers, and should be more # extreme in the sasnormal. The 97.772% quantiles should be the same. norm_samps, sasnorm_samps = sess.run( [norm.sample(int(5e5), seed=2), sasnorm.sample(int(5e5), seed=2)]) np.testing.assert_array_less( np.percentile(sasnorm_samps, 0.1, axis=0), np.percentile(norm_samps, 0.1, axis=0)) np.testing.assert_array_less( np.percentile(norm_samps, 99.9, axis=0), np.percentile(sasnorm_samps, 99.9, axis=0)) # 100. * sp.stats.norm.cdf(2.) q = 100 * 0.97724986805182079 self.assertAllClose( np.percentile(sasnorm_samps, q, axis=0), np.percentile(norm_samps, q, axis=0), rtol=0.03) self.assertAllClose( np.percentile(sasnorm_samps, 100 - q, axis=0), np.percentile(norm_samps, 100 - q, axis=0), rtol=0.03) def test_positive_skewness_moves_mean_to_the_right(self): d = 10 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(1.0) loc = rng.randn(d) with self.cached_session() as sess: sasnorm = ds.VectorSinhArcsinhDiag( loc=loc, scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, skewness=3.0, validate_args=True) sasnorm_samps = sess.run(sasnorm.sample(10000, seed=4)) np.testing.assert_array_less(loc, sasnorm_samps.mean(axis=0)) def test_consistency_random_parameters_with_batch_dim(self): b, d = 5, 2 scale_diag = rng.rand(b, d) scale_identity_multiplier = np.float64(1.1) with self.cached_session() as sess: sasnorm = ds.VectorSinhArcsinhDiag( scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, skewness=rng.randn(d) * 0.5, tailweight=rng.rand(b, d) + 0.7, validate_args=True) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=0., rtol=0.1) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=-0.15, rtol=0.1) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=0.15, rtol=0.1) def test_consistency_random_parameters_no_batch_dims(self): d = 3 scale_diag = rng.rand(d) scale_identity_multiplier = np.float64(1.1) with self.cached_session() as sess: sasnorm = ds.VectorSinhArcsinhDiag( scale_diag=scale_diag, scale_identity_multiplier=scale_identity_multiplier, skewness=rng.randn(d) * 0.5, tailweight=rng.rand(d) + 0.7, validate_args=True) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=0., rtol=0.1) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=-0.15, rtol=0.1) self.run_test_sample_consistent_log_prob( sess.run, sasnorm, radius=1.0, center=0.15, rtol=0.1) def test_pdf_reflected_for_negative_skewness(self): with self.cached_session() as sess: sas_pos_skew = ds.VectorSinhArcsinhDiag( loc=[0.], scale_identity_multiplier=1., skewness=2., validate_args=True) sas_neg_skew = ds.VectorSinhArcsinhDiag( loc=[0.], scale_identity_multiplier=1., skewness=-2., validate_args=True) x = np.linspace(-2, 2, num=5).astype(np.float32).reshape(5, 1) self.assertAllClose( *sess.run([sas_pos_skew.prob(x), sas_neg_skew.prob(x[::-1])])) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 11388, 51, 17695, 27604, 15831, 16094, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 3228, 14, 2828, 492, 10208, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 795, 275, 10208, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 4288, 9, 421, 199, 533, 11388, 51, 17695, 27604, 15831, 16094, 774, 8, 396, 63, 1974, 14, 3646, 8580, 774, 4433, 83, 12, 1816, 511, 14, 1746, 304, 819, 347, 511, 63, 885, 63, 374, 63, 7191, 63, 305, 63, 3302, 8, 277, 304, 272, 366, 275, 1616, 272, 4666, 63, 6706, 275, 9038, 14, 3759, 8, 68, 9, 272, 4666, 63, 5582, 63, 15812, 275, 980, 14, 1609, 772, 8, 17, 14, 16, 9, 272, 4355, 275, 9038, 14, 10843, 8, 68, 9, 272, 543, 291, 14, 5245, 63, 1730, 342, 465, 4043, 26, 489, 6316, 275, 6364, 14, 3947, 13805, 6241, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 489, 26336, 4791, 275, 6364, 14, 3646, 51, 17695, 27604, 15831, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 2541, 671, 275, 9038, 14, 10843, 8, 21, 12, 366, 9, 489, 6316, 63, 5607, 12, 26336, 4791, 63, 5607, 275, 4043, 14, 1065, 779, 4791, 14, 6101, 8, 88, 395, 26336, 4791, 14, 6101, 8, 88, 3948, 489, 291, 14, 7260, 8, 4791, 63, 5607, 12, 26336, 4791, 63, 5607, 9, 2541, 6316, 63, 2231, 13408, 12, 26336, 4791, 63, 2231, 13408, 275, 4043, 14, 1065, 8, 881, 359, 4791, 14, 3271, 8, 9943, 12, 6347, 29, 16, 395, 1779, 26336, 4791, 14, 3271, 8, 9943, 12, 6347, 29, 16, 3948, 489, 291, 14, 7260, 8, 2102, 12, 26336, 4791, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 6316, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 26336, 4791, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 6316, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 26336, 4791, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 819, 347, 511, 63, 29436, 63, 262, 63, 416, 2778, 63, 6666, 63, 4322, 63, 374, 63, 7191, 63, 305, 63, 416, 2778, 8, 277, 304, 272, 366, 275, 1616, 272, 4666, 63, 6706, 275, 9038, 14, 3759, 8, 68, 9, 272, 4666, 63, 5582, 63, 15812, 275, 980, 14, 1609, 772, 8, 17, 14, 18, 9, 272, 4355, 275, 9038, 14, 10843, 8, 68, 9, 272, 543, 291, 14, 5245, 63, 1730, 342, 465, 4043, 26, 489, 373, 4762, 275, 6364, 14, 3646, 44, 439, 1071, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 489, 26336, 86, 4762, 275, 6364, 14, 3646, 51, 17695, 27604, 15831, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4084, 29, 795, 14, 44, 439, 1071, 8, 1590, 14, 1609, 772, 8, 16, 15631, 980, 14, 1609, 772, 8, 17, 14, 1826, 881, 4107, 63, 589, 29, 549, 9, 2541, 671, 275, 9038, 14, 10843, 8, 21, 12, 366, 9, 489, 373, 4762, 63, 5607, 12, 26336, 86, 4762, 63, 5607, 275, 4043, 14, 1065, 779, 86, 4762, 14, 6101, 8, 88, 395, 26336, 86, 4762, 14, 6101, 8, 88, 3948, 489, 291, 14, 7260, 8, 86, 4762, 63, 5607, 12, 26336, 86, 4762, 63, 5607, 9, 2541, 373, 4762, 63, 2231, 13408, 12, 26336, 86, 4762, 63, 2231, 13408, 275, 4043, 14, 1065, 8, 881, 359, 86, 4762, 14, 3271, 8, 9943, 12, 6347, 29, 16, 395, 1779, 26336, 86, 4762, 14, 3271, 8, 9943, 12, 6347, 29, 16, 3948, 489, 291, 14, 7260, 8, 2102, 12, 26336, 86, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 373, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 26336, 86, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 373, 4762, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 26336, 86, 4762, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 819, 347, 511, 63, 1521, 3463, 63, 7241, 63, 71, 7602, 63, 70, 546, 281, 63, 28622, 63, 13797, 63, 3302 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 11388, 51, 17695, 27604, 15831, 16094, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 3228, 14, 2828, 492, 10208, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 795, 275, 10208, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 4288, 9, 421, 199, 533, 11388, 51, 17695, 27604, 15831, 16094, 774, 8, 396, 63, 1974, 14, 3646, 8580, 774, 4433, 83, 12, 1816, 511, 14, 1746, 304, 819, 347, 511, 63, 885, 63, 374, 63, 7191, 63, 305, 63, 3302, 8, 277, 304, 272, 366, 275, 1616, 272, 4666, 63, 6706, 275, 9038, 14, 3759, 8, 68, 9, 272, 4666, 63, 5582, 63, 15812, 275, 980, 14, 1609, 772, 8, 17, 14, 16, 9, 272, 4355, 275, 9038, 14, 10843, 8, 68, 9, 272, 543, 291, 14, 5245, 63, 1730, 342, 465, 4043, 26, 489, 6316, 275, 6364, 14, 3947, 13805, 6241, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 489, 26336, 4791, 275, 6364, 14, 3646, 51, 17695, 27604, 15831, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 2541, 671, 275, 9038, 14, 10843, 8, 21, 12, 366, 9, 489, 6316, 63, 5607, 12, 26336, 4791, 63, 5607, 275, 4043, 14, 1065, 779, 4791, 14, 6101, 8, 88, 395, 26336, 4791, 14, 6101, 8, 88, 3948, 489, 291, 14, 7260, 8, 4791, 63, 5607, 12, 26336, 4791, 63, 5607, 9, 2541, 6316, 63, 2231, 13408, 12, 26336, 4791, 63, 2231, 13408, 275, 4043, 14, 1065, 8, 881, 359, 4791, 14, 3271, 8, 9943, 12, 6347, 29, 16, 395, 1779, 26336, 4791, 14, 3271, 8, 9943, 12, 6347, 29, 16, 3948, 489, 291, 14, 7260, 8, 2102, 12, 26336, 4791, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 6316, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 26336, 4791, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 6316, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 26336, 4791, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 819, 347, 511, 63, 29436, 63, 262, 63, 416, 2778, 63, 6666, 63, 4322, 63, 374, 63, 7191, 63, 305, 63, 416, 2778, 8, 277, 304, 272, 366, 275, 1616, 272, 4666, 63, 6706, 275, 9038, 14, 3759, 8, 68, 9, 272, 4666, 63, 5582, 63, 15812, 275, 980, 14, 1609, 772, 8, 17, 14, 18, 9, 272, 4355, 275, 9038, 14, 10843, 8, 68, 9, 272, 543, 291, 14, 5245, 63, 1730, 342, 465, 4043, 26, 489, 373, 4762, 275, 6364, 14, 3646, 44, 439, 1071, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4107, 63, 589, 29, 549, 9, 489, 26336, 86, 4762, 275, 6364, 14, 3646, 51, 17695, 27604, 15831, 16094, 8, 881, 4355, 29, 2102, 12, 881, 4666, 63, 6706, 29, 3467, 63, 6706, 12, 881, 4666, 63, 5582, 63, 15812, 29, 3467, 63, 5582, 63, 15812, 12, 881, 4084, 29, 795, 14, 44, 439, 1071, 8, 1590, 14, 1609, 772, 8, 16, 15631, 980, 14, 1609, 772, 8, 17, 14, 1826, 881, 4107, 63, 589, 29, 549, 9, 2541, 671, 275, 9038, 14, 10843, 8, 21, 12, 366, 9, 489, 373, 4762, 63, 5607, 12, 26336, 86, 4762, 63, 5607, 275, 4043, 14, 1065, 779, 86, 4762, 14, 6101, 8, 88, 395, 26336, 86, 4762, 14, 6101, 8, 88, 3948, 489, 291, 14, 7260, 8, 86, 4762, 63, 5607, 12, 26336, 86, 4762, 63, 5607, 9, 2541, 373, 4762, 63, 2231, 13408, 12, 26336, 86, 4762, 63, 2231, 13408, 275, 4043, 14, 1065, 8, 881, 359, 86, 4762, 14, 3271, 8, 9943, 12, 6347, 29, 16, 395, 1779, 26336, 86, 4762, 14, 3271, 8, 9943, 12, 6347, 29, 16, 3948, 489, 291, 14, 7260, 8, 2102, 12, 26336, 86, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 373, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 26336, 86, 4762, 63, 2231, 13408, 14, 3670, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 489, 291, 14, 7260, 8, 881, 373, 4762, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 26336, 86, 4762, 63, 2231, 13408, 14, 1516, 8, 3127, 29, 16, 395, 9543, 29, 16, 14, 17, 9, 819, 347, 511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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 ]
jamezpolley/pip
pip/_vendor/html5lib/serializer/htmlserializer.py
436
12855
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type try: from functools import reduce except ImportError: pass from ..constants import voidElements, booleanAttributes, spaceCharacters from ..constants import rcdataElements, entities, xmlEntities from .. import utils from xml.sax.saxutils import escape spaceCharacters = "".join(spaceCharacters) try: from codecs import register_error, xmlcharrefreplace_errors except ImportError: unicode_encode_errors = "strict" else: unicode_encode_errors = "htmlentityreplace" encode_entity_map = {} is_ucs4 = len("\U0010FFFF") == 1 for k, v in list(entities.items()): # skip multi-character entities if ((is_ucs4 and len(v) > 1) or (not is_ucs4 and len(v) > 2)): continue if v != "&": if len(v) == 2: v = utils.surrogatePairToCodepoint(v) else: v = ord(v) if v not in encode_entity_map or k.islower(): # prefer &lt; over &LT; and similarly for &amp;, &gt;, etc. encode_entity_map[v] = k def htmlentityreplace_errors(exc): if isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError)): res = [] codepoints = [] skip = False for i, c in enumerate(exc.object[exc.start:exc.end]): if skip: skip = False continue index = i + exc.start if utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]): codepoint = utils.surrogatePairToCodepoint(exc.object[index:index + 2]) skip = True else: codepoint = ord(c) codepoints.append(codepoint) for cp in codepoints: e = encode_entity_map.get(cp) if e: res.append("&") res.append(e) if not e.endswith(";"): res.append(";") else: res.append("&#x%s;" % (hex(cp)[2:])) return ("".join(res), exc.end) else: return xmlcharrefreplace_errors(exc) register_error(unicode_encode_errors, htmlentityreplace_errors) del register_error class HTMLSerializer(object): # attribute quoting options quote_attr_values = False quote_char = '"' use_best_quote_char = True # tag syntax options omit_optional_tags = True minimize_boolean_attributes = True use_trailing_solidus = False space_before_trailing_solidus = True # escaping options escape_lt_in_attrs = False escape_rcdata = False resolve_entities = True # miscellaneous options alphabetical_attributes = False inject_meta_charset = True strip_whitespace = False sanitize = False options = ("quote_attr_values", "quote_char", "use_best_quote_char", "omit_optional_tags", "minimize_boolean_attributes", "use_trailing_solidus", "space_before_trailing_solidus", "escape_lt_in_attrs", "escape_rcdata", "resolve_entities", "alphabetical_attributes", "inject_meta_charset", "strip_whitespace", "sanitize") def __init__(self, **kwargs): """Initialize HTMLSerializer. Keyword options (default given first unless specified) include: inject_meta_charset=True|False Whether it insert a meta element to define the character set of the document. quote_attr_values=True|False Whether to quote attribute values that don't require quoting per HTML5 parsing rules. quote_char=u'"'|u"'" Use given quote character for attribute quoting. Default is to use double quote unless attribute value contains a double quote, in which case single quotes are used instead. escape_lt_in_attrs=False|True Whether to escape < in attribute values. escape_rcdata=False|True Whether to escape characters that need to be escaped within normal elements within rcdata elements such as style. resolve_entities=True|False Whether to resolve named character entities that appear in the source tree. The XML predefined entities &lt; &gt; &amp; &quot; &apos; are unaffected by this setting. strip_whitespace=False|True Whether to remove semantically meaningless whitespace. (This compresses all whitespace to a single space except within pre.) minimize_boolean_attributes=True|False Shortens boolean attributes to give just the attribute value, for example <input disabled="disabled"> becomes <input disabled>. use_trailing_solidus=False|True Includes a close-tag slash at the end of the start tag of void elements (empty elements whose end tag is forbidden). E.g. <hr/>. space_before_trailing_solidus=True|False Places a space immediately before the closing slash in a tag using a trailing solidus. E.g. <hr />. Requires use_trailing_solidus. sanitize=False|True Strip all unsafe or unknown constructs from output. See `html5lib user documentation`_ omit_optional_tags=True|False Omit start/end tags that are optional. alphabetical_attributes=False|True Reorder attributes to be in alphabetical order. .. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation """ if 'quote_char' in kwargs: self.use_best_quote_char = False for attr in self.options: setattr(self, attr, kwargs.get(attr, getattr(self, attr))) self.errors = [] self.strict = False def encode(self, string): assert(isinstance(string, text_type)) if self.encoding: return string.encode(self.encoding, unicode_encode_errors) else: return string def encodeStrict(self, string): assert(isinstance(string, text_type)) if self.encoding: return string.encode(self.encoding, "strict") else: return string def serialize(self, treewalker, encoding=None): self.encoding = encoding in_cdata = False self.errors = [] if encoding and self.inject_meta_charset: from ..filters.inject_meta_charset import Filter treewalker = Filter(treewalker, encoding) # WhitespaceFilter should be used before OptionalTagFilter # for maximum efficiently of this latter filter if self.strip_whitespace: from ..filters.whitespace import Filter treewalker = Filter(treewalker) if self.sanitize: from ..filters.sanitizer import Filter treewalker = Filter(treewalker) if self.omit_optional_tags: from ..filters.optionaltags import Filter treewalker = Filter(treewalker) # Alphabetical attributes must be last, as other filters # could add attributes and alter the order if self.alphabetical_attributes: from ..filters.alphabeticalattributes import Filter treewalker = Filter(treewalker) for token in treewalker: type = token["type"] if type == "Doctype": doctype = "<!DOCTYPE %s" % token["name"] if token["publicId"]: doctype += ' PUBLIC "%s"' % token["publicId"] elif token["systemId"]: doctype += " SYSTEM" if token["systemId"]: if token["systemId"].find('"') >= 0: if token["systemId"].find("'") >= 0: self.serializeError("System identifer contains both single and double quote characters") quote_char = "'" else: quote_char = '"' doctype += " %s%s%s" % (quote_char, token["systemId"], quote_char) doctype += ">" yield self.encodeStrict(doctype) elif type in ("Characters", "SpaceCharacters"): if type == "SpaceCharacters" or in_cdata: if in_cdata and token["data"].find("</") >= 0: self.serializeError("Unexpected </ in CDATA") yield self.encode(token["data"]) else: yield self.encode(escape(token["data"])) elif type in ("StartTag", "EmptyTag"): name = token["name"] yield self.encodeStrict("<%s" % name) if name in rcdataElements and not self.escape_rcdata: in_cdata = True elif in_cdata: self.serializeError("Unexpected child element of a CDATA element") for (attr_namespace, attr_name), attr_value in token["data"].items(): # TODO: Add namespace support here k = attr_name v = attr_value yield self.encodeStrict(' ') yield self.encodeStrict(k) if not self.minimize_boolean_attributes or \ (k not in booleanAttributes.get(name, tuple()) and k not in booleanAttributes.get("", tuple())): yield self.encodeStrict("=") if self.quote_attr_values or not v: quote_attr = True else: quote_attr = reduce(lambda x, y: x or (y in v), spaceCharacters + ">\"'=", False) v = v.replace("&", "&amp;") if self.escape_lt_in_attrs: v = v.replace("<", "&lt;") if quote_attr: quote_char = self.quote_char if self.use_best_quote_char: if "'" in v and '"' not in v: quote_char = '"' elif '"' in v and "'" not in v: quote_char = "'" if quote_char == "'": v = v.replace("'", "&#39;") else: v = v.replace('"', "&quot;") yield self.encodeStrict(quote_char) yield self.encode(v) yield self.encodeStrict(quote_char) else: yield self.encode(v) if name in voidElements and self.use_trailing_solidus: if self.space_before_trailing_solidus: yield self.encodeStrict(" /") else: yield self.encodeStrict("/") yield self.encode(">") elif type == "EndTag": name = token["name"] if name in rcdataElements: in_cdata = False elif in_cdata: self.serializeError("Unexpected child element of a CDATA element") yield self.encodeStrict("</%s>" % name) elif type == "Comment": data = token["data"] if data.find("--") >= 0: self.serializeError("Comment contains --") yield self.encodeStrict("<!--%s-->" % token["data"]) elif type == "Entity": name = token["name"] key = name + ";" if key not in entities: self.serializeError("Entity %s not recognized" % name) if self.resolve_entities and key not in xmlEntities: data = entities[key] else: data = "&%s;" % name yield self.encodeStrict(data) else: self.serializeError(token["data"]) def render(self, treewalker, encoding=None): if encoding: return b"".join(list(self.serialize(treewalker, encoding))) else: return "".join(list(self.serialize(treewalker))) def serializeError(self, data="XXX ERROR MESSAGE NEEDED"): # XXX The idea is to make data mandatory. self.errors.append(data) if self.strict: raise SerializeError def SerializeError(Exception): """Error in serialized tree""" pass
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 7305, 423, 9884, 14, 4174, 492, 1318, 63, 466, 199, 199, 893, 26, 272, 687, 9143, 492, 7114, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 2508, 5559, 492, 2309, 6255, 12, 5046, 5379, 12, 25431, 199, 504, 2508, 5559, 492, 4819, 576, 6255, 12, 9045, 12, 2748, 24672, 199, 504, 2508, 492, 3778, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 4772, 199, 199, 2638, 9272, 275, 10587, 904, 8, 2638, 9272, 9, 199, 199, 893, 26, 272, 687, 6010, 492, 2274, 63, 705, 12, 2748, 24253, 1814, 63, 2550, 199, 2590, 3545, 26, 272, 2649, 63, 2143, 63, 2550, 275, 298, 4768, 2, 199, 2836, 26, 272, 2649, 63, 2143, 63, 2550, 275, 298, 15575, 552, 1701, 1814, 2, 339, 3752, 63, 4502, 63, 1130, 275, 1052, 272, 365, 63, 23880, 20, 275, 822, 4582, 53, 17657, 6968, 531, 508, 413, 272, 367, 1022, 12, 373, 315, 769, 8, 8327, 14, 1744, 5109, 267, 327, 3372, 3510, 13, 10856, 9045, 267, 340, 3666, 374, 63, 23880, 20, 436, 822, 8, 86, 9, 690, 413, 9, 503, 355, 334, 1397, 365, 63, 23880, 20, 436, 822, 8, 86, 9, 690, 499, 2298, 288, 1980, 267, 340, 373, 1137, 11746, 582, 288, 340, 822, 8, 86, 9, 508, 499, 26, 355, 373, 275, 3778, 14, 16380, 12882, 1378, 3034, 1403, 8, 86, 9, 288, 587, 26, 355, 373, 275, 6206, 8, 86, 9, 288, 340, 373, 440, 315, 3752, 63, 4502, 63, 1130, 503, 1022, 14, 374, 2325, 837, 355, 327, 16602, 1253, 4116, 27, 1806, 1253, 17090, 27, 436, 8545, 590, 367, 1253, 5282, 27031, 1253, 3308, 27031, 5423, 14, 355, 3752, 63, 4502, 63, 1130, 59, 86, 61, 275, 1022, 339, 347, 30010, 552, 1701, 1814, 63, 2550, 8, 2804, 304, 267, 340, 1228, 8, 2804, 12, 334, 7087, 19994, 12, 6140, 18355, 547, 2298, 288, 522, 275, 942, 288, 1233, 3438, 275, 942, 288, 3372, 275, 756, 288, 367, 284, 12, 286, 315, 3874, 8, 2804, 14, 785, 59, 2804, 14, 928, 26, 2804, 14, 500, 4682, 355, 340, 3372, 26, 490, 3372, 275, 756, 490, 1980, 355, 1478, 275, 284, 435, 3178, 14, 928, 355, 340, 3778, 14, 374, 11762, 13095, 12882, 8, 2804, 14, 785, 59, 1080, 26, 827, 779, 2804, 14, 500, 12, 1478, 435, 499, 566, 4682, 490, 1233, 1403, 275, 3778, 14, 16380, 12882, 1378, 3034, 1403, 8, 2804, 14, 785, 59, 1080, 26, 1080, 435, 499, 566, 490, 3372, 275, 715, 355, 587, 26, 490, 1233, 1403, 275, 6206, 8, 67, 9, 355, 1233, 3438, 14, 740, 8, 19300, 9, 288, 367, 7667, 315, 1233, 3438, 26, 355, 325, 275, 3752, 63, 4502, 63, 1130, 14, 362, 8, 1850, 9, 355, 340, 325, 26, 490, 522, 14, 740, 22077, 531, 490, 522, 14, 740, 8, 69, 9, 490, 340, 440, 325, 14, 4130, 480, 27, 2349, 717, 522, 14, 740, 480, 15027, 355, 587, 26, 490, 522, 14, 740, 480, 7997, 88, 5, 83, 9426, 450, 334, 4097, 8, 1850, 2788, 18, 16720, 288, 372, 334, 25148, 904, 8, 470, 395, 3178, 14, 500, 9, 267, 587, 26, 288, 372, 2748, 24253, 1814, 63, 2550, 8, 2804, 9, 339, 2274, 63, 705, 8, 2975, 63, 2143, 63, 2550, 12, 30010, 552, 1701, 1814, 63, 2550, 9, 339, 2150, 2274, 63, 705, 421, 199, 533, 4163, 7299, 8, 785, 304, 339, 327, 2225, 18593, 1511, 272, 6313, 63, 962, 63, 1459, 275, 756, 272, 6313, 63, 1560, 275, 14788, 272, 675, 63, 7010, 63, 3513, 63, 1560, 275, 715, 339, 327, 1947, 6302, 1511, 272, 19413, 63, 4144, 63, 2969, 275, 715, 272, 24720, 63, 4871, 63, 2987, 275, 715, 272, 675, 63, 15910, 63, 18533, 527, 275, 756, 272, 4601, 63, 5182, 63, 15910, 63, 18533, 527, 275, 715, 339, 327, 21375, 1511, 272, 4772, 63, 4116, 63, 262, 63, 3288, 275, 756, 272, 4772, 63, 1195, 576, 275, 756, 272, 7512, 63, 8327, 275, 715, 339, 327, 3201, 19549, 1511, 272, 23331, 3294, 63, 2987, 275, 756, 272, 16182, 63, 2024, 63, 6043, 275, 715, 272, 6202, 63, 8506, 275, 756, 272, 21077, 275, 756, 339, 1511, 275, 1689, 3513, 63, 962, 63, 1459, 401, 298, 3513, 63, 1560, 401, 298, 1180, 63, 7010, 63, 3513, 63, 1560, 401, 2049, 298, 19007, 63, 4144, 63, 2969, 401, 298, 19333, 63, 4871, 63, 2987, 401, 2049, 298, 1180, 63, 15910, 63, 18533, 527, 401, 298, 2638, 63, 5182, 63, 15910, 63, 18533, 527, 401, 2049, 298, 3765, 63, 4116, 63, 262, 63, 3288, 401, 298, 3765, 63, 1195, 576, 401, 298, 6983, 63, 8327, 401, 2049, 298, 10305, 7570, 3294, 63, 2987, 401, 298, 14815, 63, 2024, 63, 6043, 401, 2049, 298, 1913, 63, 8506, 401, 298, 18177, 531, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 408, 9345, 4163, 7299, 14, 398, 6431, 1511, 334, 885, 1627, 1642, 7444, 2013, 9, 2387, 26, 398, 16182, 63, 2024, 63, 6043, 29, 549, 92, 797, 881, 7480, 652, 5518, 282, 3404, 1819, 370, 5627, 314, 4528, 663, 402, 314, 881, 2213, 14, 267, 6313, 63, 962, 63, 1459, 29, 549, 92, 797, 881, 7480, 370, 6313, 2225, 1338, 626, 2793, 1133, 4409, 18593, 881, 1126, 4163, 21, 6057, 4713, 14, 267, 6313, 63, 1560, 29, 85, 4065, 17018, 85, 2, 4065, 881, 3645, 1627, 6313, 4528, 367, 2225, 18593, 14, 3758, 365, 370, 881, 675, 4270, 6313, 7444, 2225, 574, 3509, 282, 4270, 6313, 12, 881, 315, 1314, 1930, 2849, 9344, 787, 1202, 3140, 14, 267, 4772, 63, 4116, 63, 262, 63, 3288, 29, 797, 92, 549, 881, 7480, 370, 4772, 665, 315, 2225, 1338, 14, 267, 4772, 63, 1195, 576, 29, 797, 92, 549, 881, 7480, 370, 4772, 4110, 626, 1929, 370, 506, 11077, 4453, 3293, 881, 4008, 4453, 4819, 576, 4008, 4066, 465, 3449, 14, 267, 7512, 63, 8327, 29, 549, 92, 797, 881, 7480, 370, 7512, 4310, 4528, 9045, 626, 7468, 315, 314, 881, 1350, 3123, 14, 710, 4692, 27684, 9045, 1253, 4116, 27, 1253, 3308, 27, 1253, 5282, 27, 1253, 5184 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 7305, 423, 9884, 14, 4174, 492, 1318, 63, 466, 199, 199, 893, 26, 272, 687, 9143, 492, 7114, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 2508, 5559, 492, 2309, 6255, 12, 5046, 5379, 12, 25431, 199, 504, 2508, 5559, 492, 4819, 576, 6255, 12, 9045, 12, 2748, 24672, 199, 504, 2508, 492, 3778, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 4772, 199, 199, 2638, 9272, 275, 10587, 904, 8, 2638, 9272, 9, 199, 199, 893, 26, 272, 687, 6010, 492, 2274, 63, 705, 12, 2748, 24253, 1814, 63, 2550, 199, 2590, 3545, 26, 272, 2649, 63, 2143, 63, 2550, 275, 298, 4768, 2, 199, 2836, 26, 272, 2649, 63, 2143, 63, 2550, 275, 298, 15575, 552, 1701, 1814, 2, 339, 3752, 63, 4502, 63, 1130, 275, 1052, 272, 365, 63, 23880, 20, 275, 822, 4582, 53, 17657, 6968, 531, 508, 413, 272, 367, 1022, 12, 373, 315, 769, 8, 8327, 14, 1744, 5109, 267, 327, 3372, 3510, 13, 10856, 9045, 267, 340, 3666, 374, 63, 23880, 20, 436, 822, 8, 86, 9, 690, 413, 9, 503, 355, 334, 1397, 365, 63, 23880, 20, 436, 822, 8, 86, 9, 690, 499, 2298, 288, 1980, 267, 340, 373, 1137, 11746, 582, 288, 340, 822, 8, 86, 9, 508, 499, 26, 355, 373, 275, 3778, 14, 16380, 12882, 1378, 3034, 1403, 8, 86, 9, 288, 587, 26, 355, 373, 275, 6206, 8, 86, 9, 288, 340, 373, 440, 315, 3752, 63, 4502, 63, 1130, 503, 1022, 14, 374, 2325, 837, 355, 327, 16602, 1253, 4116, 27, 1806, 1253, 17090, 27, 436, 8545, 590, 367, 1253, 5282, 27031, 1253, 3308, 27031, 5423, 14, 355, 3752, 63, 4502, 63, 1130, 59, 86, 61, 275, 1022, 339, 347, 30010, 552, 1701, 1814, 63, 2550, 8, 2804, 304, 267, 340, 1228, 8, 2804, 12, 334, 7087, 19994, 12, 6140, 18355, 547, 2298, 288, 522, 275, 942, 288, 1233, 3438, 275, 942, 288, 3372, 275, 756, 288, 367, 284, 12, 286, 315, 3874, 8, 2804, 14, 785, 59, 2804, 14, 928, 26, 2804, 14, 500, 4682, 355, 340, 3372, 26, 490, 3372, 275, 756, 490, 1980, 355, 1478, 275, 284, 435, 3178, 14, 928, 355, 340, 3778, 14, 374, 11762, 13095, 12882, 8, 2804, 14, 785, 59, 1080, 26, 827, 779, 2804, 14, 500, 12, 1478, 435, 499, 566, 4682, 490, 1233, 1403, 275, 3778, 14, 16380, 12882, 1378, 3034, 1403, 8, 2804, 14, 785, 59, 1080, 26, 1080, 435, 499, 566, 490, 3372, 275, 715, 355, 587, 26, 490, 1233, 1403, 275, 6206, 8, 67, 9, 355, 1233, 3438, 14, 740, 8, 19300, 9, 288, 367, 7667, 315, 1233, 3438, 26, 355, 325, 275, 3752, 63, 4502, 63, 1130, 14, 362, 8, 1850, 9, 355, 340, 325, 26, 490, 522, 14, 740, 22077, 531, 490, 522, 14, 740, 8, 69, 9, 490, 340, 440, 325, 14, 4130, 480, 27, 2349, 717, 522, 14, 740, 480, 15027, 355, 587, 26, 490, 522, 14, 740, 480, 7997, 88, 5, 83, 9426, 450, 334, 4097, 8, 1850, 2788, 18, 16720, 288, 372, 334, 25148, 904, 8, 470, 395, 3178, 14, 500, 9, 267, 587, 26, 288, 372, 2748, 24253, 1814, 63, 2550, 8, 2804, 9, 339, 2274, 63, 705, 8, 2975, 63, 2143, 63, 2550, 12, 30010, 552, 1701, 1814, 63, 2550, 9, 339, 2150, 2274, 63, 705, 421, 199, 533, 4163, 7299, 8, 785, 304, 339, 327, 2225, 18593, 1511, 272, 6313, 63, 962, 63, 1459, 275, 756, 272, 6313, 63, 1560, 275, 14788, 272, 675, 63, 7010, 63, 3513, 63, 1560, 275, 715, 339, 327, 1947, 6302, 1511, 272, 19413, 63, 4144, 63, 2969, 275, 715, 272, 24720, 63, 4871, 63, 2987, 275, 715, 272, 675, 63, 15910, 63, 18533, 527, 275, 756, 272, 4601, 63, 5182, 63, 15910, 63, 18533, 527, 275, 715, 339, 327, 21375, 1511, 272, 4772, 63, 4116, 63, 262, 63, 3288, 275, 756, 272, 4772, 63, 1195, 576, 275, 756, 272, 7512, 63, 8327, 275, 715, 339, 327, 3201, 19549, 1511, 272, 23331, 3294, 63, 2987, 275, 756, 272, 16182, 63, 2024, 63, 6043, 275, 715, 272, 6202, 63, 8506, 275, 756, 272, 21077, 275, 756, 339, 1511, 275, 1689, 3513, 63, 962, 63, 1459, 401, 298, 3513, 63, 1560, 401, 298, 1180, 63, 7010, 63, 3513, 63, 1560, 401, 2049, 298, 19007, 63, 4144, 63, 2969, 401, 298, 19333, 63, 4871, 63, 2987, 401, 2049, 298, 1180, 63, 15910, 63, 18533, 527, 401, 298, 2638, 63, 5182, 63, 15910, 63, 18533, 527, 401, 2049, 298, 3765, 63, 4116, 63, 262, 63, 3288, 401, 298, 3765, 63, 1195, 576, 401, 298, 6983, 63, 8327, 401, 2049, 298, 10305, 7570, 3294, 63, 2987, 401, 298, 14815, 63, 2024, 63, 6043, 401, 2049, 298, 1913, 63, 8506, 401, 298, 18177, 531, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 408, 9345, 4163, 7299, 14, 398, 6431, 1511, 334, 885, 1627, 1642, 7444, 2013, 9, 2387, 26, 398, 16182, 63, 2024, 63, 6043, 29, 549, 92, 797, 881, 7480, 652, 5518, 282, 3404, 1819, 370, 5627, 314, 4528, 663, 402, 314, 881, 2213, 14, 267, 6313, 63, 962, 63, 1459, 29, 549, 92, 797, 881, 7480, 370, 6313, 2225, 1338, 626, 2793, 1133, 4409, 18593, 881, 1126, 4163, 21, 6057, 4713, 14, 267, 6313, 63, 1560, 29, 85, 4065, 17018, 85, 2, 4065, 881, 3645, 1627, 6313, 4528, 367, 2225, 18593, 14, 3758, 365, 370, 881, 675, 4270, 6313, 7444, 2225, 574, 3509, 282, 4270, 6313, 12, 881, 315, 1314, 1930, 2849, 9344, 787, 1202, 3140, 14, 267, 4772, 63, 4116, 63, 262, 63, 3288, 29, 797, 92, 549, 881, 7480, 370, 4772, 665, 315, 2225, 1338, 14, 267, 4772, 63, 1195, 576, 29, 797, 92, 549, 881, 7480, 370, 4772, 4110, 626, 1929, 370, 506, 11077, 4453, 3293, 881, 4008, 4453, 4819, 576, 4008, 4066, 465, 3449, 14, 267, 7512, 63, 8327, 29, 549, 92, 797, 881, 7480, 370, 7512, 4310, 4528, 9045, 626, 7468, 315, 314, 881, 1350, 3123, 14, 710, 4692, 27684, 9045, 1253, 4116, 27, 1253, 3308, 27, 1253, 5282, 27, 1253, 5184, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
citrix-openstack-build/oslo.concurrency
oslo/concurrency/openstack/common/fixture/logging.py
73
1117
# 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 fixtures def get_logging_handle_error_fixture(): """returns a fixture to make logging raise formatting exceptions. Usage: self.useFixture(logging.get_logging_handle_error_fixture()) """ return fixtures.MonkeyPatch('logging.Handler.handleError', _handleError) def _handleError(self, record): """Monkey patch for logging.Handler.handleError. The default handleError just logs the error to stderr but we want the option of actually raising an exception. """ raise
apache-2.0
[ 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 15188, 421, 199, 318, 664, 63, 4806, 63, 2479, 63, 705, 63, 5997, 837, 272, 408, 5808, 282, 10949, 370, 1852, 2050, 746, 10803, 4967, 14, 339, 11028, 26, 272, 291, 14, 31015, 8, 4806, 14, 362, 63, 4806, 63, 2479, 63, 705, 63, 5997, 1012, 272, 408, 272, 372, 15188, 14, 6671, 498, 11173, 360, 4806, 14, 2461, 14, 2479, 547, 297, 1816, 485, 2479, 547, 9, 421, 199, 318, 485, 2479, 547, 8, 277, 12, 2777, 304, 272, 408, 6671, 498, 3371, 367, 2050, 14, 2461, 14, 2479, 547, 14, 339, 710, 849, 2429, 547, 2951, 9610, 314, 1125, 370, 4635, 1325, 781, 2934, 272, 314, 945, 402, 5965, 17026, 376, 1919, 14, 272, 408, 272, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 15188, 421, 199, 318, 664, 63, 4806, 63, 2479, 63, 705, 63, 5997, 837, 272, 408, 5808, 282, 10949, 370, 1852, 2050, 746, 10803, 4967, 14, 339, 11028, 26, 272, 291, 14, 31015, 8, 4806, 14, 362, 63, 4806, 63, 2479, 63, 705, 63, 5997, 1012, 272, 408, 272, 372, 15188, 14, 6671, 498, 11173, 360, 4806, 14, 2461, 14, 2479, 547, 297, 1816, 485, 2479, 547, 9, 421, 199, 318, 485, 2479, 547, 8, 277, 12, 2777, 304, 272, 408, 6671, 498, 3371, 367, 2050, 14, 2461, 14, 2479, 547, 14, 339, 710, 849, 2429, 547, 2951, 9610, 314, 1125, 370, 4635, 1325, 781, 2934, 272, 314, 945, 402, 5965, 17026, 376, 1919, 14, 272, 408, 272, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
vyos/wpa
wpa_supplicant/examples/wpas-dbus-new-getall.py
114
1742
#!/usr/bin/python import dbus import sys, os import time import gobject def main(): bus = dbus.SystemBus() wpas_obj = bus.get_object("fi.w1.wpa_supplicant1", "/fi/w1/wpa_supplicant1") props = wpas_obj.GetAll("fi.w1.wpa_supplicant1", dbus_interface=dbus.PROPERTIES_IFACE) print "GetAll(fi.w1.wpa_supplicant1, /fi/w1/wpa_supplicant1):" print props if len(sys.argv) != 2: os._exit(1) ifname = sys.argv[1] wpas = dbus.Interface(wpas_obj, "fi.w1.wpa_supplicant1") path = wpas.GetInterface(ifname) if_obj = bus.get_object("fi.w1.wpa_supplicant1", path) props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface", dbus_interface=dbus.PROPERTIES_IFACE) print print "GetAll(fi.w1.wpa_supplicant1.Interface, %s):" % (path) print props props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface.WPS", dbus_interface=dbus.PROPERTIES_IFACE) print print "GetAll(fi.w1.wpa_supplicant1.Interface.WPS, %s):" % (path) print props res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'BSSs', dbus_interface=dbus.PROPERTIES_IFACE) if len(res) > 0: bss_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0]) props = bss_obj.GetAll("fi.w1.wpa_supplicant1.BSS", dbus_interface=dbus.PROPERTIES_IFACE) print print "GetAll(fi.w1.wpa_supplicant1.BSS, %s):" % (res[0]) print props res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'Networks', dbus_interface=dbus.PROPERTIES_IFACE) if len(res) > 0: net_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0]) props = net_obj.GetAll("fi.w1.wpa_supplicant1.Network", dbus_interface=dbus.PROPERTIES_IFACE) print print "GetAll(fi.w1.wpa_supplicant1.Network, %s):" % (res[0]) print props if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 21140, 199, 646, 984, 12, 747, 199, 646, 900, 199, 646, 25595, 199, 199, 318, 2446, 837, 199, 198, 5610, 275, 21140, 14, 3989, 12106, 342, 199, 198, 14649, 305, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 1871, 221, 3286, 329, 15, 87, 17, 15, 87, 387, 63, 8621, 606, 867, 17, 531, 199, 198, 6750, 275, 336, 15534, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 1585, 198, 17066, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 12, 1182, 329, 15, 87, 17, 15, 87, 387, 63, 8621, 606, 867, 17, 304, 2, 199, 198, 1361, 10792, 421, 198, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 507, 198, 736, 423, 2224, 8, 17, 9, 421, 198, 30702, 275, 984, 14, 3020, 59, 17, 61, 421, 198, 14649, 305, 275, 21140, 14, 4267, 8, 14649, 305, 63, 1113, 12, 298, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 531, 199, 198, 515, 275, 336, 15534, 14, 32109, 8, 30702, 9, 199, 198, 692, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 931, 9, 199, 198, 6750, 275, 340, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 1585, 420, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 12, 450, 83, 304, 2, 450, 334, 515, 9, 199, 198, 1361, 10792, 421, 198, 6750, 275, 340, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 14, 55, 5067, 401, 1585, 420, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 14, 55, 5067, 12, 450, 83, 304, 2, 450, 334, 515, 9, 199, 198, 1361, 10792, 421, 198, 470, 275, 340, 63, 1113, 14, 1002, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 283, 34, 2300, 83, 297, 1585, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 692, 822, 8, 470, 9, 690, 378, 26, 507, 198, 66, 385, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 522, 59, 16, 566, 507, 198, 6750, 275, 330, 385, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 34, 2300, 401, 1871, 755, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 507, 198, 1361, 507, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 34, 2300, 12, 450, 83, 304, 2, 450, 334, 470, 59, 16, 566, 507, 198, 1361, 10792, 421, 198, 470, 275, 340, 63, 1113, 14, 1002, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 283, 30551, 297, 1585, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 692, 822, 8, 470, 9, 690, 378, 26, 507, 198, 846, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 522, 59, 16, 566, 507, 198, 6750, 275, 1851, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4491, 401, 1871, 755, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 507, 198, 1361, 507, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4491, 12, 450, 83, 304, 2, 450, 334, 470, 59, 16, 566, 507, 198, 1361, 10792, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 199, 198, 973, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 21140, 199, 646, 984, 12, 747, 199, 646, 900, 199, 646, 25595, 199, 199, 318, 2446, 837, 199, 198, 5610, 275, 21140, 14, 3989, 12106, 342, 199, 198, 14649, 305, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 1871, 221, 3286, 329, 15, 87, 17, 15, 87, 387, 63, 8621, 606, 867, 17, 531, 199, 198, 6750, 275, 336, 15534, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 1585, 198, 17066, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 12, 1182, 329, 15, 87, 17, 15, 87, 387, 63, 8621, 606, 867, 17, 304, 2, 199, 198, 1361, 10792, 421, 198, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 507, 198, 736, 423, 2224, 8, 17, 9, 421, 198, 30702, 275, 984, 14, 3020, 59, 17, 61, 421, 198, 14649, 305, 275, 21140, 14, 4267, 8, 14649, 305, 63, 1113, 12, 298, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 531, 199, 198, 515, 275, 336, 15534, 14, 32109, 8, 30702, 9, 199, 198, 692, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 931, 9, 199, 198, 6750, 275, 340, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 1585, 420, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 12, 450, 83, 304, 2, 450, 334, 515, 9, 199, 198, 1361, 10792, 421, 198, 6750, 275, 340, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 14, 55, 5067, 401, 1585, 420, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 1361, 199, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 14, 55, 5067, 12, 450, 83, 304, 2, 450, 334, 515, 9, 199, 198, 1361, 10792, 421, 198, 470, 275, 340, 63, 1113, 14, 1002, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 283, 34, 2300, 83, 297, 1585, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 692, 822, 8, 470, 9, 690, 378, 26, 507, 198, 66, 385, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 522, 59, 16, 566, 507, 198, 6750, 275, 330, 385, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 34, 2300, 401, 1871, 755, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 507, 198, 1361, 507, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 34, 2300, 12, 450, 83, 304, 2, 450, 334, 470, 59, 16, 566, 507, 198, 1361, 10792, 421, 198, 470, 275, 340, 63, 1113, 14, 1002, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4267, 401, 283, 30551, 297, 1585, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 199, 198, 692, 822, 8, 470, 9, 690, 378, 26, 507, 198, 846, 63, 1113, 275, 10414, 14, 362, 63, 785, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 401, 522, 59, 16, 566, 507, 198, 6750, 275, 1851, 63, 1113, 14, 24578, 480, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4491, 401, 1871, 755, 21140, 63, 3266, 29, 17066, 14, 18858, 29807, 63, 4656, 4121, 9, 507, 198, 1361, 507, 198, 1361, 298, 24578, 8, 329, 14, 87, 17, 14, 87, 387, 63, 8621, 606, 867, 17, 14, 4491, 12, 450, 83, 304, 2, 450, 334, 470, 59, 16, 566, 507, 198, 1361, 10792, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 199, 198, 973, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ppwwyyxx/tensorflow
tensorflow/python/keras/optimizers.py
3
30372
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # pylint: disable=invalid-name """Built-in optimizer classes.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import six from six.moves import zip # pylint: disable=redefined-builtin from tensorflow.python.distribute import distribution_strategy_context from tensorflow.python.framework import ops from tensorflow.python.keras import backend as K from tensorflow.python.keras.optimizer_v2 import adadelta as adadelta_v2 from tensorflow.python.keras.optimizer_v2 import adagrad as adagrad_v2 from tensorflow.python.keras.optimizer_v2 import adam as adam_v2 from tensorflow.python.keras.optimizer_v2 import adamax as adamax_v2 from tensorflow.python.keras.optimizer_v2 import ftrl from tensorflow.python.keras.optimizer_v2 import gradient_descent as gradient_descent_v2 from tensorflow.python.keras.optimizer_v2 import nadam as nadam_v2 from tensorflow.python.keras.optimizer_v2 import optimizer_v2 from tensorflow.python.keras.optimizer_v2 import rmsprop as rmsprop_v2 from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object from tensorflow.python.keras.utils.generic_utils import serialize_keras_object from tensorflow.python.ops import clip_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import state_ops from tensorflow.python.training import optimizer as tf_optimizer_module from tensorflow.python.training import training_util from tensorflow.python.training.tracking import base as trackable from tensorflow.python.util.tf_export import keras_export class Optimizer(object): """Abstract optimizer base class. Note: this is the parent class of all optimizers, not an actual optimizer that can be used for training models. All Keras optimizers support the following keyword arguments: clipnorm: float >= 0. Gradients will be clipped when their L2 norm exceeds this value. clipvalue: float >= 0. Gradients will be clipped when their absolute value exceeds this value. """ def __init__(self, **kwargs): allowed_kwargs = {'clipnorm', 'clipvalue'} for k in kwargs: if k not in allowed_kwargs: raise TypeError('Unexpected keyword argument ' 'passed to optimizer: ' + str(k)) # checks that clipnorm >= 0 and clipvalue >= 0 if kwargs[k] < 0: raise ValueError('Expected {} >= 0, received: {}'.format(k, kwargs[k])) self.__dict__.update(kwargs) self.updates = [] self.weights = [] def get_updates(self, loss, params): raise NotImplementedError def get_gradients(self, loss, params): """Returns gradients of `loss` with respect to `params`. Arguments: loss: Loss tensor. params: List of variables. Returns: List of gradient tensors. Raises: ValueError: In case any gradient cannot be computed (e.g. if gradient function not implemented). """ grads = K.gradients(loss, params) if any([g is None for g in grads]): raise ValueError('An operation has `None` for gradient. ' 'Please make sure that all of your ops have a ' 'gradient defined (i.e. are differentiable). ' 'Common ops without gradient: ' 'K.argmax, K.round, K.eval.') if hasattr(self, 'clipnorm'): grads = [clip_ops.clip_by_norm(g, self.clipnorm) for g in grads] if hasattr(self, 'clipvalue'): grads = [ clip_ops.clip_by_value(g, -self.clipvalue, self.clipvalue) for g in grads ] return grads def set_weights(self, weights): """Sets the weights of the optimizer, from Numpy arrays. Should only be called after computing the gradients (otherwise the optimizer has no weights). Arguments: weights: a list of Numpy arrays. The number of arrays and their shape must match number of the dimensions of the weights of the optimizer (i.e. it should match the output of `get_weights`). Raises: ValueError: in case of incompatible weight shapes. """ params = self.weights if len(params) != len(weights): raise ValueError('Length of the specified weight list (' + str(len(weights)) + ') does not match the number of weights ' 'of the optimizer (' + str(len(params)) + ')') weight_value_tuples = [] param_values = K.batch_get_value(params) for pv, p, w in zip(param_values, params, weights): if pv.shape != w.shape: raise ValueError('Optimizer weight shape ' + str(pv.shape) + ' not compatible with ' 'provided weight shape ' + str(w.shape)) weight_value_tuples.append((p, w)) K.batch_set_value(weight_value_tuples) def get_weights(self): """Returns the current value of the weights of the optimizer. Returns: A list of numpy arrays. """ return K.batch_get_value(self.weights) def get_config(self): config = {} if hasattr(self, 'clipnorm'): config['clipnorm'] = self.clipnorm if hasattr(self, 'clipvalue'): config['clipvalue'] = self.clipvalue return config @classmethod def from_config(cls, config): return cls(**config) class SGD(Optimizer): """Stochastic gradient descent optimizer. Includes support for momentum, learning rate decay, and Nesterov momentum. Arguments: lr: float >= 0. Learning rate. momentum: float >= 0. Parameter that accelerates SGD in the relevant direction and dampens oscillations. decay: float >= 0. Learning rate decay over each update. nesterov: boolean. Whether to apply Nesterov momentum. """ def __init__(self, lr=0.01, momentum=0., decay=0., nesterov=False, **kwargs): super(SGD, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.iterations = K.variable(0, dtype='int64', name='iterations') self.lr = K.variable(lr, name='lr') self.momentum = K.variable(momentum, name='momentum') self.decay = K.variable(decay, name='decay') self.initial_decay = decay self.nesterov = nesterov def get_updates(self, loss, params): grads = self.get_gradients(loss, params) self.updates = [state_ops.assign_add(self.iterations, 1)] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) # momentum shapes = [K.int_shape(p) for p in params] moments = [K.zeros(shape) for shape in shapes] self.weights = [self.iterations] + moments for p, g, m in zip(params, grads, moments): v = self.momentum * m - lr * g # velocity self.updates.append(state_ops.assign(m, v)) if self.nesterov: new_p = p + self.momentum * v - lr * g else: new_p = p + v # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'momentum': float(K.get_value(self.momentum)), 'decay': float(K.get_value(self.decay)), 'nesterov': self.nesterov } base_config = super(SGD, self).get_config() return dict(list(base_config.items()) + list(config.items())) class RMSprop(Optimizer): """RMSProp optimizer. It is recommended to leave the parameters of this optimizer at their default values (except the learning rate, which can be freely tuned). Arguments: lr: float >= 0. Learning rate. rho: float >= 0. epsilon: float >= 0. Fuzz factor. If `None`, defaults to `K.epsilon()`. decay: float >= 0. Learning rate decay over each update. """ def __init__(self, lr=0.001, rho=0.9, epsilon=None, decay=0., **kwargs): super(RMSprop, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.lr = K.variable(lr, name='lr') self.rho = K.variable(rho, name='rho') self.decay = K.variable(decay, name='decay') self.iterations = K.variable(0, dtype='int64', name='iterations') if epsilon is None: epsilon = K.epsilon() self.epsilon = epsilon self.initial_decay = decay def get_updates(self, loss, params): grads = self.get_gradients(loss, params) accumulators = [K.zeros(K.int_shape(p), dtype=K.dtype(p)) for p in params] self.weights = accumulators self.updates = [state_ops.assign_add(self.iterations, 1)] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) for p, g, a in zip(params, grads, accumulators): # update accumulator new_a = self.rho * a + (1. - self.rho) * math_ops.square(g) self.updates.append(state_ops.assign(a, new_a)) new_p = p - lr * g / (K.sqrt(new_a) + self.epsilon) # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'rho': float(K.get_value(self.rho)), 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon } base_config = super(RMSprop, self).get_config() return dict(list(base_config.items()) + list(config.items())) class Adagrad(Optimizer): """Adagrad optimizer. Adagrad is an optimizer with parameter-specific learning rates, which are adapted relative to how frequently a parameter gets updated during training. The more updates a parameter receives, the smaller the updates. It is recommended to leave the parameters of this optimizer at their default values. # Arguments lr: float >= 0. Initial learning rate. epsilon: float >= 0. If `None`, defaults to `K.epsilon()`. decay: float >= 0. Learning rate decay over each update. # References - [Adaptive Subgradient Methods for Online Learning and Stochastic Optimization](http://www.jmlr.org/papers/volume12/duchi11a/duchi11a.pdf) """ def __init__(self, lr=0.01, epsilon=None, decay=0., **kwargs): super(Adagrad, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.lr = K.variable(lr, name='lr') self.decay = K.variable(decay, name='decay') self.iterations = K.variable(0, dtype='int64', name='iterations') if epsilon is None: epsilon = K.epsilon() self.epsilon = epsilon self.initial_decay = decay def get_updates(self, loss, params): grads = self.get_gradients(loss, params) shapes = [K.int_shape(p) for p in params] accumulators = [K.zeros(shape) for shape in shapes] self.weights = accumulators self.updates = [state_ops.assign_add(self.iterations, 1)] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) for p, g, a in zip(params, grads, accumulators): new_a = a + math_ops.square(g) # update accumulator self.updates.append(state_ops.assign(a, new_a)) new_p = p - lr * g / (K.sqrt(new_a) + self.epsilon) # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon } base_config = super(Adagrad, self).get_config() return dict(list(base_config.items()) + list(config.items())) class Adadelta(Optimizer): """Adadelta optimizer. Adadelta is a more robust extension of Adagrad that adapts learning rates based on a moving window of gradient updates, instead of accumulating all past gradients. This way, Adadelta continues learning even when many updates have been done. Compared to Adagrad, in the original version of Adadelta you don't have to set an initial learning rate. In this version, initial learning rate and decay factor can be set, as in most other Keras optimizers. It is recommended to leave the parameters of this optimizer at their default values. # Arguments lr: float >= 0. Initial learning rate, defaults to 1. It is recommended to leave it at the default value. rho: float >= 0. Adadelta decay factor, corresponding to fraction of gradient to keep at each time step. epsilon: float >= 0. Fuzz factor. If `None`, defaults to `K.epsilon()`. decay: float >= 0. Initial learning rate decay. # References - [Adadelta - an adaptive learning rate method](http://arxiv.org/abs/1212.5701) """ def __init__(self, lr=1.0, rho=0.95, epsilon=None, decay=0., **kwargs): super(Adadelta, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.lr = K.variable(lr, name='lr') self.decay = K.variable(decay, name='decay') self.iterations = K.variable(0, dtype='int64', name='iterations') if epsilon is None: epsilon = K.epsilon() self.rho = rho self.epsilon = epsilon self.initial_decay = decay def get_updates(self, loss, params): grads = self.get_gradients(loss, params) shapes = [K.int_shape(p) for p in params] accumulators = [K.zeros(shape) for shape in shapes] delta_accumulators = [K.zeros(shape) for shape in shapes] self.weights = accumulators + delta_accumulators self.updates = [state_ops.assign_add(self.iterations, 1)] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) for p, g, a, d_a in zip(params, grads, accumulators, delta_accumulators): # update accumulator new_a = self.rho * a + (1. - self.rho) * math_ops.square(g) self.updates.append(state_ops.assign(a, new_a)) # use the new accumulator and the *old* delta_accumulator update = g * K.sqrt(d_a + self.epsilon) / K.sqrt(new_a + self.epsilon) new_p = p - lr * update # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) # update delta_accumulator new_d_a = self.rho * d_a + (1 - self.rho) * math_ops.square(update) self.updates.append(state_ops.assign(d_a, new_d_a)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'rho': self.rho, 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon } base_config = super(Adadelta, self).get_config() return dict(list(base_config.items()) + list(config.items())) class Adam(Optimizer): """Adam optimizer. Default parameters follow those provided in the original paper. Arguments: lr: float >= 0. Learning rate. beta_1: float, 0 < beta < 1. Generally close to 1. beta_2: float, 0 < beta < 1. Generally close to 1. epsilon: float >= 0. Fuzz factor. If `None`, defaults to `K.epsilon()`. decay: float >= 0. Learning rate decay over each update. amsgrad: boolean. Whether to apply the AMSGrad variant of this algorithm from the paper "On the Convergence of Adam and Beyond". """ def __init__(self, lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0., amsgrad=False, **kwargs): super(Adam, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.iterations = K.variable(0, dtype='int64', name='iterations') self.lr = K.variable(lr, name='lr') self.beta_1 = K.variable(beta_1, name='beta_1') self.beta_2 = K.variable(beta_2, name='beta_2') self.decay = K.variable(decay, name='decay') if epsilon is None: epsilon = K.epsilon() self.epsilon = epsilon self.initial_decay = decay self.amsgrad = amsgrad def get_updates(self, loss, params): grads = self.get_gradients(loss, params) self.updates = [] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) with ops.control_dependencies([state_ops.assign_add(self.iterations, 1)]): t = math_ops.cast(self.iterations, K.floatx()) lr_t = lr * ( K.sqrt(1. - math_ops.pow(self.beta_2, t)) / (1. - math_ops.pow(self.beta_1, t))) ms = [K.zeros(K.int_shape(p), dtype=K.dtype(p)) for p in params] vs = [K.zeros(K.int_shape(p), dtype=K.dtype(p)) for p in params] if self.amsgrad: vhats = [K.zeros(K.int_shape(p), dtype=K.dtype(p)) for p in params] else: vhats = [K.zeros(1) for _ in params] self.weights = [self.iterations] + ms + vs + vhats for p, g, m, v, vhat in zip(params, grads, ms, vs, vhats): m_t = (self.beta_1 * m) + (1. - self.beta_1) * g v_t = (self.beta_2 * v) + (1. - self.beta_2) * math_ops.square(g) if self.amsgrad: vhat_t = math_ops.maximum(vhat, v_t) p_t = p - lr_t * m_t / (K.sqrt(vhat_t) + self.epsilon) self.updates.append(state_ops.assign(vhat, vhat_t)) else: p_t = p - lr_t * m_t / (K.sqrt(v_t) + self.epsilon) self.updates.append(state_ops.assign(m, m_t)) self.updates.append(state_ops.assign(v, v_t)) new_p = p_t # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'beta_1': float(K.get_value(self.beta_1)), 'beta_2': float(K.get_value(self.beta_2)), 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon, 'amsgrad': self.amsgrad } base_config = super(Adam, self).get_config() return dict(list(base_config.items()) + list(config.items())) class Adamax(Optimizer): """Adamax optimizer from Adam paper's Section 7. It is a variant of Adam based on the infinity norm. Default parameters follow those provided in the paper. Arguments: lr: float >= 0. Learning rate. beta_1/beta_2: floats, 0 < beta < 1. Generally close to 1. epsilon: float >= 0. Fuzz factor. If `None`, defaults to `K.epsilon()`. decay: float >= 0. Learning rate decay over each update. """ def __init__(self, lr=0.002, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0., **kwargs): super(Adamax, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.iterations = K.variable(0, dtype='int64', name='iterations') self.lr = K.variable(lr, name='lr') self.beta_1 = K.variable(beta_1, name='beta_1') self.beta_2 = K.variable(beta_2, name='beta_2') self.decay = K.variable(decay, name='decay') if epsilon is None: epsilon = K.epsilon() self.epsilon = epsilon self.initial_decay = decay def get_updates(self, loss, params): grads = self.get_gradients(loss, params) self.updates = [] lr = self.lr if self.initial_decay > 0: lr = lr * ( # pylint: disable=g-no-augmented-assignment 1. / (1. + self.decay * math_ops.cast(self.iterations, K.dtype(self.decay)))) with ops.control_dependencies([state_ops.assign_add(self.iterations, 1)]): t = math_ops.cast(self.iterations, K.floatx()) lr_t = lr / (1. - math_ops.pow(self.beta_1, t)) shapes = [K.int_shape(p) for p in params] # zero init of 1st moment ms = [K.zeros(shape) for shape in shapes] # zero init of exponentially weighted infinity norm us = [K.zeros(shape) for shape in shapes] self.weights = [self.iterations] + ms + us for p, g, m, u in zip(params, grads, ms, us): m_t = (self.beta_1 * m) + (1. - self.beta_1) * g u_t = math_ops.maximum(self.beta_2 * u, math_ops.abs(g)) p_t = p - lr_t * m_t / (u_t + self.epsilon) self.updates.append(state_ops.assign(m, m_t)) self.updates.append(state_ops.assign(u, u_t)) new_p = p_t # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'beta_1': float(K.get_value(self.beta_1)), 'beta_2': float(K.get_value(self.beta_2)), 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon } base_config = super(Adamax, self).get_config() return dict(list(base_config.items()) + list(config.items())) class Nadam(Optimizer): """Nesterov Adam optimizer. Much like Adam is essentially RMSprop with momentum, Nadam is Adam RMSprop with Nesterov momentum. Default parameters follow those provided in the paper. It is recommended to leave the parameters of this optimizer at their default values. Arguments: lr: float >= 0. Learning rate. beta_1/beta_2: floats, 0 < beta < 1. Generally close to 1. epsilon: float >= 0. Fuzz factor. If `None`, defaults to `K.epsilon()`. """ def __init__(self, lr=0.002, beta_1=0.9, beta_2=0.999, epsilon=None, schedule_decay=0.004, **kwargs): super(Nadam, self).__init__(**kwargs) with K.name_scope(self.__class__.__name__): self.iterations = K.variable(0, dtype='int64', name='iterations') self.m_schedule = K.variable(1., name='m_schedule') self.lr = K.variable(lr, name='lr') self.beta_1 = K.variable(beta_1, name='beta_1') self.beta_2 = K.variable(beta_2, name='beta_2') if epsilon is None: epsilon = K.epsilon() self.epsilon = epsilon self.schedule_decay = schedule_decay def get_updates(self, loss, params): grads = self.get_gradients(loss, params) self.updates = [] with ops.control_dependencies([state_ops.assign_add(self.iterations, 1)]): t = math_ops.cast(self.iterations, K.floatx()) # Due to the recommendations in [2], i.e. warming momentum schedule momentum_cache_t = self.beta_1 * ( 1. - 0.5 * (math_ops.pow(K.cast_to_floatx(0.96), t * self.schedule_decay))) momentum_cache_t_1 = self.beta_1 * ( 1. - 0.5 * (math_ops.pow(K.cast_to_floatx(0.96), (t + 1) * self.schedule_decay))) m_schedule_new = self.m_schedule * momentum_cache_t m_schedule_next = self.m_schedule * momentum_cache_t * momentum_cache_t_1 self.updates.append((self.m_schedule, m_schedule_new)) shapes = [K.int_shape(p) for p in params] ms = [K.zeros(shape) for shape in shapes] vs = [K.zeros(shape) for shape in shapes] self.weights = [self.iterations, self.m_schedule] + ms + vs for p, g, m, v in zip(params, grads, ms, vs): # the following equations given in [1] g_prime = g / (1. - m_schedule_new) m_t = self.beta_1 * m + (1. - self.beta_1) * g m_t_prime = m_t / (1. - m_schedule_next) v_t = self.beta_2 * v + (1. - self.beta_2) * math_ops.square(g) v_t_prime = v_t / (1. - math_ops.pow(self.beta_2, t)) m_t_bar = (1. - momentum_cache_t) * g_prime + momentum_cache_t_1 * m_t_prime self.updates.append(state_ops.assign(m, m_t)) self.updates.append(state_ops.assign(v, v_t)) p_t = p - self.lr * m_t_bar / (K.sqrt(v_t_prime) + self.epsilon) new_p = p_t # Apply constraints. if getattr(p, 'constraint', None) is not None: new_p = p.constraint(new_p) self.updates.append(state_ops.assign(p, new_p)) return self.updates def get_config(self): config = { 'lr': float(K.get_value(self.lr)), 'beta_1': float(K.get_value(self.beta_1)), 'beta_2': float(K.get_value(self.beta_2)), 'epsilon': self.epsilon, 'schedule_decay': self.schedule_decay } base_config = super(Nadam, self).get_config() return dict(list(base_config.items()) + list(config.items())) class TFOptimizer(Optimizer, trackable.Trackable): """Wrapper class for native TensorFlow optimizers.""" def __init__(self, optimizer, iterations=None): # pylint: disable=super-init-not-called self.optimizer = optimizer self._track_trackable(optimizer, name='optimizer') if iterations is None: with K.name_scope(self.__class__.__name__): self.iterations = K.variable(0, dtype='int64', name='iterations') else: self.iterations = iterations self._track_trackable(self.iterations, name='global_step') def apply_gradients(self, grads): self.optimizer.apply_gradients(grads, global_step=self.iterations) def get_grads(self, loss, params): return self.optimizer.compute_gradients(loss, params) def get_updates(self, loss, params): if distribution_strategy_context.has_strategy(): self.updates = [] if not params: # After the model vars have been created, the second call to get_updates # is called with params as an empty list. This ensures that we call # compute_gradients with params=None. grads = self.optimizer.compute_gradients(loss) else: grads = self.optimizer.compute_gradients(loss, params) global_step = training_util.get_global_step() opt_update = self.optimizer.apply_gradients(grads, global_step) else: if not params: self.updates = [state_ops.assign_add(self.iterations, 1)] return self.updates # Updates list starts out empty because the iterations variable is # incremented in optimizer.apply_gradients() self.updates = [] grads = self.optimizer.compute_gradients(loss, params) opt_update = self.optimizer.apply_gradients( grads, global_step=self.iterations) self.updates.append(opt_update) return self.updates @property def weights(self): raise NotImplementedError def get_config(self): raise NotImplementedError def from_config(self, config): raise NotImplementedError # Aliases. sgd = SGD rmsprop = RMSprop adagrad = Adagrad adadelta = Adadelta adam = Adam adamax = Adamax nadam = Nadam @keras_export('keras.optimizers.serialize') def serialize(optimizer): return serialize_keras_object(optimizer) @keras_export('keras.optimizers.deserialize') def deserialize(config, custom_objects=None): """Inverse of the `serialize` function. Arguments: config: Optimizer configuration dictionary. custom_objects: Optional dictionary mapping names (strings) to custom objects (classes and functions) to be considered during deserialization. Returns: A Keras Optimizer instance. """ # loss_scale_optimizer has a direct dependency of optimizer, import here # rather than top to avoid the cyclic dependency. from tensorflow.python.keras.mixed_precision.experimental import loss_scale_optimizer # pylint: disable=g-import-not-at-top all_classes = { 'adadelta': adadelta_v2.Adadelta, 'adagrad': adagrad_v2.Adagrad, 'adam': adam_v2.Adam, 'adamax': adamax_v2.Adamax, 'nadam': nadam_v2.Nadam, 'rmsprop': rmsprop_v2.RMSprop, 'sgd': gradient_descent_v2.SGD, 'ftrl': ftrl.Ftrl, 'lossscaleoptimizer': loss_scale_optimizer.LossScaleOptimizer, } # Make deserialization case-insensitive for built-in optimizers. if config['class_name'].lower() in all_classes: config['class_name'] = config['class_name'].lower() return deserialize_keras_object( config, module_objects=all_classes, custom_objects=custom_objects, printable_module_name='optimizer') @keras_export('keras.optimizers.get') def get(identifier): """Retrieves a Keras Optimizer instance. Arguments: identifier: Optimizer identifier, one of - String: name of an optimizer - Dictionary: configuration dictionary. - Keras Optimizer instance (it will be returned unchanged). - TensorFlow Optimizer instance (it will be wrapped as a Keras Optimizer). Returns: A Keras Optimizer instance. Raises: ValueError: If `identifier` cannot be interpreted. """ if isinstance(identifier, (Optimizer, optimizer_v2.OptimizerV2)): return identifier # Wrap TF optimizer instances elif isinstance(identifier, tf_optimizer_module.Optimizer): opt = TFOptimizer(identifier) K.track_tf_optimizer(opt) return opt elif isinstance(identifier, dict): return deserialize(identifier) elif isinstance(identifier, six.string_types): config = {'class_name': str(identifier), 'config': {}} return deserialize(config) else: raise ValueError('Could not interpret optimizer identifier:', identifier)
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 624, 32406, 13, 262, 10736, 3992, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 3482, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 199, 504, 3228, 14, 1548, 14, 3470, 492, 4084, 63, 8590, 63, 1100, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 8811, 492, 4865, 465, 1804, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 282, 983, 3136, 465, 282, 983, 3136, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 1503, 27707, 465, 1503, 27707, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 1503, 455, 465, 1503, 455, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 282, 983, 988, 465, 282, 983, 988, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 289, 7245, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 6709, 63, 26269, 465, 6709, 63, 26269, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 302, 27679, 465, 302, 27679, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 10736, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 32205, 4469, 465, 32205, 4469, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 1208, 14, 6767, 63, 1208, 492, 22920, 63, 8811, 63, 785, 199, 504, 3228, 14, 1548, 14, 8811, 14, 1208, 14, 6767, 63, 1208, 492, 8437, 63, 8811, 63, 785, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1174, 63, 1483, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 465, 2833, 63, 12290, 63, 578, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6093, 63, 1974, 199, 504, 3228, 14, 1548, 14, 7588, 14, 14428, 492, 1300, 465, 4426, 461, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 11708, 63, 3790, 421, 199, 533, 19246, 1793, 8, 785, 304, 523, 408, 8458, 10736, 1300, 1021, 14, 819, 3390, 26, 642, 365, 314, 1676, 1021, 402, 1006, 5323, 6315, 12, 440, 376, 3503, 10736, 523, 626, 883, 506, 1202, 367, 6093, 1709, 14, 819, 2900, 1804, 30037, 5323, 6315, 2291, 314, 2569, 4252, 2368, 26, 2541, 11353, 4791, 26, 2069, 2356, 378, 14, 19603, 83, 911, 506, 11353, 1915, 881, 1380, 3932, 491, 18, 6316, 22338, 642, 574, 14, 489, 11353, 585, 26, 2069, 2356, 378, 14, 19603, 83, 911, 506, 11353, 1915, 881, 1380, 3932, 3679, 574, 22338, 642, 574, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 4370, 63, 958, 275, 791, 7548, 4791, 297, 283, 7548, 585, 936, 272, 367, 1022, 315, 2074, 26, 489, 340, 1022, 440, 315, 4370, 63, 958, 26, 267, 746, 3146, 360, 8708, 4252, 1423, 283, 717, 283, 12070, 370, 10736, 26, 283, 435, 620, 8, 75, 430, 489, 327, 5920, 626, 11353, 4791, 2356, 378, 436, 11353, 585, 2356, 378, 489, 340, 2074, 59, 75, 61, 665, 378, 26, 267, 746, 1722, 360, 6964, 1052, 2356, 378, 12, 3086, 26, 9499, 908, 8, 75, 12, 2074, 59, 75, 2459, 272, 291, 855, 807, 4343, 873, 8, 958, 9, 272, 291, 14, 7618, 275, 942, 272, 291, 14, 4916, 275, 942, 819, 347, 664, 63, 7618, 8, 277, 12, 5621, 12, 1862, 304, 272, 746, 4279, 819, 347, 664, 63, 13065, 8, 277, 12, 5621, 12, 1862, 304, 272, 408, 3407, 12661, 402, 658, 4358, 64, 543, 14021, 370, 658, 1162, 2313, 339, 7628, 26, 267, 5621, 26, 3835, 385, 2345, 14, 267, 1862, 26, 3820, 402, 2860, 14, 339, 1803, 26, 267, 3820, 402, 6709, 10519, 14, 339, 6218, 26, 267, 1722, 26, 1010, 1930, 1263, 6709, 3913, 506, 9235, 334, 69, 14, 71, 14, 340, 6709, 881, 805, 440, 6366, 680, 272, 408, 272, 18300, 275, 1804, 14, 13065, 8, 4358, 12, 1862, 9, 272, 340, 1263, 779, 71, 365, 488, 367, 486, 315, 18300, 4682, 489, 746, 1722, 360, 2493, 3439, 965, 658, 403, 64, 367, 6709, 14, 283, 2432, 283, 8254, 1852, 3238, 626, 1006, 402, 2195, 4156, 1172, 282, 283, 2432, 283, 7490, 3247, 334, 73, 14, 69, 14, 787, 26796, 461, 680, 283, 2432, 283, 7844, 4156, 1928, 6709, 26, 283, 2432, 283, 43, 14, 16383, 12, 1804, 14, 2363, 12, 1804, 14, 2579, 2659, 272, 340, 2688, 8, 277, 12, 283, 7548, 4791, 735, 489, 18300, 275, 359, 7548, 63, 1483, 14, 7548, 63, 991, 63, 4791, 8, 71, 12, 291, 14, 7548, 4791, 9, 367, 486, 315, 18300, 61, 272, 340, 2688, 8, 277, 12, 283, 7548, 585, 735, 489, 18300, 275, 359, 881, 11353, 63, 1483, 14, 7548, 63, 991, 63, 585, 8, 71, 12, 446, 277, 14, 7548, 585, 12 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 624, 32406, 13, 262, 10736, 3992, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 3482, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 199, 504, 3228, 14, 1548, 14, 3470, 492, 4084, 63, 8590, 63, 1100, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 8811, 492, 4865, 465, 1804, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 282, 983, 3136, 465, 282, 983, 3136, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 1503, 27707, 465, 1503, 27707, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 1503, 455, 465, 1503, 455, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 282, 983, 988, 465, 282, 983, 988, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 289, 7245, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 6709, 63, 26269, 465, 6709, 63, 26269, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 302, 27679, 465, 302, 27679, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 10736, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 12290, 63, 86, 18, 492, 32205, 4469, 465, 32205, 4469, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 8811, 14, 1208, 14, 6767, 63, 1208, 492, 22920, 63, 8811, 63, 785, 199, 504, 3228, 14, 1548, 14, 8811, 14, 1208, 14, 6767, 63, 1208, 492, 8437, 63, 8811, 63, 785, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1174, 63, 1483, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 465, 2833, 63, 12290, 63, 578, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6093, 63, 1974, 199, 504, 3228, 14, 1548, 14, 7588, 14, 14428, 492, 1300, 465, 4426, 461, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 11708, 63, 3790, 421, 199, 533, 19246, 1793, 8, 785, 304, 523, 408, 8458, 10736, 1300, 1021, 14, 819, 3390, 26, 642, 365, 314, 1676, 1021, 402, 1006, 5323, 6315, 12, 440, 376, 3503, 10736, 523, 626, 883, 506, 1202, 367, 6093, 1709, 14, 819, 2900, 1804, 30037, 5323, 6315, 2291, 314, 2569, 4252, 2368, 26, 2541, 11353, 4791, 26, 2069, 2356, 378, 14, 19603, 83, 911, 506, 11353, 1915, 881, 1380, 3932, 491, 18, 6316, 22338, 642, 574, 14, 489, 11353, 585, 26, 2069, 2356, 378, 14, 19603, 83, 911, 506, 11353, 1915, 881, 1380, 3932, 3679, 574, 22338, 642, 574, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 4370, 63, 958, 275, 791, 7548, 4791, 297, 283, 7548, 585, 936, 272, 367, 1022, 315, 2074, 26, 489, 340, 1022, 440, 315, 4370, 63, 958, 26, 267, 746, 3146, 360, 8708, 4252, 1423, 283, 717, 283, 12070, 370, 10736, 26, 283, 435, 620, 8, 75, 430, 489, 327, 5920, 626, 11353, 4791, 2356, 378, 436, 11353, 585, 2356, 378, 489, 340, 2074, 59, 75, 61, 665, 378, 26, 267, 746, 1722, 360, 6964, 1052, 2356, 378, 12, 3086, 26, 9499, 908, 8, 75, 12, 2074, 59, 75, 2459, 272, 291, 855, 807, 4343, 873, 8, 958, 9, 272, 291, 14, 7618, 275, 942, 272, 291, 14, 4916, 275, 942, 819, 347, 664, 63, 7618, 8, 277, 12, 5621, 12, 1862, 304, 272, 746, 4279, 819, 347, 664, 63, 13065, 8, 277, 12, 5621, 12, 1862, 304, 272, 408, 3407, 12661, 402, 658, 4358, 64, 543, 14021, 370, 658, 1162, 2313, 339, 7628, 26, 267, 5621, 26, 3835, 385, 2345, 14, 267, 1862, 26, 3820, 402, 2860, 14, 339, 1803, 26, 267, 3820, 402, 6709, 10519, 14, 339, 6218, 26, 267, 1722, 26, 1010, 1930, 1263, 6709, 3913, 506, 9235, 334, 69, 14, 71, 14, 340, 6709, 881, 805, 440, 6366, 680, 272, 408, 272, 18300, 275, 1804, 14, 13065, 8, 4358, 12, 1862, 9, 272, 340, 1263, 779, 71, 365, 488, 367, 486, 315, 18300, 4682, 489, 746, 1722, 360, 2493, 3439, 965, 658, 403, 64, 367, 6709, 14, 283, 2432, 283, 8254, 1852, 3238, 626, 1006, 402, 2195, 4156, 1172, 282, 283, 2432, 283, 7490, 3247, 334, 73, 14, 69, 14, 787, 26796, 461, 680, 283, 2432, 283, 7844, 4156, 1928, 6709, 26, 283, 2432, 283, 43, 14, 16383, 12, 1804, 14, 2363, 12, 1804, 14, 2579, 2659, 272, 340, 2688, 8, 277, 12, 283, 7548, 4791, 735, 489, 18300, 275, 359, 7548, 63, 1483, 14, 7548, 63, 991, 63, 4791, 8, 71, 12, 291, 14, 7548, 4791, 9, 367, 486, 315, 18300, 61, 272, 340, 2688, 8, 277, 12, 283, 7548, 585, 735, 489, 18300, 275, 359, 881, 11353, 63, 1483, 14, 7548, 63, 991, 63, 585, 8, 71, 12, 446, 277, 14, 7548, 585, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
zhjunlang/kbengine
kbe/res/scripts/common/Lib/lib2to3/pgen2/token.py
77
1264
#! /usr/bin/env python3 """Token constants (from "token.h").""" # Taken from Python (r53757) and modified to include some tokens # originally monkeypatched in by pgen2.tokenize #--start constants-- ENDMARKER = 0 NAME = 1 NUMBER = 2 STRING = 3 NEWLINE = 4 INDENT = 5 DEDENT = 6 LPAR = 7 RPAR = 8 LSQB = 9 RSQB = 10 COLON = 11 COMMA = 12 SEMI = 13 PLUS = 14 MINUS = 15 STAR = 16 SLASH = 17 VBAR = 18 AMPER = 19 LESS = 20 GREATER = 21 EQUAL = 22 DOT = 23 PERCENT = 24 BACKQUOTE = 25 LBRACE = 26 RBRACE = 27 EQEQUAL = 28 NOTEQUAL = 29 LESSEQUAL = 30 GREATEREQUAL = 31 TILDE = 32 CIRCUMFLEX = 33 LEFTSHIFT = 34 RIGHTSHIFT = 35 DOUBLESTAR = 36 PLUSEQUAL = 37 MINEQUAL = 38 STAREQUAL = 39 SLASHEQUAL = 40 PERCENTEQUAL = 41 AMPEREQUAL = 42 VBAREQUAL = 43 CIRCUMFLEXEQUAL = 44 LEFTSHIFTEQUAL = 45 RIGHTSHIFTEQUAL = 46 DOUBLESTAREQUAL = 47 DOUBLESLASH = 48 DOUBLESLASHEQUAL = 49 AT = 50 ATEQUAL = 51 OP = 52 COMMENT = 53 NL = 54 RARROW = 55 ERRORTOKEN = 56 N_TOKENS = 57 NT_OFFSET = 256 #--end constants-- tok_name = {} for _name, _value in list(globals().items()): if type(_value) is type(0): tok_name[_value] = _name def ISTERMINAL(x): return x < NT_OFFSET def ISNONTERMINAL(x): return x >= NT_OFFSET def ISEOF(x): return x == ENDMARKER
lgpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 3264, 5262, 334, 504, 298, 1418, 14, 72, 531, 1041, 199, 199, 3, 221, 32316, 917, 687, 2018, 334, 82, 24416, 1641, 9, 436, 6042, 370, 2387, 2005, 4645, 199, 3, 257, 20657, 17309, 379, 315, 701, 299, 2268, 18, 14, 15246, 199, 199, 3, 306, 928, 5262, 306, 199, 3902, 18997, 275, 378, 199, 2339, 275, 413, 199, 9190, 275, 499, 199, 5353, 275, 650, 199, 28758, 275, 841, 199, 29080, 275, 959, 199, 8280, 1309, 275, 1227, 199, 44, 4014, 275, 1520, 199, 50, 4014, 275, 1695, 199, 5296, 31893, 275, 1749, 199, 15062, 31893, 275, 1616, 199, 3978, 615, 275, 4119, 199, 11265, 2054, 275, 3144, 199, 899, 10709, 275, 4944, 199, 27280, 275, 4329, 199, 18004, 275, 4114, 199, 30302, 275, 3193, 199, 27192, 275, 5557, 199, 54, 13895, 275, 6155, 199, 1156, 4227, 275, 5851, 199, 30928, 275, 3388, 199, 39, 21780, 275, 7829, 199, 16352, 275, 6928, 199, 13203, 275, 6546, 199, 4227, 17349, 275, 5504, 199, 7111, 18495, 275, 5661, 199, 44, 29246, 275, 7875, 199, 50, 29246, 275, 8087, 199, 17420, 16352, 275, 7294, 199, 4609, 16352, 275, 7349, 199, 11344, 7326, 748, 275, 4233, 199, 39, 21780, 16352, 275, 7105, 199, 52, 13922, 275, 4337, 199, 3553, 50, 9976, 275, 9404, 199, 9894, 18013, 275, 8177, 199, 12811, 18013, 275, 8685, 199, 1649, 2533, 44, 1719, 689, 275, 8780, 199, 2749, 4701, 9283, 275, 6877, 199, 45, 3565, 9283, 275, 10448, 199, 840, 8693, 9283, 275, 10551, 199, 4929, 1179, 1645, 9283, 275, 6335, 199, 4227, 17349, 16352, 275, 13385, 199, 1156, 4227, 16352, 275, 5685, 199, 27966, 8693, 9283, 275, 11851, 199, 3553, 50, 9976, 16352, 275, 10868, 199, 9894, 18013, 16352, 275, 10416, 199, 12811, 18013, 16352, 275, 12426, 199, 1649, 2533, 44, 1719, 8693, 9283, 275, 10954, 199, 1649, 2533, 11344, 44, 8100, 275, 9615, 199, 1649, 2533, 11344, 44, 1179, 1645, 9283, 275, 12260, 199, 619, 275, 5238, 199, 1951, 9283, 275, 8026, 199, 1938, 275, 14589, 199, 10973, 275, 13564, 199, 14176, 275, 13470, 199, 50, 689, 11415, 275, 12766, 199, 3170, 8803, 275, 12001, 199, 46, 63, 8803, 51, 275, 12699, 199, 12460, 63, 14839, 275, 7633, 199, 3, 306, 500, 5262, 306, 199, 199, 9305, 63, 354, 275, 1052, 199, 509, 485, 354, 12, 485, 585, 315, 769, 8, 8473, 1252, 1744, 5109, 272, 340, 730, 1547, 585, 9, 365, 730, 8, 16, 304, 267, 8431, 63, 354, 13040, 585, 61, 275, 485, 354, 421, 199, 318, 473, 14471, 4896, 748, 8, 88, 304, 272, 372, 671, 665, 23350, 63, 14839, 199, 199, 318, 2281, 13887, 28376, 748, 8, 88, 304, 272, 372, 671, 2356, 23350, 63, 14839, 199, 199, 318, 473, 899, 3359, 8, 88, 304, 272, 372, 671, 508, 7729, 18997, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 3264, 5262, 334, 504, 298, 1418, 14, 72, 531, 1041, 199, 199, 3, 221, 32316, 917, 687, 2018, 334, 82, 24416, 1641, 9, 436, 6042, 370, 2387, 2005, 4645, 199, 3, 257, 20657, 17309, 379, 315, 701, 299, 2268, 18, 14, 15246, 199, 199, 3, 306, 928, 5262, 306, 199, 3902, 18997, 275, 378, 199, 2339, 275, 413, 199, 9190, 275, 499, 199, 5353, 275, 650, 199, 28758, 275, 841, 199, 29080, 275, 959, 199, 8280, 1309, 275, 1227, 199, 44, 4014, 275, 1520, 199, 50, 4014, 275, 1695, 199, 5296, 31893, 275, 1749, 199, 15062, 31893, 275, 1616, 199, 3978, 615, 275, 4119, 199, 11265, 2054, 275, 3144, 199, 899, 10709, 275, 4944, 199, 27280, 275, 4329, 199, 18004, 275, 4114, 199, 30302, 275, 3193, 199, 27192, 275, 5557, 199, 54, 13895, 275, 6155, 199, 1156, 4227, 275, 5851, 199, 30928, 275, 3388, 199, 39, 21780, 275, 7829, 199, 16352, 275, 6928, 199, 13203, 275, 6546, 199, 4227, 17349, 275, 5504, 199, 7111, 18495, 275, 5661, 199, 44, 29246, 275, 7875, 199, 50, 29246, 275, 8087, 199, 17420, 16352, 275, 7294, 199, 4609, 16352, 275, 7349, 199, 11344, 7326, 748, 275, 4233, 199, 39, 21780, 16352, 275, 7105, 199, 52, 13922, 275, 4337, 199, 3553, 50, 9976, 275, 9404, 199, 9894, 18013, 275, 8177, 199, 12811, 18013, 275, 8685, 199, 1649, 2533, 44, 1719, 689, 275, 8780, 199, 2749, 4701, 9283, 275, 6877, 199, 45, 3565, 9283, 275, 10448, 199, 840, 8693, 9283, 275, 10551, 199, 4929, 1179, 1645, 9283, 275, 6335, 199, 4227, 17349, 16352, 275, 13385, 199, 1156, 4227, 16352, 275, 5685, 199, 27966, 8693, 9283, 275, 11851, 199, 3553, 50, 9976, 16352, 275, 10868, 199, 9894, 18013, 16352, 275, 10416, 199, 12811, 18013, 16352, 275, 12426, 199, 1649, 2533, 44, 1719, 8693, 9283, 275, 10954, 199, 1649, 2533, 11344, 44, 8100, 275, 9615, 199, 1649, 2533, 11344, 44, 1179, 1645, 9283, 275, 12260, 199, 619, 275, 5238, 199, 1951, 9283, 275, 8026, 199, 1938, 275, 14589, 199, 10973, 275, 13564, 199, 14176, 275, 13470, 199, 50, 689, 11415, 275, 12766, 199, 3170, 8803, 275, 12001, 199, 46, 63, 8803, 51, 275, 12699, 199, 12460, 63, 14839, 275, 7633, 199, 3, 306, 500, 5262, 306, 199, 199, 9305, 63, 354, 275, 1052, 199, 509, 485, 354, 12, 485, 585, 315, 769, 8, 8473, 1252, 1744, 5109, 272, 340, 730, 1547, 585, 9, 365, 730, 8, 16, 304, 267, 8431, 63, 354, 13040, 585, 61, 275, 485, 354, 421, 199, 318, 473, 14471, 4896, 748, 8, 88, 304, 272, 372, 671, 665, 23350, 63, 14839, 199, 199, 318, 2281, 13887, 28376, 748, 8, 88, 304, 272, 372, 671, 2356, 23350, 63, 14839, 199, 199, 318, 473, 899, 3359, 8, 88, 304, 272, 372, 671, 508, 7729, 18997, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
rledisez/shinken
contrib/livestatus/splitlivelogs.py
18
2388
#!/usr/bin/env python # Copyright (C) 2009-2014: # Gabes Jean, naparuba@gmail.com # Gerhard Lausser, Gerhard.Lausser@consol.de # # This file is part of Shinken. # # Shinken 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. # # Shinken 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 Shinken. If not, see <http://www.gnu.org/licenses/>. """ This script will take the sqlite database of the livestatus module and split up the contents in single datafiles (1 for each day of data found). """ import sys import optparse import os sys.path.append("..") sys.path.append("../shinken") sys.path.append("../../shinken") sys.path.append("../../../shinken") #sys.path.append("../bin") #sys.path.append(os.path.abspath("bin")) #import shinken from shinken.modules.livestatus_broker.livestatus_db import LiveStatusDb parser = optparse.OptionParser( "%prog [options] -d database [-a archive]") parser.add_option('-d', '--database', action='store', dest="database", help="The sqlite datafile of your livestatus module") parser.add_option('-a', '--archive', action='store', dest="archive_path", help="(optional) path to the archive directory") opts, args = parser.parse_args() if not opts.database: parser.error("Requires at least the database file (option -d/--database") if not opts.archive_path: opts.archive_path = os.path.join(os.path.dirname(opts.database), 'archives') pass # Protect for windows multiprocessing that will RELAUNCH all if __name__ == '__main__': if os.path.exists(opts.database): try: os.stat(opts.archive_path) except Exception: os.mkdir(opts.archive_path) dbh = LiveStatusDb(opts.database, opts.archive_path, 3600) dbh.log_db_do_archive() dbh.close() else: print "database %s does not exist" % opts.database # For perf tuning:
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 35, 9, 8937, 13, 7280, 26, 199, 3, 259, 598, 371, 397, 1603, 69, 290, 12, 302, 439, 285, 9405, 32, 6799, 14, 957, 199, 3, 259, 22261, 8726, 7964, 527, 332, 12, 22261, 8726, 14, 7833, 527, 332, 32, 388, 7873, 14, 271, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 5244, 30864, 14, 199, 3, 199, 3, 5244, 30864, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 5244, 30864, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 5244, 30864, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 2765, 2884, 911, 5452, 314, 11723, 3050, 402, 314, 12166, 1205, 859, 436, 199, 1294, 1536, 314, 4072, 315, 2849, 666, 1725, 334, 17, 367, 1924, 5382, 402, 666, 1911, 680, 199, 624, 199, 199, 646, 984, 199, 646, 8691, 199, 646, 747, 199, 199, 1274, 14, 515, 14, 740, 480, 703, 531, 199, 1274, 14, 515, 14, 740, 480, 5093, 609, 30864, 531, 199, 1274, 14, 515, 14, 740, 480, 9707, 609, 30864, 531, 199, 1274, 14, 515, 14, 740, 480, 29866, 609, 30864, 531, 199, 3, 1274, 14, 515, 14, 740, 480, 5093, 1393, 531, 199, 3, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 480, 1393, 2237, 421, 199, 3, 646, 1033, 30864, 199, 504, 1033, 30864, 14, 3112, 14, 6442, 1205, 63, 16620, 14, 6442, 1205, 63, 697, 492, 24683, 3694, 8882, 199, 199, 2087, 275, 8691, 14, 14553, 8, 272, 2071, 6595, 359, 1419, 61, 446, 68, 3050, 5243, 65, 6359, 12523, 199, 2087, 14, 525, 63, 1422, 3654, 68, 297, 2850, 4659, 297, 1595, 534, 1617, 297, 2116, 2053, 628, 4659, 401, 2116, 1720, 628, 1918, 11723, 666, 493, 402, 2195, 12166, 1205, 859, 531, 199, 2087, 14, 525, 63, 1422, 3654, 65, 297, 2850, 6404, 297, 1595, 534, 1617, 297, 2116, 2053, 628, 6404, 63, 515, 401, 2116, 1720, 628, 8, 4144, 9, 931, 370, 314, 6359, 2082, 531, 199, 199, 3291, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 440, 3999, 14, 4659, 26, 272, 1798, 14, 705, 480, 18153, 737, 5210, 314, 3050, 570, 334, 1422, 446, 68, 25695, 4659, 531, 199, 692, 440, 3999, 14, 6404, 63, 515, 26, 272, 3999, 14, 6404, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 3291, 14, 4659, 395, 283, 28067, 358, 272, 986, 199, 199, 3, 2165, 5302, 367, 10061, 12866, 626, 911, 820, 2901, 33, 1734, 1244, 1006, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 747, 14, 515, 14, 2444, 8, 3291, 14, 4659, 304, 267, 862, 26, 288, 747, 14, 3736, 8, 3291, 14, 6404, 63, 515, 9, 267, 871, 2186, 26, 288, 747, 14, 8215, 8, 3291, 14, 6404, 63, 515, 9, 267, 1592, 72, 275, 24683, 3694, 8882, 8, 3291, 14, 4659, 12, 3999, 14, 6404, 63, 515, 12, 15751, 9, 267, 1592, 72, 14, 793, 63, 697, 63, 1117, 63, 6404, 342, 267, 1592, 72, 14, 1600, 342, 272, 587, 26, 267, 870, 298, 4659, 450, 83, 1630, 440, 2187, 2, 450, 3999, 14, 4659, 421, 199, 3, 2104, 8582, 15486, 316, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 35, 9, 8937, 13, 7280, 26, 199, 3, 259, 598, 371, 397, 1603, 69, 290, 12, 302, 439, 285, 9405, 32, 6799, 14, 957, 199, 3, 259, 22261, 8726, 7964, 527, 332, 12, 22261, 8726, 14, 7833, 527, 332, 32, 388, 7873, 14, 271, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 5244, 30864, 14, 199, 3, 199, 3, 5244, 30864, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 5244, 30864, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 5244, 30864, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 2765, 2884, 911, 5452, 314, 11723, 3050, 402, 314, 12166, 1205, 859, 436, 199, 1294, 1536, 314, 4072, 315, 2849, 666, 1725, 334, 17, 367, 1924, 5382, 402, 666, 1911, 680, 199, 624, 199, 199, 646, 984, 199, 646, 8691, 199, 646, 747, 199, 199, 1274, 14, 515, 14, 740, 480, 703, 531, 199, 1274, 14, 515, 14, 740, 480, 5093, 609, 30864, 531, 199, 1274, 14, 515, 14, 740, 480, 9707, 609, 30864, 531, 199, 1274, 14, 515, 14, 740, 480, 29866, 609, 30864, 531, 199, 3, 1274, 14, 515, 14, 740, 480, 5093, 1393, 531, 199, 3, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 480, 1393, 2237, 421, 199, 3, 646, 1033, 30864, 199, 504, 1033, 30864, 14, 3112, 14, 6442, 1205, 63, 16620, 14, 6442, 1205, 63, 697, 492, 24683, 3694, 8882, 199, 199, 2087, 275, 8691, 14, 14553, 8, 272, 2071, 6595, 359, 1419, 61, 446, 68, 3050, 5243, 65, 6359, 12523, 199, 2087, 14, 525, 63, 1422, 3654, 68, 297, 2850, 4659, 297, 1595, 534, 1617, 297, 2116, 2053, 628, 4659, 401, 2116, 1720, 628, 1918, 11723, 666, 493, 402, 2195, 12166, 1205, 859, 531, 199, 2087, 14, 525, 63, 1422, 3654, 65, 297, 2850, 6404, 297, 1595, 534, 1617, 297, 2116, 2053, 628, 6404, 63, 515, 401, 2116, 1720, 628, 8, 4144, 9, 931, 370, 314, 6359, 2082, 531, 199, 199, 3291, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 440, 3999, 14, 4659, 26, 272, 1798, 14, 705, 480, 18153, 737, 5210, 314, 3050, 570, 334, 1422, 446, 68, 25695, 4659, 531, 199, 692, 440, 3999, 14, 6404, 63, 515, 26, 272, 3999, 14, 6404, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 3291, 14, 4659, 395, 283, 28067, 358, 272, 986, 199, 199, 3, 2165, 5302, 367, 10061, 12866, 626, 911, 820, 2901, 33, 1734, 1244, 1006, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 747, 14, 515, 14, 2444, 8, 3291, 14, 4659, 304, 267, 862, 26, 288, 747, 14, 3736, 8, 3291, 14, 6404, 63, 515, 9, 267, 871, 2186, 26, 288, 747, 14, 8215, 8, 3291, 14, 6404, 63, 515, 9, 267, 1592, 72, 275, 24683, 3694, 8882, 8, 3291, 14, 4659, 12, 3999, 14, 6404, 63, 515, 12, 15751, 9, 267, 1592, 72, 14, 793, 63, 697, 63, 1117, 63, 6404, 342, 267, 1592, 72, 14, 1600, 342, 272, 587, 26, 267, 870, 298, 4659, 450, 83, 1630, 440, 2187, 2, 450, 3999, 14, 4659, 421, 199, 3, 2104, 8582, 15486, 316, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
spatialdev/onadata
onadata/apps/logger/migrations/0020_auto__chg_field_instance_uuid.py
13
8321
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'Instance.uuid' db.alter_column('odk_logger_instance', 'uuid', self.gf('django.db.models.fields.CharField')(max_length=249)) def backwards(self, orm): # Changing field 'Instance.uuid' db.alter_column('odk_logger_instance', 'uuid', self.gf('django.db.models.fields.CharField')(max_length=36)) models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'odk_logger.attachment': { 'Meta': {'object_name': 'Attachment'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'instance': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attachments'", 'to': "orm['odk_logger.Instance']"}), 'media_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}) }, 'odk_logger.instance': { 'Meta': {'object_name': 'Instance'}, 'date': ('django.db.models.fields.DateField', [], {'null': 'True'}), 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'start_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "u'submitted_via_web'", 'max_length': '20'}), 'survey_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['odk_logger.SurveyType']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'surveys'", 'null': 'True', 'to': "orm['auth.User']"}), 'uuid': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '249'}), 'xform': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'surveys'", 'null': 'True', 'to': "orm['odk_logger.XForm']"}), 'xml': ('django.db.models.fields.TextField', [], {}) }, 'odk_logger.instancehistory': { 'Meta': {'object_name': 'InstanceHistory'}, 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'xform_instance': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'submission_history'", 'to': "orm['odk_logger.Instance']"}), 'xml': ('django.db.models.fields.TextField', [], {}) }, 'odk_logger.surveytype': { 'Meta': {'object_name': 'SurveyType'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'slug': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'odk_logger.xform': { 'Meta': {'ordering': "('id_string',)", 'unique_together': "(('user', 'id_string'),)", 'object_name': 'XForm'}, 'bamboo_dataset': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '60'}), 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'default': "u''", 'null': 'True'}), 'downloadable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'has_start_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'id_string': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}), 'is_crowd_form': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'json': ('django.db.models.fields.TextField', [], {'default': "u''"}), 'shared': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'shared_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'xforms'", 'null': 'True', 'to': "orm['auth.User']"}), 'uuid': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '32'}), 'xls': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True'}), 'xml': ('django.db.models.fields.TextField', [], {}) } } complete_apps = ['logger']
bsd-2-clause
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3244, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 360, 364, 75, 63, 2921, 63, 842, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 11032, 430, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3244, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 360, 364, 75, 63, 2921, 63, 842, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1344, 430, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 364, 75, 63, 2921, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3244, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 360, 364, 75, 63, 2921, 63, 842, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 11032, 430, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3244, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 360, 364, 75, 63, 2921, 63, 842, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1344, 430, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 364, 75, 63, 2921, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mmcdermo/helpinghand
server/venv/lib/python2.7/site-packages/django/contrib/flatpages/tests/test_views.py
207
5659
import os from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.flatpages.models import FlatPage from django.test import TestCase from django.test.utils import override_settings @override_settings( LOGIN_URL='/accounts/login/', MIDDLEWARE_CLASSES=( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware' ), TEMPLATE_DIRS=( os.path.join(os.path.dirname(__file__), 'templates'), ), SITE_ID=1, ) class FlatpageViewTests(TestCase): fixtures = ['sample_flatpages', 'example_site'] urls = 'django.contrib.flatpages.tests.urls' def test_view_flatpage(self): "A flatpage can be served through a view" response = self.client.get('/flatpage_root/flatpage/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it flat!</p>") def test_view_non_existent_flatpage(self): "A non-existent flatpage raises 404 when served through a view" response = self.client.get('/flatpage_root/no_such_flatpage/') self.assertEqual(response.status_code, 404) @skipIfCustomUser def test_view_authenticated_flatpage(self): "A flatpage served through a view can require authentication" response = self.client.get('/flatpage_root/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/') User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser',password='s3krit') response = self.client.get('/flatpage_root/sekrit/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it sekrit!</p>") def test_fallback_flatpage(self): "A fallback flatpage won't be served if the middleware is disabled" response = self.client.get('/flatpage/') self.assertEqual(response.status_code, 404) def test_fallback_non_existent_flatpage(self): "A non-existent flatpage won't be served if the fallback middlware is disabled" response = self.client.get('/no_such_flatpage/') self.assertEqual(response.status_code, 404) def test_view_flatpage_special_chars(self): "A flatpage with special chars in the URL can be served through a view" fp = FlatPage.objects.create( url="/some.very_special~chars-here/", title="A very special page", content="Isn't it special!", enable_comments=False, registration_required=False, ) fp.sites.add(settings.SITE_ID) response = self.client.get('/flatpage_root/some.very_special~chars-here/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it special!</p>") @override_settings( APPEND_SLASH = True, LOGIN_URL='/accounts/login/', MIDDLEWARE_CLASSES=( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware' ), TEMPLATE_DIRS=( os.path.join(os.path.dirname(__file__), 'templates'), ), SITE_ID=1, ) class FlatpageViewAppendSlashTests(TestCase): fixtures = ['sample_flatpages', 'example_site'] urls = 'django.contrib.flatpages.tests.urls' def test_redirect_view_flatpage(self): "A flatpage can be served through a view and should add a slash" response = self.client.get('/flatpage_root/flatpage') self.assertRedirects(response, '/flatpage_root/flatpage/', status_code=301) def test_redirect_view_non_existent_flatpage(self): "A non-existent flatpage raises 404 when served through a view and should not add a slash" response = self.client.get('/flatpage_root/no_such_flatpage') self.assertEqual(response.status_code, 404) def test_redirect_fallback_flatpage(self): "A fallback flatpage won't be served if the middleware is disabled and should not add a slash" response = self.client.get('/flatpage') self.assertEqual(response.status_code, 404) def test_redirect_fallback_non_existent_flatpage(self): "A non-existent flatpage won't be served if the fallback middlware is disabled and should not add a slash" response = self.client.get('/no_such_flatpage') self.assertEqual(response.status_code, 404) def test_redirect_view_flatpage_special_chars(self): "A flatpage with special chars in the URL can be served through a view and should add a slash" fp = FlatPage.objects.create( url="/some.very_special~chars-here/", title="A very special page", content="Isn't it special!", enable_comments=False, registration_required=False, ) fp.sites.add(settings.SITE_ID) response = self.client.get('/flatpage_root/some.very_special~chars-here') self.assertRedirects(response, '/flatpage_root/some.very_special~chars-here/', status_code=301)
mit
[ 646, 747, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 2828, 14, 29974, 14, 992, 492, 19005, 3276, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 421, 199, 32, 4415, 63, 1751, 8, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 2687, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 327, 949, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 7, 272, 2318, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 659, 272, 2318, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 2768, 2925, 8, 1746, 304, 272, 15188, 275, 788, 3271, 63, 29974, 297, 283, 2694, 63, 2124, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 29974, 14, 2219, 14, 3603, 7, 339, 347, 511, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 1345, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 7901, 1380, 19733, 4012, 282, 2455, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 768, 15118, 31482, 272, 347, 511, 63, 1345, 63, 12177, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 19733, 4012, 282, 2455, 883, 4409, 6299, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 17466, 8, 1310, 12, 1994, 8370, 15, 2886, 10197, 2184, 13043, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 83, 19, 75, 11133, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 21029, 297, 2060, 534, 83, 19, 75, 11133, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 542, 75, 11133, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 26587, 8, 277, 304, 267, 298, 33, 9567, 6829, 1606, 7859, 1133, 506, 19733, 340, 314, 10816, 365, 6980, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 10538, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 7859, 1133, 506, 19733, 340, 314, 9567, 10887, 5030, 1068, 365, 6980, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 1345, 63, 26587, 63, 6664, 63, 6574, 8, 277, 304, 267, 298, 33, 6829, 1606, 543, 4539, 8365, 315, 314, 2851, 883, 506, 19733, 4012, 282, 2455, 2, 267, 4090, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 9555, 3972, 14, 2588, 63, 6664, 94, 6574, 13, 1681, 10665, 288, 2538, 628, 33, 7437, 4539, 2034, 401, 288, 1564, 628, 1831, 78, 1133, 652, 4539, 17716, 288, 4756, 63, 6223, 29, 797, 12, 288, 10991, 63, 2427, 29, 797, 12, 267, 776, 267, 4090, 14, 8619, 14, 525, 8, 1751, 14, 7917, 63, 998, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 3972, 14, 2588, 63, 6664, 94, 6574, 13, 1681, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 4539, 28718, 80, 9579, 421, 199, 32, 4415, 63, 1751, 8, 272, 19525, 3902, 63, 27192, 275, 715, 12, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 2687, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 327, 949, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 7, 272, 2318, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 659, 272, 2318, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 2768, 8310, 11592, 1119, 2925, 8, 1746, 304, 272, 15188, 275, 788, 3271, 63, 29974, 297, 283, 2694, 63, 2124, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 29974, 14, 2219, 14, 3603, 7, 339, 347, 511, 63, 4876, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 436, 1077, 1050, 282, 14457, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 358 ]
[ 747, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 2828, 14, 29974, 14, 992, 492, 19005, 3276, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 421, 199, 32, 4415, 63, 1751, 8, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 2687, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 327, 949, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 7, 272, 2318, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 659, 272, 2318, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 2768, 2925, 8, 1746, 304, 272, 15188, 275, 788, 3271, 63, 29974, 297, 283, 2694, 63, 2124, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 29974, 14, 2219, 14, 3603, 7, 339, 347, 511, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 1345, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 7901, 1380, 19733, 4012, 282, 2455, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 768, 15118, 31482, 272, 347, 511, 63, 1345, 63, 12177, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 19733, 4012, 282, 2455, 883, 4409, 6299, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 17466, 8, 1310, 12, 1994, 8370, 15, 2886, 10197, 2184, 13043, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 83, 19, 75, 11133, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 21029, 297, 2060, 534, 83, 19, 75, 11133, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 542, 75, 11133, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 26587, 8, 277, 304, 267, 298, 33, 9567, 6829, 1606, 7859, 1133, 506, 19733, 340, 314, 10816, 365, 6980, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 10538, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 7859, 1133, 506, 19733, 340, 314, 9567, 10887, 5030, 1068, 365, 6980, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 1345, 63, 26587, 63, 6664, 63, 6574, 8, 277, 304, 267, 298, 33, 6829, 1606, 543, 4539, 8365, 315, 314, 2851, 883, 506, 19733, 4012, 282, 2455, 2, 267, 4090, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 9555, 3972, 14, 2588, 63, 6664, 94, 6574, 13, 1681, 10665, 288, 2538, 628, 33, 7437, 4539, 2034, 401, 288, 1564, 628, 1831, 78, 1133, 652, 4539, 17716, 288, 4756, 63, 6223, 29, 797, 12, 288, 10991, 63, 2427, 29, 797, 12, 267, 776, 267, 4090, 14, 8619, 14, 525, 8, 1751, 14, 7917, 63, 998, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 3972, 14, 2588, 63, 6664, 94, 6574, 13, 1681, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 4539, 28718, 80, 9579, 421, 199, 32, 4415, 63, 1751, 8, 272, 19525, 3902, 63, 27192, 275, 715, 12, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 2687, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 327, 949, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 7, 272, 2318, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 659, 272, 2318, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 2768, 8310, 11592, 1119, 2925, 8, 1746, 304, 272, 15188, 275, 788, 3271, 63, 29974, 297, 283, 2694, 63, 2124, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 29974, 14, 2219, 14, 3603, 7, 339, 347, 511, 63, 4876, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 436, 1077, 1050, 282, 14457, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 358, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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