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
blueburningcoder/pybrain
pybrain/optimization/populationbased/evolution.py
31
1133
__author__ = 'Tom Schaul, tom@idsia.ch' from pybrain.utilities import abstractMethod from pybrain.optimization.optimizer import BlackBoxOptimizer class Evolution(BlackBoxOptimizer): """ Base class for evolutionary algorithms, seen as function optimizers. """ populationSize = 10 storeAllPopulations = False mustMaximize = True def _additionalInit(self): self.currentpop = [] self.fitnesses = [] self._allGenerations = [] self.initPopulation() def _learnStep(self): """ do one generation step """ self.fitnesses = [self._oneEvaluation(indiv) for indiv in self.currentpop] if self.storeAllPopulations: self._allGenerations.append((self.currentpop, self.fitnesses)) self.produceOffspring() def initPopulation(self): """ initialize the population """ abstractMethod() def produceOffspring(self): """ generate the new generation of offspring, given the current population, and their fitnesses """ abstractMethod() @property def batchSize(self): return self.populationSize
bsd-3-clause
[ 363, 2502, 363, 275, 283, 52, 676, 428, 9518, 348, 12, 370, 77, 32, 344, 10971, 14, 335, 7, 199, 199, 504, 1134, 22246, 14, 16355, 492, 9006, 3767, 199, 504, 1134, 22246, 14, 31405, 14, 12290, 492, 30593, 3532, 13946, 421, 199, 533, 662, 86, 3347, 8, 23405, 3532, 13946, 304, 272, 408, 3523, 1021, 367, 8145, 3347, 695, 18036, 12, 6775, 465, 805, 5323, 6315, 14, 408, 339, 16423, 2320, 275, 1616, 339, 3877, 2422, 9606, 21429, 275, 756, 339, 1471, 4261, 11807, 275, 715, 339, 347, 485, 8460, 9346, 8, 277, 304, 267, 291, 14, 1818, 1935, 275, 942, 267, 291, 14, 3269, 17775, 874, 275, 942, 267, 291, 423, 452, 3139, 1298, 275, 942, 267, 291, 14, 826, 31824, 342, 339, 347, 485, 4643, 7801, 8, 277, 304, 267, 408, 886, 1373, 10152, 3650, 408, 267, 291, 14, 3269, 17775, 874, 275, 359, 277, 423, 368, 29786, 8, 262, 3015, 9, 367, 2539, 86, 315, 291, 14, 1818, 1935, 61, 267, 340, 291, 14, 1617, 2422, 9606, 21429, 26, 288, 291, 423, 452, 3139, 1298, 14, 740, 1332, 277, 14, 1818, 1935, 12, 291, 14, 3269, 17775, 874, 430, 267, 291, 14, 7832, 5195, 26008, 342, 339, 347, 4205, 31824, 8, 277, 304, 267, 408, 8265, 314, 16423, 408, 267, 9006, 3767, 342, 339, 347, 7389, 5195, 26008, 8, 277, 304, 267, 408, 3550, 314, 892, 10152, 402, 2331, 26008, 12, 1627, 314, 1453, 16423, 12, 436, 3932, 5542, 17775, 874, 408, 267, 9006, 3767, 342, 339, 768, 1829, 272, 347, 3522, 2320, 8, 277, 304, 267, 372, 291, 14, 16003, 2320, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 52, 676, 428, 9518, 348, 12, 370, 77, 32, 344, 10971, 14, 335, 7, 199, 199, 504, 1134, 22246, 14, 16355, 492, 9006, 3767, 199, 504, 1134, 22246, 14, 31405, 14, 12290, 492, 30593, 3532, 13946, 421, 199, 533, 662, 86, 3347, 8, 23405, 3532, 13946, 304, 272, 408, 3523, 1021, 367, 8145, 3347, 695, 18036, 12, 6775, 465, 805, 5323, 6315, 14, 408, 339, 16423, 2320, 275, 1616, 339, 3877, 2422, 9606, 21429, 275, 756, 339, 1471, 4261, 11807, 275, 715, 339, 347, 485, 8460, 9346, 8, 277, 304, 267, 291, 14, 1818, 1935, 275, 942, 267, 291, 14, 3269, 17775, 874, 275, 942, 267, 291, 423, 452, 3139, 1298, 275, 942, 267, 291, 14, 826, 31824, 342, 339, 347, 485, 4643, 7801, 8, 277, 304, 267, 408, 886, 1373, 10152, 3650, 408, 267, 291, 14, 3269, 17775, 874, 275, 359, 277, 423, 368, 29786, 8, 262, 3015, 9, 367, 2539, 86, 315, 291, 14, 1818, 1935, 61, 267, 340, 291, 14, 1617, 2422, 9606, 21429, 26, 288, 291, 423, 452, 3139, 1298, 14, 740, 1332, 277, 14, 1818, 1935, 12, 291, 14, 3269, 17775, 874, 430, 267, 291, 14, 7832, 5195, 26008, 342, 339, 347, 4205, 31824, 8, 277, 304, 267, 408, 8265, 314, 16423, 408, 267, 9006, 3767, 342, 339, 347, 7389, 5195, 26008, 8, 277, 304, 267, 408, 3550, 314, 892, 10152, 402, 2331, 26008, 12, 1627, 314, 1453, 16423, 12, 436, 3932, 5542, 17775, 874, 408, 267, 9006, 3767, 342, 339, 768, 1829, 272, 347, 3522, 2320, 8, 277, 304, 267, 372, 291, 14, 16003, 2320, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
OpenUpgrade/OpenUpgrade
addons/email_template/wizard/__init__.py
446
1130
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2009 Sharoon Thomas # Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU 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 email_template_preview import mail_compose_message # 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, 8937, 5244, 285, 79, 265, 27864, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 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, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 646, 3031, 63, 1160, 63, 7780, 199, 646, 6016, 63, 12607, 63, 1188, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8937, 5244, 285, 79, 265, 27864, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 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, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 646, 3031, 63, 1160, 63, 7780, 199, 646, 6016, 63, 12607, 63, 1188, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wdv4758h/ZipPy
lib-python/3/encodings/quopri_codec.py
55
1550
"""Codec for quoted-printable encoding. This codec de/encodes from bytes to bytes and is therefore usable with bytes.transform() and bytes.untransform(). """ import codecs import quopri from io import BytesIO def quopri_encode(input, errors='strict'): assert errors == 'strict' f = BytesIO(input) g = BytesIO() quopri.encode(f, g, 1) return (g.getvalue(), len(input)) def quopri_decode(input, errors='strict'): assert errors == 'strict' f = BytesIO(input) g = BytesIO() quopri.decode(f, g) return (g.getvalue(), len(input)) class Codec(codecs.Codec): def encode(self, input, errors='strict'): return quopri_encode(input, errors) def decode(self, input, errors='strict'): return quopri_decode(input, errors) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return quopri_encode(input, self.errors)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return quopri_decode(input, self.errors)[0] class StreamWriter(Codec, codecs.StreamWriter): charbuffertype = bytes class StreamReader(Codec, codecs.StreamReader): charbuffertype = bytes # encodings module API def getregentry(): return codecs.CodecInfo( name='quopri', encode=quopri_encode, decode=quopri_decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, )
bsd-3-clause
[ 624, 8818, 367, 10999, 13, 20557, 2644, 14, 199, 199, 2765, 9076, 477, 15, 2143, 83, 687, 2783, 370, 2783, 436, 365, 16119, 18025, 543, 199, 2394, 14, 4711, 342, 436, 2783, 14, 324, 4711, 1252, 199, 624, 199, 199, 646, 6010, 199, 646, 2173, 21993, 199, 504, 5890, 492, 11808, 199, 199, 318, 2173, 21993, 63, 2143, 8, 1210, 12, 2552, 534, 4768, 735, 272, 702, 2552, 508, 283, 4768, 7, 272, 289, 275, 11808, 8, 1210, 9, 272, 486, 275, 11808, 342, 272, 2173, 21993, 14, 2143, 8, 70, 12, 486, 12, 413, 9, 272, 372, 334, 71, 14, 7150, 1062, 822, 8, 1210, 430, 199, 199, 318, 2173, 21993, 63, 2708, 8, 1210, 12, 2552, 534, 4768, 735, 272, 702, 2552, 508, 283, 4768, 7, 272, 289, 275, 11808, 8, 1210, 9, 272, 486, 275, 11808, 342, 272, 2173, 21993, 14, 2708, 8, 70, 12, 486, 9, 272, 372, 334, 71, 14, 7150, 1062, 822, 8, 1210, 430, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 2173, 21993, 63, 2143, 8, 1210, 12, 2552, 9, 272, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 2173, 21993, 63, 2708, 8, 1210, 12, 2552, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 2173, 21993, 63, 2143, 8, 1210, 12, 291, 14, 2550, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 2173, 21993, 63, 2708, 8, 1210, 12, 291, 14, 2550, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 6010, 14, 16551, 304, 272, 1495, 2738, 466, 275, 2783, 199, 199, 533, 22970, 8, 8818, 12, 6010, 14, 16132, 304, 272, 1495, 2738, 466, 275, 2783, 199, 199, 3, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 392, 21993, 297, 267, 3752, 29, 392, 21993, 63, 2143, 12, 267, 4849, 29, 392, 21993, 63, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26112, 29, 16551, 12, 267, 26101, 29, 16132, 12, 272, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8818, 367, 10999, 13, 20557, 2644, 14, 199, 199, 2765, 9076, 477, 15, 2143, 83, 687, 2783, 370, 2783, 436, 365, 16119, 18025, 543, 199, 2394, 14, 4711, 342, 436, 2783, 14, 324, 4711, 1252, 199, 624, 199, 199, 646, 6010, 199, 646, 2173, 21993, 199, 504, 5890, 492, 11808, 199, 199, 318, 2173, 21993, 63, 2143, 8, 1210, 12, 2552, 534, 4768, 735, 272, 702, 2552, 508, 283, 4768, 7, 272, 289, 275, 11808, 8, 1210, 9, 272, 486, 275, 11808, 342, 272, 2173, 21993, 14, 2143, 8, 70, 12, 486, 12, 413, 9, 272, 372, 334, 71, 14, 7150, 1062, 822, 8, 1210, 430, 199, 199, 318, 2173, 21993, 63, 2708, 8, 1210, 12, 2552, 534, 4768, 735, 272, 702, 2552, 508, 283, 4768, 7, 272, 289, 275, 11808, 8, 1210, 9, 272, 486, 275, 11808, 342, 272, 2173, 21993, 14, 2708, 8, 70, 12, 486, 9, 272, 372, 334, 71, 14, 7150, 1062, 822, 8, 1210, 430, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 2173, 21993, 63, 2143, 8, 1210, 12, 2552, 9, 272, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 2173, 21993, 63, 2708, 8, 1210, 12, 2552, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 2173, 21993, 63, 2143, 8, 1210, 12, 291, 14, 2550, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 2173, 21993, 63, 2708, 8, 1210, 12, 291, 14, 2550, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 6010, 14, 16551, 304, 272, 1495, 2738, 466, 275, 2783, 199, 199, 533, 22970, 8, 8818, 12, 6010, 14, 16132, 304, 272, 1495, 2738, 466, 275, 2783, 199, 199, 3, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 392, 21993, 297, 267, 3752, 29, 392, 21993, 63, 2143, 12, 267, 4849, 29, 392, 21993, 63, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26112, 29, 16551, 12, 267, 26101, 29, 16132, 12, 272, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
martinghunt/ariba
ariba/sequence_metadata.py
2
1992
from ariba import sequence_variant class Error (Exception): pass class SequenceMetadata: def __init__(self, line): try: self.name, seq_type, var_only, variant, variant_id, self.free_text = line.rstrip().split('\t') except: raise Error('Error parsing line of file:\n' + line) if seq_type not in {'0', '1'}: raise Error('Error. Second column must be "0" or "1". Cannot continue. Line was:\n' + line) self.seq_type = 'n' if seq_type == '0' else 'p' if var_only not in {'0', '1'}: raise Error('Error. Third column must be "0" or "1". Cannot continue. Line was:\n' + line) self.variant_only = var_only == '1' if variant == '.': self.variant = None else: self.variant = sequence_variant.Variant(self.seq_type, variant, variant_id) def __eq__(self, other): return type(other) is type(self) and self.name == other.name and self.seq_type == other.seq_type and self.variant_only == other.variant_only and self.variant == other.variant and self.free_text == other.free_text def __lt__(self, other): return self.name < other.name or (self.name == other.name and self.variant is not None and other.variant is not None and self.variant < other.variant) def __hash__(self): return hash((self.name, self.seq_type, str(self.variant), self.free_text)) def __str__(self): return self.to_string() def to_string(self, separator='\t'): return separator.join([ self.name, '1' if self.seq_type == 'p' else '0', '1' if self.variant_only else '0', '.' if self.variant is None else str(self.variant), '.' if (self.variant is None or self.variant.identifier is None) else self.variant.identifier, self.free_text ]) def has_variant(self, seq): return self.variant is not None and self.variant.has_variant(seq)
gpl-3.0
[ 504, 14554, 2470, 492, 3414, 63, 8759, 199, 199, 533, 4520, 334, 1726, 304, 986, 421, 199, 533, 10975, 5142, 26, 272, 347, 636, 826, 721, 277, 12, 1004, 304, 267, 862, 26, 288, 291, 14, 354, 12, 5412, 63, 466, 12, 2729, 63, 2118, 12, 9854, 12, 9854, 63, 344, 12, 291, 14, 4624, 63, 505, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 267, 871, 26, 288, 746, 4520, 360, 547, 6057, 1004, 402, 570, 3427, 78, 7, 435, 1004, 9, 398, 340, 5412, 63, 466, 440, 315, 791, 16, 297, 283, 17, 936, 26, 288, 746, 4520, 360, 547, 14, 16707, 2763, 1471, 506, 298, 16, 2, 503, 298, 17, 1674, 18435, 1980, 14, 7030, 1990, 3427, 78, 7, 435, 1004, 9, 398, 291, 14, 3610, 63, 466, 275, 283, 78, 7, 340, 5412, 63, 466, 508, 283, 16, 7, 587, 283, 80, 7, 398, 340, 2729, 63, 2118, 440, 315, 791, 16, 297, 283, 17, 936, 26, 288, 746, 4520, 360, 547, 14, 31079, 2763, 1471, 506, 298, 16, 2, 503, 298, 17, 1674, 18435, 1980, 14, 7030, 1990, 3427, 78, 7, 435, 1004, 9, 398, 291, 14, 8759, 63, 2118, 275, 2729, 63, 2118, 508, 283, 17, 7, 398, 340, 9854, 508, 26351, 288, 291, 14, 8759, 275, 488, 267, 587, 26, 288, 291, 14, 8759, 275, 3414, 63, 8759, 14, 12935, 8, 277, 14, 3610, 63, 466, 12, 9854, 12, 9854, 63, 344, 9, 2378, 347, 636, 4077, 721, 277, 12, 1163, 304, 2126, 372, 730, 8, 1848, 9, 365, 730, 8, 277, 9, 436, 291, 14, 354, 508, 1163, 14, 354, 436, 291, 14, 3610, 63, 466, 508, 1163, 14, 3610, 63, 466, 436, 291, 14, 8759, 63, 2118, 508, 1163, 14, 8759, 63, 2118, 436, 291, 14, 8759, 508, 1163, 14, 8759, 436, 291, 14, 4624, 63, 505, 508, 1163, 14, 4624, 63, 505, 2378, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 665, 1163, 14, 354, 503, 334, 277, 14, 354, 508, 1163, 14, 354, 436, 291, 14, 8759, 365, 440, 488, 436, 1163, 14, 8759, 365, 440, 488, 436, 291, 14, 8759, 665, 1163, 14, 8759, 9, 2378, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 1332, 277, 14, 354, 12, 291, 14, 3610, 63, 466, 12, 620, 8, 277, 14, 8759, 395, 291, 14, 4624, 63, 505, 430, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 475, 63, 875, 342, 2378, 347, 370, 63, 875, 8, 277, 12, 9432, 17115, 84, 735, 267, 372, 9432, 14, 904, 779, 288, 291, 14, 354, 12, 288, 283, 17, 7, 340, 291, 14, 3610, 63, 466, 508, 283, 80, 7, 587, 283, 16, 297, 288, 283, 17, 7, 340, 291, 14, 8759, 63, 2118, 587, 283, 16, 297, 288, 7815, 340, 291, 14, 8759, 365, 488, 587, 620, 8, 277, 14, 8759, 395, 288, 7815, 340, 334, 277, 14, 8759, 365, 488, 503, 291, 14, 8759, 14, 5364, 365, 488, 9, 587, 291, 14, 8759, 14, 5364, 12, 288, 291, 14, 4624, 63, 505, 267, 4794, 2378, 347, 965, 63, 8759, 8, 277, 12, 5412, 304, 267, 372, 291, 14, 8759, 365, 440, 488, 436, 291, 14, 8759, 14, 1989, 63, 8759, 8, 3610, 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 ]
[ 14554, 2470, 492, 3414, 63, 8759, 199, 199, 533, 4520, 334, 1726, 304, 986, 421, 199, 533, 10975, 5142, 26, 272, 347, 636, 826, 721, 277, 12, 1004, 304, 267, 862, 26, 288, 291, 14, 354, 12, 5412, 63, 466, 12, 2729, 63, 2118, 12, 9854, 12, 9854, 63, 344, 12, 291, 14, 4624, 63, 505, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 267, 871, 26, 288, 746, 4520, 360, 547, 6057, 1004, 402, 570, 3427, 78, 7, 435, 1004, 9, 398, 340, 5412, 63, 466, 440, 315, 791, 16, 297, 283, 17, 936, 26, 288, 746, 4520, 360, 547, 14, 16707, 2763, 1471, 506, 298, 16, 2, 503, 298, 17, 1674, 18435, 1980, 14, 7030, 1990, 3427, 78, 7, 435, 1004, 9, 398, 291, 14, 3610, 63, 466, 275, 283, 78, 7, 340, 5412, 63, 466, 508, 283, 16, 7, 587, 283, 80, 7, 398, 340, 2729, 63, 2118, 440, 315, 791, 16, 297, 283, 17, 936, 26, 288, 746, 4520, 360, 547, 14, 31079, 2763, 1471, 506, 298, 16, 2, 503, 298, 17, 1674, 18435, 1980, 14, 7030, 1990, 3427, 78, 7, 435, 1004, 9, 398, 291, 14, 8759, 63, 2118, 275, 2729, 63, 2118, 508, 283, 17, 7, 398, 340, 9854, 508, 26351, 288, 291, 14, 8759, 275, 488, 267, 587, 26, 288, 291, 14, 8759, 275, 3414, 63, 8759, 14, 12935, 8, 277, 14, 3610, 63, 466, 12, 9854, 12, 9854, 63, 344, 9, 2378, 347, 636, 4077, 721, 277, 12, 1163, 304, 2126, 372, 730, 8, 1848, 9, 365, 730, 8, 277, 9, 436, 291, 14, 354, 508, 1163, 14, 354, 436, 291, 14, 3610, 63, 466, 508, 1163, 14, 3610, 63, 466, 436, 291, 14, 8759, 63, 2118, 508, 1163, 14, 8759, 63, 2118, 436, 291, 14, 8759, 508, 1163, 14, 8759, 436, 291, 14, 4624, 63, 505, 508, 1163, 14, 4624, 63, 505, 2378, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 665, 1163, 14, 354, 503, 334, 277, 14, 354, 508, 1163, 14, 354, 436, 291, 14, 8759, 365, 440, 488, 436, 1163, 14, 8759, 365, 440, 488, 436, 291, 14, 8759, 665, 1163, 14, 8759, 9, 2378, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 1332, 277, 14, 354, 12, 291, 14, 3610, 63, 466, 12, 620, 8, 277, 14, 8759, 395, 291, 14, 4624, 63, 505, 430, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 475, 63, 875, 342, 2378, 347, 370, 63, 875, 8, 277, 12, 9432, 17115, 84, 735, 267, 372, 9432, 14, 904, 779, 288, 291, 14, 354, 12, 288, 283, 17, 7, 340, 291, 14, 3610, 63, 466, 508, 283, 80, 7, 587, 283, 16, 297, 288, 283, 17, 7, 340, 291, 14, 8759, 63, 2118, 587, 283, 16, 297, 288, 7815, 340, 291, 14, 8759, 365, 488, 587, 620, 8, 277, 14, 8759, 395, 288, 7815, 340, 334, 277, 14, 8759, 365, 488, 503, 291, 14, 8759, 14, 5364, 365, 488, 9, 587, 291, 14, 8759, 14, 5364, 12, 288, 291, 14, 4624, 63, 505, 267, 4794, 2378, 347, 965, 63, 8759, 8, 277, 12, 5412, 304, 267, 372, 291, 14, 8759, 365, 440, 488, 436, 291, 14, 8759, 14, 1989, 63, 8759, 8, 3610, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
roadev/electron
script/lib/github.py
200
2214
#!/usr/bin/env python import json import os import re import sys REQUESTS_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor', 'requests')) sys.path.append(os.path.join(REQUESTS_DIR, 'build', 'lib')) sys.path.append(os.path.join(REQUESTS_DIR, 'build', 'lib.linux-x86_64-2.7')) import requests GITHUB_URL = 'https://api.github.com' GITHUB_UPLOAD_ASSET_URL = 'https://uploads.github.com' class GitHub: def __init__(self, access_token): self._authorization = 'token %s' % access_token pattern = '^/repos/{0}/{0}/releases/{1}/assets$'.format('[^/]+', '[0-9]+') self._releases_upload_api_pattern = re.compile(pattern) def __getattr__(self, attr): return _Callable(self, '/%s' % attr) def send(self, method, path, **kw): if not 'headers' in kw: kw['headers'] = dict() headers = kw['headers'] headers['Authorization'] = self._authorization headers['Accept'] = 'application/vnd.github.manifold-preview' # Switch to a different domain for the releases uploading API. if self._releases_upload_api_pattern.match(path): url = '%s%s' % (GITHUB_UPLOAD_ASSET_URL, path) else: url = '%s%s' % (GITHUB_URL, path) # Data are sent in JSON format. if 'data' in kw: kw['data'] = json.dumps(kw['data']) r = getattr(requests, method)(url, **kw).json() if 'message' in r: raise Exception(json.dumps(r, indent=2, separators=(',', ': '))) return r class _Executable: def __init__(self, gh, method, path): self._gh = gh self._method = method self._path = path def __call__(self, **kw): return self._gh.send(self._method, self._path, **kw) class _Callable(object): def __init__(self, gh, name): self._gh = gh self._name = name def __call__(self, *args): if len(args) == 0: return self name = '%s/%s' % (self._name, '/'.join([str(arg) for arg in args])) return _Callable(self._gh, name) def __getattr__(self, attr): if attr in ['get', 'put', 'post', 'patch', 'delete']: return _Executable(self._gh, attr, self._name) name = '%s/%s' % (self._name, attr) return _Callable(self._gh, name)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 6780, 51, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 19155, 19155, 19155, 4490, 283, 9884, 297, 283, 6615, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6780, 51, 63, 3022, 12, 283, 1506, 297, 283, 773, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6780, 51, 63, 3022, 12, 283, 1506, 297, 283, 773, 14, 5135, 13, 88, 1184, 63, 772, 13, 18, 14, 23, 1333, 199, 646, 4145, 199, 199, 39, 30087, 63, 2632, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 7, 199, 39, 30087, 63, 16418, 63, 1179, 3597, 63, 2632, 275, 283, 2859, 921, 21725, 14, 5031, 14, 957, 7, 199, 199, 533, 25141, 26, 523, 347, 636, 826, 721, 277, 12, 2879, 63, 1418, 304, 272, 291, 423, 15846, 275, 283, 1418, 450, 83, 7, 450, 2879, 63, 1418, 339, 3851, 275, 14452, 15, 11857, 5321, 16, 16152, 16, 5995, 11840, 5321, 17, 5995, 12186, 4, 1370, 908, 360, 4735, 15, 11529, 6730, 16, 13, 25, 2807, 358, 272, 291, 423, 11840, 63, 5064, 63, 1246, 63, 3401, 275, 295, 14, 2014, 8, 3401, 9, 819, 347, 636, 5675, 721, 277, 12, 1921, 304, 272, 372, 485, 16410, 8, 277, 12, 1994, 5, 83, 7, 450, 1921, 9, 819, 347, 3222, 8, 277, 12, 1083, 12, 931, 12, 1011, 829, 304, 272, 340, 440, 283, 2139, 7, 315, 4775, 26, 489, 4775, 459, 2139, 418, 275, 1211, 342, 272, 2323, 275, 4775, 459, 2139, 418, 272, 2323, 459, 11626, 418, 275, 291, 423, 15846, 272, 2323, 459, 8422, 418, 275, 283, 3578, 15, 26379, 14, 5031, 14, 1237, 32294, 13, 7780, 7, 339, 327, 17711, 370, 282, 3365, 2881, 367, 314, 19015, 24349, 3261, 14, 272, 340, 291, 423, 11840, 63, 5064, 63, 1246, 63, 3401, 14, 1431, 8, 515, 304, 489, 1166, 275, 1543, 83, 5, 83, 7, 450, 334, 39, 30087, 63, 16418, 63, 1179, 3597, 63, 2632, 12, 931, 9, 272, 587, 26, 489, 1166, 275, 1543, 83, 5, 83, 7, 450, 334, 39, 30087, 63, 2632, 12, 931, 9, 489, 327, 3918, 787, 4847, 315, 4840, 1475, 14, 489, 340, 283, 576, 7, 315, 4775, 26, 267, 4775, 459, 576, 418, 275, 2022, 14, 4180, 8, 829, 459, 576, 1105, 339, 519, 275, 2519, 8, 6615, 12, 1083, 5130, 633, 12, 1011, 829, 680, 1001, 342, 272, 340, 283, 1188, 7, 315, 519, 26, 489, 746, 2186, 8, 1001, 14, 4180, 8, 82, 12, 4363, 29, 18, 12, 17658, 2687, 23324, 7596, 283, 1724, 272, 372, 519, 421, 199, 533, 485, 18039, 26, 523, 347, 636, 826, 721, 277, 12, 23310, 12, 1083, 12, 931, 304, 272, 291, 423, 3561, 275, 23310, 272, 291, 423, 765, 275, 1083, 272, 291, 423, 515, 275, 931, 819, 347, 636, 1250, 721, 277, 12, 1011, 829, 304, 272, 372, 291, 423, 3561, 14, 2254, 8, 277, 423, 765, 12, 291, 423, 515, 12, 1011, 829, 9, 421, 199, 533, 485, 16410, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 23310, 12, 536, 304, 272, 291, 423, 3561, 275, 23310, 272, 291, 423, 354, 275, 536, 819, 347, 636, 1250, 721, 277, 12, 627, 589, 304, 272, 340, 822, 8, 589, 9, 508, 378, 26, 489, 372, 291, 339, 536, 275, 1543, 83, 3149, 83, 7, 450, 334, 277, 423, 354, 12, 20538, 904, 779, 495, 8, 1273, 9, 367, 1680, 315, 1249, 2459, 272, 372, 485, 16410, 8, 277, 423, 3561, 12, 536, 9, 819, 347, 636, 5675, 721, 277, 12, 1921, 304, 272, 340, 1921, 315, 788, 362, 297, 283, 524, 297, 283, 1932, 297, 283, 2068, 297, 283, 1807, 2565, 489, 372, 485, 18039, 8, 277, 423, 3561, 12, 1921, 12, 291, 423, 354, 9, 339, 536, 275, 1543, 83, 3149, 83, 7, 450, 334, 277, 423, 354, 12, 1921, 9, 272, 372, 485, 16410, 8, 277, 423, 3561, 12, 536, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 6780, 51, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 19155, 19155, 19155, 4490, 283, 9884, 297, 283, 6615, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6780, 51, 63, 3022, 12, 283, 1506, 297, 283, 773, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6780, 51, 63, 3022, 12, 283, 1506, 297, 283, 773, 14, 5135, 13, 88, 1184, 63, 772, 13, 18, 14, 23, 1333, 199, 646, 4145, 199, 199, 39, 30087, 63, 2632, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 7, 199, 39, 30087, 63, 16418, 63, 1179, 3597, 63, 2632, 275, 283, 2859, 921, 21725, 14, 5031, 14, 957, 7, 199, 199, 533, 25141, 26, 523, 347, 636, 826, 721, 277, 12, 2879, 63, 1418, 304, 272, 291, 423, 15846, 275, 283, 1418, 450, 83, 7, 450, 2879, 63, 1418, 339, 3851, 275, 14452, 15, 11857, 5321, 16, 16152, 16, 5995, 11840, 5321, 17, 5995, 12186, 4, 1370, 908, 360, 4735, 15, 11529, 6730, 16, 13, 25, 2807, 358, 272, 291, 423, 11840, 63, 5064, 63, 1246, 63, 3401, 275, 295, 14, 2014, 8, 3401, 9, 819, 347, 636, 5675, 721, 277, 12, 1921, 304, 272, 372, 485, 16410, 8, 277, 12, 1994, 5, 83, 7, 450, 1921, 9, 819, 347, 3222, 8, 277, 12, 1083, 12, 931, 12, 1011, 829, 304, 272, 340, 440, 283, 2139, 7, 315, 4775, 26, 489, 4775, 459, 2139, 418, 275, 1211, 342, 272, 2323, 275, 4775, 459, 2139, 418, 272, 2323, 459, 11626, 418, 275, 291, 423, 15846, 272, 2323, 459, 8422, 418, 275, 283, 3578, 15, 26379, 14, 5031, 14, 1237, 32294, 13, 7780, 7, 339, 327, 17711, 370, 282, 3365, 2881, 367, 314, 19015, 24349, 3261, 14, 272, 340, 291, 423, 11840, 63, 5064, 63, 1246, 63, 3401, 14, 1431, 8, 515, 304, 489, 1166, 275, 1543, 83, 5, 83, 7, 450, 334, 39, 30087, 63, 16418, 63, 1179, 3597, 63, 2632, 12, 931, 9, 272, 587, 26, 489, 1166, 275, 1543, 83, 5, 83, 7, 450, 334, 39, 30087, 63, 2632, 12, 931, 9, 489, 327, 3918, 787, 4847, 315, 4840, 1475, 14, 489, 340, 283, 576, 7, 315, 4775, 26, 267, 4775, 459, 576, 418, 275, 2022, 14, 4180, 8, 829, 459, 576, 1105, 339, 519, 275, 2519, 8, 6615, 12, 1083, 5130, 633, 12, 1011, 829, 680, 1001, 342, 272, 340, 283, 1188, 7, 315, 519, 26, 489, 746, 2186, 8, 1001, 14, 4180, 8, 82, 12, 4363, 29, 18, 12, 17658, 2687, 23324, 7596, 283, 1724, 272, 372, 519, 421, 199, 533, 485, 18039, 26, 523, 347, 636, 826, 721, 277, 12, 23310, 12, 1083, 12, 931, 304, 272, 291, 423, 3561, 275, 23310, 272, 291, 423, 765, 275, 1083, 272, 291, 423, 515, 275, 931, 819, 347, 636, 1250, 721, 277, 12, 1011, 829, 304, 272, 372, 291, 423, 3561, 14, 2254, 8, 277, 423, 765, 12, 291, 423, 515, 12, 1011, 829, 9, 421, 199, 533, 485, 16410, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 23310, 12, 536, 304, 272, 291, 423, 3561, 275, 23310, 272, 291, 423, 354, 275, 536, 819, 347, 636, 1250, 721, 277, 12, 627, 589, 304, 272, 340, 822, 8, 589, 9, 508, 378, 26, 489, 372, 291, 339, 536, 275, 1543, 83, 3149, 83, 7, 450, 334, 277, 423, 354, 12, 20538, 904, 779, 495, 8, 1273, 9, 367, 1680, 315, 1249, 2459, 272, 372, 485, 16410, 8, 277, 423, 3561, 12, 536, 9, 819, 347, 636, 5675, 721, 277, 12, 1921, 304, 272, 340, 1921, 315, 788, 362, 297, 283, 524, 297, 283, 1932, 297, 283, 2068, 297, 283, 1807, 2565, 489, 372, 485, 18039, 8, 277, 423, 3561, 12, 1921, 12, 291, 423, 354, 9, 339, 536, 275, 1543, 83, 3149, 83, 7, 450, 334, 277, 423, 354, 12, 1921, 9, 272, 372, 485, 16410, 8, 277, 423, 3561, 12, 536, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dboyliao/codecombat
scripts/analytics/mixpanelLevelRates.py
97
6288
# Calculate level completion rates via mixpanel export API # TODO: why are our 'time' fields in PST time? targetLevels = ['dungeons-of-kithgard', 'the-raised-sword', 'endangered-burl'] eventFunnel = ['Started Level', 'Saw Victory'] import sys from datetime import datetime, timedelta from mixpanel import Mixpanel try: import json except ImportError: import simplejson as json # NOTE: mixpanel dates are by day and inclusive # E.g. '2014-12-08' is any date that day, up to 2014-12-09 12am if __name__ == '__main__': if not len(sys.argv) is 3: print "Script format: <script> <api_key> <api_secret>" else: scriptStart = datetime.now() api_key = sys.argv[1] api_secret = sys.argv[2] api = Mixpanel( api_key = api_key, api_secret = api_secret ) # startDate = '2015-01-11' # endDate = '2015-01-17' startDate = '2015-01-23' endDate = '2015-01-23' # endDate = '2015-01-28' startEvent = eventFunnel[0] endEvent = eventFunnel[-1] print("Requesting data for {0} to {1}".format(startDate, endDate)) data = api.request(['export'], { 'event' : eventFunnel, 'from_date' : startDate, 'to_date' : endDate }) # Map ordering: level, user, event, day userDataMap = {} lines = data.split('\n') print "Received %d entries" % len(lines) for line in lines: try: if len(line) is 0: continue eventData = json.loads(line) eventName = eventData['event'] if not eventName in eventFunnel: print 'Unexpected event ' + eventName break if not 'properties' in eventData: continue properties = eventData['properties'] if not 'distinct_id' in properties: continue user = properties['distinct_id'] if not 'time' in properties: continue time = properties['time'] pst = datetime.fromtimestamp(int(properties['time'])) utc = pst + timedelta(0, 8 * 60 * 60) dateCreated = utc.isoformat() day = dateCreated[0:10] if day < startDate or day > endDate: print "Skipping {0}".format(day) continue if 'levelID' in properties: level = properties['levelID'] elif 'level' in properties: level = properties['level'].lower().replace(' ', '-') else: print("Unkonwn level for", eventName) print(properties) break if not level in targetLevels: continue # print level if not level in userDataMap: userDataMap[level] = {} if not user in userDataMap[level]: userDataMap[level][user] = {} if not eventName in userDataMap[level][user] or userDataMap[level][user][eventName] > day: userDataMap[level][user][eventName] = day except: print "Unexpected error:", sys.exc_info()[0] print line break # print(userDataMap) levelFunnelData = {} for level in userDataMap: for user in userDataMap[level]: funnelStartDay = None for event in userDataMap[level][user]: day = userDataMap[level][user][event] if not level in levelFunnelData: levelFunnelData[level] = {} if not day in levelFunnelData[level]: levelFunnelData[level][day] = {} if not event in levelFunnelData[level][day]: levelFunnelData[level][day][event] = 0 if eventFunnel[0] == event: levelFunnelData[level][day][event] += 1 funnelStartDay = day break if funnelStartDay: for event in userDataMap[level][user]: if not event in levelFunnelData[level][funnelStartDay]: levelFunnelData[level][funnelStartDay][event] = 0 if not eventFunnel[0] == event: levelFunnelData[level][funnelStartDay][event] += 1 for i in range(1, len(eventFunnel)): event = eventFunnel[i] if not event in levelFunnelData[level][funnelStartDay]: levelFunnelData[level][funnelStartDay][event] = 0 # print(levelFunnelData) totals = {} for level in levelFunnelData: for day in levelFunnelData[level]: if startEvent in levelFunnelData[level][day]: started = levelFunnelData[level][day][startEvent] else: started = 0 if endEvent in levelFunnelData[level][day]: finished = levelFunnelData[level][day][endEvent] else: finished = 0 if not level in totals: totals[level] = {} if not startEvent in totals[level]: totals[level][startEvent] = 0 if not endEvent in totals[level]: totals[level][endEvent] = 0 totals[level][startEvent] += started totals[level][endEvent] += finished if started > 0: print("{0}\t{1}\t{2}\t{3}\t{4}%".format(level, day, started, finished, float(finished) / started * 100)) else: print("{0}\t{1}\t{2}\t{3}\t".format(level, day, started, finished)) for level in totals: started = totals[level][startEvent] finished = totals[level][endEvent] if started > 0: print("{0}\t{1}\t{2}\t{3}%".format(level, started, finished, float(finished) / started * 100)) else: print("{0}\t{1}\t{2}\t".format(level, started, finished)) print("Script runtime: {0}".format(datetime.now() - scriptStart))
mit
[ 3, 12707, 2166, 13659, 24434, 4799, 13667, 7885, 4843, 3261, 199, 199, 3, 3254, 26, 10842, 787, 4154, 283, 521, 7, 1504, 315, 510, 840, 900, 31, 199, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 297, 283, 1589, 13, 21597, 13, 83, 1027, 297, 283, 500, 618, 581, 13, 66, 633, 418, 199, 1430, 19941, 2715, 275, 788, 21031, 20400, 297, 283, 51, 10084, 6561, 1076, 418, 199, 199, 646, 984, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 13667, 7885, 492, 603, 1148, 7885, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 3, 6944, 26, 13667, 7885, 10831, 787, 701, 5382, 436, 20728, 199, 3, 662, 14, 71, 14, 283, 7280, 13, 713, 13, 2036, 7, 365, 1263, 1434, 626, 5382, 12, 1536, 370, 6927, 13, 713, 13, 1643, 3144, 455, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 822, 8, 1274, 14, 3020, 9, 365, 650, 26, 267, 870, 298, 5229, 1475, 26, 665, 1579, 30, 665, 1246, 63, 498, 30, 665, 1246, 63, 4731, 4335, 272, 587, 26, 267, 2884, 3162, 275, 2197, 14, 2131, 342, 398, 2986, 63, 498, 275, 984, 14, 3020, 59, 17, 61, 267, 2986, 63, 4731, 275, 984, 14, 3020, 59, 18, 61, 267, 2986, 275, 603, 1148, 7885, 8, 288, 2986, 63, 498, 275, 2986, 63, 498, 12, 288, 2986, 63, 4731, 275, 2986, 63, 4731, 267, 776, 398, 327, 1343, 2506, 275, 283, 7806, 13, 614, 13, 845, 7, 267, 327, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1196, 7, 267, 1343, 2506, 275, 283, 7806, 13, 614, 13, 1789, 7, 267, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1789, 7, 267, 327, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1651, 7, 398, 1343, 2390, 275, 1566, 19941, 2715, 59, 16, 61, 267, 1284, 2390, 275, 1566, 19941, 2715, 1988, 17, 61, 398, 870, 480, 2017, 316, 666, 367, 469, 16, 93, 370, 469, 17, 5469, 908, 8, 928, 2506, 12, 1284, 2506, 430, 267, 666, 275, 2986, 14, 1069, 2941, 3790, 995, 469, 288, 283, 1430, 7, 520, 1566, 19941, 2715, 12, 288, 283, 504, 63, 602, 7, 520, 1343, 2506, 12, 288, 283, 475, 63, 602, 7, 520, 1284, 2506, 267, 3828, 7318, 327, 9672, 7794, 26, 2166, 12, 922, 12, 1566, 12, 5382, 267, 922, 1451, 2956, 275, 1052, 267, 2385, 275, 666, 14, 1294, 2258, 78, 358, 267, 870, 298, 9392, 450, 68, 4811, 2, 450, 822, 8, 1278, 9, 267, 367, 1004, 315, 2385, 26, 288, 862, 26, 355, 340, 822, 8, 604, 9, 365, 378, 26, 1980, 355, 1566, 1451, 275, 2022, 14, 3640, 8, 604, 9, 355, 1566, 985, 275, 1566, 1451, 459, 1430, 418, 355, 340, 440, 1566, 985, 315, 1566, 19941, 2715, 26, 490, 870, 283, 8708, 1566, 283, 435, 1566, 985, 490, 2059, 355, 340, 440, 283, 3282, 7, 315, 1566, 1451, 26, 1980, 355, 4382, 275, 1566, 1451, 459, 3282, 418, 355, 340, 440, 283, 12926, 63, 344, 7, 315, 4382, 26, 1980, 355, 922, 275, 4382, 459, 12926, 63, 344, 418, 355, 340, 440, 283, 521, 7, 315, 4382, 26, 1980, 355, 900, 275, 4382, 459, 521, 418, 355, 299, 270, 275, 2197, 14, 18531, 8, 442, 8, 3282, 459, 521, 5156, 355, 19314, 275, 299, 270, 435, 6871, 8, 16, 12, 1695, 627, 5212, 627, 5212, 9, 355, 1434, 10502, 275, 19314, 14, 17070, 342, 355, 5382, 275, 1434, 10502, 59, 16, 26, 709, 61, 355, 340, 5382, 665, 1343, 2506, 503, 5382, 690, 1284, 2506, 26, 490, 870, 298, 18297, 469, 16, 5469, 908, 8, 2977, 9, 490, 1980, 2234, 340, 283, 1896, 998, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 998, 418, 355, 916, 283, 1896, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 2278, 2325, 1252, 1814, 360, 1656, 26942, 355, 587, 26, 490, 870, 480, 1358, 75, 265, 3501, 2166, 367, 401, 1566, 985, 9, 490, 870, 8, 3282, 9, 490, 2059, 2234, 340, 440, 2166, 315, 1347, 4670, 83, 26, 490, 1980, 2234, 327, 870, 2166, 2234, 340, 440, 2166, 315, 922, 1451, 2956, 26, 922, 1451, 2956, 59, 1896, 61, 275, 1052, 355, 340, 440, 922, 315, 922, 1451, 2956, 59, 1896, 2189, 922, 1451, 2956, 59, 1896, 1527, 751, 61, 275, 1052, 355, 340, 440, 1566, 985, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 61, 503, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 985, 61, 690, 5382, 26, 490, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 985, 61, 275, 5382, 288, 871, 26, 355, 870, 298, 8708, 1125, 6783, 984, 14, 2804, 63, 815, 3430, 16, 61, 355, 870, 1004, 355, 2059, 398, 327, 870, 8, 751, 1451, 2956, 9, 398, 2166, 19941, 2715, 1451, 275, 1052, 267, 367, 2166, 315, 922, 1451, 2956, 26, 288, 367, 922, 315, 922, 1451, 2956, 59, 1896, 2189, 355, 9627, 2715, 3162, 12631, 275, 488, 355, 367, 1566, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 2189, 490, 5382, 275, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 61, 490, 340, 440, 2166, 315, 2166, 19941, 2715, 1451, 26, 2166, 19941, 2715, 1451, 59, 1896, 61, 275, 1052, 490, 340, 440, 5382, 315, 2166, 19941, 2715, 1451, 59, 1896, 2189, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 61, 275, 1052, 490, 340, 440, 1566, 315, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 2189, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 1527, 1430, 61, 275, 378, 490, 340, 1566, 19941, 2715, 59, 16, 61, 508, 1566, 26, 717, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 1527, 1430, 61, 847, 413, 717, 9627, 2715, 3162, 12631, 275, 5382, 717, 2059, 2234, 340, 9627, 2715, 3162, 12631, 26, 490, 367, 1566, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 2189, 717, 340, 440, 1566, 315, 2166, 19941, 2715, 1451, 59, 1896, 1527, 7036, 2715, 3162, 12631, 2189, 1169, 2166, 19941, 2715, 1451, 59, 1896, 1527, 7036, 2715, 3162, 12631, 1527, 1430, 61, 275, 378, 717, 340 ]
[ 12707, 2166, 13659, 24434, 4799, 13667, 7885, 4843, 3261, 199, 199, 3, 3254, 26, 10842, 787, 4154, 283, 521, 7, 1504, 315, 510, 840, 900, 31, 199, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 297, 283, 1589, 13, 21597, 13, 83, 1027, 297, 283, 500, 618, 581, 13, 66, 633, 418, 199, 1430, 19941, 2715, 275, 788, 21031, 20400, 297, 283, 51, 10084, 6561, 1076, 418, 199, 199, 646, 984, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 13667, 7885, 492, 603, 1148, 7885, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 3, 6944, 26, 13667, 7885, 10831, 787, 701, 5382, 436, 20728, 199, 3, 662, 14, 71, 14, 283, 7280, 13, 713, 13, 2036, 7, 365, 1263, 1434, 626, 5382, 12, 1536, 370, 6927, 13, 713, 13, 1643, 3144, 455, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 822, 8, 1274, 14, 3020, 9, 365, 650, 26, 267, 870, 298, 5229, 1475, 26, 665, 1579, 30, 665, 1246, 63, 498, 30, 665, 1246, 63, 4731, 4335, 272, 587, 26, 267, 2884, 3162, 275, 2197, 14, 2131, 342, 398, 2986, 63, 498, 275, 984, 14, 3020, 59, 17, 61, 267, 2986, 63, 4731, 275, 984, 14, 3020, 59, 18, 61, 267, 2986, 275, 603, 1148, 7885, 8, 288, 2986, 63, 498, 275, 2986, 63, 498, 12, 288, 2986, 63, 4731, 275, 2986, 63, 4731, 267, 776, 398, 327, 1343, 2506, 275, 283, 7806, 13, 614, 13, 845, 7, 267, 327, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1196, 7, 267, 1343, 2506, 275, 283, 7806, 13, 614, 13, 1789, 7, 267, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1789, 7, 267, 327, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1651, 7, 398, 1343, 2390, 275, 1566, 19941, 2715, 59, 16, 61, 267, 1284, 2390, 275, 1566, 19941, 2715, 1988, 17, 61, 398, 870, 480, 2017, 316, 666, 367, 469, 16, 93, 370, 469, 17, 5469, 908, 8, 928, 2506, 12, 1284, 2506, 430, 267, 666, 275, 2986, 14, 1069, 2941, 3790, 995, 469, 288, 283, 1430, 7, 520, 1566, 19941, 2715, 12, 288, 283, 504, 63, 602, 7, 520, 1343, 2506, 12, 288, 283, 475, 63, 602, 7, 520, 1284, 2506, 267, 3828, 7318, 327, 9672, 7794, 26, 2166, 12, 922, 12, 1566, 12, 5382, 267, 922, 1451, 2956, 275, 1052, 267, 2385, 275, 666, 14, 1294, 2258, 78, 358, 267, 870, 298, 9392, 450, 68, 4811, 2, 450, 822, 8, 1278, 9, 267, 367, 1004, 315, 2385, 26, 288, 862, 26, 355, 340, 822, 8, 604, 9, 365, 378, 26, 1980, 355, 1566, 1451, 275, 2022, 14, 3640, 8, 604, 9, 355, 1566, 985, 275, 1566, 1451, 459, 1430, 418, 355, 340, 440, 1566, 985, 315, 1566, 19941, 2715, 26, 490, 870, 283, 8708, 1566, 283, 435, 1566, 985, 490, 2059, 355, 340, 440, 283, 3282, 7, 315, 1566, 1451, 26, 1980, 355, 4382, 275, 1566, 1451, 459, 3282, 418, 355, 340, 440, 283, 12926, 63, 344, 7, 315, 4382, 26, 1980, 355, 922, 275, 4382, 459, 12926, 63, 344, 418, 355, 340, 440, 283, 521, 7, 315, 4382, 26, 1980, 355, 900, 275, 4382, 459, 521, 418, 355, 299, 270, 275, 2197, 14, 18531, 8, 442, 8, 3282, 459, 521, 5156, 355, 19314, 275, 299, 270, 435, 6871, 8, 16, 12, 1695, 627, 5212, 627, 5212, 9, 355, 1434, 10502, 275, 19314, 14, 17070, 342, 355, 5382, 275, 1434, 10502, 59, 16, 26, 709, 61, 355, 340, 5382, 665, 1343, 2506, 503, 5382, 690, 1284, 2506, 26, 490, 870, 298, 18297, 469, 16, 5469, 908, 8, 2977, 9, 490, 1980, 2234, 340, 283, 1896, 998, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 998, 418, 355, 916, 283, 1896, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 2278, 2325, 1252, 1814, 360, 1656, 26942, 355, 587, 26, 490, 870, 480, 1358, 75, 265, 3501, 2166, 367, 401, 1566, 985, 9, 490, 870, 8, 3282, 9, 490, 2059, 2234, 340, 440, 2166, 315, 1347, 4670, 83, 26, 490, 1980, 2234, 327, 870, 2166, 2234, 340, 440, 2166, 315, 922, 1451, 2956, 26, 922, 1451, 2956, 59, 1896, 61, 275, 1052, 355, 340, 440, 922, 315, 922, 1451, 2956, 59, 1896, 2189, 922, 1451, 2956, 59, 1896, 1527, 751, 61, 275, 1052, 355, 340, 440, 1566, 985, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 61, 503, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 985, 61, 690, 5382, 26, 490, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 985, 61, 275, 5382, 288, 871, 26, 355, 870, 298, 8708, 1125, 6783, 984, 14, 2804, 63, 815, 3430, 16, 61, 355, 870, 1004, 355, 2059, 398, 327, 870, 8, 751, 1451, 2956, 9, 398, 2166, 19941, 2715, 1451, 275, 1052, 267, 367, 2166, 315, 922, 1451, 2956, 26, 288, 367, 922, 315, 922, 1451, 2956, 59, 1896, 2189, 355, 9627, 2715, 3162, 12631, 275, 488, 355, 367, 1566, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 2189, 490, 5382, 275, 922, 1451, 2956, 59, 1896, 1527, 751, 1527, 1430, 61, 490, 340, 440, 2166, 315, 2166, 19941, 2715, 1451, 26, 2166, 19941, 2715, 1451, 59, 1896, 61, 275, 1052, 490, 340, 440, 5382, 315, 2166, 19941, 2715, 1451, 59, 1896, 2189, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 61, 275, 1052, 490, 340, 440, 1566, 315, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 2189, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 1527, 1430, 61, 275, 378, 490, 340, 1566, 19941, 2715, 59, 16, 61, 508, 1566, 26, 717, 2166, 19941, 2715, 1451, 59, 1896, 1527, 2977, 1527, 1430, 61, 847, 413, 717, 9627, 2715, 3162, 12631, 275, 5382, 717, 2059, 2234, 340, 9627, 2715, 3162, 12631, 26, 490, 367, 1566, 315, 922, 1451, 2956, 59, 1896, 1527, 751, 2189, 717, 340, 440, 1566, 315, 2166, 19941, 2715, 1451, 59, 1896, 1527, 7036, 2715, 3162, 12631, 2189, 1169, 2166, 19941, 2715, 1451, 59, 1896, 1527, 7036, 2715, 3162, 12631, 1527, 1430, 61, 275, 378, 717, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
arenadata/ambari
ambari-server/src/main/resources/stacks/ADH/1.4/services/SOLR/package/scripts/service_check.py
2
1936
#!/usr/bin/env python import os from resource_management.core.logger import Logger from resource_management.core.resources.system import Execute from resource_management.libraries.functions.format import format from resource_management.libraries.script import Script from solr_utils import exists_collection class ServiceCheck(Script): def service_check(self, env): import params env.set_params(params) if not os.path.isfile(params.solr_config_pid_file): Logger.error(format("PID file {solr_config_pid_file} does not exist")) exit(1) if not params.solr_collection_sample_create: Logger.info("Create sample collection unchecked, skipping ...") return if exists_collection(params.solr_collection_name): Logger.warning(format("Collection {solr_collection_name} already exists, skipping ...")) return if not params.solr_cloud_mode: Execute( format( '{solr_config_bin_dir}/solr create_core -c {solr_collection_name}' + ' -d {solr_collection_config_dir} -p {solr_config_port} >> {solr_config_service_log_file} 2>&1' ), environment={'JAVA_HOME': params.java64_home}, user=params.solr_config_user ) else: Execute(format( '{solr_config_bin_dir}/solr create_collection -c {solr_collection_name}' + ' -d {solr_collection_config_dir} -p {solr_config_port}' + ' -s {solr_collection_shards} -rf {solr_collection_replicas}' + ' >> {solr_config_service_log_file} 2>&1'), environment={'JAVA_HOME': params.java64_home}, user=params.solr_config_user ) if __name__ == "__main__": ServiceCheck().execute()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 199, 504, 2073, 63, 8110, 14, 1018, 14, 2921, 492, 15996, 199, 504, 2073, 63, 8110, 14, 1018, 14, 4435, 14, 2253, 492, 17009, 199, 504, 2073, 63, 8110, 14, 10159, 14, 5777, 14, 908, 492, 1475, 199, 504, 2073, 63, 8110, 14, 10159, 14, 1579, 492, 14914, 199, 199, 504, 8597, 82, 63, 1208, 492, 3495, 63, 3627, 421, 199, 533, 7591, 1799, 8, 5229, 304, 272, 347, 2435, 63, 1074, 8, 277, 12, 2589, 304, 267, 492, 1862, 267, 2589, 14, 409, 63, 1162, 8, 1162, 9, 398, 340, 440, 747, 14, 515, 14, 6292, 8, 1162, 14, 28627, 63, 888, 63, 3150, 63, 493, 304, 288, 15996, 14, 705, 8, 908, 480, 16098, 570, 469, 28627, 63, 888, 63, 3150, 63, 493, 93, 1630, 440, 2187, 2237, 288, 4458, 8, 17, 9, 398, 340, 440, 1862, 14, 28627, 63, 3627, 63, 3271, 63, 981, 26, 288, 15996, 14, 815, 480, 2499, 2690, 3245, 625, 10718, 12, 16068, 2263, 531, 288, 372, 398, 340, 3495, 63, 3627, 8, 1162, 14, 28627, 63, 3627, 63, 354, 304, 288, 15996, 14, 3764, 8, 908, 480, 7768, 469, 28627, 63, 3627, 63, 354, 93, 2575, 3495, 12, 16068, 2263, 2237, 288, 372, 398, 340, 440, 1862, 14, 28627, 63, 4091, 63, 632, 26, 288, 17009, 8, 490, 1475, 8, 1169, 5041, 28627, 63, 888, 63, 1393, 63, 694, 5995, 28627, 1218, 63, 1018, 446, 67, 469, 28627, 63, 3627, 63, 354, 6834, 435, 1169, 283, 446, 68, 469, 28627, 63, 3627, 63, 888, 63, 694, 93, 446, 80, 469, 28627, 63, 888, 63, 719, 93, 4331, 469, 28627, 63, 888, 63, 1364, 63, 793, 63, 493, 93, 499, 18181, 17, 7, 490, 2318, 490, 3734, 3713, 42, 28520, 63, 9524, 356, 1862, 14, 6138, 772, 63, 4219, 1386, 490, 922, 29, 1162, 14, 28627, 63, 888, 63, 751, 288, 776, 267, 587, 26, 288, 17009, 8, 908, 8, 490, 5041, 28627, 63, 888, 63, 1393, 63, 694, 5995, 28627, 1218, 63, 3627, 446, 67, 469, 28627, 63, 3627, 63, 354, 6834, 435, 490, 283, 446, 68, 469, 28627, 63, 3627, 63, 888, 63, 694, 93, 446, 80, 469, 28627, 63, 888, 63, 719, 6834, 435, 490, 283, 446, 83, 469, 28627, 63, 3627, 63, 15570, 93, 446, 3941, 469, 28627, 63, 3627, 63, 16755, 6834, 435, 490, 283, 4331, 469, 28627, 63, 888, 63, 1364, 63, 793, 63, 493, 93, 499, 18181, 17, 659, 490, 3734, 3713, 42, 28520, 63, 9524, 356, 1862, 14, 6138, 772, 63, 4219, 1386, 490, 922, 29, 1162, 14, 28627, 63, 888, 63, 751, 288, 776, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 7591, 1799, 1252, 2526, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 199, 504, 2073, 63, 8110, 14, 1018, 14, 2921, 492, 15996, 199, 504, 2073, 63, 8110, 14, 1018, 14, 4435, 14, 2253, 492, 17009, 199, 504, 2073, 63, 8110, 14, 10159, 14, 5777, 14, 908, 492, 1475, 199, 504, 2073, 63, 8110, 14, 10159, 14, 1579, 492, 14914, 199, 199, 504, 8597, 82, 63, 1208, 492, 3495, 63, 3627, 421, 199, 533, 7591, 1799, 8, 5229, 304, 272, 347, 2435, 63, 1074, 8, 277, 12, 2589, 304, 267, 492, 1862, 267, 2589, 14, 409, 63, 1162, 8, 1162, 9, 398, 340, 440, 747, 14, 515, 14, 6292, 8, 1162, 14, 28627, 63, 888, 63, 3150, 63, 493, 304, 288, 15996, 14, 705, 8, 908, 480, 16098, 570, 469, 28627, 63, 888, 63, 3150, 63, 493, 93, 1630, 440, 2187, 2237, 288, 4458, 8, 17, 9, 398, 340, 440, 1862, 14, 28627, 63, 3627, 63, 3271, 63, 981, 26, 288, 15996, 14, 815, 480, 2499, 2690, 3245, 625, 10718, 12, 16068, 2263, 531, 288, 372, 398, 340, 3495, 63, 3627, 8, 1162, 14, 28627, 63, 3627, 63, 354, 304, 288, 15996, 14, 3764, 8, 908, 480, 7768, 469, 28627, 63, 3627, 63, 354, 93, 2575, 3495, 12, 16068, 2263, 2237, 288, 372, 398, 340, 440, 1862, 14, 28627, 63, 4091, 63, 632, 26, 288, 17009, 8, 490, 1475, 8, 1169, 5041, 28627, 63, 888, 63, 1393, 63, 694, 5995, 28627, 1218, 63, 1018, 446, 67, 469, 28627, 63, 3627, 63, 354, 6834, 435, 1169, 283, 446, 68, 469, 28627, 63, 3627, 63, 888, 63, 694, 93, 446, 80, 469, 28627, 63, 888, 63, 719, 93, 4331, 469, 28627, 63, 888, 63, 1364, 63, 793, 63, 493, 93, 499, 18181, 17, 7, 490, 2318, 490, 3734, 3713, 42, 28520, 63, 9524, 356, 1862, 14, 6138, 772, 63, 4219, 1386, 490, 922, 29, 1162, 14, 28627, 63, 888, 63, 751, 288, 776, 267, 587, 26, 288, 17009, 8, 908, 8, 490, 5041, 28627, 63, 888, 63, 1393, 63, 694, 5995, 28627, 1218, 63, 3627, 446, 67, 469, 28627, 63, 3627, 63, 354, 6834, 435, 490, 283, 446, 68, 469, 28627, 63, 3627, 63, 888, 63, 694, 93, 446, 80, 469, 28627, 63, 888, 63, 719, 6834, 435, 490, 283, 446, 83, 469, 28627, 63, 3627, 63, 15570, 93, 446, 3941, 469, 28627, 63, 3627, 63, 16755, 6834, 435, 490, 283, 4331, 469, 28627, 63, 888, 63, 1364, 63, 793, 63, 493, 93, 499, 18181, 17, 659, 490, 3734, 3713, 42, 28520, 63, 9524, 356, 1862, 14, 6138, 772, 63, 4219, 1386, 490, 922, 29, 1162, 14, 28627, 63, 888, 63, 751, 288, 776, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 7591, 1799, 1252, 2526, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
arenadata/ambari
ambari-server/src/test/python/TestStackAdvisor.py
2
19610
''' Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from unittest import TestCase import os class TestStackAdvisorInitialization(TestCase): def setUp(self): import imp self.test_directory = os.path.dirname(os.path.abspath(__file__)) stack_advisor_path = os.path.join(self.test_directory, '../../main/resources/scripts/stack_advisor.py') with open(stack_advisor_path, 'rb') as fp: self.stack_advisor = imp.load_module( 'stack_advisor', fp, stack_advisor_path, ('.py', 'rb', imp.PY_SOURCE) ) def test_stackAdvisorLoadedForNotHDPStack(self): path_template = os.path.join(self.test_directory, '../resources/stacks/{0}/{1}/services/stack_advisor.py') path_template_name = "STACK_ADVISOR_IMPL_PATH_TEMPLATE" setattr(self.stack_advisor, path_template_name, path_template) self.assertEquals(path_template, getattr(self.stack_advisor, path_template_name)) instantiate_stack_advisor_method_name = 'instantiateStackAdvisor' instantiate_stack_advisor_method = getattr(self.stack_advisor, instantiate_stack_advisor_method_name) stack_advisor = instantiate_stack_advisor_method("XYZ", "1.0.1", ["1.0.0"]) self.assertEquals("XYZ101StackAdvisor", stack_advisor.__class__.__name__) services = { "Versions": { "stack_name":"XYZ", "stack_version":"1.0.1" }, "services":[ { "StackServices":{ "service_name":"YARN" }, "components":[ { "StackServiceComponents": { "component_name": "RESOURCEMANAGER" } }, { "StackServiceComponents": { "component_name": "APP_TIMELINE_SERVER" } }, { "StackServiceComponents": { "component_name":"YARN_CLIENT" } }, { "StackServiceComponents": { "component_name": "NODEMANAGER" } } ] } ] } hosts= { "items": [ {"Hosts": {"host_name": "host1"}}, {"Hosts": {"host_name": "host2"}} ] } config_recommendations = stack_advisor.recommendConfigurations(services, hosts) yarn_configs = config_recommendations["recommendations"]["blueprint"]["configurations"]["yarn-site"]["properties"] '''Check that value is populated from child class, not parent''' self.assertEquals("-Xmx101m", yarn_configs["yarn.nodemanager.resource.memory-mb"]) def test_stackAdvisorDefaultImpl(self): instantiate_stack_advisor_method_name = 'instantiateStackAdvisor' instantiate_stack_advisor_method = getattr(self.stack_advisor, instantiate_stack_advisor_method_name) '''Not existent stack - to return default implementation''' default_stack_advisor = instantiate_stack_advisor_method("HDP1", "2.0.6", []) self.assertEquals("DefaultStackAdvisor", default_stack_advisor.__class__.__name__) services = { "Versions": { "stack_name":"HDP1", "stack_version":"2.0.6" }, "services" : [ { "StackServices" : { "service_name" : "GANGLIA", "service_version" : "3.5.0", }, "components" : [ { "StackServiceComponents" : { "cardinality" : "ALL", "component_name" : "GANGLIA_MONITOR", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1", "component_name" : "GANGLIA_SERVER", "is_master" : True, "hostnames" : [ ] } } ] }, { "StackServices" : { "service_name" : "HBASE", "service_version" : "0.98.0.2.1" }, "components" : [ { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "HBASE_CLIENT", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "HBASE_MASTER", "is_master" : True, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "HBASE_REGIONSERVER", "is_master" : False, "hostnames" : [ ] } } ] }, { "StackServices" : { "service_name" : "HDFS", "service_version" : "2.4.0.2.1" }, "components" : [ { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "DATANODE", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "HDFS_CLIENT", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "0+", "component_name" : "JOURNALNODE", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1-2", "component_name" : "NAMENODE", "is_master" : True, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1", "component_name" : "SECONDARY_NAMENODE", "is_master" : True, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "0+", "component_name" : "ZKFC", "is_master" : False, "hostnames" : [ ] } } ] }, { "StackServices" : { "service_name" : "PIG", "service_version" : "0.12.1.2.1" }, "components" : [ { "StackServiceComponents" : { "cardinality" : "0+", "component_name" : "PIG", "is_master" : False, "hostnames" : [ ] } } ] }, { "StackServices" : { "service_name" : "TEZ", "service_version" : "0.4.0.2.1" }, "components" : [ { "StackServiceComponents" : { "cardinality" : "0+", "component_name" : "TEZ_CLIENT", "is_master" : False, "hostnames" : [ ] } } ] }, { "StackServices" : { "service_name" : "ZOOKEEPER", "service_version" : "3.4.5.2.1", }, "components" : [ { "StackServiceComponents" : { "cardinality" : "1+", "component_category" : "CLIENT", "component_name" : "ZOOKEEPER_CLIENT", "is_master" : False, "hostnames" : [ ] } }, { "StackServiceComponents" : { "cardinality" : "1+", "component_name" : "ZOOKEEPER_SERVER", "is_master" : True, "hostnames" : [ ] } } ] } ], "configurations" : {} } hosts= { "items": [ {"Hosts": {"host_name": "host1"}}, {"Hosts": {"host_name": "host2"}} ] } actualValidateConfigResponse = default_stack_advisor.validateConfigurations(services, hosts) actualValidateLayoutResponse = default_stack_advisor.validateComponentLayout(services, hosts) expectedValidationResponse = { "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"}, "items": [] } self.assertEquals(actualValidateConfigResponse, expectedValidationResponse) self.assertEquals(actualValidateLayoutResponse, expectedValidationResponse) actualRecommendConfigResponse = default_stack_advisor.recommendConfigurations(services, hosts) expectedRecommendConfigResponse = { "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"}, "hosts": ["host1", "host2"], "services": ['GANGLIA', 'HBASE', 'HDFS', 'PIG', 'TEZ', 'ZOOKEEPER'], "recommendations": { "blueprint": { "configurations": {}, "host_groups": [] }, "blueprint_cluster_binding": { "host_groups": [] } } } self.assertEquals(actualRecommendConfigResponse, expectedRecommendConfigResponse) actualRecommendLayoutResponse = default_stack_advisor.recommendComponentLayout(services, hosts) expectedRecommendLayoutResponse = { "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"}, "hosts": ["host1", "host2"], "services": ['GANGLIA', 'HBASE', 'HDFS', 'PIG', 'TEZ', 'ZOOKEEPER'], "recommendations": { "blueprint": { "host_groups": [ { "name": "host-group-1", "components": [] }, { "name": "host-group-2", "components": [ {"name": "GANGLIA_SERVER"}, {"name": "HBASE_MASTER"}, {"name": "NAMENODE"}, {"name": "SECONDARY_NAMENODE"}, {"name": "ZOOKEEPER_SERVER"}, {"name": "ZOOKEEPER_CLIENT"} ] } ] }, "blueprint_cluster_binding": { "host_groups": [ { "name": "host-group-1", "hosts": [{"fqdn": "host2"}] }, { "name": "host-group-2", "hosts": [{"fqdn": "host1"}] } ] } } } self.assertEquals(actualRecommendLayoutResponse, expectedRecommendLayoutResponse) # Test with maintenance_state. One host is in maintenance mode. hosts= { "items": [ {"Hosts": {"host_name": "host1", "maintenance_state":"OFF"}}, {"Hosts": {"host_name": "host2", "maintenance_state":"ON"}} ] } actualRecommendLayoutResponse = default_stack_advisor.recommendComponentLayout(services, hosts) expectedRecommendLayoutResponse = { "services": ["GANGLIA", "HBASE", "HDFS", "PIG", "TEZ", "ZOOKEEPER"], "recommendations": { "blueprint": { "host_groups": [ { "name": "host-group-1", "components": [ { "name": "GANGLIA_SERVER" }, { "name": "HBASE_MASTER" }, { "name": "NAMENODE" }, { "name": "SECONDARY_NAMENODE" }, { "name": "ZOOKEEPER_SERVER" }, { "name": "ZOOKEEPER_CLIENT" } ] } ] }, "blueprint_cluster_binding": { "host_groups": [ { "hosts": [{"fqdn": "host1"}], "name": "host-group-1" } ] } }, "hosts": ["host1"], "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"} } self.assertEquals(actualRecommendLayoutResponse, expectedRecommendLayoutResponse) # Test with maintenance_state. Both hosts are in maintenance mode. hosts= { "items": [ {"Hosts": {"host_name": "host1", "maintenance_state":"ON"}}, {"Hosts": {"host_name": "host2", "maintenance_state":"ON"}} ] } actualRecommendLayoutResponse = default_stack_advisor.recommendComponentLayout(services, hosts) expectedRecommendLayoutResponse = { "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"}, "hosts": [], "services": ['GANGLIA', 'HBASE', 'HDFS', 'PIG', 'TEZ', 'ZOOKEEPER'], "recommendations": { "blueprint": { "host_groups": [] }, "blueprint_cluster_binding": { "host_groups": [] } } } self.assertEquals(actualRecommendLayoutResponse, expectedRecommendLayoutResponse) # Config groups support by default services["config-groups"] = [{ "configurations": { }, "hosts": [ 'host2' ] }] actualConfigGroupRecommendConfigResponse = \ default_stack_advisor.recommendConfigurations(services, hosts) expectedConfigGroupRecommendConfigResponse = { "Versions": {"stack_name": "HDP1", "stack_version": "2.0.6"}, "hosts": ["host1", "host2"], "services": ['GANGLIA', 'HBASE', 'HDFS', 'PIG', 'TEZ', 'ZOOKEEPER'], "recommendations": { 'config-groups': [ { 'configurations': {}, 'dependent_configurations': {}, 'hosts': [ 'host2' ] } ], "blueprint": { "configurations": {}, "host_groups": [] }, "blueprint_cluster_binding": { "host_groups": [] } } } self.assertEquals(actualConfigGroupRecommendConfigResponse, expectedConfigGroupRecommendConfigResponse) services = { "services": [ { "StackServices" : { "service_name" : "YARN", "stack_name" : "HDP", "stack_version" : "2.3" }, "configurations" : [ { "StackConfigurations" : { "property_depended_by" : [ { "type" : "yarn-site", "name" : "yarn.scheduler.minimum-allocation-vcores" }, { "type" : "yarn-site", "name" : "yarn.scheduler.maximum-allocation-vcores" } ], "property_name" : "yarn.nodemanager.resource.cpu-vcores", "type" : "yarn-site.xml" }, "dependencies": [] }, { "StackConfigurations" : { "property_name" : "yarn.nodemanager.resource.memory-mb", "type" : "yarn-site.xml" }, "dependencies": [ { "StackConfigurationDependency" : { "dependency_name": "yarn.scheduler.maximum-allocation-mb", "dependency_type": "yarn-site" } }, { "StackConfigurationDependency" : { "dependency_name": "yarn.scheduler.minimum-allocation-mb", "dependency_type": "yarn-site" } }, ] }, { "StackConfigurations" : { "property_depended_by" : [ { "type" : "mapred-site", "name" : "yarn.app.mapreduce.am.resource.mb" }, { "type" : "mapred-site", "name" : "mapreduce.map.memory.mb" }, { "type" : "mapred-site", "name" : "mapreduce.reduce.memory.mb" } ], "property_name" : "yarn.scheduler.maximum-allocation-mb", "type" : "yarn-site.xml" }, "dependencies": [] }, { "StackConfigurations" : { "property_depended_by" : [ ], "property_name" : "yarn.scheduler.maximum-allocation-vcores", "type" : "yarn-site.xml" }, "dependencies": [] }, { "StackConfigurations" : { "property_name" : "yarn.scheduler.minimum-allocation-mb", "type" : "yarn-site.xml" }, "dependencies": [ { "StackConfigurationDependency" : { "dependency_name": "hive.tez.container.size", "dependency_type": "hive-site" } }, { "StackConfigurationDependency" : { "dependency_name": "yarn.app.mapreduce.am.resource.mb", "dependency_type": "mapred-site" } }, { "StackConfigurationDependency" : { "dependency_name": "mapreduce.map.memory.mb", "dependency_type": "mapred-site" } }, { "StackConfigurationDependency" : { "dependency_name": "mapreduce.reduce.memory.mb", "dependency_type": "mapred-site" } }, ] }, { "StackConfigurations" : { "property_name" : "yarn.scheduler.minimum-allocation-vcores", "type" : "yarn-site.xml" }, "dependencies": [] } ] } ], "changed-configurations": [ { "type": "yarn-site", "name": "yarn.nodemanager.resource.memory-mb" } ] } properties_dict = default_stack_advisor.getAffectedConfigs(services) expected_properties_dict = [{'name': 'yarn.scheduler.maximum-allocation-mb', 'type': 'yarn-site'}, {'name': 'yarn.scheduler.minimum-allocation-mb', 'type': 'yarn-site'}, {'name': 'hive.tez.container.size', 'type': 'hive-site'}, {'name': 'yarn.app.mapreduce.am.resource.mb', 'type': 'mapred-site'}, {'name': 'mapreduce.map.memory.mb', 'type': 'mapred-site'}, {'name': 'mapreduce.reduce.memory.mb', 'type': 'mapred-site'}] self.assertEquals(properties_dict, expected_properties_dict)
apache-2.0
[ 2344, 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 199, 504, 2882, 492, 7640, 199, 646, 747, 199, 199, 533, 1379, 4851, 2767, 8286, 5733, 2072, 8, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 492, 1742, 339, 291, 14, 396, 63, 3619, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 272, 3464, 63, 350, 8286, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 3619, 12, 283, 9707, 973, 15, 4435, 15, 6429, 15, 2340, 63, 350, 8286, 14, 647, 358, 272, 543, 1551, 8, 2340, 63, 350, 8286, 63, 515, 12, 283, 4848, 358, 465, 4090, 26, 267, 291, 14, 2340, 63, 350, 8286, 275, 1742, 14, 912, 63, 578, 8, 283, 2340, 63, 350, 8286, 297, 4090, 12, 3464, 63, 350, 8286, 63, 515, 12, 23500, 647, 297, 283, 4848, 297, 1742, 14, 4521, 63, 10187, 9, 776, 819, 347, 511, 63, 2340, 2767, 8286, 19757, 1858, 1763, 40, 11741, 4851, 8, 277, 304, 272, 931, 63, 1160, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 3619, 12, 20644, 4435, 15, 21707, 5321, 16, 16152, 17, 5995, 5950, 15, 2340, 63, 350, 8286, 14, 647, 358, 272, 931, 63, 1160, 63, 354, 275, 298, 17014, 63, 1554, 11793, 726, 63, 26312, 63, 3243, 63, 7433, 2, 272, 5371, 8, 277, 14, 2340, 63, 350, 8286, 12, 931, 63, 1160, 63, 354, 12, 931, 63, 1160, 9, 272, 291, 14, 2947, 8, 515, 63, 1160, 12, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 931, 63, 1160, 63, 354, 430, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 275, 283, 3615, 18973, 4851, 2767, 8286, 7, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 275, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 9, 272, 3464, 63, 350, 8286, 275, 17321, 63, 2340, 63, 350, 8286, 63, 765, 480, 16694, 401, 298, 17, 14, 16, 14, 17, 401, 2097, 17, 14, 16, 14, 16, 3135, 272, 291, 14, 2947, 480, 16694, 4893, 4851, 2767, 8286, 401, 3464, 63, 350, 8286, 855, 533, 4914, 354, 3368, 272, 8500, 275, 469, 489, 298, 21167, 582, 267, 469, 881, 298, 2340, 63, 354, 5122, 16694, 401, 881, 298, 2340, 63, 1023, 5122, 17, 14, 16, 14, 17, 2, 267, 1660, 489, 298, 5950, 19086, 267, 469, 881, 298, 4851, 15803, 582, 91, 288, 298, 1364, 63, 354, 5122, 57, 26513, 2, 881, 1660, 881, 298, 4608, 19086, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 14110, 28541, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 7121, 63, 11342, 2901, 3565, 63, 6613, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 5122, 57, 26513, 63, 9901, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 8063, 28541, 2, 1598, 789, 288, 789, 881, 1622, 267, 789, 489, 1622, 272, 789, 272, 7057, 29, 469, 489, 298, 1744, 582, 359, 267, 2420, 19620, 582, 2420, 1102, 63, 354, 582, 298, 1102, 17, 3570, 1386, 267, 2420, 19620, 582, 2420, 1102, 63, 354, 582, 298, 1102, 18, 32655, 489, 1622, 272, 789, 272, 1101, 63, 264, 14447, 1298, 275, 3464, 63, 350, 8286, 14, 264, 14447, 25808, 8, 5950, 12, 7057, 9, 272, 612, 1060, 63, 7532, 275, 1101, 63, 264, 14447, 1298, 905, 264, 14447, 1298, 6611, 15918, 6611, 10057, 6611, 89, 1060, 13, 2124, 6611, 3282, 937, 272, 1449, 1799, 626, 574, 365, 16460, 687, 1982, 1021, 12, 440, 1676, 2344, 272, 291, 14, 2947, 6096, 56, 9457, 4893, 77, 401, 612, 1060, 63, 7532, 905, 89, 1060, 14, 932, 2609, 14, 1927, 14, 4844, 13, 887, 3135, 819, 347, 511, 63, 2340, 2767, 8286, 2698, 4748, 8, 277, 304, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 275, 283, 3615, 18973, 4851, 2767, 8286, 7, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 275, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 9, 272, 1449, 1763, 444, 13298, 3464, 446, 370, 372, 849, 4514, 2344, 272, 849, 63, 2340, 63, 350, 8286, 275, 17321, 63, 2340, 63, 350, 8286, 63, 765, 480, 40, 11741, 17, 401, 298, 18, 14, 16, 14, 22, 401, 3073, 272, 291, 14, 2947, 480, 2698, 4851, 2767, 8286, 401, 849, 63, 2340, 63, 350, 8286, 855, 533, 4914, 354, 3368, 272, 8500, 275, 469, 489, 298, 21167, 582, 267, 469, 881, 298, 2340, 63, 354, 5122, 40, 11741, 17, 401, 881, 298, 2340, 63, 1023, 5122, 18, 14, 16, 14, 22, 2, 267, 1660, 489, 298, 5950, 2, 520, 359, 267, 469, 881, 298, 4851, 15803, 2, 520, 469, 288, 298, 1364, 63, 354, 2, 520, 298, 39, 879, 2226, 13033, 401, 288, 298, 1364, 63, 1023, 2, 520, 298, 19, 14, 21, 14, 16, 401, 881, 1660, 881, 298, 4608 ]
[ 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 199, 504, 2882, 492, 7640, 199, 646, 747, 199, 199, 533, 1379, 4851, 2767, 8286, 5733, 2072, 8, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 492, 1742, 339, 291, 14, 396, 63, 3619, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 272, 3464, 63, 350, 8286, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 3619, 12, 283, 9707, 973, 15, 4435, 15, 6429, 15, 2340, 63, 350, 8286, 14, 647, 358, 272, 543, 1551, 8, 2340, 63, 350, 8286, 63, 515, 12, 283, 4848, 358, 465, 4090, 26, 267, 291, 14, 2340, 63, 350, 8286, 275, 1742, 14, 912, 63, 578, 8, 283, 2340, 63, 350, 8286, 297, 4090, 12, 3464, 63, 350, 8286, 63, 515, 12, 23500, 647, 297, 283, 4848, 297, 1742, 14, 4521, 63, 10187, 9, 776, 819, 347, 511, 63, 2340, 2767, 8286, 19757, 1858, 1763, 40, 11741, 4851, 8, 277, 304, 272, 931, 63, 1160, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 3619, 12, 20644, 4435, 15, 21707, 5321, 16, 16152, 17, 5995, 5950, 15, 2340, 63, 350, 8286, 14, 647, 358, 272, 931, 63, 1160, 63, 354, 275, 298, 17014, 63, 1554, 11793, 726, 63, 26312, 63, 3243, 63, 7433, 2, 272, 5371, 8, 277, 14, 2340, 63, 350, 8286, 12, 931, 63, 1160, 63, 354, 12, 931, 63, 1160, 9, 272, 291, 14, 2947, 8, 515, 63, 1160, 12, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 931, 63, 1160, 63, 354, 430, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 275, 283, 3615, 18973, 4851, 2767, 8286, 7, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 275, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 9, 272, 3464, 63, 350, 8286, 275, 17321, 63, 2340, 63, 350, 8286, 63, 765, 480, 16694, 401, 298, 17, 14, 16, 14, 17, 401, 2097, 17, 14, 16, 14, 16, 3135, 272, 291, 14, 2947, 480, 16694, 4893, 4851, 2767, 8286, 401, 3464, 63, 350, 8286, 855, 533, 4914, 354, 3368, 272, 8500, 275, 469, 489, 298, 21167, 582, 267, 469, 881, 298, 2340, 63, 354, 5122, 16694, 401, 881, 298, 2340, 63, 1023, 5122, 17, 14, 16, 14, 17, 2, 267, 1660, 489, 298, 5950, 19086, 267, 469, 881, 298, 4851, 15803, 582, 91, 288, 298, 1364, 63, 354, 5122, 57, 26513, 2, 881, 1660, 881, 298, 4608, 19086, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 14110, 28541, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 7121, 63, 11342, 2901, 3565, 63, 6613, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 5122, 57, 26513, 63, 9901, 2, 1598, 789, 288, 1660, 288, 469, 1598, 298, 4851, 3167, 22714, 582, 469, 355, 298, 3173, 63, 354, 582, 298, 8063, 28541, 2, 1598, 789, 288, 789, 881, 1622, 267, 789, 489, 1622, 272, 789, 272, 7057, 29, 469, 489, 298, 1744, 582, 359, 267, 2420, 19620, 582, 2420, 1102, 63, 354, 582, 298, 1102, 17, 3570, 1386, 267, 2420, 19620, 582, 2420, 1102, 63, 354, 582, 298, 1102, 18, 32655, 489, 1622, 272, 789, 272, 1101, 63, 264, 14447, 1298, 275, 3464, 63, 350, 8286, 14, 264, 14447, 25808, 8, 5950, 12, 7057, 9, 272, 612, 1060, 63, 7532, 275, 1101, 63, 264, 14447, 1298, 905, 264, 14447, 1298, 6611, 15918, 6611, 10057, 6611, 89, 1060, 13, 2124, 6611, 3282, 937, 272, 1449, 1799, 626, 574, 365, 16460, 687, 1982, 1021, 12, 440, 1676, 2344, 272, 291, 14, 2947, 6096, 56, 9457, 4893, 77, 401, 612, 1060, 63, 7532, 905, 89, 1060, 14, 932, 2609, 14, 1927, 14, 4844, 13, 887, 3135, 819, 347, 511, 63, 2340, 2767, 8286, 2698, 4748, 8, 277, 304, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 275, 283, 3615, 18973, 4851, 2767, 8286, 7, 272, 17321, 63, 2340, 63, 350, 8286, 63, 765, 275, 2519, 8, 277, 14, 2340, 63, 350, 8286, 12, 17321, 63, 2340, 63, 350, 8286, 63, 765, 63, 354, 9, 272, 1449, 1763, 444, 13298, 3464, 446, 370, 372, 849, 4514, 2344, 272, 849, 63, 2340, 63, 350, 8286, 275, 17321, 63, 2340, 63, 350, 8286, 63, 765, 480, 40, 11741, 17, 401, 298, 18, 14, 16, 14, 22, 401, 3073, 272, 291, 14, 2947, 480, 2698, 4851, 2767, 8286, 401, 849, 63, 2340, 63, 350, 8286, 855, 533, 4914, 354, 3368, 272, 8500, 275, 469, 489, 298, 21167, 582, 267, 469, 881, 298, 2340, 63, 354, 5122, 40, 11741, 17, 401, 881, 298, 2340, 63, 1023, 5122, 18, 14, 16, 14, 22, 2, 267, 1660, 489, 298, 5950, 2, 520, 359, 267, 469, 881, 298, 4851, 15803, 2, 520, 469, 288, 298, 1364, 63, 354, 2, 520, 298, 39, 879, 2226, 13033, 401, 288, 298, 1364, 63, 1023, 2, 520, 298, 19, 14, 21, 14, 16, 401, 881, 1660, 881, 298, 4608, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
insiderr/insiderr-app
ios-patches/basemodules/twisted/web/_newclient.py
5
58220
# -*- test-case-name: twisted.web.test.test_newclient -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ An U{HTTP 1.1<http://www.w3.org/Protocols/rfc2616/rfc2616.html>} client. The way to use the functionality provided by this module is to: - Connect a L{HTTP11ClientProtocol} to an HTTP server - Create a L{Request} with the appropriate data - Pass the request to L{HTTP11ClientProtocol.request} - The returned Deferred will fire with a L{Response} object - Create a L{IProtocol} provider which can handle the response body - Connect it to the response with L{Response.deliverBody} - When the protocol's C{connectionLost} method is called, the response is complete. See L{Response.deliverBody} for details. Various other classes in this module support this usage: - HTTPParser is the basic HTTP parser. It can handle the parts of HTTP which are symmetric between requests and responses. - HTTPClientParser extends HTTPParser to handle response-specific parts of HTTP. One instance is created for each request to parse the corresponding response. """ __metaclass__ = type from zope.interface import implements from twisted.python import log from twisted.python.components import proxyForInterface from twisted.python.reflect import fullyQualifiedName from twisted.python.failure import Failure from twisted.internet.interfaces import IConsumer, IPushProducer from twisted.internet.error import ConnectionDone from twisted.internet.defer import Deferred, succeed, fail, maybeDeferred from twisted.internet.defer import CancelledError from twisted.internet.protocol import Protocol from twisted.protocols.basic import LineReceiver from twisted.web.iweb import UNKNOWN_LENGTH, IResponse, IClientRequest from twisted.web.http_headers import Headers from twisted.web.http import NO_CONTENT, NOT_MODIFIED from twisted.web.http import _DataLoss, PotentialDataLoss from twisted.web.http import _IdentityTransferDecoder, _ChunkedTransferDecoder # States HTTPParser can be in STATUS = 'STATUS' HEADER = 'HEADER' BODY = 'BODY' DONE = 'DONE' class BadHeaders(Exception): """ Headers passed to L{Request} were in some way invalid. """ class ExcessWrite(Exception): """ The body L{IBodyProducer} for a request tried to write data after indicating it had finished writing data. """ class ParseError(Exception): """ Some received data could not be parsed. @ivar data: The string which could not be parsed. """ def __init__(self, reason, data): Exception.__init__(self, reason, data) self.data = data class BadResponseVersion(ParseError): """ The version string in a status line was unparsable. """ class _WrapperException(Exception): """ L{_WrapperException} is the base exception type for exceptions which include one or more other exceptions as the low-level causes. @ivar reasons: A list of exceptions. See subclass documentation for more details. """ def __init__(self, reasons): Exception.__init__(self, reasons) self.reasons = reasons class RequestGenerationFailed(_WrapperException): """ There was an error while creating the bytes which make up a request. @ivar reasons: A C{list} of one or more L{Failure} instances giving the reasons the request generation was considered to have failed. """ class RequestTransmissionFailed(_WrapperException): """ There was an error while sending the bytes which make up a request. @ivar reasons: A C{list} of one or more L{Failure} instances giving the reasons the request transmission was considered to have failed. """ class ConnectionAborted(Exception): """ The connection was explicitly aborted by application code. """ class WrongBodyLength(Exception): """ An L{IBodyProducer} declared the number of bytes it was going to produce (via its C{length} attribute) and then produced a different number of bytes. """ class ResponseDone(Exception): """ L{ResponseDone} may be passed to L{IProtocol.connectionLost} on the protocol passed to L{Response.deliverBody} and indicates that the entire response has been delivered. """ class ResponseFailed(_WrapperException): """ L{ResponseFailed} indicates that all of the response to a request was not received for some reason. @ivar reasons: A C{list} of one or more L{Failure} instances giving the reasons the response was considered to have failed. @ivar response: If specified, the L{Response} received from the server (and in particular the status code and the headers). """ def __init__(self, reasons, response=None): _WrapperException.__init__(self, reasons) self.response = response class ResponseNeverReceived(ResponseFailed): """ A L{ResponseFailed} that knows no response bytes at all have been received. """ class RequestNotSent(Exception): """ L{RequestNotSent} indicates that an attempt was made to issue a request but for reasons unrelated to the details of the request itself, the request could not be sent. For example, this may indicate that an attempt was made to send a request using a protocol which is no longer connected to a server. """ def _callAppFunction(function): """ Call C{function}. If it raises an exception, log it with a minimal description of the source. @return: C{None} """ try: function() except: log.err(None, "Unexpected exception from %s" % ( fullyQualifiedName(function),)) class HTTPParser(LineReceiver): """ L{HTTPParser} handles the parsing side of HTTP processing. With a suitable subclass, it can parse either the client side or the server side of the connection. @ivar headers: All of the non-connection control message headers yet received. @ivar state: State indicator for the response parsing state machine. One of C{STATUS}, C{HEADER}, C{BODY}, C{DONE}. @ivar _partialHeader: C{None} or a C{list} of the lines of a multiline header while that header is being received. """ # NOTE: According to HTTP spec, we're supposed to eat the # 'Proxy-Authenticate' and 'Proxy-Authorization' headers also, but that # doesn't sound like a good idea to me, because it makes it impossible to # have a non-authenticating transparent proxy in front of an authenticating # proxy. An authenticating proxy can eat them itself. -jknight # # Further, quoting # http://homepages.tesco.net/J.deBoynePollard/FGA/web-proxy-connection-header.html # regarding the 'Proxy-Connection' header: # # The Proxy-Connection: header is a mistake in how some web browsers # use HTTP. Its name is the result of a false analogy. It is not a # standard part of the protocol. There is a different standard # protocol mechanism for doing what it does. And its existence # imposes a requirement upon HTTP servers such that no proxy HTTP # server can be standards-conforming in practice. # # -exarkun # Some servers (like http://news.ycombinator.com/) return status lines and # HTTP headers delimited by \n instead of \r\n. delimiter = '\n' CONNECTION_CONTROL_HEADERS = set([ 'content-length', 'connection', 'keep-alive', 'te', 'trailers', 'transfer-encoding', 'upgrade', 'proxy-connection']) def connectionMade(self): self.headers = Headers() self.connHeaders = Headers() self.state = STATUS self._partialHeader = None def switchToBodyMode(self, decoder): """ Switch to body parsing mode - interpret any more bytes delivered as part of the message body and deliver them to the given decoder. """ if self.state == BODY: raise RuntimeError("already in body mode") self.bodyDecoder = decoder self.state = BODY self.setRawMode() def lineReceived(self, line): """ Handle one line from a response. """ # Handle the normal CR LF case. if line[-1:] == '\r': line = line[:-1] if self.state == STATUS: self.statusReceived(line) self.state = HEADER elif self.state == HEADER: if not line or line[0] not in ' \t': if self._partialHeader is not None: header = ''.join(self._partialHeader) name, value = header.split(':', 1) value = value.strip() self.headerReceived(name, value) if not line: # Empty line means the header section is over. self.allHeadersReceived() else: # Line not beginning with LWS is another header. self._partialHeader = [line] else: # A line beginning with LWS is a continuation of a header # begun on a previous line. self._partialHeader.append(line) def rawDataReceived(self, data): """ Pass data from the message body to the body decoder object. """ self.bodyDecoder.dataReceived(data) def isConnectionControlHeader(self, name): """ Return C{True} if the given lower-cased name is the name of a connection control header (rather than an entity header). According to RFC 2616, section 14.10, the tokens in the Connection header are probably relevant here. However, I am not sure what the practical consequences of either implementing or ignoring that are. So I leave it unimplemented for the time being. """ return name in self.CONNECTION_CONTROL_HEADERS def statusReceived(self, status): """ Callback invoked whenever the first line of a new message is received. Override this. @param status: The first line of an HTTP request or response message without trailing I{CR LF}. @type status: C{str} """ def headerReceived(self, name, value): """ Store the given header in C{self.headers}. """ name = name.lower() if self.isConnectionControlHeader(name): headers = self.connHeaders else: headers = self.headers headers.addRawHeader(name, value) def allHeadersReceived(self): """ Callback invoked after the last header is passed to C{headerReceived}. Override this to change to the C{BODY} or C{DONE} state. """ self.switchToBodyMode(None) class HTTPClientParser(HTTPParser): """ An HTTP parser which only handles HTTP responses. @ivar request: The request with which the expected response is associated. @type request: L{Request} @ivar NO_BODY_CODES: A C{set} of response codes which B{MUST NOT} have a body. @ivar finisher: A callable to invoke when this response is fully parsed. @ivar _responseDeferred: A L{Deferred} which will be called back with the response when all headers in the response have been received. Thereafter, C{None}. @ivar _everReceivedData: C{True} if any bytes have been received. """ NO_BODY_CODES = set([NO_CONTENT, NOT_MODIFIED]) _transferDecoders = { 'chunked': _ChunkedTransferDecoder, } bodyDecoder = None def __init__(self, request, finisher): self.request = request self.finisher = finisher self._responseDeferred = Deferred() self._everReceivedData = False def dataReceived(self, data): """ Override so that we know if any response has been received. """ self._everReceivedData = True HTTPParser.dataReceived(self, data) def parseVersion(self, strversion): """ Parse version strings of the form Protocol '/' Major '.' Minor. E.g. 'HTTP/1.1'. Returns (protocol, major, minor). Will raise ValueError on bad syntax. """ try: proto, strnumber = strversion.split('/') major, minor = strnumber.split('.') major, minor = int(major), int(minor) except ValueError, e: raise BadResponseVersion(str(e), strversion) if major < 0 or minor < 0: raise BadResponseVersion("version may not be negative", strversion) return (proto, major, minor) def statusReceived(self, status): """ Parse the status line into its components and create a response object to keep track of this response's state. """ parts = status.split(' ', 2) if len(parts) != 3: raise ParseError("wrong number of parts", status) try: statusCode = int(parts[1]) except ValueError: raise ParseError("non-integer status code", status) self.response = Response._construct( self.parseVersion(parts[0]), statusCode, parts[2], self.headers, self.transport, self.request) def _finished(self, rest): """ Called to indicate that an entire response has been received. No more bytes will be interpreted by this L{HTTPClientParser}. Extra bytes are passed up and the state of this L{HTTPClientParser} is set to I{DONE}. @param rest: A C{str} giving any extra bytes delivered to this L{HTTPClientParser} which are not part of the response being parsed. """ self.state = DONE self.finisher(rest) def isConnectionControlHeader(self, name): """ Content-Length in the response to a HEAD request is an entity header, not a connection control header. """ if self.request.method == 'HEAD' and name == 'content-length': return False return HTTPParser.isConnectionControlHeader(self, name) def allHeadersReceived(self): """ Figure out how long the response body is going to be by examining headers and stuff. """ if (self.response.code in self.NO_BODY_CODES or self.request.method == 'HEAD'): self.response.length = 0 # The order of the next two lines might be of interest when adding # support for pipelining. self._finished(self.clearLineBuffer()) self.response._bodyDataFinished() else: transferEncodingHeaders = self.connHeaders.getRawHeaders( 'transfer-encoding') if transferEncodingHeaders: # This could be a KeyError. However, that would mean we do not # know how to decode the response body, so failing the request # is as good a behavior as any. Perhaps someday we will want # to normalize/document/test this specifically, but failing # seems fine to me for now. transferDecoder = self._transferDecoders[transferEncodingHeaders[0].lower()] # If anyone ever invents a transfer encoding other than # chunked (yea right), and that transfer encoding can predict # the length of the response body, it might be sensible to # allow the transfer decoder to set the response object's # length attribute. else: contentLengthHeaders = self.connHeaders.getRawHeaders('content-length') if contentLengthHeaders is None: contentLength = None elif len(contentLengthHeaders) == 1: contentLength = int(contentLengthHeaders[0]) self.response.length = contentLength else: # "HTTP Message Splitting" or "HTTP Response Smuggling" # potentially happening. Or it's just a buggy server. raise ValueError( "Too many Content-Length headers; response is invalid") if contentLength == 0: self._finished(self.clearLineBuffer()) transferDecoder = None else: transferDecoder = lambda x, y: _IdentityTransferDecoder( contentLength, x, y) if transferDecoder is None: self.response._bodyDataFinished() else: # Make sure as little data as possible from the response body # gets delivered to the response object until the response # object actually indicates it is ready to handle bytes # (probably because an application gave it a way to interpret # them). self.transport.pauseProducing() self.switchToBodyMode(transferDecoder( self.response._bodyDataReceived, self._finished)) # This must be last. If it were first, then application code might # change some state (for example, registering a protocol to receive the # response body). Then the pauseProducing above would be wrong since # the response is ready for bytes and nothing else would ever resume # the transport. self._responseDeferred.callback(self.response) del self._responseDeferred def connectionLost(self, reason): if self.bodyDecoder is not None: try: try: self.bodyDecoder.noMoreData() except PotentialDataLoss: self.response._bodyDataFinished(Failure()) except _DataLoss: self.response._bodyDataFinished( Failure(ResponseFailed([reason, Failure()], self.response))) else: self.response._bodyDataFinished() except: # Handle exceptions from both the except suites and the else # suite. Those functions really shouldn't raise exceptions, # but maybe there's some buggy application code somewhere # making things difficult. log.err() elif self.state != DONE: if self._everReceivedData: exceptionClass = ResponseFailed else: exceptionClass = ResponseNeverReceived self._responseDeferred.errback(Failure(exceptionClass([reason]))) del self._responseDeferred class Request: """ A L{Request} instance describes an HTTP request to be sent to an HTTP server. @ivar method: See L{__init__}. @ivar uri: See L{__init__}. @ivar headers: See L{__init__}. @ivar bodyProducer: See L{__init__}. @ivar persistent: See L{__init__}. @ivar _parsedURI: Parsed I{URI} for the request, or C{None}. @type _parsedURI: L{_URI} """ implements(IClientRequest) def __init__(self, method, uri, headers, bodyProducer, persistent=False): """ @param method: The HTTP method to for this request, ex: 'GET', 'HEAD', 'POST', etc. @type method: L{str} @param uri: The relative URI of the resource to request. For example, C{'/foo/bar?baz=quux'}. @type uri: L{str} @param headers: Headers to be sent to the server. It is important to note that this object does not create any implicit headers. So it is up to the HTTP Client to add required headers such as 'Host'. @type headers: L{twisted.web.http_headers.Headers} @param bodyProducer: C{None} or an L{IBodyProducer} provider which produces the content body to send to the remote HTTP server. @param persistent: Set to C{True} when you use HTTP persistent connection, defaults to C{False}. @type persistent: L{bool} """ self.method = method self.uri = uri self.headers = headers self.bodyProducer = bodyProducer self.persistent = persistent self._parsedURI = None @classmethod def _construct(cls, method, uri, headers, bodyProducer, persistent=False, parsedURI=None): """ Private constructor. @param method: See L{__init__}. @param uri: See L{__init__}. @param headers: See L{__init__}. @param bodyProducer: See L{__init__}. @param persistent: See L{__init__}. @param parsedURI: See L{Request._parsedURI}. @return: L{Request} instance. """ request = cls(method, uri, headers, bodyProducer, persistent) request._parsedURI = parsedURI return request @property def absoluteURI(self): """ The absolute URI of the request as C{bytes}, or C{None} if the absolute URI cannot be determined. """ return getattr(self._parsedURI, 'toBytes', lambda: None)() def _writeHeaders(self, transport, TEorCL): hosts = self.headers.getRawHeaders('host', ()) if len(hosts) != 1: raise BadHeaders("Exactly one Host header required") # In the future, having the protocol version be a parameter to this # method would probably be good. It would be nice if this method # weren't limited to issueing HTTP/1.1 requests. requestLines = [] requestLines.append( '%s %s HTTP/1.1\r\n' % (self.method, self.uri)) if not self.persistent: requestLines.append('Connection: close\r\n') if TEorCL is not None: requestLines.append(TEorCL) for name, values in self.headers.getAllRawHeaders(): requestLines.extend(['%s: %s\r\n' % (name, v) for v in values]) requestLines.append('\r\n') transport.writeSequence(requestLines) def _writeToChunked(self, transport): """ Write this request to the given transport using chunked transfer-encoding to frame the body. """ self._writeHeaders(transport, 'Transfer-Encoding: chunked\r\n') encoder = ChunkedEncoder(transport) encoder.registerProducer(self.bodyProducer, True) d = self.bodyProducer.startProducing(encoder) def cbProduced(ignored): encoder.unregisterProducer() def ebProduced(err): encoder._allowNoMoreWrites() # Don't call the encoder's unregisterProducer because it will write # a zero-length chunk. This would indicate to the server that the # request body is complete. There was an error, though, so we # don't want to do that. transport.unregisterProducer() return err d.addCallbacks(cbProduced, ebProduced) return d def _writeToContentLength(self, transport): """ Write this request to the given transport using content-length to frame the body. """ self._writeHeaders( transport, 'Content-Length: %d\r\n' % (self.bodyProducer.length,)) # This Deferred is used to signal an error in the data written to the # encoder below. It can only errback and it will only do so before too # many bytes have been written to the encoder and before the producer # Deferred fires. finishedConsuming = Deferred() # This makes sure the producer writes the correct number of bytes for # the request body. encoder = LengthEnforcingConsumer( self.bodyProducer, transport, finishedConsuming) transport.registerProducer(self.bodyProducer, True) finishedProducing = self.bodyProducer.startProducing(encoder) def combine(consuming, producing): # This Deferred is returned and will be fired when the first of # consuming or producing fires. If it's cancelled, forward that # cancellation to the producer. def cancelConsuming(ign): finishedProducing.cancel() ultimate = Deferred(cancelConsuming) # Keep track of what has happened so far. This initially # contains None, then an integer uniquely identifying what # sequence of events happened. See the callbacks and errbacks # defined below for the meaning of each value. state = [None] def ebConsuming(err): if state == [None]: # The consuming Deferred failed first. This means the # overall writeTo Deferred is going to errback now. The # producing Deferred should not fire later (because the # consumer should have called stopProducing on the # producer), but if it does, a callback will be ignored # and an errback will be logged. state[0] = 1 ultimate.errback(err) else: # The consuming Deferred errbacked after the producing # Deferred fired. This really shouldn't ever happen. # If it does, I goofed. Log the error anyway, just so # there's a chance someone might notice and complain. log.err( err, "Buggy state machine in %r/[%d]: " "ebConsuming called" % (self, state[0])) def cbProducing(result): if state == [None]: # The producing Deferred succeeded first. Nothing will # ever happen to the consuming Deferred. Tell the # encoder we're done so it can check what the producer # wrote and make sure it was right. state[0] = 2 try: encoder._noMoreWritesExpected() except: # Fail the overall writeTo Deferred - something the # producer did was wrong. ultimate.errback() else: # Success - succeed the overall writeTo Deferred. ultimate.callback(None) # Otherwise, the consuming Deferred already errbacked. The # producing Deferred wasn't supposed to fire, but it did # anyway. It's buggy, but there's not really anything to be # done about it. Just ignore this result. def ebProducing(err): if state == [None]: # The producing Deferred failed first. This means the # overall writeTo Deferred is going to errback now. # Tell the encoder that we're done so it knows to reject # further writes from the producer (which should not # happen, but the producer may be buggy). state[0] = 3 encoder._allowNoMoreWrites() ultimate.errback(err) else: # The producing Deferred failed after the consuming # Deferred failed. It shouldn't have, so it's buggy. # Log the exception in case anyone who can fix the code # is watching. log.err(err, "Producer is buggy") consuming.addErrback(ebConsuming) producing.addCallbacks(cbProducing, ebProducing) return ultimate d = combine(finishedConsuming, finishedProducing) def f(passthrough): # Regardless of what happens with the overall Deferred, once it # fires, the producer registered way up above the definition of # combine should be unregistered. transport.unregisterProducer() return passthrough d.addBoth(f) return d def writeTo(self, transport): """ Format this L{Request} as an HTTP/1.1 request and write it to the given transport. If bodyProducer is not None, it will be associated with an L{IConsumer}. @return: A L{Deferred} which fires with C{None} when the request has been completely written to the transport or with a L{Failure} if there is any problem generating the request bytes. """ if self.bodyProducer is not None: if self.bodyProducer.length is UNKNOWN_LENGTH: return self._writeToChunked(transport) else: return self._writeToContentLength(transport) else: self._writeHeaders(transport, None) return succeed(None) def stopWriting(self): """ Stop writing this request to the transport. This can only be called after C{writeTo} and before the L{Deferred} returned by C{writeTo} fires. It should cancel any asynchronous task started by C{writeTo}. The L{Deferred} returned by C{writeTo} need not be fired if this method is called. """ # If bodyProducer is None, then the Deferred returned by writeTo has # fired already and this method cannot be called. _callAppFunction(self.bodyProducer.stopProducing) class LengthEnforcingConsumer: """ An L{IConsumer} proxy which enforces an exact length requirement on the total data written to it. @ivar _length: The number of bytes remaining to be written. @ivar _producer: The L{IBodyProducer} which is writing to this consumer. @ivar _consumer: The consumer to which at most C{_length} bytes will be forwarded. @ivar _finished: A L{Deferred} which will be fired with a L{Failure} if too many bytes are written to this consumer. """ def __init__(self, producer, consumer, finished): self._length = producer.length self._producer = producer self._consumer = consumer self._finished = finished def _allowNoMoreWrites(self): """ Indicate that no additional writes are allowed. Attempts to write after calling this method will be met with an exception. """ self._finished = None def write(self, bytes): """ Write C{bytes} to the underlying consumer unless C{_noMoreWritesExpected} has been called or there are/have been too many bytes. """ if self._finished is None: # No writes are supposed to happen any more. Try to convince the # calling code to stop calling this method by calling its # stopProducing method and then throwing an exception at it. This # exception isn't documented as part of the API because you're # never supposed to expect it: only buggy code will ever receive # it. self._producer.stopProducing() raise ExcessWrite() if len(bytes) <= self._length: self._length -= len(bytes) self._consumer.write(bytes) else: # No synchronous exception is raised in *this* error path because # we still have _finished which we can use to report the error to a # better place than the direct caller of this method (some # arbitrary application code). _callAppFunction(self._producer.stopProducing) self._finished.errback(WrongBodyLength("too many bytes written")) self._allowNoMoreWrites() def _noMoreWritesExpected(self): """ Called to indicate no more bytes will be written to this consumer. Check to see that the correct number have been written. @raise WrongBodyLength: If not enough bytes have been written. """ if self._finished is not None: self._allowNoMoreWrites() if self._length: raise WrongBodyLength("too few bytes written") def makeStatefulDispatcher(name, template): """ Given a I{dispatch} name and a function, return a function which can be used as a method and which, when called, will call another method defined on the instance and return the result. The other method which is called is determined by the value of the C{_state} attribute of the instance. @param name: A string which is used to construct the name of the subsidiary method to invoke. The subsidiary method is named like C{'_%s_%s' % (name, _state)}. @param template: A function object which is used to give the returned function a docstring. @return: The dispatcher function. """ def dispatcher(self, *args, **kwargs): func = getattr(self, '_' + name + '_' + self._state, None) if func is None: raise RuntimeError( "%r has no %s method in state %s" % (self, name, self._state)) return func(*args, **kwargs) dispatcher.__doc__ = template.__doc__ return dispatcher class Response: """ A L{Response} instance describes an HTTP response received from an HTTP server. L{Response} should not be subclassed or instantiated. @ivar _transport: See L{__init__}. @ivar _bodyProtocol: The L{IProtocol} provider to which the body is delivered. C{None} before one has been registered with C{deliverBody}. @ivar _bodyBuffer: A C{list} of the strings passed to C{bodyDataReceived} before C{deliverBody} is called. C{None} afterwards. @ivar _state: Indicates what state this L{Response} instance is in, particularly with respect to delivering bytes from the response body to an application-suppled protocol object. This may be one of C{'INITIAL'}, C{'CONNECTED'}, C{'DEFERRED_CLOSE'}, or C{'FINISHED'}, with the following meanings: - INITIAL: This is the state L{Response} objects start in. No protocol has yet been provided and the underlying transport may still have bytes to deliver to it. - DEFERRED_CLOSE: If the underlying transport indicates all bytes have been delivered but no application-provided protocol is yet available, the L{Response} moves to this state. Data is buffered and waiting for a protocol to be delivered to. - CONNECTED: If a protocol is provided when the state is INITIAL, the L{Response} moves to this state. Any buffered data is delivered and any data which arrives from the transport subsequently is given directly to the protocol. - FINISHED: If a protocol is provided in the DEFERRED_CLOSE state, the L{Response} moves to this state after delivering all buffered data to the protocol. Otherwise, if the L{Response} is in the CONNECTED state, if the transport indicates there is no more data, the L{Response} moves to this state. Nothing else can happen once the L{Response} is in this state. """ implements(IResponse) length = UNKNOWN_LENGTH _bodyProtocol = None _bodyFinished = False def __init__(self, version, code, phrase, headers, _transport): """ @param version: HTTP version components protocol, major, minor. E.g. C{('HTTP', 1, 1)} to mean C{'HTTP/1.1'}. @param code: HTTP status code. @type code: L{int} @param phrase: HTTP reason phrase, intended to give a short description of the HTTP status code. @param headers: HTTP response headers. @type headers: L{twisted.web.http_headers.Headers} @param _transport: The transport which is delivering this response. """ self.version = version self.code = code self.phrase = phrase self.headers = headers self._transport = _transport self._bodyBuffer = [] self._state = 'INITIAL' self.request = None self.previousResponse = None @classmethod def _construct(cls, version, code, phrase, headers, _transport, request): """ Private constructor. @param version: See L{__init__}. @param code: See L{__init__}. @param phrase: See L{__init__}. @param headers: See L{__init__}. @param _transport: See L{__init__}. @param request: See L{IResponse.request}. @return: L{Response} instance. """ response = Response(version, code, phrase, headers, _transport) response.request = proxyForInterface(IClientRequest)(request) return response def setPreviousResponse(self, previousResponse): self.previousResponse = previousResponse def deliverBody(self, protocol): """ Dispatch the given L{IProtocol} depending of the current state of the response. """ deliverBody = makeStatefulDispatcher('deliverBody', deliverBody) def _deliverBody_INITIAL(self, protocol): """ Deliver any buffered data to C{protocol} and prepare to deliver any future data to it. Move to the C{'CONNECTED'} state. """ # Now that there's a protocol to consume the body, resume the # transport. It was previously paused by HTTPClientParser to avoid # reading too much data before it could be handled. self._transport.resumeProducing() protocol.makeConnection(self._transport) self._bodyProtocol = protocol for data in self._bodyBuffer: self._bodyProtocol.dataReceived(data) self._bodyBuffer = None self._state = 'CONNECTED' def _deliverBody_CONNECTED(self, protocol): """ It is invalid to attempt to deliver data to a protocol when it is already being delivered to another protocol. """ raise RuntimeError( "Response already has protocol %r, cannot deliverBody " "again" % (self._bodyProtocol,)) def _deliverBody_DEFERRED_CLOSE(self, protocol): """ Deliver any buffered data to C{protocol} and then disconnect the protocol. Move to the C{'FINISHED'} state. """ # Unlike _deliverBody_INITIAL, there is no need to resume the # transport here because all of the response data has been received # already. Some higher level code may want to resume the transport if # that code expects further data to be received over it. protocol.makeConnection(self._transport) for data in self._bodyBuffer: protocol.dataReceived(data) self._bodyBuffer = None protocol.connectionLost(self._reason) self._state = 'FINISHED' def _deliverBody_FINISHED(self, protocol): """ It is invalid to attempt to deliver data to a protocol after the response body has been delivered to another protocol. """ raise RuntimeError( "Response already finished, cannot deliverBody now.") def _bodyDataReceived(self, data): """ Called by HTTPClientParser with chunks of data from the response body. They will be buffered or delivered to the protocol passed to deliverBody. """ _bodyDataReceived = makeStatefulDispatcher('bodyDataReceived', _bodyDataReceived) def _bodyDataReceived_INITIAL(self, data): """ Buffer any data received for later delivery to a protocol passed to C{deliverBody}. Little or no data should be buffered by this method, since the transport has been paused and will not be resumed until a protocol is supplied. """ self._bodyBuffer.append(data) def _bodyDataReceived_CONNECTED(self, data): """ Deliver any data received to the protocol to which this L{Response} is connected. """ self._bodyProtocol.dataReceived(data) def _bodyDataReceived_DEFERRED_CLOSE(self, data): """ It is invalid for data to be delivered after it has been indicated that the response body has been completely delivered. """ raise RuntimeError("Cannot receive body data after _bodyDataFinished") def _bodyDataReceived_FINISHED(self, data): """ It is invalid for data to be delivered after the response body has been delivered to a protocol. """ raise RuntimeError("Cannot receive body data after protocol disconnected") def _bodyDataFinished(self, reason=None): """ Called by HTTPClientParser when no more body data is available. If the optional reason is supplied, this indicates a problem or potential problem receiving all of the response body. """ _bodyDataFinished = makeStatefulDispatcher('bodyDataFinished', _bodyDataFinished) def _bodyDataFinished_INITIAL(self, reason=None): """ Move to the C{'DEFERRED_CLOSE'} state to wait for a protocol to which to deliver the response body. """ self._state = 'DEFERRED_CLOSE' if reason is None: reason = Failure(ResponseDone("Response body fully received")) self._reason = reason def _bodyDataFinished_CONNECTED(self, reason=None): """ Disconnect the protocol and move to the C{'FINISHED'} state. """ if reason is None: reason = Failure(ResponseDone("Response body fully received")) self._bodyProtocol.connectionLost(reason) self._bodyProtocol = None self._state = 'FINISHED' def _bodyDataFinished_DEFERRED_CLOSE(self): """ It is invalid to attempt to notify the L{Response} of the end of the response body data more than once. """ raise RuntimeError("Cannot finish body data more than once") def _bodyDataFinished_FINISHED(self): """ It is invalid to attempt to notify the L{Response} of the end of the response body data more than once. """ raise RuntimeError("Cannot finish body data after protocol disconnected") class ChunkedEncoder: """ Helper object which exposes L{IConsumer} on top of L{HTTP11ClientProtocol} for streaming request bodies to the server. """ implements(IConsumer) def __init__(self, transport): self.transport = transport def _allowNoMoreWrites(self): """ Indicate that no additional writes are allowed. Attempts to write after calling this method will be met with an exception. """ self.transport = None def registerProducer(self, producer, streaming): """ Register the given producer with C{self.transport}. """ self.transport.registerProducer(producer, streaming) def write(self, data): """ Write the given request body bytes to the transport using chunked encoding. @type data: C{str} """ if self.transport is None: raise ExcessWrite() self.transport.writeSequence(("%x\r\n" % len(data), data, "\r\n")) def unregisterProducer(self): """ Indicate that the request body is complete and finish the request. """ self.write('') self.transport.unregisterProducer() self._allowNoMoreWrites() class TransportProxyProducer: """ An L{IPushProducer} implementation which wraps another such thing and proxies calls to it until it is told to stop. @ivar _producer: The wrapped L{IPushProducer} provider or C{None} after this proxy has been stopped. """ implements(IPushProducer) # LineReceiver uses this undocumented attribute of transports to decide # when to stop calling lineReceived or rawDataReceived (if it finds it to # be true, it doesn't bother to deliver any more data). Set disconnecting # to False here and never change it to true so that all data is always # delivered to us and so that LineReceiver doesn't fail with an # AttributeError. disconnecting = False def __init__(self, producer): self._producer = producer def _stopProxying(self): """ Stop forwarding calls of L{IPushProducer} methods to the underlying L{IPushProvider} provider. """ self._producer = None def stopProducing(self): """ Proxy the stoppage to the underlying producer, unless this proxy has been stopped. """ if self._producer is not None: self._producer.stopProducing() def resumeProducing(self): """ Proxy the resumption to the underlying producer, unless this proxy has been stopped. """ if self._producer is not None: self._producer.resumeProducing() def pauseProducing(self): """ Proxy the pause to the underlying producer, unless this proxy has been stopped. """ if self._producer is not None: self._producer.pauseProducing() class HTTP11ClientProtocol(Protocol): """ L{HTTP11ClientProtocol} is an implementation of the HTTP 1.1 client protocol. It supports as few features as possible. @ivar _parser: After a request is issued, the L{HTTPClientParser} to which received data making up the response to that request is delivered. @ivar _finishedRequest: After a request is issued, the L{Deferred} which will fire when a L{Response} object corresponding to that request is available. This allows L{HTTP11ClientProtocol} to fail the request if there is a connection or parsing problem. @ivar _currentRequest: After a request is issued, the L{Request} instance used to make that request. This allows L{HTTP11ClientProtocol} to stop request generation if necessary (for example, if the connection is lost). @ivar _transportProxy: After a request is issued, the L{TransportProxyProducer} to which C{_parser} is connected. This allows C{_parser} to pause and resume the transport in a way which L{HTTP11ClientProtocol} can exert some control over. @ivar _responseDeferred: After a request is issued, the L{Deferred} from C{_parser} which will fire with a L{Response} when one has been received. This is eventually chained with C{_finishedRequest}, but only in certain cases to avoid double firing that Deferred. @ivar _state: Indicates what state this L{HTTP11ClientProtocol} instance is in with respect to transmission of a request and reception of a response. This may be one of the following strings: - QUIESCENT: This is the state L{HTTP11ClientProtocol} instances start in. Nothing is happening: no request is being sent and no response is being received or expected. - TRANSMITTING: When a request is made (via L{request}), the instance moves to this state. L{Request.writeTo} has been used to start to send a request but it has not yet finished. - TRANSMITTING_AFTER_RECEIVING_RESPONSE: The server has returned a complete response but the request has not yet been fully sent yet. The instance will remain in this state until the request is fully sent. - GENERATION_FAILED: There was an error while the request. The request was not fully sent to the network. - WAITING: The request was fully sent to the network. The instance is now waiting for the response to be fully received. - ABORTING: Application code has requested that the HTTP connection be aborted. - CONNECTION_LOST: The connection has been lost. @ivar _abortDeferreds: A list of C{Deferred} instances that will fire when the connection is lost. """ _state = 'QUIESCENT' _parser = None _finishedRequest = None _currentRequest = None _transportProxy = None _responseDeferred = None def __init__(self, quiescentCallback=lambda c: None): self._quiescentCallback = quiescentCallback self._abortDeferreds = [] @property def state(self): return self._state def request(self, request): """ Issue C{request} over C{self.transport} and return a L{Deferred} which will fire with a L{Response} instance or an error. @param request: The object defining the parameters of the request to issue. @type request: L{Request} @rtype: L{Deferred} @return: The deferred may errback with L{RequestGenerationFailed} if the request was not fully written to the transport due to a local error. It may errback with L{RequestTransmissionFailed} if it was not fully written to the transport due to a network error. It may errback with L{ResponseFailed} if the request was sent (not necessarily received) but some or all of the response was lost. It may errback with L{RequestNotSent} if it is not possible to send any more requests using this L{HTTP11ClientProtocol}. """ if self._state != 'QUIESCENT': return fail(RequestNotSent()) self._state = 'TRANSMITTING' _requestDeferred = maybeDeferred(request.writeTo, self.transport) def cancelRequest(ign): # Explicitly cancel the request's deferred if it's still trying to # write when this request is cancelled. if self._state in ( 'TRANSMITTING', 'TRANSMITTING_AFTER_RECEIVING_RESPONSE'): _requestDeferred.cancel() else: self.transport.abortConnection() self._disconnectParser(Failure(CancelledError())) self._finishedRequest = Deferred(cancelRequest) # Keep track of the Request object in case we need to call stopWriting # on it. self._currentRequest = request self._transportProxy = TransportProxyProducer(self.transport) self._parser = HTTPClientParser(request, self._finishResponse) self._parser.makeConnection(self._transportProxy) self._responseDeferred = self._parser._responseDeferred def cbRequestWrotten(ignored): if self._state == 'TRANSMITTING': self._state = 'WAITING' self._responseDeferred.chainDeferred(self._finishedRequest) def ebRequestWriting(err): if self._state == 'TRANSMITTING': self._state = 'GENERATION_FAILED' self.transport.abortConnection() self._finishedRequest.errback( Failure(RequestGenerationFailed([err]))) else: log.err(err, 'Error writing request, but not in valid state ' 'to finalize request: %s' % self._state) _requestDeferred.addCallbacks(cbRequestWrotten, ebRequestWriting) return self._finishedRequest def _finishResponse(self, rest): """ Called by an L{HTTPClientParser} to indicate that it has parsed a complete response. @param rest: A C{str} giving any trailing bytes which were given to the L{HTTPClientParser} which were not part of the response it was parsing. """ _finishResponse = makeStatefulDispatcher('finishResponse', _finishResponse) def _finishResponse_WAITING(self, rest): # Currently the rest parameter is ignored. Don't forget to use it if # we ever add support for pipelining. And maybe check what trailers # mean. if self._state == 'WAITING': self._state = 'QUIESCENT' else: # The server sent the entire response before we could send the # whole request. That sucks. Oh well. Fire the request() # Deferred with the response. But first, make sure that if the # request does ever finish being written that it won't try to fire # that Deferred. self._state = 'TRANSMITTING_AFTER_RECEIVING_RESPONSE' self._responseDeferred.chainDeferred(self._finishedRequest) # This will happen if we're being called due to connection being lost; # if so, no need to disconnect parser again, or to call # _quiescentCallback. if self._parser is None: return reason = ConnectionDone("synthetic!") connHeaders = self._parser.connHeaders.getRawHeaders('connection', ()) if (('close' in connHeaders) or self._state != "QUIESCENT" or not self._currentRequest.persistent): self._giveUp(Failure(reason)) else: # We call the quiescent callback first, to ensure connection gets # added back to connection pool before we finish the request. try: self._quiescentCallback(self) except: # If callback throws exception, just log it and disconnect; # keeping persistent connections around is an optimisation: log.err() self.transport.loseConnection() self._disconnectParser(reason) _finishResponse_TRANSMITTING = _finishResponse_WAITING def _disconnectParser(self, reason): """ If there is still a parser, call its C{connectionLost} method with the given reason. If there is not, do nothing. @type reason: L{Failure} """ if self._parser is not None: parser = self._parser self._parser = None self._currentRequest = None self._finishedRequest = None self._responseDeferred = None # The parser is no longer allowed to do anything to the real # transport. Stop proxying from the parser's transport to the real # transport before telling the parser it's done so that it can't do # anything. self._transportProxy._stopProxying() self._transportProxy = None parser.connectionLost(reason) def _giveUp(self, reason): """ Lose the underlying connection and disconnect the parser with the given L{Failure}. Use this method instead of calling the transport's loseConnection method directly otherwise random things will break. """ self.transport.loseConnection() self._disconnectParser(reason) def dataReceived(self, bytes): """ Handle some stuff from some place. """ try: self._parser.dataReceived(bytes) except: self._giveUp(Failure()) def connectionLost(self, reason): """ The underlying transport went away. If appropriate, notify the parser object. """ connectionLost = makeStatefulDispatcher('connectionLost', connectionLost) def _connectionLost_QUIESCENT(self, reason): """ Nothing is currently happening. Move to the C{'CONNECTION_LOST'} state but otherwise do nothing. """ self._state = 'CONNECTION_LOST' def _connectionLost_GENERATION_FAILED(self, reason): """ The connection was in an inconsistent state. Move to the C{'CONNECTION_LOST'} state but otherwise do nothing. """ self._state = 'CONNECTION_LOST' def _connectionLost_TRANSMITTING(self, reason): """ Fail the L{Deferred} for the current request, notify the request object that it does not need to continue transmitting itself, and move to the C{'CONNECTION_LOST'} state. """ self._state = 'CONNECTION_LOST' self._finishedRequest.errback( Failure(RequestTransmissionFailed([reason]))) del self._finishedRequest # Tell the request that it should stop bothering now. self._currentRequest.stopWriting() def _connectionLost_TRANSMITTING_AFTER_RECEIVING_RESPONSE(self, reason): """ Move to the C{'CONNECTION_LOST'} state. """ self._state = 'CONNECTION_LOST' def _connectionLost_WAITING(self, reason): """ Disconnect the response parser so that it can propagate the event as necessary (for example, to call an application protocol's C{connectionLost} method, or to fail a request L{Deferred}) and move to the C{'CONNECTION_LOST'} state. """ self._disconnectParser(reason) self._state = 'CONNECTION_LOST' def _connectionLost_ABORTING(self, reason): """ Disconnect the response parser with a L{ConnectionAborted} failure, and move to the C{'CONNECTION_LOST'} state. """ self._disconnectParser(Failure(ConnectionAborted())) self._state = 'CONNECTION_LOST' for d in self._abortDeferreds: d.callback(None) self._abortDeferreds = [] def abort(self): """ Close the connection and cause all outstanding L{request} L{Deferred}s to fire with an error. """ if self._state == "CONNECTION_LOST": return succeed(None) self.transport.loseConnection() self._state = 'ABORTING' d = Deferred() self._abortDeferreds.append(d) return d
gpl-3.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2520, 14, 396, 14, 396, 63, 1222, 1258, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2493, 738, 91, 2856, 413, 14, 17, 28, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 14, 1360, 23307, 1890, 14, 199, 199, 1918, 4340, 370, 675, 314, 9330, 2741, 701, 642, 859, 365, 370, 26, 819, 446, 15175, 282, 491, 91, 2856, 845, 3041, 3658, 93, 370, 376, 3101, 1654, 523, 446, 2790, 282, 491, 91, 2017, 93, 543, 314, 5827, 666, 523, 446, 8325, 314, 1056, 370, 491, 91, 2856, 845, 3041, 3658, 14, 1069, 93, 523, 446, 710, 2138, 17448, 911, 8344, 543, 282, 491, 91, 2364, 93, 909, 523, 446, 2790, 282, 491, 91, 41, 3658, 93, 5022, 1314, 883, 2429, 314, 1177, 2396, 523, 446, 15175, 652, 370, 314, 1177, 543, 491, 91, 2364, 14, 31584, 8173, 93, 523, 446, 3979, 314, 4113, 1159, 445, 91, 2105, 14074, 93, 1083, 365, 2797, 12, 314, 1177, 365, 272, 4890, 14, 221, 1666, 491, 91, 2364, 14, 31584, 8173, 93, 367, 2436, 14, 199, 199, 9958, 1785, 1163, 3992, 315, 642, 859, 2291, 642, 4503, 26, 819, 446, 3101, 2842, 365, 314, 5678, 3101, 1798, 14, 221, 2779, 883, 2429, 314, 4184, 402, 3101, 1314, 272, 787, 16371, 3382, 4145, 436, 9320, 14, 819, 446, 3101, 3041, 2842, 16879, 3101, 2842, 370, 2429, 1177, 13, 6100, 4184, 402, 272, 3101, 14, 221, 7309, 1256, 365, 2737, 367, 1924, 1056, 370, 2198, 314, 5226, 272, 1177, 14, 199, 624, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 1548, 14, 4608, 492, 4566, 1858, 4267, 199, 504, 7390, 14, 1548, 14, 21963, 492, 9999, 23279, 985, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 18186, 12, 3531, 2084, 15532, 199, 504, 7390, 14, 4901, 14, 705, 492, 8113, 10759, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 17961, 12, 2449, 12, 11703, 9937, 199, 504, 7390, 14, 4901, 14, 11610, 492, 28374, 1146, 547, 199, 504, 7390, 14, 4901, 14, 3922, 492, 11557, 199, 504, 7390, 14, 16541, 14, 4316, 492, 7030, 21800, 199, 504, 7390, 14, 2520, 14, 73, 2520, 492, 24740, 63, 9127, 12, 473, 2364, 12, 473, 3041, 2017, 199, 504, 7390, 14, 2520, 14, 1014, 63, 2139, 492, 21391, 199, 504, 7390, 14, 2520, 14, 1014, 492, 4825, 63, 9663, 12, 2845, 63, 30389, 199, 504, 7390, 14, 2520, 14, 1014, 492, 485, 1451, 8610, 12, 4376, 9443, 1451, 8610, 199, 504, 7390, 14, 2520, 14, 1014, 492, 485, 10193, 11761, 8326, 12, 485, 9856, 379, 11761, 8326, 199, 199, 3, 24230, 3101, 2842, 883, 506, 315, 199, 6305, 275, 283, 6305, 7, 199, 7311, 275, 283, 7311, 7, 199, 23708, 275, 283, 23708, 7, 199, 22162, 275, 283, 22162, 7, 421, 199, 533, 8857, 9883, 8, 1726, 304, 272, 408, 272, 21391, 3032, 370, 491, 91, 2017, 93, 4898, 315, 2005, 4340, 3866, 14, 272, 408, 4388, 199, 533, 1316, 670, 3534, 8, 1726, 304, 272, 408, 272, 710, 2396, 491, 91, 2100, 1351, 15532, 93, 367, 282, 1056, 16416, 370, 2218, 666, 2410, 272, 9297, 652, 10530, 9158, 3575, 666, 14, 272, 408, 421, 199, 533, 21743, 8, 1726, 304, 272, 408, 272, 6601, 3086, 666, 4293, 440, 506, 4565, 14, 339, 768, 7725, 666, 26, 710, 1059, 1314, 4293, 440, 506, 4565, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 4499, 12, 666, 304, 267, 2186, 855, 826, 721, 277, 12, 4499, 12, 666, 9, 267, 291, 14, 576, 275, 666, 4388, 199, 533, 8857, 2364, 3353, 8, 9123, 304, 272, 408, 272, 710, 1015, 1059, 315, 282, 2004, 1004, 1990, 625, 21152, 461, 14, 272, 408, 4388, 199, 533, 485, 4590, 1726, 8, 1726, 304, 272, 408, 272, 491, 26975, 4590, 1726, 93, 365, 314, 1300, 1919, 730, 367, 4967, 1314, 272, 2387, 1373, 503, 1655, 1163, 4967, 465, 314, 6465, 13, 1896, 14486, 14, 339, 768, 7725, 14872, 26, 437, 769, 402, 4967, 14, 221, 1666, 5516, 3794, 367, 1655, 267, 2436, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 14872, 304, 267, 2186, 855, 826, 721, 277, 12, 14872, 9, 267, 291, 14, 5764, 83, 275, 14872, 4388, 199, 533, 4784, 18514, 4276, 1547, 4590, 1726, 304, 272, 408, 272, 6006, 1990, 376, 1125, 1830, 6425, 314, 2783, 1314, 1852, 1536, 282, 1056, 14, 339, 768, 7725, 14872, 26, 437, 445, 91, 513, 93, 402, 1373, 503, 1655, 491, 91, 6782, 93, 4454, 15131, 314, 267, 14872, 314, 1056, 10152, 1990, 8652, 370, 1172, 3405, 14, 272, 408, 4388, 199, 533, 4784, 24011, 4276, 1547, 4590, 1726, 304, 272, 408, 272, 6006, 1990, 376, 1125, 1830, 10209, 314, 2783, 1314, 1852, 1536, 282, 1056, 14, 339, 768, 7725, 14872, 26, 437, 445, 91, 513, 93, 402, 1373, 503, 1655, 491, 91, 6782, 93, 4454, 15131, 314, 267, 14872, 314, 1056, 1752, 2250, 1990, 8652, 370, 1172, 3405, 14, 272, 408, 4388, 199, 533, 8113, 5583, 1376, 8, 1726, 304, 272, 408, 272, 710, 1950, 1990, 7662, 26815, 701, 4223, 1233, 14, 272, 408, 4388, 199, 533, 30801, 8173, 4625, 8, 1726, 304, 272, 408, 272, 1626, 491, 91, 2100, 1351, 15532, 93, 14290, 314, 1329, 402, 2783, 652, 1990, 9995, 370, 272, 7389, 334, 12897, 2399, 445, 91, 1267, 93, 2225, 9, 436, 2066, 13584, 282, 3365, 1329, 272, 402, 2783, 14, 272, 408, 4388, 199, 533, 7232, 10759, 8, 1726, 304, 272, 408, 272, 491, 91, 2364, 10759, 93, 1443, 506, 3032, 370, 491, 91, 41, 3658, 14, 2105, 14074, 93, 641, 314, 272, 4113, 3032, 370, 491, 91, 2364, 14, 31584, 8173, 93, 436, 9126, 626, 314, 8039, 272, 1177, 965, 2757, 28218, 14, 272, 408, 4388, 199, 533, 7232, 4276, 1547, 4590, 1726, 304, 272, 408, 272, 491, 91, 2364, 4276, 93, 9126, 626, 1006, 402 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2520, 14, 396, 14, 396, 63, 1222, 1258, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2493, 738, 91, 2856, 413, 14, 17, 28, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 14, 1360, 23307, 1890, 14, 199, 199, 1918, 4340, 370, 675, 314, 9330, 2741, 701, 642, 859, 365, 370, 26, 819, 446, 15175, 282, 491, 91, 2856, 845, 3041, 3658, 93, 370, 376, 3101, 1654, 523, 446, 2790, 282, 491, 91, 2017, 93, 543, 314, 5827, 666, 523, 446, 8325, 314, 1056, 370, 491, 91, 2856, 845, 3041, 3658, 14, 1069, 93, 523, 446, 710, 2138, 17448, 911, 8344, 543, 282, 491, 91, 2364, 93, 909, 523, 446, 2790, 282, 491, 91, 41, 3658, 93, 5022, 1314, 883, 2429, 314, 1177, 2396, 523, 446, 15175, 652, 370, 314, 1177, 543, 491, 91, 2364, 14, 31584, 8173, 93, 523, 446, 3979, 314, 4113, 1159, 445, 91, 2105, 14074, 93, 1083, 365, 2797, 12, 314, 1177, 365, 272, 4890, 14, 221, 1666, 491, 91, 2364, 14, 31584, 8173, 93, 367, 2436, 14, 199, 199, 9958, 1785, 1163, 3992, 315, 642, 859, 2291, 642, 4503, 26, 819, 446, 3101, 2842, 365, 314, 5678, 3101, 1798, 14, 221, 2779, 883, 2429, 314, 4184, 402, 3101, 1314, 272, 787, 16371, 3382, 4145, 436, 9320, 14, 819, 446, 3101, 3041, 2842, 16879, 3101, 2842, 370, 2429, 1177, 13, 6100, 4184, 402, 272, 3101, 14, 221, 7309, 1256, 365, 2737, 367, 1924, 1056, 370, 2198, 314, 5226, 272, 1177, 14, 199, 624, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 1548, 14, 4608, 492, 4566, 1858, 4267, 199, 504, 7390, 14, 1548, 14, 21963, 492, 9999, 23279, 985, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 18186, 12, 3531, 2084, 15532, 199, 504, 7390, 14, 4901, 14, 705, 492, 8113, 10759, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 17961, 12, 2449, 12, 11703, 9937, 199, 504, 7390, 14, 4901, 14, 11610, 492, 28374, 1146, 547, 199, 504, 7390, 14, 4901, 14, 3922, 492, 11557, 199, 504, 7390, 14, 16541, 14, 4316, 492, 7030, 21800, 199, 504, 7390, 14, 2520, 14, 73, 2520, 492, 24740, 63, 9127, 12, 473, 2364, 12, 473, 3041, 2017, 199, 504, 7390, 14, 2520, 14, 1014, 63, 2139, 492, 21391, 199, 504, 7390, 14, 2520, 14, 1014, 492, 4825, 63, 9663, 12, 2845, 63, 30389, 199, 504, 7390, 14, 2520, 14, 1014, 492, 485, 1451, 8610, 12, 4376, 9443, 1451, 8610, 199, 504, 7390, 14, 2520, 14, 1014, 492, 485, 10193, 11761, 8326, 12, 485, 9856, 379, 11761, 8326, 199, 199, 3, 24230, 3101, 2842, 883, 506, 315, 199, 6305, 275, 283, 6305, 7, 199, 7311, 275, 283, 7311, 7, 199, 23708, 275, 283, 23708, 7, 199, 22162, 275, 283, 22162, 7, 421, 199, 533, 8857, 9883, 8, 1726, 304, 272, 408, 272, 21391, 3032, 370, 491, 91, 2017, 93, 4898, 315, 2005, 4340, 3866, 14, 272, 408, 4388, 199, 533, 1316, 670, 3534, 8, 1726, 304, 272, 408, 272, 710, 2396, 491, 91, 2100, 1351, 15532, 93, 367, 282, 1056, 16416, 370, 2218, 666, 2410, 272, 9297, 652, 10530, 9158, 3575, 666, 14, 272, 408, 421, 199, 533, 21743, 8, 1726, 304, 272, 408, 272, 6601, 3086, 666, 4293, 440, 506, 4565, 14, 339, 768, 7725, 666, 26, 710, 1059, 1314, 4293, 440, 506, 4565, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 4499, 12, 666, 304, 267, 2186, 855, 826, 721, 277, 12, 4499, 12, 666, 9, 267, 291, 14, 576, 275, 666, 4388, 199, 533, 8857, 2364, 3353, 8, 9123, 304, 272, 408, 272, 710, 1015, 1059, 315, 282, 2004, 1004, 1990, 625, 21152, 461, 14, 272, 408, 4388, 199, 533, 485, 4590, 1726, 8, 1726, 304, 272, 408, 272, 491, 26975, 4590, 1726, 93, 365, 314, 1300, 1919, 730, 367, 4967, 1314, 272, 2387, 1373, 503, 1655, 1163, 4967, 465, 314, 6465, 13, 1896, 14486, 14, 339, 768, 7725, 14872, 26, 437, 769, 402, 4967, 14, 221, 1666, 5516, 3794, 367, 1655, 267, 2436, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 14872, 304, 267, 2186, 855, 826, 721, 277, 12, 14872, 9, 267, 291, 14, 5764, 83, 275, 14872, 4388, 199, 533, 4784, 18514, 4276, 1547, 4590, 1726, 304, 272, 408, 272, 6006, 1990, 376, 1125, 1830, 6425, 314, 2783, 1314, 1852, 1536, 282, 1056, 14, 339, 768, 7725, 14872, 26, 437, 445, 91, 513, 93, 402, 1373, 503, 1655, 491, 91, 6782, 93, 4454, 15131, 314, 267, 14872, 314, 1056, 10152, 1990, 8652, 370, 1172, 3405, 14, 272, 408, 4388, 199, 533, 4784, 24011, 4276, 1547, 4590, 1726, 304, 272, 408, 272, 6006, 1990, 376, 1125, 1830, 10209, 314, 2783, 1314, 1852, 1536, 282, 1056, 14, 339, 768, 7725, 14872, 26, 437, 445, 91, 513, 93, 402, 1373, 503, 1655, 491, 91, 6782, 93, 4454, 15131, 314, 267, 14872, 314, 1056, 1752, 2250, 1990, 8652, 370, 1172, 3405, 14, 272, 408, 4388, 199, 533, 8113, 5583, 1376, 8, 1726, 304, 272, 408, 272, 710, 1950, 1990, 7662, 26815, 701, 4223, 1233, 14, 272, 408, 4388, 199, 533, 30801, 8173, 4625, 8, 1726, 304, 272, 408, 272, 1626, 491, 91, 2100, 1351, 15532, 93, 14290, 314, 1329, 402, 2783, 652, 1990, 9995, 370, 272, 7389, 334, 12897, 2399, 445, 91, 1267, 93, 2225, 9, 436, 2066, 13584, 282, 3365, 1329, 272, 402, 2783, 14, 272, 408, 4388, 199, 533, 7232, 10759, 8, 1726, 304, 272, 408, 272, 491, 91, 2364, 10759, 93, 1443, 506, 3032, 370, 491, 91, 41, 3658, 14, 2105, 14074, 93, 641, 314, 272, 4113, 3032, 370, 491, 91, 2364, 14, 31584, 8173, 93, 436, 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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 ]
himmih/cluedo
venv/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/sax.py
1835
1661
from __future__ import absolute_import, division, unicode_literals from xml.sax.xmlreader import AttributesNSImpl from ..constants import adjustForeignAttributes, unadjustForeignAttributes prefix_mapping = {} for prefix, localName, namespace in adjustForeignAttributes.values(): if prefix is not None: prefix_mapping[prefix] = namespace def to_sax(walker, handler): """Call SAX-like content handler based on treewalker walker""" handler.startDocument() for prefix, namespace in prefix_mapping.items(): handler.startPrefixMapping(prefix, namespace) for token in walker: type = token["type"] if type == "Doctype": continue elif type in ("StartTag", "EmptyTag"): attrs = AttributesNSImpl(token["data"], unadjustForeignAttributes) handler.startElementNS((token["namespace"], token["name"]), token["name"], attrs) if type == "EmptyTag": handler.endElementNS((token["namespace"], token["name"]), token["name"]) elif type == "EndTag": handler.endElementNS((token["namespace"], token["name"]), token["name"]) elif type in ("Characters", "SpaceCharacters"): handler.characters(token["data"]) elif type == "Comment": pass else: assert False, "Unknown token type" for prefix, namespace in prefix_mapping.items(): handler.endPrefixMapping(prefix) handler.endDocument()
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 2748, 14, 14338, 14, 1652, 5503, 492, 9382, 46, 2684, 2421, 199, 199, 504, 2508, 5559, 492, 11311, 20931, 5379, 12, 625, 10917, 20931, 5379, 199, 199, 1861, 63, 4745, 275, 1052, 199, 509, 2403, 12, 2257, 985, 12, 3231, 315, 11311, 20931, 5379, 14, 1459, 837, 272, 340, 2403, 365, 440, 488, 26, 267, 2403, 63, 4745, 59, 1861, 61, 275, 3231, 421, 199, 318, 370, 63, 14338, 8, 87, 14976, 12, 3016, 304, 272, 408, 2176, 19310, 13, 2930, 1564, 3016, 4079, 641, 20991, 546, 14976, 336, 14976, 624, 272, 3016, 14, 928, 5564, 342, 272, 367, 2403, 12, 3231, 315, 2403, 63, 4745, 14, 1744, 837, 267, 3016, 14, 928, 4793, 7674, 8, 1861, 12, 3231, 9, 339, 367, 1526, 315, 336, 14976, 26, 267, 730, 275, 1526, 905, 466, 937, 267, 340, 730, 508, 298, 21629, 582, 288, 1980, 267, 916, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 288, 3290, 275, 9382, 46, 2684, 2421, 8, 1418, 905, 576, 2255, 3660, 625, 10917, 20931, 5379, 9, 288, 3016, 14, 30398, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 3521, 1526, 905, 354, 2255, 3521, 3290, 9, 288, 340, 730, 508, 298, 4699, 1931, 582, 355, 3016, 14, 31290, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 3660, 1526, 905, 354, 3135, 267, 916, 730, 508, 298, 16906, 582, 288, 3016, 14, 31290, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 639, 1526, 905, 354, 3135, 267, 916, 730, 315, 1689, 9272, 401, 298, 28501, 2349, 288, 3016, 14, 16516, 8, 1418, 905, 576, 3135, 267, 916, 730, 508, 298, 7488, 582, 288, 986, 267, 587, 26, 288, 702, 756, 12, 298, 5912, 1526, 730, 2, 339, 367, 2403, 12, 3231, 315, 2403, 63, 4745, 14, 1744, 837, 267, 3016, 14, 500, 4793, 7674, 8, 1861, 9, 272, 3016, 14, 500, 5564, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 2748, 14, 14338, 14, 1652, 5503, 492, 9382, 46, 2684, 2421, 199, 199, 504, 2508, 5559, 492, 11311, 20931, 5379, 12, 625, 10917, 20931, 5379, 199, 199, 1861, 63, 4745, 275, 1052, 199, 509, 2403, 12, 2257, 985, 12, 3231, 315, 11311, 20931, 5379, 14, 1459, 837, 272, 340, 2403, 365, 440, 488, 26, 267, 2403, 63, 4745, 59, 1861, 61, 275, 3231, 421, 199, 318, 370, 63, 14338, 8, 87, 14976, 12, 3016, 304, 272, 408, 2176, 19310, 13, 2930, 1564, 3016, 4079, 641, 20991, 546, 14976, 336, 14976, 624, 272, 3016, 14, 928, 5564, 342, 272, 367, 2403, 12, 3231, 315, 2403, 63, 4745, 14, 1744, 837, 267, 3016, 14, 928, 4793, 7674, 8, 1861, 12, 3231, 9, 339, 367, 1526, 315, 336, 14976, 26, 267, 730, 275, 1526, 905, 466, 937, 267, 340, 730, 508, 298, 21629, 582, 288, 1980, 267, 916, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 288, 3290, 275, 9382, 46, 2684, 2421, 8, 1418, 905, 576, 2255, 3660, 625, 10917, 20931, 5379, 9, 288, 3016, 14, 30398, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 3521, 1526, 905, 354, 2255, 3521, 3290, 9, 288, 340, 730, 508, 298, 4699, 1931, 582, 355, 3016, 14, 31290, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 3660, 1526, 905, 354, 3135, 267, 916, 730, 508, 298, 16906, 582, 288, 3016, 14, 31290, 2709, 1332, 1418, 905, 3251, 2255, 1526, 905, 354, 10252, 639, 1526, 905, 354, 3135, 267, 916, 730, 315, 1689, 9272, 401, 298, 28501, 2349, 288, 3016, 14, 16516, 8, 1418, 905, 576, 3135, 267, 916, 730, 508, 298, 7488, 582, 288, 986, 267, 587, 26, 288, 702, 756, 12, 298, 5912, 1526, 730, 2, 339, 367, 2403, 12, 3231, 315, 2403, 63, 4745, 14, 1744, 837, 267, 3016, 14, 500, 4793, 7674, 8, 1861, 9, 272, 3016, 14, 500, 5564, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Southpaw-TACTIC/Team
src/python/Lib/site-packages/PySide/examples/declarative/scrolling.py
1
2311
#!/usr/bin/env python # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # Contact: PySide Team (pyside@openbossa.org) # # This file is part of the examples of PySide: Python for Qt. # # You may use this file under the terms of the BSD license as follows: # # "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 Nokia Corporation and its Subsidiary(-ies) 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 PySide.QtCore import QUrl from PySide.QtGui import QPushButton, QApplication from PySide.QtDeclarative import QDeclarativeView # This example uses a QML file to show a scrolling list containing # all the items listed into dataList. dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] app = QApplication([]) view = QDeclarativeView() ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) url = QUrl('view.qml') view.setSource(url) view.show() app.exec_()
epl-1.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 3, 2900, 4481, 4644, 14, 199, 3, 18684, 26, 1611, 15414, 11682, 334, 647, 2441, 32, 1490, 25020, 65, 14, 1308, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 7251, 402, 1611, 15414, 26, 2018, 367, 3959, 14, 199, 3, 199, 3, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 3, 199, 3, 298, 497, 4972, 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, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 3, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 258, 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, 2122, 199, 199, 504, 1611, 15414, 14, 10901, 492, 1413, 6417, 199, 504, 1611, 15414, 14, 10604, 492, 1413, 20083, 12, 29469, 199, 504, 1611, 15414, 14, 4238, 31963, 1905, 492, 1413, 31963, 1905, 2768, 199, 199, 3, 961, 2893, 4440, 282, 1413, 1698, 570, 370, 2498, 282, 13704, 316, 769, 3035, 199, 3, 1006, 314, 2974, 10532, 1901, 666, 1296, 14, 199, 199, 576, 1296, 275, 2097, 2081, 413, 401, 298, 2081, 499, 401, 298, 2081, 650, 401, 298, 2081, 841, 937, 199, 199, 571, 275, 29469, 4157, 199, 1345, 275, 1413, 31963, 1905, 2768, 342, 199, 199, 6725, 275, 2455, 14, 1231, 2998, 342, 199, 6725, 14, 409, 2998, 3697, 480, 1662, 1685, 401, 666, 1296, 9, 199, 199, 633, 275, 1413, 6417, 360, 1345, 14, 81, 757, 358, 199, 199, 1345, 14, 409, 2980, 8, 633, 9, 199, 1345, 14, 2384, 342, 199, 199, 571, 14, 1628, 12798, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 3, 2900, 4481, 4644, 14, 199, 3, 18684, 26, 1611, 15414, 11682, 334, 647, 2441, 32, 1490, 25020, 65, 14, 1308, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 7251, 402, 1611, 15414, 26, 2018, 367, 3959, 14, 199, 3, 199, 3, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 3, 199, 3, 298, 497, 4972, 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, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 3, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 258, 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, 2122, 199, 199, 504, 1611, 15414, 14, 10901, 492, 1413, 6417, 199, 504, 1611, 15414, 14, 10604, 492, 1413, 20083, 12, 29469, 199, 504, 1611, 15414, 14, 4238, 31963, 1905, 492, 1413, 31963, 1905, 2768, 199, 199, 3, 961, 2893, 4440, 282, 1413, 1698, 570, 370, 2498, 282, 13704, 316, 769, 3035, 199, 3, 1006, 314, 2974, 10532, 1901, 666, 1296, 14, 199, 199, 576, 1296, 275, 2097, 2081, 413, 401, 298, 2081, 499, 401, 298, 2081, 650, 401, 298, 2081, 841, 937, 199, 199, 571, 275, 29469, 4157, 199, 1345, 275, 1413, 31963, 1905, 2768, 342, 199, 199, 6725, 275, 2455, 14, 1231, 2998, 342, 199, 6725, 14, 409, 2998, 3697, 480, 1662, 1685, 401, 666, 1296, 9, 199, 199, 633, 275, 1413, 6417, 360, 1345, 14, 81, 757, 358, 199, 199, 1345, 14, 409, 2980, 8, 633, 9, 199, 1345, 14, 2384, 342, 199, 199, 571, 14, 1628, 12798, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
hosseinmh/jango_learning
.venv/lib/python2.7/site-packages/django/db/models/fields/related.py
33
66699
from __future__ import unicode_literals import warnings from functools import partial from django import forms from django.apps import apps from django.core import checks, exceptions from django.db import connection, router from django.db.backends import utils from django.db.models import Q from django.db.models.deletion import CASCADE, SET_DEFAULT, SET_NULL from django.db.models.query_utils import PathInfo from django.db.models.utils import make_model_tuple from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text from django.utils.functional import cached_property, curry from django.utils.translation import ugettext_lazy as _ from django.utils.version import get_docs_version from . import Field from .related_descriptors import ( ForwardManyToOneDescriptor, ManyToManyDescriptor, ReverseManyToOneDescriptor, ReverseOneToOneDescriptor, ) from .related_lookups import ( RelatedExact, RelatedGreaterThan, RelatedGreaterThanOrEqual, RelatedIn, RelatedIsNull, RelatedLessThan, RelatedLessThanOrEqual, ) from .reverse_related import ( ForeignObjectRel, ManyToManyRel, ManyToOneRel, OneToOneRel, ) RECURSIVE_RELATIONSHIP_CONSTANT = 'self' def resolve_relation(scope_model, relation): """ Transform relation into a model or fully-qualified model string of the form "app_label.ModelName", relative to scope_model. The relation argument can be: * RECURSIVE_RELATIONSHIP_CONSTANT, i.e. the string "self", in which case the model argument will be returned. * A bare model name without an app_label, in which case scope_model's app_label will be prepended. * An "app_label.ModelName" string. * A model class, which will be returned unchanged. """ # Check for recursive relations if relation == RECURSIVE_RELATIONSHIP_CONSTANT: relation = scope_model # Look for an "app.Model" relation if isinstance(relation, six.string_types): if "." not in relation: relation = "%s.%s" % (scope_model._meta.app_label, relation) return relation def lazy_related_operation(function, model, *related_models, **kwargs): """ Schedule `function` to be called once `model` and all `related_models` have been imported and registered with the app registry. `function` will be called with the newly-loaded model classes as its positional arguments, plus any optional keyword arguments. The `model` argument must be a model class. Each subsequent positional argument is another model, or a reference to another model - see `resolve_relation()` for the various forms these may take. Any relative references will be resolved relative to `model`. This is a convenience wrapper for `Apps.lazy_model_operation` - the app registry model used is the one found in `model._meta.apps`. """ models = [model] + [resolve_relation(model, rel) for rel in related_models] model_keys = (make_model_tuple(m) for m in models) apps = model._meta.apps return apps.lazy_model_operation(partial(function, **kwargs), *model_keys) def add_lazy_relation(cls, field, relation, operation): warnings.warn( "add_lazy_relation() has been superseded by lazy_related_operation() " "and related methods on the Apps class.", RemovedInDjango20Warning, stacklevel=2) # Rearrange args for new Apps.lazy_model_operation def function(local, related, field): return operation(field, related, local) lazy_related_operation(function, cls, relation, field=field) class RelatedField(Field): """ Base class that all relational fields inherit from. """ # Field flags one_to_many = False one_to_one = False many_to_many = False many_to_one = False @cached_property def related_model(self): # Can't cache this property until all the models are loaded. apps.check_models_ready() return self.remote_field.model def check(self, **kwargs): errors = super(RelatedField, self).check(**kwargs) errors.extend(self._check_related_name_is_valid()) errors.extend(self._check_relation_model_exists()) errors.extend(self._check_referencing_to_swapped_model()) errors.extend(self._check_clashes()) return errors def _check_related_name_is_valid(self): import re import keyword related_name = self.remote_field.related_name if related_name is None: return [] is_valid_id = True if keyword.iskeyword(related_name): is_valid_id = False if six.PY3: if not related_name.isidentifier(): is_valid_id = False else: if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*\Z', related_name): is_valid_id = False if not (is_valid_id or related_name.endswith('+')): return [ checks.Error( "The name '%s' is invalid related_name for field %s.%s" % (self.remote_field.related_name, self.model._meta.object_name, self.name), hint="Related name must be a valid Python identifier or end with a '+'", obj=self, id='fields.E306', ) ] return [] def _check_relation_model_exists(self): rel_is_missing = self.remote_field.model not in self.opts.apps.get_models() rel_is_string = isinstance(self.remote_field.model, six.string_types) model_name = self.remote_field.model if rel_is_string else self.remote_field.model._meta.object_name if rel_is_missing and (rel_is_string or not self.remote_field.model._meta.swapped): return [ checks.Error( "Field defines a relation with model '%s', which is either " "not installed, or is abstract." % model_name, obj=self, id='fields.E300', ) ] return [] def _check_referencing_to_swapped_model(self): if (self.remote_field.model not in self.opts.apps.get_models() and not isinstance(self.remote_field.model, six.string_types) and self.remote_field.model._meta.swapped): model = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name ) return [ checks.Error( "Field defines a relation with the model '%s', which has " "been swapped out." % model, hint="Update the relation to point at 'settings.%s'." % self.remote_field.model._meta.swappable, obj=self, id='fields.E301', ) ] return [] def _check_clashes(self): """ Check accessor and reverse query name clashes. """ from django.db.models.base import ModelBase errors = [] opts = self.model._meta # `f.remote_field.model` may be a string instead of a model. Skip if model name is # not resolved. if not isinstance(self.remote_field.model, ModelBase): return [] # Consider that we are checking field `Model.foreign` and the models # are: # # class Target(models.Model): # model = models.IntegerField() # model_set = models.IntegerField() # # class Model(models.Model): # foreign = models.ForeignKey(Target) # m2m = models.ManyToManyField(Target) # rel_opts.object_name == "Target" rel_opts = self.remote_field.model._meta # If the field doesn't install a backward relation on the target model # (so `is_hidden` returns True), then there are no clashes to check # and we can skip these fields. rel_is_hidden = self.remote_field.is_hidden() rel_name = self.remote_field.get_accessor_name() # i. e. "model_set" rel_query_name = self.related_query_name() # i. e. "model" field_name = "%s.%s" % (opts.object_name, self.name) # i. e. "Model.field" # Check clashes between accessor or reverse query name of `field` # and any other field name -- i.e. accessor for Model.foreign is # model_set and it clashes with Target.model_set. potential_clashes = rel_opts.fields + rel_opts.many_to_many for clash_field in potential_clashes: clash_name = "%s.%s" % (rel_opts.object_name, clash_field.name) # i.e. "Target.model_set" if not rel_is_hidden and clash_field.name == rel_name: errors.append( checks.Error( "Reverse accessor for '%s' clashes with field name '%s'." % (field_name, clash_name), hint=("Rename field '%s', or add/change a related_name " "argument to the definition for field '%s'.") % (clash_name, field_name), obj=self, id='fields.E302', ) ) if clash_field.name == rel_query_name: errors.append( checks.Error( "Reverse query name for '%s' clashes with field name '%s'." % (field_name, clash_name), hint=("Rename field '%s', or add/change a related_name " "argument to the definition for field '%s'.") % (clash_name, field_name), obj=self, id='fields.E303', ) ) # Check clashes between accessors/reverse query names of `field` and # any other field accessor -- i. e. Model.foreign accessor clashes with # Model.m2m accessor. potential_clashes = (r for r in rel_opts.related_objects if r.field is not self) for clash_field in potential_clashes: clash_name = "%s.%s" % ( # i. e. "Model.m2m" clash_field.related_model._meta.object_name, clash_field.field.name) if not rel_is_hidden and clash_field.get_accessor_name() == rel_name: errors.append( checks.Error( "Reverse accessor for '%s' clashes with reverse accessor for '%s'." % (field_name, clash_name), hint=("Add or change a related_name argument " "to the definition for '%s' or '%s'.") % (field_name, clash_name), obj=self, id='fields.E304', ) ) if clash_field.get_accessor_name() == rel_query_name: errors.append( checks.Error( "Reverse query name for '%s' clashes with reverse query name for '%s'." % (field_name, clash_name), hint=("Add or change a related_name argument " "to the definition for '%s' or '%s'.") % (field_name, clash_name), obj=self, id='fields.E305', ) ) return errors def db_type(self, connection): # By default related field will not have a column as it relates to # columns from another table. return None def contribute_to_class(self, cls, name, private_only=False, **kwargs): super(RelatedField, self).contribute_to_class(cls, name, private_only=private_only, **kwargs) self.opts = cls._meta if not cls._meta.abstract: if self.remote_field.related_name: related_name = self.remote_field.related_name else: related_name = self.opts.default_related_name if related_name: related_name = force_text(related_name) % { 'class': cls.__name__.lower(), 'model_name': cls._meta.model_name.lower(), 'app_label': cls._meta.app_label.lower() } self.remote_field.related_name = related_name if self.remote_field.related_query_name: related_query_name = force_text(self.remote_field.related_query_name) % { 'class': cls.__name__.lower(), 'app_label': cls._meta.app_label.lower(), } self.remote_field.related_query_name = related_query_name def resolve_related_class(model, related, field): field.remote_field.model = related field.do_related_class(related, model) lazy_related_operation(resolve_related_class, cls, self.remote_field.model, field=self) def get_forward_related_filter(self, obj): """ Return the keyword arguments that when supplied to self.model.object.filter(), would select all instances related through this field to the remote obj. This is used to build the querysets returned by related descriptors. obj is an instance of self.related_field.model. """ return { '%s__%s' % (self.name, rh_field.name): getattr(obj, rh_field.attname) for _, rh_field in self.related_fields } def get_reverse_related_filter(self, obj): """ Complement to get_forward_related_filter(). Return the keyword arguments that when passed to self.related_field.model.object.filter() select all instances of self.related_field.model related through this field to obj. obj is an instance of self.model. """ base_filter = { rh_field.attname: getattr(obj, lh_field.attname) for lh_field, rh_field in self.related_fields } descriptor_filter = self.get_extra_descriptor_filter(obj) base_q = Q(**base_filter) if isinstance(descriptor_filter, dict): return base_q & Q(**descriptor_filter) elif descriptor_filter: return base_q & descriptor_filter return base_q @property def swappable_setting(self): """ Get the setting that this is powered from for swapping, or None if it's not swapped in / marked with swappable=False. """ if self.swappable: # Work out string form of "to" if isinstance(self.remote_field.model, six.string_types): to_string = self.remote_field.model else: to_string = self.remote_field.model._meta.label return apps.get_swappable_settings_name(to_string) return None def set_attributes_from_rel(self): self.name = ( self.name or (self.remote_field.model._meta.model_name + '_' + self.remote_field.model._meta.pk.name) ) if self.verbose_name is None: self.verbose_name = self.remote_field.model._meta.verbose_name self.remote_field.set_field_name() def do_related_class(self, other, cls): self.set_attributes_from_rel() self.contribute_to_related_class(other, self.remote_field) def get_limit_choices_to(self): """ Return ``limit_choices_to`` for this model field. If it is a callable, it will be invoked and the result will be returned. """ if callable(self.remote_field.limit_choices_to): return self.remote_field.limit_choices_to() return self.remote_field.limit_choices_to def formfield(self, **kwargs): """ Pass ``limit_choices_to`` to the field being constructed. Only passes it if there is a type that supports related fields. This is a similar strategy used to pass the ``queryset`` to the field being constructed. """ defaults = {} if hasattr(self.remote_field, 'get_related_field'): # If this is a callable, do not invoke it here. Just pass # it in the defaults for when the form class will later be # instantiated. limit_choices_to = self.remote_field.limit_choices_to defaults.update({ 'limit_choices_to': limit_choices_to, }) defaults.update(kwargs) return super(RelatedField, self).formfield(**defaults) def related_query_name(self): """ Define the name that can be used to identify this related object in a table-spanning query. """ return self.remote_field.related_query_name or self.remote_field.related_name or self.opts.model_name @property def target_field(self): """ When filtering against this relation, returns the field on the remote model against which the filtering should happen. """ target_fields = self.get_path_info()[-1].target_fields if len(target_fields) > 1: raise exceptions.FieldError( "The relation has multiple target fields, but only single target field was asked for") return target_fields[0] class ForeignObject(RelatedField): """ Abstraction of the ForeignKey relation, supports multi-column relations. """ # Field flags many_to_many = False many_to_one = True one_to_many = False one_to_one = False requires_unique_target = True related_accessor_class = ReverseManyToOneDescriptor rel_class = ForeignObjectRel def __init__(self, to, on_delete, from_fields, to_fields, rel=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, swappable=True, **kwargs): if rel is None: rel = self.rel_class( self, to, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, parent_link=parent_link, on_delete=on_delete, ) super(ForeignObject, self).__init__(rel=rel, **kwargs) self.from_fields = from_fields self.to_fields = to_fields self.swappable = swappable def check(self, **kwargs): errors = super(ForeignObject, self).check(**kwargs) errors.extend(self._check_unique_target()) return errors def _check_unique_target(self): rel_is_string = isinstance(self.remote_field.model, six.string_types) if rel_is_string or not self.requires_unique_target: return [] try: self.foreign_related_fields except exceptions.FieldDoesNotExist: return [] if not self.foreign_related_fields: return [] unique_foreign_fields = { frozenset([f.name]) for f in self.remote_field.model._meta.get_fields() if getattr(f, 'unique', False) } unique_foreign_fields.update({ frozenset(ut) for ut in self.remote_field.model._meta.unique_together }) foreign_fields = {f.name for f in self.foreign_related_fields} has_unique_constraint = any(u <= foreign_fields for u in unique_foreign_fields) if not has_unique_constraint and len(self.foreign_related_fields) > 1: field_combination = ', '.join( "'%s'" % rel_field.name for rel_field in self.foreign_related_fields ) model_name = self.remote_field.model.__name__ return [ checks.Error( "No subset of the fields %s on model '%s' is unique." % (field_combination, model_name), hint=( "Add unique=True on any of those fields or add at " "least a subset of them to a unique_together constraint." ), obj=self, id='fields.E310', ) ] elif not has_unique_constraint: field_name = self.foreign_related_fields[0].name model_name = self.remote_field.model.__name__ return [ checks.Error( "'%s.%s' must set unique=True because it is referenced by " "a foreign key." % (model_name, field_name), obj=self, id='fields.E311', ) ] else: return [] def deconstruct(self): name, path, args, kwargs = super(ForeignObject, self).deconstruct() kwargs['on_delete'] = self.remote_field.on_delete kwargs['from_fields'] = self.from_fields kwargs['to_fields'] = self.to_fields if self.remote_field.related_name is not None: kwargs['related_name'] = self.remote_field.related_name if self.remote_field.related_query_name is not None: kwargs['related_query_name'] = self.remote_field.related_query_name if self.remote_field.parent_link: kwargs['parent_link'] = self.remote_field.parent_link # Work out string form of "to" if isinstance(self.remote_field.model, six.string_types): kwargs['to'] = self.remote_field.model else: kwargs['to'] = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name, ) # If swappable is True, then see if we're actually pointing to the target # of a swap. swappable_setting = self.swappable_setting if swappable_setting is not None: # If it's already a settings reference, error if hasattr(kwargs['to'], "setting_name"): if kwargs['to'].setting_name != swappable_setting: raise ValueError( "Cannot deconstruct a ForeignKey pointing to a model " "that is swapped in place of more than one model (%s and %s)" % (kwargs['to'].setting_name, swappable_setting) ) # Set it from django.db.migrations.writer import SettingsReference kwargs['to'] = SettingsReference( kwargs['to'], swappable_setting, ) return name, path, args, kwargs def resolve_related_fields(self): if len(self.from_fields) < 1 or len(self.from_fields) != len(self.to_fields): raise ValueError('Foreign Object from and to fields must be the same non-zero length') if isinstance(self.remote_field.model, six.string_types): raise ValueError('Related model %r cannot be resolved' % self.remote_field.model) related_fields = [] for index in range(len(self.from_fields)): from_field_name = self.from_fields[index] to_field_name = self.to_fields[index] from_field = (self if from_field_name == 'self' else self.opts.get_field(from_field_name)) to_field = (self.remote_field.model._meta.pk if to_field_name is None else self.remote_field.model._meta.get_field(to_field_name)) related_fields.append((from_field, to_field)) return related_fields @property def related_fields(self): if not hasattr(self, '_related_fields'): self._related_fields = self.resolve_related_fields() return self._related_fields @property def reverse_related_fields(self): return [(rhs_field, lhs_field) for lhs_field, rhs_field in self.related_fields] @property def local_related_fields(self): return tuple(lhs_field for lhs_field, rhs_field in self.related_fields) @property def foreign_related_fields(self): return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field) def get_local_related_value(self, instance): return self.get_instance_value_for_fields(instance, self.local_related_fields) def get_foreign_related_value(self, instance): return self.get_instance_value_for_fields(instance, self.foreign_related_fields) @staticmethod def get_instance_value_for_fields(instance, fields): ret = [] opts = instance._meta for field in fields: # Gotcha: in some cases (like fixture loading) a model can have # different values in parent_ptr_id and parent's id. So, use # instance.pk (that is, parent_ptr_id) when asked for instance.id. if field.primary_key: possible_parent_link = opts.get_ancestor_link(field.model) if (not possible_parent_link or possible_parent_link.primary_key or possible_parent_link.model._meta.abstract): ret.append(instance.pk) continue ret.append(getattr(instance, field.attname)) return tuple(ret) def get_attname_column(self): attname, column = super(ForeignObject, self).get_attname_column() return attname, None def get_joining_columns(self, reverse_join=False): source = self.reverse_related_fields if reverse_join else self.related_fields return tuple((lhs_field.column, rhs_field.column) for lhs_field, rhs_field in source) def get_reverse_joining_columns(self): return self.get_joining_columns(reverse_join=True) def get_extra_descriptor_filter(self, instance): """ Return an extra filter condition for related object fetching when user does 'instance.fieldname', that is the extra filter is used in the descriptor of the field. The filter should be either a dict usable in .filter(**kwargs) call or a Q-object. The condition will be ANDed together with the relation's joining columns. A parallel method is get_extra_restriction() which is used in JOIN and subquery conditions. """ return {} def get_extra_restriction(self, where_class, alias, related_alias): """ Return a pair condition used for joining and subquery pushdown. The condition is something that responds to as_sql(compiler, connection) method. Note that currently referring both the 'alias' and 'related_alias' will not work in some conditions, like subquery pushdown. A parallel method is get_extra_descriptor_filter() which is used in instance.fieldname related object fetching. """ return None def get_path_info(self): """ Get path from this field to the related model. """ opts = self.remote_field.model._meta from_opts = self.model._meta return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] def get_reverse_path_info(self): """ Get path from the related model to this field's model. """ opts = self.model._meta from_opts = self.remote_field.model._meta pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)] return pathinfos def get_lookup(self, lookup_name): if lookup_name == 'in': return RelatedIn elif lookup_name == 'exact': return RelatedExact elif lookup_name == 'gt': return RelatedGreaterThan elif lookup_name == 'gte': return RelatedGreaterThanOrEqual elif lookup_name == 'lt': return RelatedLessThan elif lookup_name == 'lte': return RelatedLessThanOrEqual elif lookup_name == 'isnull': return RelatedIsNull else: raise TypeError('Related Field got invalid lookup: %s' % lookup_name) def get_transform(self, *args, **kwargs): raise NotImplementedError('Relational fields do not support transforms.') def contribute_to_class(self, cls, name, private_only=False, **kwargs): super(ForeignObject, self).contribute_to_class(cls, name, private_only=private_only, **kwargs) setattr(cls, self.name, ForwardManyToOneDescriptor(self)) def contribute_to_related_class(self, cls, related): # Internal FK's - i.e., those with a related name ending with '+' - # and swapped models don't get a related descriptor. if not self.remote_field.is_hidden() and not related.related_model._meta.swapped: setattr(cls._meta.concrete_model, related.get_accessor_name(), self.related_accessor_class(related)) # While 'limit_choices_to' might be a callable, simply pass # it along for later - this is too early because it's still # model load time. if self.remote_field.limit_choices_to: cls._meta.related_fkey_lookups.append(self.remote_field.limit_choices_to) class ForeignKey(ForeignObject): """ Provide a many-to-one relation by adding a column to the local model to hold the remote value. By default ForeignKey will target the pk of the remote model but this behavior can be changed by using the ``to_field`` argument. """ # Field flags many_to_many = False many_to_one = True one_to_many = False one_to_one = False rel_class = ManyToOneRel empty_strings_allowed = False default_error_messages = { 'invalid': _('%(model)s instance with %(field)s %(value)r does not exist.') } description = _("Foreign Key (type determined by related field)") def __init__(self, to, on_delete=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, to_field=None, db_constraint=True, **kwargs): try: to._meta.model_name except AttributeError: assert isinstance(to, six.string_types), ( "%s(%r) is invalid. First parameter to ForeignKey must be " "either a model, a model name, or the string %r" % ( self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT, ) ) else: # For backwards compatibility purposes, we need to *try* and set # the to_field during FK construction. It won't be guaranteed to # be correct until contribute_to_class is called. Refs #12190. to_field = to_field or (to._meta.pk and to._meta.pk.name) if on_delete is None: warnings.warn( "on_delete will be a required arg for %s in Django 2.0. Set " "it to models.CASCADE on models and in existing migrations " "if you want to maintain the current default behavior. " "See https://docs.djangoproject.com/en/%s/ref/models/fields/" "#django.db.models.ForeignKey.on_delete" % ( self.__class__.__name__, get_docs_version(), ), RemovedInDjango20Warning, 2) on_delete = CASCADE elif not callable(on_delete): warnings.warn( "The signature for {0} will change in Django 2.0. " "Pass to_field='{1}' as a kwarg instead of as an arg.".format( self.__class__.__name__, on_delete, ), RemovedInDjango20Warning, 2) on_delete, to_field = to_field, on_delete kwargs['rel'] = self.rel_class( self, to, to_field, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, parent_link=parent_link, on_delete=on_delete, ) kwargs['db_index'] = kwargs.get('db_index', True) super(ForeignKey, self).__init__( to, on_delete, from_fields=['self'], to_fields=[to_field], **kwargs) self.db_constraint = db_constraint def check(self, **kwargs): errors = super(ForeignKey, self).check(**kwargs) errors.extend(self._check_on_delete()) errors.extend(self._check_unique()) return errors def _check_on_delete(self): on_delete = getattr(self.remote_field, 'on_delete', None) if on_delete == SET_NULL and not self.null: return [ checks.Error( 'Field specifies on_delete=SET_NULL, but cannot be null.', hint='Set null=True argument on the field, or change the on_delete rule.', obj=self, id='fields.E320', ) ] elif on_delete == SET_DEFAULT and not self.has_default(): return [ checks.Error( 'Field specifies on_delete=SET_DEFAULT, but has no default value.', hint='Set a default value, or change the on_delete rule.', obj=self, id='fields.E321', ) ] else: return [] def _check_unique(self, **kwargs): return [ checks.Warning( 'Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.', hint='ForeignKey(unique=True) is usually better served by a OneToOneField.', obj=self, id='fields.W342', ) ] if self.unique else [] def deconstruct(self): name, path, args, kwargs = super(ForeignKey, self).deconstruct() del kwargs['to_fields'] del kwargs['from_fields'] # Handle the simpler arguments if self.db_index: del kwargs['db_index'] else: kwargs['db_index'] = False if self.db_constraint is not True: kwargs['db_constraint'] = self.db_constraint # Rel needs more work. to_meta = getattr(self.remote_field.model, "_meta", None) if self.remote_field.field_name and ( not to_meta or (to_meta.pk and self.remote_field.field_name != to_meta.pk.name)): kwargs['to_field'] = self.remote_field.field_name return name, path, args, kwargs @property def target_field(self): return self.foreign_related_fields[0] def get_reverse_path_info(self): """ Get path from the related model to this field's model. """ opts = self.model._meta from_opts = self.remote_field.model._meta pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)] return pathinfos def validate(self, value, model_instance): if self.remote_field.parent_link: return super(ForeignKey, self).validate(value, model_instance) if value is None: return using = router.db_for_read(model_instance.__class__, instance=model_instance) qs = self.remote_field.model._default_manager.using(using).filter( **{self.remote_field.field_name: value} ) qs = qs.complex_filter(self.get_limit_choices_to()) if not qs.exists(): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={ 'model': self.remote_field.model._meta.verbose_name, 'pk': value, 'field': self.remote_field.field_name, 'value': value, }, # 'pk' is included for backwards compatibility ) def get_attname(self): return '%s_id' % self.name def get_attname_column(self): attname = self.get_attname() column = self.db_column or attname return attname, column def get_default(self): "Here we check if the default value is an object and return the to_field if so." field_default = super(ForeignKey, self).get_default() if isinstance(field_default, self.remote_field.model): return getattr(field_default, self.target_field.attname) return field_default def get_db_prep_save(self, value, connection): if value is None or (value == '' and (not self.target_field.empty_strings_allowed or connection.features.interprets_empty_strings_as_nulls)): return None else: return self.target_field.get_db_prep_save(value, connection=connection) def get_db_prep_value(self, value, connection, prepared=False): return self.target_field.get_db_prep_value(value, connection, prepared) def contribute_to_related_class(self, cls, related): super(ForeignKey, self).contribute_to_related_class(cls, related) if self.remote_field.field_name is None: self.remote_field.field_name = cls._meta.pk.name def formfield(self, **kwargs): db = kwargs.pop('using', None) if isinstance(self.remote_field.model, six.string_types): raise ValueError("Cannot create form field for %r yet, because " "its related model %r has not been loaded yet" % (self.name, self.remote_field.model)) defaults = { 'form_class': forms.ModelChoiceField, 'queryset': self.remote_field.model._default_manager.using(db), 'to_field_name': self.remote_field.field_name, } defaults.update(kwargs) return super(ForeignKey, self).formfield(**defaults) def db_check(self, connection): return [] def db_type(self, connection): return self.target_field.rel_db_type(connection=connection) def db_parameters(self, connection): return {"type": self.db_type(connection), "check": self.db_check(connection)} def convert_empty_strings(self, value, expression, connection, context): if (not value) and isinstance(value, six.string_types): return None return value def get_db_converters(self, connection): converters = super(ForeignKey, self).get_db_converters(connection) if connection.features.interprets_empty_strings_as_nulls: converters += [self.convert_empty_strings] return converters def get_col(self, alias, output_field=None): return super(ForeignKey, self).get_col(alias, output_field or self.target_field) class OneToOneField(ForeignKey): """ A OneToOneField is essentially the same as a ForeignKey, with the exception that it always carries a "unique" constraint with it and the reverse relation always returns the object pointed to (since there will only ever be one), rather than returning a list. """ # Field flags many_to_many = False many_to_one = False one_to_many = False one_to_one = True related_accessor_class = ReverseOneToOneDescriptor rel_class = OneToOneRel description = _("One-to-one relationship") def __init__(self, to, on_delete=None, to_field=None, **kwargs): kwargs['unique'] = True if on_delete is None: warnings.warn( "on_delete will be a required arg for %s in Django 2.0. Set " "it to models.CASCADE on models and in existing migrations " "if you want to maintain the current default behavior. " "See https://docs.djangoproject.com/en/%s/ref/models/fields/" "#django.db.models.ForeignKey.on_delete" % ( self.__class__.__name__, get_docs_version(), ), RemovedInDjango20Warning, 2) on_delete = CASCADE elif not callable(on_delete): warnings.warn( "The signature for {0} will change in Django 2.0. " "Pass to_field='{1}' as a kwarg instead of as an arg.".format( self.__class__.__name__, on_delete, ), RemovedInDjango20Warning, 2) to_field = on_delete on_delete = CASCADE # Avoid warning in superclass super(OneToOneField, self).__init__(to, on_delete, to_field=to_field, **kwargs) def deconstruct(self): name, path, args, kwargs = super(OneToOneField, self).deconstruct() if "unique" in kwargs: del kwargs['unique'] return name, path, args, kwargs def formfield(self, **kwargs): if self.remote_field.parent_link: return None return super(OneToOneField, self).formfield(**kwargs) def save_form_data(self, instance, data): if isinstance(data, self.remote_field.model): setattr(instance, self.name, data) else: setattr(instance, self.attname, data) def _check_unique(self, **kwargs): # Override ForeignKey since check isn't applicable here. return [] def create_many_to_many_intermediary_model(field, klass): from django.db import models def set_managed(model, related, through): through._meta.managed = model._meta.managed or related._meta.managed to_model = resolve_relation(klass, field.remote_field.model) name = '%s_%s' % (klass._meta.object_name, field.name) lazy_related_operation(set_managed, klass, to_model, name) to = make_model_tuple(to_model)[1] from_ = klass._meta.model_name if to == from_: to = 'to_%s' % to from_ = 'from_%s' % from_ meta = type(str('Meta'), (object,), { 'db_table': field._get_m2m_db_table(klass._meta), 'auto_created': klass, 'app_label': klass._meta.app_label, 'db_tablespace': klass._meta.db_tablespace, 'unique_together': (from_, to), 'verbose_name': _('%(from)s-%(to)s relationship') % {'from': from_, 'to': to}, 'verbose_name_plural': _('%(from)s-%(to)s relationships') % {'from': from_, 'to': to}, 'apps': field.model._meta.apps, }) # Construct and return the new class. return type(str(name), (models.Model,), { 'Meta': meta, '__module__': klass.__module__, from_: models.ForeignKey( klass, related_name='%s+' % name, db_tablespace=field.db_tablespace, db_constraint=field.remote_field.db_constraint, on_delete=CASCADE, ), to: models.ForeignKey( to_model, related_name='%s+' % name, db_tablespace=field.db_tablespace, db_constraint=field.remote_field.db_constraint, on_delete=CASCADE, ) }) class ManyToManyField(RelatedField): """ Provide a many-to-many relation by using an intermediary model that holds two ForeignKey fields pointed at the two sides of the relation. Unless a ``through`` model was provided, ManyToManyField will use the create_many_to_many_intermediary_model factory to automatically generate the intermediary model. """ # Field flags many_to_many = True many_to_one = False one_to_many = False one_to_one = False rel_class = ManyToManyRel description = _("Many-to-many relationship") def __init__(self, to, related_name=None, related_query_name=None, limit_choices_to=None, symmetrical=None, through=None, through_fields=None, db_constraint=True, db_table=None, swappable=True, **kwargs): try: to._meta except AttributeError: assert isinstance(to, six.string_types), ( "%s(%r) is invalid. First parameter to ManyToManyField must be " "either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT) ) # Class names must be ASCII in Python 2.x, so we forcibly coerce it # here to break early if there's a problem. to = str(to) if symmetrical is None: symmetrical = (to == RECURSIVE_RELATIONSHIP_CONSTANT) if through is not None: assert db_table is None, ( "Cannot specify a db_table if an intermediary model is used." ) kwargs['rel'] = self.rel_class( self, to, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, symmetrical=symmetrical, through=through, through_fields=through_fields, db_constraint=db_constraint, ) self.has_null_arg = 'null' in kwargs super(ManyToManyField, self).__init__(**kwargs) self.db_table = db_table self.swappable = swappable def check(self, **kwargs): errors = super(ManyToManyField, self).check(**kwargs) errors.extend(self._check_unique(**kwargs)) errors.extend(self._check_relationship_model(**kwargs)) errors.extend(self._check_ignored_options(**kwargs)) return errors def _check_unique(self, **kwargs): if self.unique: return [ checks.Error( 'ManyToManyFields cannot be unique.', obj=self, id='fields.E330', ) ] return [] def _check_ignored_options(self, **kwargs): warnings = [] if self.has_null_arg: warnings.append( checks.Warning( 'null has no effect on ManyToManyField.', obj=self, id='fields.W340', ) ) if len(self._validators) > 0: warnings.append( checks.Warning( 'ManyToManyField does not support validators.', obj=self, id='fields.W341', ) ) return warnings def _check_relationship_model(self, from_model=None, **kwargs): if hasattr(self.remote_field.through, '_meta'): qualified_model_name = "%s.%s" % ( self.remote_field.through._meta.app_label, self.remote_field.through.__name__) else: qualified_model_name = self.remote_field.through errors = [] if self.remote_field.through not in self.opts.apps.get_models(include_auto_created=True): # The relationship model is not installed. errors.append( checks.Error( "Field specifies a many-to-many relation through model " "'%s', which has not been installed." % qualified_model_name, obj=self, id='fields.E331', ) ) else: assert from_model is not None, ( "ManyToManyField with intermediate " "tables cannot be checked if you don't pass the model " "where the field is attached to." ) # Set some useful local variables to_model = resolve_relation(from_model, self.remote_field.model) from_model_name = from_model._meta.object_name if isinstance(to_model, six.string_types): to_model_name = to_model else: to_model_name = to_model._meta.object_name relationship_model_name = self.remote_field.through._meta.object_name self_referential = from_model == to_model # Check symmetrical attribute. if (self_referential and self.remote_field.symmetrical and not self.remote_field.through._meta.auto_created): errors.append( checks.Error( 'Many-to-many fields with intermediate tables must not be symmetrical.', obj=self, id='fields.E332', ) ) # Count foreign keys in intermediate model if self_referential: seen_self = sum( from_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields ) if seen_self > 2 and not self.remote_field.through_fields: errors.append( checks.Error( "The model is used as an intermediate model by " "'%s', but it has more than two foreign keys " "to '%s', which is ambiguous. You must specify " "which two foreign keys Django should use via the " "through_fields keyword argument." % (self, from_model_name), hint="Use through_fields to specify which two foreign keys Django should use.", obj=self.remote_field.through, id='fields.E333', ) ) else: # Count foreign keys in relationship model seen_from = sum( from_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields ) seen_to = sum( to_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields ) if seen_from > 1 and not self.remote_field.through_fields: errors.append( checks.Error( ("The model is used as an intermediate model by " "'%s', but it has more than one foreign key " "from '%s', which is ambiguous. You must specify " "which foreign key Django should use via the " "through_fields keyword argument.") % (self, from_model_name), hint=( 'If you want to create a recursive relationship, ' 'use ForeignKey("self", symmetrical=False, through="%s").' ) % relationship_model_name, obj=self, id='fields.E334', ) ) if seen_to > 1 and not self.remote_field.through_fields: errors.append( checks.Error( "The model is used as an intermediate model by " "'%s', but it has more than one foreign key " "to '%s', which is ambiguous. You must specify " "which foreign key Django should use via the " "through_fields keyword argument." % (self, to_model_name), hint=( 'If you want to create a recursive relationship, ' 'use ForeignKey("self", symmetrical=False, through="%s").' ) % relationship_model_name, obj=self, id='fields.E335', ) ) if seen_from == 0 or seen_to == 0: errors.append( checks.Error( "The model is used as an intermediate model by " "'%s', but it does not have a foreign key to '%s' or '%s'." % ( self, from_model_name, to_model_name ), obj=self.remote_field.through, id='fields.E336', ) ) # Validate `through_fields`. if self.remote_field.through_fields is not None: # Validate that we're given an iterable of at least two items # and that none of them is "falsy". if not (len(self.remote_field.through_fields) >= 2 and self.remote_field.through_fields[0] and self.remote_field.through_fields[1]): errors.append( checks.Error( "Field specifies 'through_fields' but does not provide " "the names of the two link fields that should be used " "for the relation through model '%s'." % qualified_model_name, hint="Make sure you specify 'through_fields' as through_fields=('field1', 'field2')", obj=self, id='fields.E337', ) ) # Validate the given through fields -- they should be actual # fields on the through model, and also be foreign keys to the # expected models. else: assert from_model is not None, ( "ManyToManyField with intermediate " "tables cannot be checked if you don't pass the model " "where the field is attached to." ) source, through, target = from_model, self.remote_field.through, self.remote_field.model source_field_name, target_field_name = self.remote_field.through_fields[:2] for field_name, related_model in ((source_field_name, source), (target_field_name, target)): possible_field_names = [] for f in through._meta.fields: if hasattr(f, 'remote_field') and getattr(f.remote_field, 'model', None) == related_model: possible_field_names.append(f.name) if possible_field_names: hint = "Did you mean one of the following foreign keys to '%s': %s?" % ( related_model._meta.object_name, ', '.join(possible_field_names), ) else: hint = None try: field = through._meta.get_field(field_name) except exceptions.FieldDoesNotExist: errors.append( checks.Error( "The intermediary model '%s' has no field '%s'." % (qualified_model_name, field_name), hint=hint, obj=self, id='fields.E338', ) ) else: if not (hasattr(field, 'remote_field') and getattr(field.remote_field, 'model', None) == related_model): errors.append( checks.Error( "'%s.%s' is not a foreign key to '%s'." % ( through._meta.object_name, field_name, related_model._meta.object_name, ), hint=hint, obj=self, id='fields.E339', ) ) return errors def deconstruct(self): name, path, args, kwargs = super(ManyToManyField, self).deconstruct() # Handle the simpler arguments. if self.db_table is not None: kwargs['db_table'] = self.db_table if self.remote_field.db_constraint is not True: kwargs['db_constraint'] = self.remote_field.db_constraint if self.remote_field.related_name is not None: kwargs['related_name'] = self.remote_field.related_name if self.remote_field.related_query_name is not None: kwargs['related_query_name'] = self.remote_field.related_query_name # Rel needs more work. if isinstance(self.remote_field.model, six.string_types): kwargs['to'] = self.remote_field.model else: kwargs['to'] = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name, ) if getattr(self.remote_field, 'through', None) is not None: if isinstance(self.remote_field.through, six.string_types): kwargs['through'] = self.remote_field.through elif not self.remote_field.through._meta.auto_created: kwargs['through'] = "%s.%s" % ( self.remote_field.through._meta.app_label, self.remote_field.through._meta.object_name, ) # If swappable is True, then see if we're actually pointing to the target # of a swap. swappable_setting = self.swappable_setting if swappable_setting is not None: # If it's already a settings reference, error. if hasattr(kwargs['to'], "setting_name"): if kwargs['to'].setting_name != swappable_setting: raise ValueError( "Cannot deconstruct a ManyToManyField pointing to a " "model that is swapped in place of more than one model " "(%s and %s)" % (kwargs['to'].setting_name, swappable_setting) ) from django.db.migrations.writer import SettingsReference kwargs['to'] = SettingsReference( kwargs['to'], swappable_setting, ) return name, path, args, kwargs def _get_path_info(self, direct=False): """ Called by both direct and indirect m2m traversal. """ pathinfos = [] int_model = self.remote_field.through linkfield1 = int_model._meta.get_field(self.m2m_field_name()) linkfield2 = int_model._meta.get_field(self.m2m_reverse_field_name()) if direct: join1infos = linkfield1.get_reverse_path_info() join2infos = linkfield2.get_path_info() else: join1infos = linkfield2.get_reverse_path_info() join2infos = linkfield1.get_path_info() pathinfos.extend(join1infos) pathinfos.extend(join2infos) return pathinfos def get_path_info(self): return self._get_path_info(direct=True) def get_reverse_path_info(self): return self._get_path_info(direct=False) def _get_m2m_db_table(self, opts): """ Function that can be curried to provide the m2m table name for this relation. """ if self.remote_field.through is not None: return self.remote_field.through._meta.db_table elif self.db_table: return self.db_table else: return utils.truncate_name('%s_%s' % (opts.db_table, self.name), connection.ops.max_name_length()) def _get_m2m_attr(self, related, attr): """ Function that can be curried to provide the source accessor or DB column name for the m2m table. """ cache_attr = '_m2m_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) if self.remote_field.through_fields is not None: link_field_name = self.remote_field.through_fields[0] else: link_field_name = None for f in self.remote_field.through._meta.fields: if (f.is_relation and f.remote_field.model == related.related_model and (link_field_name is None or link_field_name == f.name)): setattr(self, cache_attr, getattr(f, attr)) return getattr(self, cache_attr) def _get_m2m_reverse_attr(self, related, attr): """ Function that can be curried to provide the related accessor or DB column name for the m2m table. """ cache_attr = '_m2m_reverse_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) found = False if self.remote_field.through_fields is not None: link_field_name = self.remote_field.through_fields[1] else: link_field_name = None for f in self.remote_field.through._meta.fields: if f.is_relation and f.remote_field.model == related.model: if link_field_name is None and related.related_model == related.model: # If this is an m2m-intermediate to self, # the first foreign key you find will be # the source column. Keep searching for # the second foreign key. if found: setattr(self, cache_attr, getattr(f, attr)) break else: found = True elif link_field_name is None or link_field_name == f.name: setattr(self, cache_attr, getattr(f, attr)) break return getattr(self, cache_attr) def contribute_to_class(self, cls, name, **kwargs): # To support multiple relations to self, it's useful to have a non-None # related name on symmetrical relations for internal reasons. The # concept doesn't make a lot of sense externally ("you want me to # specify *what* on my non-reversible relation?!"), so we set it up # automatically. The funky name reduces the chance of an accidental # clash. if self.remote_field.symmetrical and ( self.remote_field.model == "self" or self.remote_field.model == cls._meta.object_name): self.remote_field.related_name = "%s_rel_+" % name elif self.remote_field.is_hidden(): # If the backwards relation is disabled, replace the original # related_name with one generated from the m2m field name. Django # still uses backwards relations internally and we need to avoid # clashes between multiple m2m fields with related_name == '+'. self.remote_field.related_name = "_%s_%s_+" % (cls.__name__.lower(), name) super(ManyToManyField, self).contribute_to_class(cls, name, **kwargs) # The intermediate m2m model is not auto created if: # 1) There is a manually specified intermediate, or # 2) The class owning the m2m field is abstract. # 3) The class owning the m2m field has been swapped out. if not cls._meta.abstract: if self.remote_field.through: def resolve_through_model(_, model, field): field.remote_field.through = model lazy_related_operation(resolve_through_model, cls, self.remote_field.through, field=self) elif not cls._meta.swapped: self.remote_field.through = create_many_to_many_intermediary_model(self, cls) # Add the descriptor for the m2m relation. setattr(cls, self.name, ManyToManyDescriptor(self.remote_field, reverse=False)) # Set up the accessor for the m2m table name for the relation. self.m2m_db_table = curry(self._get_m2m_db_table, cls._meta) def contribute_to_related_class(self, cls, related): # Internal M2Ms (i.e., those with a related name ending with '+') # and swapped models don't get a related descriptor. if not self.remote_field.is_hidden() and not related.related_model._meta.swapped: setattr(cls, related.get_accessor_name(), ManyToManyDescriptor(self.remote_field, reverse=True)) # Set up the accessors for the column names on the m2m table. self.m2m_column_name = curry(self._get_m2m_attr, related, 'column') self.m2m_reverse_name = curry(self._get_m2m_reverse_attr, related, 'column') self.m2m_field_name = curry(self._get_m2m_attr, related, 'name') self.m2m_reverse_field_name = curry(self._get_m2m_reverse_attr, related, 'name') get_m2m_rel = curry(self._get_m2m_attr, related, 'remote_field') self.m2m_target_field_name = lambda: get_m2m_rel().field_name get_m2m_reverse_rel = curry(self._get_m2m_reverse_attr, related, 'remote_field') self.m2m_reverse_target_field_name = lambda: get_m2m_reverse_rel().field_name def set_attributes_from_rel(self): pass def value_from_object(self, obj): """ Return the value of this field in the given model instance. """ if obj.pk is None: return self.related_model.objects.none() return getattr(obj, self.attname).all() def save_form_data(self, instance, data): getattr(instance, self.attname).set(data) def formfield(self, **kwargs): db = kwargs.pop('using', None) defaults = { 'form_class': forms.ModelMultipleChoiceField, 'queryset': self.remote_field.model._default_manager.using(db), } defaults.update(kwargs) # If initial is passed in, it's a list of related objects, but the # MultipleChoiceField takes a list of IDs. if defaults.get('initial') is not None: initial = defaults['initial'] if callable(initial): initial = initial() defaults['initial'] = [i._get_pk_val() for i in initial] return super(ManyToManyField, self).formfield(**defaults) def db_check(self, connection): return None def db_type(self, connection): # A ManyToManyField is not represented by a single column, # so return None. return None def db_parameters(self, connection): return {"type": None, "check": None}
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 7765, 492, 3778, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 14281, 492, 27751, 9947, 12, 11543, 63, 3472, 12, 11543, 63, 8084, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 6912, 2354, 199, 504, 1639, 14, 697, 14, 992, 14, 1208, 492, 1852, 63, 1238, 63, 2960, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1165, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 1023, 492, 664, 63, 4757, 63, 1023, 199, 199, 504, 1275, 492, 5024, 199, 504, 1275, 2407, 63, 17752, 492, 334, 272, 22536, 4089, 10939, 4311, 12, 15517, 6749, 4311, 12, 272, 22734, 4089, 10939, 4311, 12, 22734, 4395, 10939, 4311, 12, 199, 9, 199, 504, 1275, 2407, 63, 17438, 492, 334, 272, 20116, 29751, 12, 20116, 11891, 19760, 12, 20116, 11891, 19760, 2844, 591, 12, 20116, 607, 12, 272, 20116, 1831, 8849, 12, 20116, 32693, 12, 20116, 32693, 2844, 591, 12, 199, 9, 199, 504, 1275, 4471, 63, 2407, 492, 334, 272, 481, 2692, 1692, 5640, 12, 15517, 6749, 5640, 12, 15517, 10939, 5640, 12, 7309, 10939, 5640, 12, 199, 9, 199, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 421, 199, 318, 7512, 63, 5690, 8, 2645, 63, 1238, 12, 5850, 304, 272, 408, 272, 19463, 5850, 1901, 282, 1402, 503, 9999, 13, 11661, 1402, 1059, 402, 314, 1824, 272, 298, 571, 63, 1302, 14, 1685, 985, 401, 3847, 370, 4194, 63, 1238, 14, 339, 710, 5850, 1423, 883, 506, 26, 489, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 12, 284, 14, 69, 14, 314, 1059, 298, 277, 401, 315, 1314, 1930, 267, 314, 1402, 1423, 911, 506, 2138, 14, 489, 627, 437, 18753, 1402, 536, 1928, 376, 1145, 63, 1302, 12, 315, 1314, 1930, 4194, 63, 1238, 1159, 267, 1145, 63, 1302, 911, 506, 20247, 14, 489, 627, 1626, 298, 571, 63, 1302, 14, 1685, 985, 2, 1059, 14, 489, 627, 437, 1402, 1021, 12, 1314, 911, 506, 2138, 14874, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 5850, 275, 4194, 63, 1238, 339, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 272, 340, 1228, 8, 5690, 12, 3816, 14, 875, 63, 1313, 304, 267, 340, 14530, 440, 315, 5850, 26, 288, 5850, 275, 2071, 83, 4111, 83, 2, 450, 334, 2645, 63, 1238, 423, 2024, 14, 571, 63, 1302, 12, 5850, 9, 339, 372, 5850, 421, 199, 318, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 1402, 12, 627, 2407, 63, 992, 12, 1011, 958, 304, 272, 408, 272, 24317, 658, 1593, 64, 370, 506, 2797, 5403, 658, 1238, 64, 436, 1006, 658, 2407, 63, 992, 64, 272, 1172, 2757, 8439, 436, 7264, 543, 314, 1145, 7086, 14, 658, 1593, 64, 911, 272, 506, 2797, 543, 314, 13903, 13, 4591, 1402, 3992, 465, 2399, 11333, 2368, 12, 272, 12254, 1263, 2716, 4252, 2368, 14, 339, 710, 658, 1238, 64, 1423, 1471, 506, 282, 1402, 1021, 14, 7048, 13372, 11333, 272, 1423, 365, 4573, 1402, 12, 503, 282, 3659, 370, 4573, 1402, 446, 1937, 272, 658, 6983, 63, 5690, 11995, 367, 314, 7750, 4513, 3520, 1443, 5452, 14, 6184, 3847, 272, 6941, 911, 506, 12152, 3847, 370, 658, 1238, 2313, 339, 961, 365, 282, 16777, 4975, 367, 658, 2640, 83, 14, 6395, 63, 1238, 63, 5735, 64, 446, 314, 1145, 272, 7086, 1402, 1202, 365, 314, 1373, 1911, 315, 658, 1238, 423, 2024, 14, 5181, 2313, 272, 408, 272, 1709, 275, 359, 1238, 61, 435, 359, 6983, 63, 5690, 8, 1238, 12, 4668, 9, 367, 4668, 315, 4048, 63, 992, 61, 272, 1402, 63, 1612, 275, 334, 1875, 63, 1238, 63, 2960, 8, 77, 9, 367, 333, 315, 1709, 9, 272, 8686, 275, 1402, 423, 2024, 14, 5181, 272, 372, 8686, 14, 6395, 63, 1238, 63, 5735, 8, 6672, 8, 1593, 12, 1011, 958, 395, 627, 1238, 63, 1612, 9, 421, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 3598, 14, 4050, 8, 267, 298, 525, 63, 6395, 63, 5690, 342, 965, 2757, 1613, 261, 770, 701, 9617, 63, 2407, 63, 5735, 342, 298, 267, 298, 460, 4048, 3102, 641, 314, 4693, 83, 1021, 4765, 267, 23687, 1165, 3849, 12, 13232, 29, 18, 9, 272, 327, 799, 285, 1842, 1249, 367, 892, 4693, 83, 14, 6395, 63, 1238, 63, 5735, 339, 347, 805, 8, 1832, 12, 4048, 12, 901, 304, 267, 372, 3439, 8, 698, 12, 4048, 12, 2257, 9, 339, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 843, 12, 5850, 12, 901, 29, 698, 9, 421, 199, 533, 20116, 792, 8, 792, 304, 272, 408, 272, 3523, 1021, 626, 1006, 5850, 279, 1504, 8287, 687, 14, 272, 408, 339, 327, 5024, 3285, 272, 1373, 63, 475, 63, 3479, 275, 756, 272, 1373, 63, 475, 63, 368, 275, 756, 272, 5002, 63, 475, 63, 3479, 275, 756, 272, 5002, 63, 475, 63, 368, 275, 756, 339, 768, 5245, 63, 1829, 272, 347, 4048, 63, 1238, 8, 277, 304, 267, 327, 6855, 1133, 2581, 642, 3324, 5133, 1006, 314, 1709, 787, 6511, 14, 267, 8686, 14, 1074, 63, 992, 63, 2179, 342, 267, 372, 291, 14, 3846, 63, 698, 14, 1238, 339, 347, 1104, 8, 277, 12, 1011, 958, 304, 267, 2552, 275, 1613, 8, 13885, 792, 12, 291, 680, 1074, 3682, 958, 9, 267, 2552, 14, 2880, 8, 277, 423, 1074 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 7765, 492, 3778, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 14281, 492, 27751, 9947, 12, 11543, 63, 3472, 12, 11543, 63, 8084, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 6912, 2354, 199, 504, 1639, 14, 697, 14, 992, 14, 1208, 492, 1852, 63, 1238, 63, 2960, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1165, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 1023, 492, 664, 63, 4757, 63, 1023, 199, 199, 504, 1275, 492, 5024, 199, 504, 1275, 2407, 63, 17752, 492, 334, 272, 22536, 4089, 10939, 4311, 12, 15517, 6749, 4311, 12, 272, 22734, 4089, 10939, 4311, 12, 22734, 4395, 10939, 4311, 12, 199, 9, 199, 504, 1275, 2407, 63, 17438, 492, 334, 272, 20116, 29751, 12, 20116, 11891, 19760, 12, 20116, 11891, 19760, 2844, 591, 12, 20116, 607, 12, 272, 20116, 1831, 8849, 12, 20116, 32693, 12, 20116, 32693, 2844, 591, 12, 199, 9, 199, 504, 1275, 4471, 63, 2407, 492, 334, 272, 481, 2692, 1692, 5640, 12, 15517, 6749, 5640, 12, 15517, 10939, 5640, 12, 7309, 10939, 5640, 12, 199, 9, 199, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 421, 199, 318, 7512, 63, 5690, 8, 2645, 63, 1238, 12, 5850, 304, 272, 408, 272, 19463, 5850, 1901, 282, 1402, 503, 9999, 13, 11661, 1402, 1059, 402, 314, 1824, 272, 298, 571, 63, 1302, 14, 1685, 985, 401, 3847, 370, 4194, 63, 1238, 14, 339, 710, 5850, 1423, 883, 506, 26, 489, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 12, 284, 14, 69, 14, 314, 1059, 298, 277, 401, 315, 1314, 1930, 267, 314, 1402, 1423, 911, 506, 2138, 14, 489, 627, 437, 18753, 1402, 536, 1928, 376, 1145, 63, 1302, 12, 315, 1314, 1930, 4194, 63, 1238, 1159, 267, 1145, 63, 1302, 911, 506, 20247, 14, 489, 627, 1626, 298, 571, 63, 1302, 14, 1685, 985, 2, 1059, 14, 489, 627, 437, 1402, 1021, 12, 1314, 911, 506, 2138, 14874, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 5850, 275, 4194, 63, 1238, 339, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 272, 340, 1228, 8, 5690, 12, 3816, 14, 875, 63, 1313, 304, 267, 340, 14530, 440, 315, 5850, 26, 288, 5850, 275, 2071, 83, 4111, 83, 2, 450, 334, 2645, 63, 1238, 423, 2024, 14, 571, 63, 1302, 12, 5850, 9, 339, 372, 5850, 421, 199, 318, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 1402, 12, 627, 2407, 63, 992, 12, 1011, 958, 304, 272, 408, 272, 24317, 658, 1593, 64, 370, 506, 2797, 5403, 658, 1238, 64, 436, 1006, 658, 2407, 63, 992, 64, 272, 1172, 2757, 8439, 436, 7264, 543, 314, 1145, 7086, 14, 658, 1593, 64, 911, 272, 506, 2797, 543, 314, 13903, 13, 4591, 1402, 3992, 465, 2399, 11333, 2368, 12, 272, 12254, 1263, 2716, 4252, 2368, 14, 339, 710, 658, 1238, 64, 1423, 1471, 506, 282, 1402, 1021, 14, 7048, 13372, 11333, 272, 1423, 365, 4573, 1402, 12, 503, 282, 3659, 370, 4573, 1402, 446, 1937, 272, 658, 6983, 63, 5690, 11995, 367, 314, 7750, 4513, 3520, 1443, 5452, 14, 6184, 3847, 272, 6941, 911, 506, 12152, 3847, 370, 658, 1238, 2313, 339, 961, 365, 282, 16777, 4975, 367, 658, 2640, 83, 14, 6395, 63, 1238, 63, 5735, 64, 446, 314, 1145, 272, 7086, 1402, 1202, 365, 314, 1373, 1911, 315, 658, 1238, 423, 2024, 14, 5181, 2313, 272, 408, 272, 1709, 275, 359, 1238, 61, 435, 359, 6983, 63, 5690, 8, 1238, 12, 4668, 9, 367, 4668, 315, 4048, 63, 992, 61, 272, 1402, 63, 1612, 275, 334, 1875, 63, 1238, 63, 2960, 8, 77, 9, 367, 333, 315, 1709, 9, 272, 8686, 275, 1402, 423, 2024, 14, 5181, 272, 372, 8686, 14, 6395, 63, 1238, 63, 5735, 8, 6672, 8, 1593, 12, 1011, 958, 395, 627, 1238, 63, 1612, 9, 421, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 3598, 14, 4050, 8, 267, 298, 525, 63, 6395, 63, 5690, 342, 965, 2757, 1613, 261, 770, 701, 9617, 63, 2407, 63, 5735, 342, 298, 267, 298, 460, 4048, 3102, 641, 314, 4693, 83, 1021, 4765, 267, 23687, 1165, 3849, 12, 13232, 29, 18, 9, 272, 327, 799, 285, 1842, 1249, 367, 892, 4693, 83, 14, 6395, 63, 1238, 63, 5735, 339, 347, 805, 8, 1832, 12, 4048, 12, 901, 304, 267, 372, 3439, 8, 698, 12, 4048, 12, 2257, 9, 339, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 843, 12, 5850, 12, 901, 29, 698, 9, 421, 199, 533, 20116, 792, 8, 792, 304, 272, 408, 272, 3523, 1021, 626, 1006, 5850, 279, 1504, 8287, 687, 14, 272, 408, 339, 327, 5024, 3285, 272, 1373, 63, 475, 63, 3479, 275, 756, 272, 1373, 63, 475, 63, 368, 275, 756, 272, 5002, 63, 475, 63, 3479, 275, 756, 272, 5002, 63, 475, 63, 368, 275, 756, 339, 768, 5245, 63, 1829, 272, 347, 4048, 63, 1238, 8, 277, 304, 267, 327, 6855, 1133, 2581, 642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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 ]
j-marjanovic/myhdl
myhdl/_always_comb.py
1
4522
# This file is part of the myhdl library, a Python package for using # Python as a Hardware Description Language. # # Copyright (C) 2003-2009 Jan Decaluwe # # The myhdl library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ Module with the always_comb function. """ from __future__ import absolute_import import sys import inspect from types import FunctionType import re import ast from myhdl import AlwaysCombError from myhdl._Signal import _Signal, _isListOfSigs from myhdl._util import _isGenFunc, _dedent from myhdl._Waiter import _Waiter, _SignalWaiter, _SignalTupleWaiter from myhdl._instance import _Instantiator from myhdl._always import _Always from myhdl._resolverefs import _AttrRefTransformer from myhdl._visitors import _SigNameVisitor class _error: pass _error.ArgType = "always_comb argument should be a classic function" _error.NrOfArgs = "always_comb argument should be a function without arguments" _error.Scope = "always_comb argument should be a local function" _error.SignalAsInout = "signal (%s) used as inout in always_comb function argument" _error.EmbeddedFunction = "embedded functions in always_comb function argument not supported" _error.EmptySensitivityList= "sensitivity list is empty" def always_comb(func): if not isinstance( func, FunctionType): raise AlwaysCombError(_error.ArgType) if _isGenFunc(func): raise AlwaysCombError(_error.ArgType) if func.__code__.co_argcount > 0: raise AlwaysCombError(_error.NrOfArgs) c = _AlwaysComb(func) return c # class _AlwaysComb(_Instantiator): class _AlwaysComb(_Always): # def __init__(self, func, symdict): # self.func = func # self.symdict = symdict # s = inspect.getsource(func) # # remove decorators # s = re.sub(r"@.*", "", s) # s = s.lstrip() # tree = compiler.parse(s) # v = _SigNameVisitor(symdict) # compiler.walk(tree, v) # self.inputs = v.inputs # self.outputs = v.outputs # senslist = [] # for n in self.inputs: # s = self.symdict[n] # if isinstance(s, Signal): # senslist.append(s) # else: # list of sigs # senslist.extend(s) # self.senslist = tuple(senslist) # self.gen = self.genfunc() # if len(self.senslist) == 0: # raise AlwaysCombError(_error.EmptySensitivityList) # if len(self.senslist) == 1: # W = _SignalWaiter # else: # W = _SignalTupleWaiter # self.waiter = W(self.gen) def __init__(self, func): senslist = [] super(_AlwaysComb, self).__init__(func, senslist) s = inspect.getsource(func) s = _dedent(s) tree = ast.parse(s) # print ast.dump(tree) v = _AttrRefTransformer(self) v.visit(tree) v = _SigNameVisitor(self.symdict) v.visit(tree) self.inputs = v.results['input'] self.outputs = v.results['output'] inouts = v.results['inout'] | self.inputs.intersection(self.outputs) if inouts: raise AlwaysCombError(_error.SignalAsInout % inouts) if v.results['embedded_func']: raise AlwaysCombError(_error.EmbeddedFunction) for n in self.inputs: s = self.symdict[n] if isinstance(s, _Signal): senslist.append(s) elif _isListOfSigs(s): senslist.extend(s) self.senslist = tuple(senslist) if len(self.senslist) == 0: raise AlwaysCombError(_error.EmptySensitivityList) def genfunc(self): senslist = self.senslist if len(senslist) == 1: senslist = senslist[0] func = self.func while 1: func() yield senslist
lgpl-2.1
[ 3, 221, 961, 570, 365, 1777, 402, 314, 3002, 28738, 3555, 12, 282, 2018, 2559, 367, 1808, 199, 3, 221, 2018, 465, 282, 22825, 1068, 11994, 8466, 14, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 13004, 13, 8664, 17474, 13966, 279, 85, 1129, 199, 3, 199, 3, 221, 710, 3002, 28738, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 199, 3, 221, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 199, 3, 221, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 221, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 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, 15673, 13, 13421, 8217, 199, 199, 624, 5673, 543, 314, 3544, 63, 6560, 805, 14, 408, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 646, 6485, 199, 504, 2943, 492, 6801, 804, 199, 646, 295, 199, 646, 6073, 199, 199, 504, 3002, 28738, 492, 16763, 4373, 66, 547, 199, 504, 3002, 28738, 423, 11274, 492, 485, 11274, 12, 485, 374, 30210, 18934, 458, 199, 504, 3002, 28738, 423, 1974, 492, 485, 374, 8168, 7465, 12, 485, 14674, 199, 504, 3002, 28738, 423, 24804, 1661, 492, 485, 24804, 1661, 12, 485, 11274, 24804, 1661, 12, 485, 11274, 7075, 24804, 1661, 199, 504, 3002, 28738, 423, 842, 492, 485, 10083, 4466, 707, 199, 504, 3002, 28738, 423, 9223, 492, 485, 2439, 2885, 199, 504, 3002, 28738, 423, 6983, 7655, 492, 485, 7144, 2891, 19761, 199, 504, 3002, 28738, 423, 5427, 1384, 492, 485, 11575, 985, 18324, 199, 199, 533, 485, 705, 26, 272, 986, 199, 63, 705, 14, 6373, 804, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 31205, 805, 2, 199, 63, 705, 14, 46, 82, 3466, 6213, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 805, 1928, 2368, 2, 199, 63, 705, 14, 7812, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 2257, 805, 2, 199, 63, 705, 14, 11274, 2822, 607, 548, 275, 298, 4653, 4366, 83, 9, 1202, 465, 315, 548, 315, 3544, 63, 6560, 805, 1423, 2, 199, 63, 705, 14, 27395, 3481, 275, 298, 18757, 3423, 315, 3544, 63, 6560, 805, 1423, 440, 3748, 2, 199, 63, 705, 14, 4699, 18569, 20635, 1296, 29, 298, 2464, 20635, 769, 365, 2701, 2, 199, 199, 318, 3544, 63, 6560, 8, 1532, 304, 272, 340, 440, 1228, 8, 2562, 12, 6801, 804, 304, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 6373, 804, 9, 272, 340, 485, 374, 8168, 7465, 8, 1532, 304, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 6373, 804, 9, 272, 340, 2562, 855, 600, 4343, 331, 63, 30513, 690, 378, 26, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 46, 82, 3466, 6213, 9, 272, 286, 275, 485, 2439, 2885, 4373, 66, 8, 1532, 9, 272, 372, 286, 421, 199, 3, 1021, 485, 2439, 2885, 4373, 66, 1547, 10083, 4466, 707, 304, 199, 533, 485, 2439, 2885, 4373, 66, 1547, 2439, 2885, 304, 199, 199, 3, 258, 347, 636, 826, 721, 277, 12, 2562, 12, 4678, 807, 304, 199, 3, 260, 291, 14, 1532, 275, 2562, 199, 3, 260, 291, 14, 3840, 807, 275, 4678, 807, 199, 3, 260, 308, 275, 6485, 14, 362, 1365, 8, 1532, 9, 199, 3, 260, 327, 2813, 20419, 199, 3, 260, 308, 275, 295, 14, 954, 8, 82, 2, 32, 2795, 401, 4873, 308, 9, 199, 3, 260, 308, 275, 308, 14, 10124, 342, 199, 3, 260, 3123, 275, 6365, 14, 1122, 8, 83, 9, 199, 3, 260, 373, 275, 485, 11575, 985, 18324, 8, 3840, 807, 9, 199, 3, 260, 6365, 14, 7757, 8, 2350, 12, 373, 9, 199, 3, 260, 291, 14, 3711, 275, 373, 14, 3711, 199, 3, 260, 291, 14, 4467, 275, 373, 14, 4467, 199, 3, 260, 542, 561, 513, 275, 942, 199, 3, 260, 367, 302, 315, 291, 14, 3711, 26, 199, 3, 3777, 308, 275, 291, 14, 3840, 807, 59, 78, 61, 199, 3, 3777, 340, 1228, 8, 83, 12, 18288, 304, 199, 3, 463, 542, 561, 513, 14, 740, 8, 83, 9, 199, 3, 3777, 587, 26, 327, 769, 402, 13877, 458, 199, 3, 463, 542, 561, 513, 14, 2880, 8, 83, 9, 199, 3, 260, 291, 14, 22891, 513, 275, 2008, 8, 22891, 513, 9, 199, 3, 260, 291, 14, 2268, 275, 291, 14, 2268, 1532, 342, 199, 3, 260, 340, 822, 8, 277, 14, 22891, 513, 9, 508, 378, 26, 199, 3, 3777, 746, 16763, 4373, 66, 547, 1547, 705, 14, 4699, 18569, 20635, 1296, 9, 199, 3, 260, 340, 822, 8, 277, 14, 22891, 513, 9, 508, 413, 26, 199, 3, 3777, 644, 275, 485, 11274, 24804, 1661, 199, 3, 260, 587, 26, 199, 3, 3777, 644, 275, 485, 11274, 7075, 24804, 1661, 199, 3, 260, 291, 14, 758, 1661, 275, 644, 8, 277, 14, 2268, 9, 339, 347, 636, 826, 721, 277, 12, 2562, 304, 267, 542, 561, 513, 275, 942, 267, 1613, 1547, 2439, 2885, 4373, 66, 12, 291, 2843, 826, 721, 1532, 12, 542, 561, 513, 9, 398, 308, 275, 6485, 14, 362, 1365, 8, 1532, 9, 267, 308, 275, 485, 14674, 8, 83, 9, 267, 3123, 275, 6073, 14, 1122, 8, 83, 9, 267, 327, 870, 6073, 14, 2724, 8, 2350, 9, 267, 373, 275, 485, 7144, 2891, 19761, 8, 277, 9, 267, 373, 14, 5427, 8, 2350, 9, 267, 373, 275, 485, 11575, 985, 18324, 8, 277, 14, 3840, 807, 9, 267, 373 ]
[ 221, 961, 570, 365, 1777, 402, 314, 3002, 28738, 3555, 12, 282, 2018, 2559, 367, 1808, 199, 3, 221, 2018, 465, 282, 22825, 1068, 11994, 8466, 14, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 13004, 13, 8664, 17474, 13966, 279, 85, 1129, 199, 3, 199, 3, 221, 710, 3002, 28738, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 199, 3, 221, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 199, 3, 221, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 221, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 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, 15673, 13, 13421, 8217, 199, 199, 624, 5673, 543, 314, 3544, 63, 6560, 805, 14, 408, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 646, 6485, 199, 504, 2943, 492, 6801, 804, 199, 646, 295, 199, 646, 6073, 199, 199, 504, 3002, 28738, 492, 16763, 4373, 66, 547, 199, 504, 3002, 28738, 423, 11274, 492, 485, 11274, 12, 485, 374, 30210, 18934, 458, 199, 504, 3002, 28738, 423, 1974, 492, 485, 374, 8168, 7465, 12, 485, 14674, 199, 504, 3002, 28738, 423, 24804, 1661, 492, 485, 24804, 1661, 12, 485, 11274, 24804, 1661, 12, 485, 11274, 7075, 24804, 1661, 199, 504, 3002, 28738, 423, 842, 492, 485, 10083, 4466, 707, 199, 504, 3002, 28738, 423, 9223, 492, 485, 2439, 2885, 199, 504, 3002, 28738, 423, 6983, 7655, 492, 485, 7144, 2891, 19761, 199, 504, 3002, 28738, 423, 5427, 1384, 492, 485, 11575, 985, 18324, 199, 199, 533, 485, 705, 26, 272, 986, 199, 63, 705, 14, 6373, 804, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 31205, 805, 2, 199, 63, 705, 14, 46, 82, 3466, 6213, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 805, 1928, 2368, 2, 199, 63, 705, 14, 7812, 275, 298, 9223, 63, 6560, 1423, 1077, 506, 282, 2257, 805, 2, 199, 63, 705, 14, 11274, 2822, 607, 548, 275, 298, 4653, 4366, 83, 9, 1202, 465, 315, 548, 315, 3544, 63, 6560, 805, 1423, 2, 199, 63, 705, 14, 27395, 3481, 275, 298, 18757, 3423, 315, 3544, 63, 6560, 805, 1423, 440, 3748, 2, 199, 63, 705, 14, 4699, 18569, 20635, 1296, 29, 298, 2464, 20635, 769, 365, 2701, 2, 199, 199, 318, 3544, 63, 6560, 8, 1532, 304, 272, 340, 440, 1228, 8, 2562, 12, 6801, 804, 304, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 6373, 804, 9, 272, 340, 485, 374, 8168, 7465, 8, 1532, 304, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 6373, 804, 9, 272, 340, 2562, 855, 600, 4343, 331, 63, 30513, 690, 378, 26, 267, 746, 16763, 4373, 66, 547, 1547, 705, 14, 46, 82, 3466, 6213, 9, 272, 286, 275, 485, 2439, 2885, 4373, 66, 8, 1532, 9, 272, 372, 286, 421, 199, 3, 1021, 485, 2439, 2885, 4373, 66, 1547, 10083, 4466, 707, 304, 199, 533, 485, 2439, 2885, 4373, 66, 1547, 2439, 2885, 304, 199, 199, 3, 258, 347, 636, 826, 721, 277, 12, 2562, 12, 4678, 807, 304, 199, 3, 260, 291, 14, 1532, 275, 2562, 199, 3, 260, 291, 14, 3840, 807, 275, 4678, 807, 199, 3, 260, 308, 275, 6485, 14, 362, 1365, 8, 1532, 9, 199, 3, 260, 327, 2813, 20419, 199, 3, 260, 308, 275, 295, 14, 954, 8, 82, 2, 32, 2795, 401, 4873, 308, 9, 199, 3, 260, 308, 275, 308, 14, 10124, 342, 199, 3, 260, 3123, 275, 6365, 14, 1122, 8, 83, 9, 199, 3, 260, 373, 275, 485, 11575, 985, 18324, 8, 3840, 807, 9, 199, 3, 260, 6365, 14, 7757, 8, 2350, 12, 373, 9, 199, 3, 260, 291, 14, 3711, 275, 373, 14, 3711, 199, 3, 260, 291, 14, 4467, 275, 373, 14, 4467, 199, 3, 260, 542, 561, 513, 275, 942, 199, 3, 260, 367, 302, 315, 291, 14, 3711, 26, 199, 3, 3777, 308, 275, 291, 14, 3840, 807, 59, 78, 61, 199, 3, 3777, 340, 1228, 8, 83, 12, 18288, 304, 199, 3, 463, 542, 561, 513, 14, 740, 8, 83, 9, 199, 3, 3777, 587, 26, 327, 769, 402, 13877, 458, 199, 3, 463, 542, 561, 513, 14, 2880, 8, 83, 9, 199, 3, 260, 291, 14, 22891, 513, 275, 2008, 8, 22891, 513, 9, 199, 3, 260, 291, 14, 2268, 275, 291, 14, 2268, 1532, 342, 199, 3, 260, 340, 822, 8, 277, 14, 22891, 513, 9, 508, 378, 26, 199, 3, 3777, 746, 16763, 4373, 66, 547, 1547, 705, 14, 4699, 18569, 20635, 1296, 9, 199, 3, 260, 340, 822, 8, 277, 14, 22891, 513, 9, 508, 413, 26, 199, 3, 3777, 644, 275, 485, 11274, 24804, 1661, 199, 3, 260, 587, 26, 199, 3, 3777, 644, 275, 485, 11274, 7075, 24804, 1661, 199, 3, 260, 291, 14, 758, 1661, 275, 644, 8, 277, 14, 2268, 9, 339, 347, 636, 826, 721, 277, 12, 2562, 304, 267, 542, 561, 513, 275, 942, 267, 1613, 1547, 2439, 2885, 4373, 66, 12, 291, 2843, 826, 721, 1532, 12, 542, 561, 513, 9, 398, 308, 275, 6485, 14, 362, 1365, 8, 1532, 9, 267, 308, 275, 485, 14674, 8, 83, 9, 267, 3123, 275, 6073, 14, 1122, 8, 83, 9, 267, 327, 870, 6073, 14, 2724, 8, 2350, 9, 267, 373, 275, 485, 7144, 2891, 19761, 8, 277, 9, 267, 373, 14, 5427, 8, 2350, 9, 267, 373, 275, 485, 11575, 985, 18324, 8, 277, 14, 3840, 807, 9, 267, 373, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
uskudnik/amazon-glacier-cmd-interface
glacier/glacierexception.py
8
9197
import traceback import re import sys import logging """ ********** Note by wvmarle: This file contains the complete code from chained_exception.py plus the error handling code from GlacierWrapper.py, allowing it to be used in other modules like glaciercorecalls as well. ********** """ class GlacierException(Exception): """ An extension of the built-in Exception class, this handles an additional cause keyword argument, adding it as cause attribute to the exception message. It logs the error message (amount of information depends on the log level) and passes it on to a higher level to handle. Furthermore it allows for the upstream handler to call for a complete stack trace or just a simple error and cause message. TODO: describe usage. """ ERRORCODE = {'InternalError': 127, # Library internal error. 'UndefinedErrorCode': 126, # Undefined code. 'NoResults': 125, # Operation yielded no results. 'GlacierConnectionError': 1, # Can not connect to Glacier. 'SdbConnectionError': 2, # Can not connect to SimpleDB. 'CommandError': 3, # Command line is invalid. 'VaultNameError': 4, # Invalid vault name. 'DescriptionError': 5, # Invalid archive description. 'IdError': 6, # Invalid upload/archive/job ID given. 'RegionError': 7, # Invalid region given. 'FileError': 8, # Error related to reading/writing a file. 'ResumeError': 9, # Problem resuming a multipart upload. 'NotReady': 10, # Requested download is not ready yet. 'BookkeepingError': 11, # Bookkeeping not available. 'SdbCommunicationError': 12, # Problem reading/writing SimpleDB data. 'ResourceNotFoundException': 13, # Glacier can not find the requested resource. 'InvalidParameterValueException': 14, # Parameter not accepted. 'DownloadError': 15, # Downloading an archive failed. 'SNSConnectionError': 126, # Can not connect to SNS 'SNSConfigurationError': 127, # Problem with configuration file 'SNSParameterError':128, # Problem with arguments passed to SNS } def __init__(self, message, code=None, cause=None): """ Constructor. Logs the error. :param message: the error message. :type message: str :param code: the error code. :type code: str :param cause: explanation on what caused the error. :type cause: str """ self.logger = logging.getLogger(self.__class__.__name__) self.exitcode = self.ERRORCODE[code] if code in self.ERRORCODE else 254 self.code = code if cause: self.logger.error('ERROR: %s'% cause) self.cause = cause if isinstance(cause, tuple) else (cause,) self.stack = traceback.format_stack()[:-2] else: self.logger.error('An error occurred, exiting.') self.cause = () # Just wrap up a cause-less exception. # Get the stack trace for this exception. self.stack = ( traceback.format_stack()[:-2] + traceback.format_tb(sys.exc_info()[2])) # ^^^ let's hope the information is still there; caller must take # care of this. self.message = message self.logger.info(self.fetch(message=True)) self.logger.debug(self.fetch(stack=True)) if self.exitcode == 254: self.logger.debug('Unknown error code: %s.'% code) # Works as a generator to help get the stack trace and the cause # written out. def causeTree(self, indentation=' ', alreadyMentionedTree=[], stack=False, message=False): """ Returns a complete stack tree, an error message, or both. Returns a warning if neither stack or message are True. """ if stack: yield "Traceback (most recent call last):\n" ellipsed = 0 for i, line in enumerate(self.stack): if (ellipsed is not False and i < len(alreadyMentionedTree) and line == alreadyMentionedTree[i]): ellipsed += 1 else: if ellipsed: yield " ... (%d frame%s repeated)\n" % ( ellipsed, "" if ellipsed == 1 else "s") ellipsed = False # marker for "given out" yield line if message: exc = self if self.message is None else self.message for line in traceback.format_exception_only(exc.__class__, exc): yield line if self.cause: yield ("Caused by: %d exception%s\n" % (len(self.cause), "" if len(self.cause) == 1 else "s")) for causePart in self.cause: if hasattr(causePart,"causeTree"): for line in causePart.causeTree(indentation, self.stack): yield re.sub(r'([^\n]*\n)', indentation + r'\1', line) else: for line in traceback.format_exception_only(causePart.__class__, causePart): yield re.sub(r'([^\n]*\n)', indentation + r'\1', line) if not message and not stack: yield ('No output. Specify message=True and/or stack=True \ to get output when calling this function.\n') def write(self, stream=None, indentation=' ', message=False, stack=False): """ Writes the error details to sys.stderr or a stream. """ stream = sys.stderr if stream is None else stream for line in self.causeTree(indentation, message=message, stack=stack): stream.write(line) def fetch(self, indentation=' ', message=False, stack=False): """ Fetches the error details and returns them as string. """ out = '' for line in self.causeTree(indentation, message=message, stack=stack): out += line return out class InputException(GlacierException): """ Exception that is raised when there is someting wrong with the user input. """ VaultNameError = 1 VaultDescriptionError = 2 def __init__(self, message, code=None, cause=None): """ Handles the exception. :param message: the error message. :type message: str :param code: the error code. :type code: :param cause: explanation on what caused the error. :type cause: str """ GlacierException.__init__(self, message, code=code, cause=cause) class ConnectionException(GlacierException): """ Exception that is raised when there is something wrong with the connection. """ GlacierConnectionError = 1 SdbConnectionError = 2 def __init__(self, message, code=None, cause=None): """ Handles the exception. :param message: the error message. :type message: str :param code: the error code. :type code: :param cause: explanation on what caused the error. :type cause: str """ GlacierException.__init__(self, message, code=code, cause=cause) class CommunicationException(GlacierException): """ Exception that is raised when there is something wrong in the communication with an external library like boto. """ def __init__(self, message, code=None, cause=None): """ Handles the exception. :param message: the error message. :type message: str :param code: the error code. :type code: :param cause: explanation on what caused the error. :type cause: str """ GlacierException.__init__(self, message, code=code, cause=cause) class ResponseException(GlacierException): """ Exception that is raised when there is an http response error. """ def __init__(self, message, code=None, cause=None): GlacierException.__init__(self, message, code=code, cause=cause) if __name__ == '__main__': class ChildrenException(Exception): def __init__(self, message): Exception.__init__(self, message) class ParentException(GlacierException): def __init__(self, message, cause=None): if cause: GlacierException.__init__(self, message, cause=cause) else: GlacierException.__init__(self, message) try: try: raise ChildrenException("parent") except ChildrenException, e: raise ParentException("children", cause=e) except ParentException, e: e.write(indentation='|| ')
mit
[ 646, 5190, 199, 646, 295, 199, 646, 984, 199, 646, 2050, 199, 199, 624, 199, 199, 1801, 538, 199, 7443, 701, 336, 2611, 285, 274, 26, 199, 199, 2765, 570, 3509, 314, 4890, 1233, 687, 6036, 379, 63, 1971, 14, 647, 12254, 314, 199, 705, 7252, 1233, 687, 598, 19976, 281, 4590, 14, 647, 12, 17266, 652, 370, 506, 1202, 315, 1163, 199, 3112, 2839, 486, 19976, 281, 1018, 5352, 465, 5521, 14, 199, 1801, 538, 199, 199, 624, 199, 533, 598, 19976, 281, 1726, 8, 1726, 304, 272, 408, 272, 1626, 3329, 402, 314, 6137, 13, 262, 2186, 1021, 12, 642, 10022, 272, 376, 4722, 7675, 4252, 1423, 12, 7791, 652, 465, 7675, 272, 2225, 370, 314, 1919, 1245, 14, 272, 2779, 9610, 314, 1125, 1245, 334, 4606, 402, 2556, 8350, 641, 314, 943, 272, 2166, 9, 436, 14933, 652, 641, 370, 282, 10948, 2166, 370, 2429, 14, 272, 28876, 6878, 652, 6127, 367, 314, 18932, 3016, 370, 1240, 367, 282, 272, 4890, 3464, 3307, 503, 2951, 282, 3486, 1125, 436, 7675, 1245, 14, 339, 3254, 26, 13743, 4503, 14, 272, 408, 339, 12539, 6012, 275, 791, 8405, 547, 356, 12792, 12, 263, 327, 11243, 5007, 1125, 14, 326, 283, 16283, 547, 3034, 356, 21572, 12, 257, 327, 25868, 1233, 14, 326, 283, 1944, 6579, 356, 19163, 12, 3322, 327, 17954, 28653, 949, 2058, 14, 326, 283, 39, 19976, 281, 20349, 356, 413, 12, 221, 327, 6855, 440, 4907, 370, 598, 19976, 281, 14, 20169, 283, 51, 697, 20349, 356, 499, 12, 258, 327, 6855, 440, 4907, 370, 5870, 2846, 14, 326, 283, 31542, 356, 650, 12, 3698, 327, 5817, 1004, 365, 3866, 14, 326, 283, 20229, 985, 547, 356, 841, 12, 260, 327, 6378, 12738, 536, 14, 326, 283, 5831, 547, 356, 959, 12, 755, 327, 6378, 6359, 1369, 14, 326, 283, 1304, 547, 356, 1227, 12, 4483, 327, 6378, 5802, 15, 6404, 15, 2423, 2870, 1627, 14, 326, 283, 10708, 547, 356, 1520, 12, 3322, 327, 6378, 4897, 1627, 14, 326, 283, 25212, 356, 1695, 12, 4519, 327, 4520, 4048, 370, 7664, 15, 14827, 282, 570, 14, 326, 283, 22279, 547, 356, 1749, 12, 3322, 327, 20980, 522, 12848, 282, 15193, 5802, 14, 326, 283, 1763, 17960, 356, 1616, 12, 4519, 327, 799, 4522, 5235, 365, 440, 10144, 5966, 14, 326, 283, 8696, 3250, 316, 547, 356, 4119, 12, 420, 327, 8944, 3250, 316, 440, 2808, 14, 326, 283, 51, 697, 27258, 5263, 356, 3144, 12, 327, 20980, 7664, 15, 14827, 5870, 2846, 666, 14, 326, 283, 4031, 22646, 356, 4944, 12, 327, 598, 19976, 281, 883, 440, 2342, 314, 5839, 2073, 14, 326, 283, 3364, 24637, 1726, 356, 4329, 12, 221, 327, 12009, 440, 10226, 14, 326, 283, 11950, 547, 356, 4114, 12, 260, 327, 13392, 8786, 376, 6359, 3405, 14, 326, 283, 51, 2709, 20349, 356, 21572, 12, 257, 327, 6855, 440, 4907, 370, 428, 2709, 326, 283, 51, 2709, 5688, 547, 356, 12792, 12, 221, 327, 20980, 543, 2897, 570, 326, 283, 51, 2709, 4720, 547, 356, 3933, 12, 258, 327, 20980, 543, 2368, 3032, 370, 428, 2709, 272, 789, 2116, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 12, 7675, 29, 403, 304, 267, 408, 267, 20297, 14, 3835, 458, 314, 1125, 14, 398, 520, 635, 1245, 26, 314, 1125, 1245, 14, 267, 520, 466, 1245, 26, 620, 267, 520, 635, 1233, 26, 314, 1125, 1233, 14, 267, 520, 466, 1233, 26, 620, 267, 520, 635, 7675, 26, 17531, 641, 4052, 18104, 314, 1125, 14, 267, 520, 466, 7675, 26, 620, 267, 408, 267, 291, 14, 2921, 275, 2050, 14, 5572, 8, 277, 855, 533, 4914, 354, 3368, 267, 291, 14, 2224, 600, 275, 291, 14, 3170, 6012, 59, 600, 61, 340, 1233, 315, 291, 14, 3170, 6012, 587, 22540, 267, 291, 14, 600, 275, 1233, 267, 340, 7675, 26, 288, 291, 14, 2921, 14, 705, 360, 3170, 26, 450, 83, 5956, 7675, 9, 288, 291, 14, 2651, 275, 7675, 340, 1228, 8, 2651, 12, 2008, 9, 587, 334, 2651, 4258, 288, 291, 14, 2340, 275, 5190, 14, 908, 63, 2340, 342, 4439, 18, 61, 398, 587, 26, 288, 291, 14, 2921, 14, 705, 360, 2493, 1125, 8920, 12, 24234, 2659, 288, 291, 14, 2651, 275, 6248, 953, 327, 13870, 4816, 1536, 282, 7675, 13, 2003, 1919, 14, 288, 327, 2372, 314, 3464, 3307, 367, 642, 1919, 14, 288, 291, 14, 2340, 275, 334, 355, 5190, 14, 908, 63, 2340, 342, 4439, 18, 61, 435, 355, 5190, 14, 908, 63, 5842, 8, 1274, 14, 2804, 63, 815, 3430, 18, 2459, 288, 327, 7167, 11871, 4691, 1159, 3661, 314, 2556, 365, 5139, 2337, 27, 8025, 1471, 5452, 288, 327, 258, 10296, 402, 642, 14, 10631, 291, 14, 1188, 275, 1245, 267, 291, 14, 2921, 14, 815, 8, 277, 14, 3535, 8, 1188, 29, 549, 430, 267, 291, 14, 2921, 14, 1757, 8, 277, 14, 3535, 8, 2340, 29, 549, 430, 267, 340, 291, 14, 2224, 600, 508, 22540, 26, 288, 291, 14, 2921, 14, 1757, 360, 5912, 1125, 1233, 26, 450, 83, 3530, 5, 1233, 9, 339, 327, 28099, 465, 282, 4306, 370, 1720, 664, 314, 3464, 3307, 436, 314, 7675, 272, 327, 5313, 734, 14, 272, 347, 7675, 3987, 8, 277, 12, 14311, 534, 221, 1656, 2575, 29230, 296, 379, 3987, 6034, 3464, 29, 797, 12, 1245, 29, 797, 304, 267, 408, 267, 1803, 282, 4890, 3464, 3123, 12, 376, 1125, 1245, 12, 503, 3865, 14, 267, 1803, 282, 5721, 340, 15564, 3464, 503, 1245, 787, 715, 14, 267, 408, 267, 340, 3464, 26, 288, 1995, 298, 15905, 334, 2786, 8058, 1240, 2061, 17211, 78, 2, 288, 16028, 939, 275, 378, 288, 367, 284, 12, 1004, 315, 3874, 8, 277, 14, 2340, 304, 355, 340, 334, 16514, 939, 365, 440, 756, 490, 436, 284, 665, 822, 8, 14039, 29230, 296, 379, 3987, 9, 490, 436, 1004, 508, 2575, 29230, 296, 379, 3987, 59, 73, 4682, 490, 16028, 939, 847, 413, 355, 587, 26, 490, 340, 16028, 939, 26, 717, 1995, 298, 221, 2263, 4366, 68, 2787, 5, 83, 10877, 2862, 78, 2, 450, 334, 1169, 16028, 939, 12, 1169, 3087, 340, 16028, 939 ]
[ 5190, 199, 646, 295, 199, 646, 984, 199, 646, 2050, 199, 199, 624, 199, 199, 1801, 538, 199, 7443, 701, 336, 2611, 285, 274, 26, 199, 199, 2765, 570, 3509, 314, 4890, 1233, 687, 6036, 379, 63, 1971, 14, 647, 12254, 314, 199, 705, 7252, 1233, 687, 598, 19976, 281, 4590, 14, 647, 12, 17266, 652, 370, 506, 1202, 315, 1163, 199, 3112, 2839, 486, 19976, 281, 1018, 5352, 465, 5521, 14, 199, 1801, 538, 199, 199, 624, 199, 533, 598, 19976, 281, 1726, 8, 1726, 304, 272, 408, 272, 1626, 3329, 402, 314, 6137, 13, 262, 2186, 1021, 12, 642, 10022, 272, 376, 4722, 7675, 4252, 1423, 12, 7791, 652, 465, 7675, 272, 2225, 370, 314, 1919, 1245, 14, 272, 2779, 9610, 314, 1125, 1245, 334, 4606, 402, 2556, 8350, 641, 314, 943, 272, 2166, 9, 436, 14933, 652, 641, 370, 282, 10948, 2166, 370, 2429, 14, 272, 28876, 6878, 652, 6127, 367, 314, 18932, 3016, 370, 1240, 367, 282, 272, 4890, 3464, 3307, 503, 2951, 282, 3486, 1125, 436, 7675, 1245, 14, 339, 3254, 26, 13743, 4503, 14, 272, 408, 339, 12539, 6012, 275, 791, 8405, 547, 356, 12792, 12, 263, 327, 11243, 5007, 1125, 14, 326, 283, 16283, 547, 3034, 356, 21572, 12, 257, 327, 25868, 1233, 14, 326, 283, 1944, 6579, 356, 19163, 12, 3322, 327, 17954, 28653, 949, 2058, 14, 326, 283, 39, 19976, 281, 20349, 356, 413, 12, 221, 327, 6855, 440, 4907, 370, 598, 19976, 281, 14, 20169, 283, 51, 697, 20349, 356, 499, 12, 258, 327, 6855, 440, 4907, 370, 5870, 2846, 14, 326, 283, 31542, 356, 650, 12, 3698, 327, 5817, 1004, 365, 3866, 14, 326, 283, 20229, 985, 547, 356, 841, 12, 260, 327, 6378, 12738, 536, 14, 326, 283, 5831, 547, 356, 959, 12, 755, 327, 6378, 6359, 1369, 14, 326, 283, 1304, 547, 356, 1227, 12, 4483, 327, 6378, 5802, 15, 6404, 15, 2423, 2870, 1627, 14, 326, 283, 10708, 547, 356, 1520, 12, 3322, 327, 6378, 4897, 1627, 14, 326, 283, 25212, 356, 1695, 12, 4519, 327, 4520, 4048, 370, 7664, 15, 14827, 282, 570, 14, 326, 283, 22279, 547, 356, 1749, 12, 3322, 327, 20980, 522, 12848, 282, 15193, 5802, 14, 326, 283, 1763, 17960, 356, 1616, 12, 4519, 327, 799, 4522, 5235, 365, 440, 10144, 5966, 14, 326, 283, 8696, 3250, 316, 547, 356, 4119, 12, 420, 327, 8944, 3250, 316, 440, 2808, 14, 326, 283, 51, 697, 27258, 5263, 356, 3144, 12, 327, 20980, 7664, 15, 14827, 5870, 2846, 666, 14, 326, 283, 4031, 22646, 356, 4944, 12, 327, 598, 19976, 281, 883, 440, 2342, 314, 5839, 2073, 14, 326, 283, 3364, 24637, 1726, 356, 4329, 12, 221, 327, 12009, 440, 10226, 14, 326, 283, 11950, 547, 356, 4114, 12, 260, 327, 13392, 8786, 376, 6359, 3405, 14, 326, 283, 51, 2709, 20349, 356, 21572, 12, 257, 327, 6855, 440, 4907, 370, 428, 2709, 326, 283, 51, 2709, 5688, 547, 356, 12792, 12, 221, 327, 20980, 543, 2897, 570, 326, 283, 51, 2709, 4720, 547, 356, 3933, 12, 258, 327, 20980, 543, 2368, 3032, 370, 428, 2709, 272, 789, 2116, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 12, 7675, 29, 403, 304, 267, 408, 267, 20297, 14, 3835, 458, 314, 1125, 14, 398, 520, 635, 1245, 26, 314, 1125, 1245, 14, 267, 520, 466, 1245, 26, 620, 267, 520, 635, 1233, 26, 314, 1125, 1233, 14, 267, 520, 466, 1233, 26, 620, 267, 520, 635, 7675, 26, 17531, 641, 4052, 18104, 314, 1125, 14, 267, 520, 466, 7675, 26, 620, 267, 408, 267, 291, 14, 2921, 275, 2050, 14, 5572, 8, 277, 855, 533, 4914, 354, 3368, 267, 291, 14, 2224, 600, 275, 291, 14, 3170, 6012, 59, 600, 61, 340, 1233, 315, 291, 14, 3170, 6012, 587, 22540, 267, 291, 14, 600, 275, 1233, 267, 340, 7675, 26, 288, 291, 14, 2921, 14, 705, 360, 3170, 26, 450, 83, 5956, 7675, 9, 288, 291, 14, 2651, 275, 7675, 340, 1228, 8, 2651, 12, 2008, 9, 587, 334, 2651, 4258, 288, 291, 14, 2340, 275, 5190, 14, 908, 63, 2340, 342, 4439, 18, 61, 398, 587, 26, 288, 291, 14, 2921, 14, 705, 360, 2493, 1125, 8920, 12, 24234, 2659, 288, 291, 14, 2651, 275, 6248, 953, 327, 13870, 4816, 1536, 282, 7675, 13, 2003, 1919, 14, 288, 327, 2372, 314, 3464, 3307, 367, 642, 1919, 14, 288, 291, 14, 2340, 275, 334, 355, 5190, 14, 908, 63, 2340, 342, 4439, 18, 61, 435, 355, 5190, 14, 908, 63, 5842, 8, 1274, 14, 2804, 63, 815, 3430, 18, 2459, 288, 327, 7167, 11871, 4691, 1159, 3661, 314, 2556, 365, 5139, 2337, 27, 8025, 1471, 5452, 288, 327, 258, 10296, 402, 642, 14, 10631, 291, 14, 1188, 275, 1245, 267, 291, 14, 2921, 14, 815, 8, 277, 14, 3535, 8, 1188, 29, 549, 430, 267, 291, 14, 2921, 14, 1757, 8, 277, 14, 3535, 8, 2340, 29, 549, 430, 267, 340, 291, 14, 2224, 600, 508, 22540, 26, 288, 291, 14, 2921, 14, 1757, 360, 5912, 1125, 1233, 26, 450, 83, 3530, 5, 1233, 9, 339, 327, 28099, 465, 282, 4306, 370, 1720, 664, 314, 3464, 3307, 436, 314, 7675, 272, 327, 5313, 734, 14, 272, 347, 7675, 3987, 8, 277, 12, 14311, 534, 221, 1656, 2575, 29230, 296, 379, 3987, 6034, 3464, 29, 797, 12, 1245, 29, 797, 304, 267, 408, 267, 1803, 282, 4890, 3464, 3123, 12, 376, 1125, 1245, 12, 503, 3865, 14, 267, 1803, 282, 5721, 340, 15564, 3464, 503, 1245, 787, 715, 14, 267, 408, 267, 340, 3464, 26, 288, 1995, 298, 15905, 334, 2786, 8058, 1240, 2061, 17211, 78, 2, 288, 16028, 939, 275, 378, 288, 367, 284, 12, 1004, 315, 3874, 8, 277, 14, 2340, 304, 355, 340, 334, 16514, 939, 365, 440, 756, 490, 436, 284, 665, 822, 8, 14039, 29230, 296, 379, 3987, 9, 490, 436, 1004, 508, 2575, 29230, 296, 379, 3987, 59, 73, 4682, 490, 16028, 939, 847, 413, 355, 587, 26, 490, 340, 16028, 939, 26, 717, 1995, 298, 221, 2263, 4366, 68, 2787, 5, 83, 10877, 2862, 78, 2, 450, 334, 1169, 16028, 939, 12, 1169, 3087, 340, 16028, 939, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dongguangming/youtube-dl
youtube_dl/extractor/vgtv.py
102
7096
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, ) class VGTVIE(InfoExtractor): IE_DESC = 'VGTV and BTTV' _VALID_URL = r'''(?x) (?: vgtv:| http://(?:www\.)? ) (?P<host>vgtv|bt) (?: :| \.no/(?:tv/)?\#!/(?:video|live)/ ) (?P<id>[0-9]+) ''' _TESTS = [ { # streamType: vod 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu', 'md5': 'b8be7a234cebb840c0d512c78013e02f', 'info_dict': { 'id': '84196', 'ext': 'mp4', 'title': 'Hevnen er søt: Episode 10 - Abu', 'description': 'md5:e25e4badb5f544b04341e14abdc72234', 'thumbnail': 're:^https?://.*\.jpg', 'duration': 648.000, 'timestamp': 1404626400, 'upload_date': '20140706', 'view_count': int, }, }, { # streamType: wasLive 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen', 'info_dict': { 'id': '100764', 'ext': 'flv', 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen', 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3', 'thumbnail': 're:^https?://.*\.jpg', 'duration': 9103.0, 'timestamp': 1410113864, 'upload_date': '20140907', 'view_count': int, }, 'params': { # m3u8 download 'skip_download': True, }, }, { # streamType: live 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla', 'info_dict': { 'id': '113063', 'ext': 'flv', 'title': 're:^DIREKTE: V75 fra Solvalla [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'description': 'md5:b3743425765355855f88e096acc93231', 'thumbnail': 're:^https?://.*\.jpg', 'duration': 0, 'timestamp': 1432975582, 'upload_date': '20150530', 'view_count': int, }, 'params': { # m3u8 download 'skip_download': True, }, }, { 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien', 'only_matching': True, }, ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') host = mobj.group('host') HOST_WEBSITES = { 'vgtv': 'vgtv', 'bt': 'bttv', } data = self._download_json( 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website' % (host, video_id, HOST_WEBSITES[host]), video_id, 'Downloading media JSON') if data.get('status') == 'inactive': raise ExtractorError( 'Video %s is no longer available' % video_id, expected=True) streams = data['streamUrls'] stream_type = data.get('streamType') formats = [] hls_url = streams.get('hls') if hls_url: formats.extend(self._extract_m3u8_formats( hls_url, video_id, 'mp4', m3u8_id='hls')) hds_url = streams.get('hds') # wasLive hds are always 404 if hds_url and stream_type != 'wasLive': formats.extend(self._extract_f4m_formats( hds_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', video_id, f4m_id='hds')) mp4_url = streams.get('mp4') if mp4_url: _url = hls_url or hds_url MP4_URL_TEMPLATE = '%s/%%s.%s' % (mp4_url.rpartition('/')[0], mp4_url.rpartition('.')[-1]) for mp4_format in _url.split(','): m = re.search('(?P<width>\d+)_(?P<height>\d+)_(?P<vbr>\d+)', mp4_format) if not m: continue width = int(m.group('width')) height = int(m.group('height')) vbr = int(m.group('vbr')) formats.append({ 'url': MP4_URL_TEMPLATE % mp4_format, 'format_id': 'mp4-%s' % vbr, 'width': width, 'height': height, 'vbr': vbr, 'preference': 1, }) self._sort_formats(formats) return { 'id': video_id, 'title': self._live_title(data['title']), 'description': data['description'], 'thumbnail': data['images']['main'] + '?t[]=900x506q80', 'timestamp': data['published'], 'duration': float_or_none(data['duration'], 1000), 'view_count': data['displays'], 'formats': formats, 'is_live': True if stream_type == 'live' else False, } class BTArticleIE(InfoExtractor): IE_NAME = 'bt:article' IE_DESC = 'Bergens Tidende Articles' _VALID_URL = 'http://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html' _TEST = { 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html', 'md5': 'd055e8ee918ef2844745fcfd1a4175fb', 'info_dict': { 'id': '23199', 'ext': 'mp4', 'title': 'Alrekstad internat', 'description': 'md5:dc81a9056c874fedb62fc48a300dac58', 'thumbnail': 're:^https?://.*\.jpg', 'duration': 191, 'timestamp': 1289991323, 'upload_date': '20101117', 'view_count': int, }, } def _real_extract(self, url): webpage = self._download_webpage(url, self._match_id(url)) video_id = self._search_regex( r'SVP\.Player\.load\(\s*(\d+)', webpage, 'video id') return self.url_result('vgtv:bt:%s' % video_id, 'VGTV') class BTVestlendingenIE(InfoExtractor): IE_NAME = 'bt:vestlendingen' IE_DESC = 'Bergens Tidende - Vestlendingen' _VALID_URL = 'http://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)' _TEST = { 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588', 'md5': 'd7d17e3337dc80de6d3a540aefbe441b', 'info_dict': { 'id': '86588', 'ext': 'mov', 'title': 'Otto Wollertsen', 'description': 'Vestlendingen Otto Fredrik Wollertsen', 'timestamp': 1430473209, 'upload_date': '20150501', }, } def _real_extract(self, url): return self.url_result('xstream:btno:%s' % self._match_id(url), 'Xstream')
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 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, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 199, 9, 421, 199, 533, 812, 8391, 54, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 54, 8391, 54, 436, 699, 1481, 54, 7, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 490, 16697, 717, 373, 3308, 86, 26, 92, 717, 1455, 921, 5169, 1544, 20316, 490, 776, 490, 7558, 48, 28, 1102, 30, 86, 3308, 86, 92, 13061, 9, 490, 16697, 717, 520, 92, 717, 971, 14, 889, 32576, 6993, 15, 5547, 60, 3381, 5169, 3722, 92, 6442, 2447, 490, 776, 490, 7558, 48, 28, 344, 9514, 16, 13, 25, 11896, 490, 1449, 272, 485, 7569, 275, 359, 267, 469, 288, 327, 2547, 804, 26, 373, 364, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 3722, 15, 1349, 10800, 15, 426, 6002, 287, 13, 281, 13, 1152, 386, 13, 9544, 13, 709, 13, 371, 85, 297, 288, 283, 1064, 21, 356, 283, 66, 24, 1235, 23, 65, 5533, 301, 2501, 13462, 67, 16, 68, 7736, 67, 2277, 13264, 69, 996, 70, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1349, 10800, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 1966, 6002, 287, 9266, 308, 31087, 84, 26, 27255, 6045, 1616, 446, 437, 464, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 69, 821, 69, 20, 4087, 66, 21, 70, 16298, 66, 966, 15590, 69, 1079, 371, 3833, 24109, 1082, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 5049, 24, 14, 1493, 12, 355, 283, 3954, 356, 4329, 966, 2789, 20543, 12, 355, 283, 5064, 63, 602, 356, 283, 7280, 1780, 1690, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 267, 1660, 267, 469, 288, 327, 2547, 804, 26, 1990, 17458, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 6442, 15, 1960, 29871, 15, 26740, 502, 75, 13, 86, 3308, 86, 13, 545, 352, 836, 13, 5633, 13, 75, 637, 1903, 332, 316, 287, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1960, 29871, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 1938, 4189, 7872, 26, 812, 8391, 54, 289, 31087, 76, 836, 26512, 13, 75, 637, 1903, 332, 316, 287, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 7332, 18, 68, 25, 67, 16, 3833, 18, 23425, 2942, 65, 31830, 66, 6683, 1355, 65, 23, 68, 20, 68, 19, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 1749, 8845, 14, 16, 12, 355, 283, 3954, 356, 413, 2953, 614, 8527, 772, 12, 355, 283, 5064, 63, 602, 356, 283, 7280, 1643, 1780, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 288, 283, 1162, 356, 469, 355, 327, 333, 19, 85, 24, 5235, 355, 283, 2759, 63, 4249, 356, 715, 12, 288, 1660, 267, 1660, 267, 469, 288, 327, 2547, 804, 26, 12166, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 6442, 15, 845, 1216, 2766, 15, 328, 264, 75, 266, 13, 86, 2194, 13, 21844, 13, 7873, 637, 416, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 845, 1216, 2766, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 264, 23497, 1914, 907, 43, 3727, 26, 812, 2194, 28213, 17991, 637, 416, 359, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 93, 359, 16, 13, 25, 8194, 18, 93, 7766, 16, 13, 25, 8194, 18, 19204, 355, 283, 1802, 356, 283, 1064, 21, 26, 66, 9880, 1082, 821, 2114, 2481, 1229, 12593, 70, 1299, 69, 9211, 5470, 27251, 2192, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 378, 12, 355, 283, 3954, 356, 4329, 708, 2576, 1229, 2564, 12, 355, 283, 5064, 63, 602, 356, 283, 1797, 13938, 1216, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 288, 283, 1162, 356, 469, 355, 327, 333, 19, 85, 24, 5235, 355, 283, 2759, 63, 4249, 356, 715, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 13061, 14, 889, 15, 6993, 15, 3381, 3722, 15, 1960, 7991, 15, 6505, 2983, 13, 9886, 266, 13, 281, 13, 509, 1339, 74, 352, 552, 13, 387, 65, 13, 17, 13, 3015, 374, 74, 265, 13, 974, 13, 69, 5333, 261, 322, 287, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 272, 1622, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 267, 1591, 275, 14208, 14, 923, 360, 1102, 358, 398, 25741, 63, 5408, 11087, 649, 654, 275, 469, 288, 283, 86, 3308, 86, 356, 283, 86, 3308, 86, 297, 288, 283, 13061, 356, 283, 66, 6215, 86, 297, 267, 789, 398, 666, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 2772, 80, 14, 10929, 14, 889, 15, 2772, 80, 15, 1246, 15, 86, 17, 3149, 83, 15, 12186, 3149, 83, 31, 571, 985, 2458, 83, 13, 7360, 7, 288, 450, 334, 1102, 12, 3991, 63, 344, 12, 25741, 63, 5408, 11087, 649, 654, 59, 1102, 2522, 288, 3991, 63, 344, 12, 283, 18085, 5898, 4840, 358, 398, 340, 666, 14, 362, 360, 1205, 358, 508, 283, 16856, 356, 288, 746, 19783, 8, 355, 283, 9166, 450, 83, 365, 949, 8088, 2808, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 13788, 275, 666, 459, 1745, 21867, 478, 418, 267, 2547, 63, 466, 275, 666, 14, 362 ]
[ 2803, 26, 2774, 13, 24, 199, 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, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 199, 9, 421, 199, 533, 812, 8391, 54, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 54, 8391, 54, 436, 699, 1481, 54, 7, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 490, 16697, 717, 373, 3308, 86, 26, 92, 717, 1455, 921, 5169, 1544, 20316, 490, 776, 490, 7558, 48, 28, 1102, 30, 86, 3308, 86, 92, 13061, 9, 490, 16697, 717, 520, 92, 717, 971, 14, 889, 32576, 6993, 15, 5547, 60, 3381, 5169, 3722, 92, 6442, 2447, 490, 776, 490, 7558, 48, 28, 344, 9514, 16, 13, 25, 11896, 490, 1449, 272, 485, 7569, 275, 359, 267, 469, 288, 327, 2547, 804, 26, 373, 364, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 3722, 15, 1349, 10800, 15, 426, 6002, 287, 13, 281, 13, 1152, 386, 13, 9544, 13, 709, 13, 371, 85, 297, 288, 283, 1064, 21, 356, 283, 66, 24, 1235, 23, 65, 5533, 301, 2501, 13462, 67, 16, 68, 7736, 67, 2277, 13264, 69, 996, 70, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1349, 10800, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 1966, 6002, 287, 9266, 308, 31087, 84, 26, 27255, 6045, 1616, 446, 437, 464, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 69, 821, 69, 20, 4087, 66, 21, 70, 16298, 66, 966, 15590, 69, 1079, 371, 3833, 24109, 1082, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 5049, 24, 14, 1493, 12, 355, 283, 3954, 356, 4329, 966, 2789, 20543, 12, 355, 283, 5064, 63, 602, 356, 283, 7280, 1780, 1690, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 267, 1660, 267, 469, 288, 327, 2547, 804, 26, 1990, 17458, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 6442, 15, 1960, 29871, 15, 26740, 502, 75, 13, 86, 3308, 86, 13, 545, 352, 836, 13, 5633, 13, 75, 637, 1903, 332, 316, 287, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1960, 29871, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 1938, 4189, 7872, 26, 812, 8391, 54, 289, 31087, 76, 836, 26512, 13, 75, 637, 1903, 332, 316, 287, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 7332, 18, 68, 25, 67, 16, 3833, 18, 23425, 2942, 65, 31830, 66, 6683, 1355, 65, 23, 68, 20, 68, 19, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 1749, 8845, 14, 16, 12, 355, 283, 3954, 356, 413, 2953, 614, 8527, 772, 12, 355, 283, 5064, 63, 602, 356, 283, 7280, 1643, 1780, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 288, 283, 1162, 356, 469, 355, 327, 333, 19, 85, 24, 5235, 355, 283, 2759, 63, 4249, 356, 715, 12, 288, 1660, 267, 1660, 267, 469, 288, 327, 2547, 804, 26, 12166, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 86, 3308, 86, 14, 889, 15, 3381, 6442, 15, 845, 1216, 2766, 15, 328, 264, 75, 266, 13, 86, 2194, 13, 21844, 13, 7873, 637, 416, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 845, 1216, 2766, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 264, 23497, 1914, 907, 43, 3727, 26, 812, 2194, 28213, 17991, 637, 416, 359, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 93, 359, 16, 13, 25, 8194, 18, 93, 7766, 16, 13, 25, 8194, 18, 19204, 355, 283, 1802, 356, 283, 1064, 21, 26, 66, 9880, 1082, 821, 2114, 2481, 1229, 12593, 70, 1299, 69, 9211, 5470, 27251, 2192, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 355, 283, 5553, 356, 378, 12, 355, 283, 3954, 356, 4329, 708, 2576, 1229, 2564, 12, 355, 283, 5064, 63, 602, 356, 283, 1797, 13938, 1216, 297, 355, 283, 1345, 63, 835, 356, 1109, 12, 288, 1660, 288, 283, 1162, 356, 469, 355, 327, 333, 19, 85, 24, 5235, 355, 283, 2759, 63, 4249, 356, 715, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 13061, 14, 889, 15, 6993, 15, 3381, 3722, 15, 1960, 7991, 15, 6505, 2983, 13, 9886, 266, 13, 281, 13, 509, 1339, 74, 352, 552, 13, 387, 65, 13, 17, 13, 3015, 374, 74, 265, 13, 974, 13, 69, 5333, 261, 322, 287, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 272, 1622, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 267, 1591, 275, 14208, 14, 923, 360, 1102, 358, 398, 25741, 63, 5408, 11087, 649, 654, 275, 469, 288, 283, 86, 3308, 86, 356, 283, 86, 3308, 86, 297, 288, 283, 13061, 356, 283, 66, 6215, 86, 297, 267, 789, 398, 666, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 2772, 80, 14, 10929, 14, 889, 15, 2772, 80, 15, 1246, 15, 86, 17, 3149, 83, 15, 12186, 3149, 83, 31, 571, 985, 2458, 83, 13, 7360, 7, 288, 450, 334, 1102, 12, 3991, 63, 344, 12, 25741, 63, 5408, 11087, 649, 654, 59, 1102, 2522, 288, 3991, 63, 344, 12, 283, 18085, 5898, 4840, 358, 398, 340, 666, 14, 362, 360, 1205, 358, 508, 283, 16856, 356, 288, 746, 19783, 8, 355, 283, 9166, 450, 83, 365, 949, 8088, 2808, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 13788, 275, 666, 459, 1745, 21867, 478, 418, 267, 2547, 63, 466, 275, 666, 14, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 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 copy import mock from rally.plugins.openstack.context.ec2 import servers from tests.unit import fakes from tests.unit import test CTX = "rally.plugins.openstack.context.ec2" SCN = "rally.plugins.openstack.scenarios" TYP = "rally.task.types" class EC2ServerGeneratorTestCase(test.TestCase): def _gen_tenants_and_users(self, tenants_count, users_per_tenant): tenants = {} for id in range(tenants_count): tenants[str(id)] = dict(name=str(id)) users = [] for tenant_id in tenants.keys(): for i in range(users_per_tenant): users.append({"id": i, "tenant_id": tenant_id, "endpoint": "endpoint"}) return tenants, users def _get_context(self, users, tenants): return { "config": { "users": { "tenants": 2, "users_per_tenant": 5, "concurrent": 10}, "ec2_servers": { "servers_per_tenant": 5, "image": {"name": "foo_image"}, "flavor": {"name": "foo_flavor"} } }, "admin": {"endpoint": mock.MagicMock()}, "task": mock.MagicMock(), "users": users, "tenants": tenants } @mock.patch("%s.ec2.utils.EC2Scenario._boot_servers" % SCN, return_value=[fakes.FakeServer(id=str(i)) for i in range(5)]) @mock.patch("%s.EC2ImageResourceType.transform" % TYP, return_value=mock.MagicMock()) @mock.patch("%s.servers.osclients" % CTX, return_value=fakes.FakeClients()) def test_setup(self, mock_osclients, mock_ec2_image_resource_type_transform, mock_ec2_scenario__boot_servers): tenants_count = 2 users_per_tenant = 5 servers_per_tenant = 5 tenants, users = self._gen_tenants_and_users(tenants_count, users_per_tenant) real_context = self._get_context(users, tenants) new_context = copy.deepcopy(real_context) for tenant_id in new_context["tenants"]: new_context["tenants"][tenant_id].setdefault("ec2_servers", []) for i in range(servers_per_tenant): new_context["tenants"][tenant_id]["ec2_servers"].append(str(i)) servers_ctx = servers.EC2ServerGenerator(real_context) servers_ctx.setup() self.assertEqual(new_context, servers_ctx.context) @mock.patch("%s.servers.osclients" % CTX) @mock.patch("%s.servers.resource_manager.cleanup" % CTX) def test_cleanup(self, mock_cleanup, mock_osclients): tenants_count = 2 users_per_tenant = 5 servers_per_tenant = 5 tenants, users = self._gen_tenants_and_users(tenants_count, users_per_tenant) for tenant_id in tenants.keys(): tenants[tenant_id].setdefault("ec2_servers", []) for i in range(servers_per_tenant): tenants[tenant_id]["ec2_servers"].append(str(i)) context = self._get_context(users, tenants) servers_ctx = servers.EC2ServerGenerator(context) servers_ctx.cleanup() mock_cleanup.assert_called_once_with(names=["ec2.servers"], users=context["users"])
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, 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, 1331, 199, 199, 646, 1683, 199, 199, 504, 519, 1183, 14, 5265, 14, 8512, 14, 1100, 14, 825, 18, 492, 8037, 199, 504, 2295, 14, 3248, 492, 14063, 199, 504, 2295, 14, 3248, 492, 511, 199, 199, 21524, 275, 298, 82, 1183, 14, 5265, 14, 8512, 14, 1100, 14, 825, 18, 2, 199, 5153, 46, 275, 298, 82, 1183, 14, 5265, 14, 8512, 14, 32225, 2, 199, 7034, 275, 298, 82, 1183, 14, 1765, 14, 1313, 2, 421, 199, 533, 15352, 18, 3120, 7599, 1746, 8, 396, 14, 1746, 304, 339, 347, 485, 2268, 63, 25021, 63, 460, 63, 3707, 8, 277, 12, 16685, 2285, 63, 835, 12, 4390, 63, 529, 63, 4647, 304, 267, 16685, 2285, 275, 1052, 267, 367, 1305, 315, 1425, 8, 25021, 63, 835, 304, 288, 16685, 2285, 59, 495, 8, 344, 1874, 275, 1211, 8, 354, 29, 495, 8, 344, 430, 398, 4390, 275, 942, 267, 367, 8261, 63, 344, 315, 16685, 2285, 14, 1612, 837, 288, 367, 284, 315, 1425, 8, 3707, 63, 529, 63, 4647, 304, 355, 4390, 14, 740, 6333, 344, 582, 284, 12, 298, 4647, 63, 344, 582, 8261, 63, 344, 12, 2892, 298, 6520, 582, 298, 6520, 5984, 267, 372, 16685, 2285, 12, 4390, 339, 347, 485, 362, 63, 1100, 8, 277, 12, 4390, 12, 16685, 2285, 304, 267, 372, 469, 288, 298, 888, 582, 469, 355, 298, 3707, 582, 469, 490, 298, 25021, 582, 499, 12, 490, 298, 3707, 63, 529, 63, 4647, 582, 959, 12, 490, 298, 27237, 582, 1616, 1386, 355, 298, 825, 18, 63, 5871, 582, 469, 490, 298, 5871, 63, 529, 63, 4647, 582, 959, 12, 490, 298, 1569, 582, 2420, 354, 582, 298, 1421, 63, 1569, 6018, 490, 298, 6081, 582, 2420, 354, 582, 298, 1421, 63, 6081, 3570, 355, 789, 288, 1660, 288, 298, 2113, 582, 2420, 6520, 582, 1683, 14, 11988, 342, 1386, 288, 298, 1765, 582, 1683, 14, 11988, 1062, 288, 298, 3707, 582, 4390, 12, 288, 298, 25021, 582, 16685, 2285, 267, 789, 339, 768, 1805, 14, 2068, 3647, 83, 14, 825, 18, 14, 1208, 14, 4220, 18, 12327, 6936, 423, 4930, 63, 5871, 2, 450, 12075, 46, 12, 355, 372, 63, 585, 1524, 27443, 14, 8249, 3120, 8, 344, 29, 495, 8, 73, 430, 367, 284, 315, 1425, 8, 21, 3948, 272, 768, 1805, 14, 2068, 3647, 83, 14, 4220, 18, 3491, 4031, 804, 14, 4711, 2, 450, 377, 7431, 12, 355, 372, 63, 585, 29, 1805, 14, 11988, 1012, 272, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 26737, 864, 83, 2, 450, 445, 10051, 12, 372, 63, 585, 29, 27443, 14, 8249, 3041, 83, 1012, 272, 347, 511, 63, 2758, 8, 277, 12, 1683, 63, 26737, 864, 83, 12, 673, 1683, 63, 825, 18, 63, 1569, 63, 1927, 63, 466, 63, 4711, 12, 673, 1683, 63, 825, 18, 63, 13444, 363, 4930, 63, 5871, 304, 398, 16685, 2285, 63, 835, 275, 499, 267, 4390, 63, 529, 63, 4647, 275, 959, 267, 8037, 63, 529, 63, 4647, 275, 959, 398, 16685, 2285, 12, 4390, 275, 291, 423, 2268, 63, 25021, 63, 460, 63, 3707, 8, 25021, 63, 835, 12, 9349, 4390, 63, 529, 63, 4647, 9, 398, 3363, 63, 1100, 275, 291, 423, 362, 63, 1100, 8, 3707, 12, 16685, 2285, 9, 398, 892, 63, 1100, 275, 1331, 14, 8293, 8, 3093, 63, 1100, 9, 267, 367, 8261, 63, 344, 315, 892, 63, 1100, 905, 25021, 6229, 288, 892, 63, 1100, 905, 25021, 9210, 4647, 63, 344, 1055, 5486, 480, 825, 18, 63, 5871, 401, 3073, 288, 367, 284, 315, 1425, 8, 5871, 63, 529, 63, 4647, 304, 355, 892, 63, 1100, 905, 25021, 9210, 4647, 63, 344, 7541, 825, 18, 63, 5871, 4140, 740, 8, 495, 8, 73, 430, 398, 8037, 63, 3799, 275, 8037, 14, 4220, 18, 3120, 7599, 8, 3093, 63, 1100, 9, 267, 8037, 63, 3799, 14, 2758, 342, 267, 291, 14, 629, 8, 1222, 63, 1100, 12, 8037, 63, 3799, 14, 1100, 9, 339, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 26737, 864, 83, 2, 450, 445, 10051, 9, 272, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 1927, 63, 2609, 14, 7661, 2, 450, 445, 10051, 9, 272, 347, 511, 63, 7661, 8, 277, 12, 1683, 63, 7661, 12, 1683, 63, 26737, 864, 83, 304, 398, 16685, 2285, 63, 835, 275, 499, 267, 4390, 63, 529, 63, 4647, 275, 959, 267, 8037, 63, 529, 63, 4647, 275, 959, 398, 16685, 2285, 12, 4390, 275, 291, 423, 2268, 63, 25021, 63, 460, 63, 3707, 8, 25021, 63, 835, 12, 9349, 4390, 63, 529, 63, 4647, 9, 267, 367, 8261, 63, 344, 315, 16685, 2285, 14, 1612, 837, 288, 16685, 2285, 59, 4647, 63, 344, 1055, 5486, 480, 825, 18, 63, 5871, 401, 3073, 288, 367, 284, 315, 1425, 8, 5871, 63, 529, 63, 4647, 304, 355, 16685, 2285, 59, 4647, 63, 344, 7541, 825, 18, 63, 5871, 4140, 740, 8, 495, 8, 73, 430, 398, 1067, 275, 291, 423, 362, 63, 1100, 8, 3707, 12, 16685, 2285, 9, 398, 8037, 63, 3799, 275, 8037, 14, 4220, 18, 3120, 7599, 8, 1100, 9, 267, 8037, 63, 3799, 14, 7661, 342, 398, 1683, 63, 7661, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1247, 6270, 825, 18, 14, 5871, 2255, 6163, 4390, 29, 1100, 905, 3707 ]
[ 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, 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, 1331, 199, 199, 646, 1683, 199, 199, 504, 519, 1183, 14, 5265, 14, 8512, 14, 1100, 14, 825, 18, 492, 8037, 199, 504, 2295, 14, 3248, 492, 14063, 199, 504, 2295, 14, 3248, 492, 511, 199, 199, 21524, 275, 298, 82, 1183, 14, 5265, 14, 8512, 14, 1100, 14, 825, 18, 2, 199, 5153, 46, 275, 298, 82, 1183, 14, 5265, 14, 8512, 14, 32225, 2, 199, 7034, 275, 298, 82, 1183, 14, 1765, 14, 1313, 2, 421, 199, 533, 15352, 18, 3120, 7599, 1746, 8, 396, 14, 1746, 304, 339, 347, 485, 2268, 63, 25021, 63, 460, 63, 3707, 8, 277, 12, 16685, 2285, 63, 835, 12, 4390, 63, 529, 63, 4647, 304, 267, 16685, 2285, 275, 1052, 267, 367, 1305, 315, 1425, 8, 25021, 63, 835, 304, 288, 16685, 2285, 59, 495, 8, 344, 1874, 275, 1211, 8, 354, 29, 495, 8, 344, 430, 398, 4390, 275, 942, 267, 367, 8261, 63, 344, 315, 16685, 2285, 14, 1612, 837, 288, 367, 284, 315, 1425, 8, 3707, 63, 529, 63, 4647, 304, 355, 4390, 14, 740, 6333, 344, 582, 284, 12, 298, 4647, 63, 344, 582, 8261, 63, 344, 12, 2892, 298, 6520, 582, 298, 6520, 5984, 267, 372, 16685, 2285, 12, 4390, 339, 347, 485, 362, 63, 1100, 8, 277, 12, 4390, 12, 16685, 2285, 304, 267, 372, 469, 288, 298, 888, 582, 469, 355, 298, 3707, 582, 469, 490, 298, 25021, 582, 499, 12, 490, 298, 3707, 63, 529, 63, 4647, 582, 959, 12, 490, 298, 27237, 582, 1616, 1386, 355, 298, 825, 18, 63, 5871, 582, 469, 490, 298, 5871, 63, 529, 63, 4647, 582, 959, 12, 490, 298, 1569, 582, 2420, 354, 582, 298, 1421, 63, 1569, 6018, 490, 298, 6081, 582, 2420, 354, 582, 298, 1421, 63, 6081, 3570, 355, 789, 288, 1660, 288, 298, 2113, 582, 2420, 6520, 582, 1683, 14, 11988, 342, 1386, 288, 298, 1765, 582, 1683, 14, 11988, 1062, 288, 298, 3707, 582, 4390, 12, 288, 298, 25021, 582, 16685, 2285, 267, 789, 339, 768, 1805, 14, 2068, 3647, 83, 14, 825, 18, 14, 1208, 14, 4220, 18, 12327, 6936, 423, 4930, 63, 5871, 2, 450, 12075, 46, 12, 355, 372, 63, 585, 1524, 27443, 14, 8249, 3120, 8, 344, 29, 495, 8, 73, 430, 367, 284, 315, 1425, 8, 21, 3948, 272, 768, 1805, 14, 2068, 3647, 83, 14, 4220, 18, 3491, 4031, 804, 14, 4711, 2, 450, 377, 7431, 12, 355, 372, 63, 585, 29, 1805, 14, 11988, 1012, 272, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 26737, 864, 83, 2, 450, 445, 10051, 12, 372, 63, 585, 29, 27443, 14, 8249, 3041, 83, 1012, 272, 347, 511, 63, 2758, 8, 277, 12, 1683, 63, 26737, 864, 83, 12, 673, 1683, 63, 825, 18, 63, 1569, 63, 1927, 63, 466, 63, 4711, 12, 673, 1683, 63, 825, 18, 63, 13444, 363, 4930, 63, 5871, 304, 398, 16685, 2285, 63, 835, 275, 499, 267, 4390, 63, 529, 63, 4647, 275, 959, 267, 8037, 63, 529, 63, 4647, 275, 959, 398, 16685, 2285, 12, 4390, 275, 291, 423, 2268, 63, 25021, 63, 460, 63, 3707, 8, 25021, 63, 835, 12, 9349, 4390, 63, 529, 63, 4647, 9, 398, 3363, 63, 1100, 275, 291, 423, 362, 63, 1100, 8, 3707, 12, 16685, 2285, 9, 398, 892, 63, 1100, 275, 1331, 14, 8293, 8, 3093, 63, 1100, 9, 267, 367, 8261, 63, 344, 315, 892, 63, 1100, 905, 25021, 6229, 288, 892, 63, 1100, 905, 25021, 9210, 4647, 63, 344, 1055, 5486, 480, 825, 18, 63, 5871, 401, 3073, 288, 367, 284, 315, 1425, 8, 5871, 63, 529, 63, 4647, 304, 355, 892, 63, 1100, 905, 25021, 9210, 4647, 63, 344, 7541, 825, 18, 63, 5871, 4140, 740, 8, 495, 8, 73, 430, 398, 8037, 63, 3799, 275, 8037, 14, 4220, 18, 3120, 7599, 8, 3093, 63, 1100, 9, 267, 8037, 63, 3799, 14, 2758, 342, 267, 291, 14, 629, 8, 1222, 63, 1100, 12, 8037, 63, 3799, 14, 1100, 9, 339, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 26737, 864, 83, 2, 450, 445, 10051, 9, 272, 768, 1805, 14, 2068, 3647, 83, 14, 5871, 14, 1927, 63, 2609, 14, 7661, 2, 450, 445, 10051, 9, 272, 347, 511, 63, 7661, 8, 277, 12, 1683, 63, 7661, 12, 1683, 63, 26737, 864, 83, 304, 398, 16685, 2285, 63, 835, 275, 499, 267, 4390, 63, 529, 63, 4647, 275, 959, 267, 8037, 63, 529, 63, 4647, 275, 959, 398, 16685, 2285, 12, 4390, 275, 291, 423, 2268, 63, 25021, 63, 460, 63, 3707, 8, 25021, 63, 835, 12, 9349, 4390, 63, 529, 63, 4647, 9, 267, 367, 8261, 63, 344, 315, 16685, 2285, 14, 1612, 837, 288, 16685, 2285, 59, 4647, 63, 344, 1055, 5486, 480, 825, 18, 63, 5871, 401, 3073, 288, 367, 284, 315, 1425, 8, 5871, 63, 529, 63, 4647, 304, 355, 16685, 2285, 59, 4647, 63, 344, 7541, 825, 18, 63, 5871, 4140, 740, 8, 495, 8, 73, 430, 398, 1067, 275, 291, 423, 362, 63, 1100, 8, 3707, 12, 16685, 2285, 9, 398, 8037, 63, 3799, 275, 8037, 14, 4220, 18, 3120, 7599, 8, 1100, 9, 267, 8037, 63, 3799, 14, 7661, 342, 398, 1683, 63, 7661, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1247, 6270, 825, 18, 14, 5871, 2255, 6163, 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, 1, 1, 1, 1, 1, 1, 1, 1 ]
ict-felix/stack
vt_manager/src/python/vt_manager/common/rpc4django/xmlrpcdispatcher.py
9
2733
""" Implements an XMLRPC dispatcher """ import sys import xmlrpclib from xmlrpclib import Fault from SimpleXMLRPCServer import SimpleXMLRPCDispatcher import traceback class XMLRPCDispatcher(SimpleXMLRPCDispatcher): """ Encodes and decodes XMLRPC messages, dispatches to the requested method and returns any responses or errors in encoded XML. This class is modified from the built-in python version so that it can also pass the HttpRequest object from the underlying request """ def __init__(self): self.funcs = {} self.instance = None self.allow_none = True self.encoding = None def dispatch(self, data, **kwargs): """ Extracts the xml marshaled parameters and method name and calls the underlying method and returns either an xml marshaled response or an XMLRPC fault Although very similar to the superclass' _marshaled_dispatch, this method has a different name due to the different parameters it takes from the superclass method. """ try: params, method = xmlrpclib.loads(data) try: response = self._dispatch(method, params, **kwargs) except TypeError: # Catch unexpected keyword argument error response = self._dispatch(method, params) # wrap response in a singleton tuple response = (response,) response = xmlrpclib.dumps(response, methodresponse=1, allow_none=self.allow_none, encoding=self.encoding) except Fault, fault: traceback.print_exc() response = xmlrpclib.dumps(fault, allow_none=self.allow_none, encoding=self.encoding) except: # report exception back to server traceback.print_exc() exc_type, exc_value, exc_tb = sys.exc_info() response = xmlrpclib.dumps( xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)), encoding=self.encoding, allow_none=self.allow_none, ) return response def _dispatch(self, method, params, **kwargs): """ Dispatches the method with the parameters to the underlying method """ func = self.funcs.get(method, None) if func is not None: if len(kwargs) > 0: return func(*params, **kwargs) else: return func(*params) else: raise Exception('method "%s" is not supported' % method)
apache-2.0
[ 624, 199, 29452, 376, 4692, 8171, 17475, 199, 624, 199, 199, 646, 984, 199, 646, 19122, 199, 504, 19122, 492, 31422, 199, 504, 5870, 27026, 3120, 492, 5870, 27026, 15461, 199, 646, 5190, 199, 199, 533, 4692, 8171, 15461, 8, 3184, 27026, 15461, 304, 272, 408, 272, 3447, 6021, 436, 4849, 83, 4692, 8171, 3788, 12, 7634, 397, 370, 314, 5839, 1083, 272, 436, 2529, 1263, 9320, 503, 2552, 315, 5737, 4692, 14, 2286, 961, 1021, 365, 6042, 687, 314, 6137, 13, 262, 2366, 1015, 880, 626, 652, 883, 272, 2597, 986, 314, 20730, 909, 687, 314, 8793, 1056, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9204, 275, 1052, 267, 291, 14, 842, 275, 488, 267, 291, 14, 3306, 63, 3592, 275, 715, 267, 291, 14, 2991, 275, 488, 25979, 347, 7634, 8, 277, 12, 666, 12, 1011, 958, 304, 267, 408, 267, 12892, 83, 314, 2748, 7557, 4835, 1146, 2633, 436, 1083, 536, 436, 4882, 314, 267, 8793, 1083, 436, 2529, 1902, 376, 2748, 7557, 4835, 1146, 1177, 267, 503, 376, 4692, 8171, 16898, 2728, 4580, 15401, 7437, 8545, 370, 314, 17035, 7, 485, 4584, 4835, 1146, 63, 6052, 12, 642, 267, 1083, 965, 282, 3365, 536, 7037, 370, 314, 3365, 2633, 652, 6181, 267, 687, 314, 17035, 1083, 14, 267, 408, 2728, 862, 26, 288, 1862, 12, 1083, 275, 19122, 14, 3640, 8, 576, 9, 7846, 862, 26, 355, 1177, 275, 291, 423, 6052, 8, 765, 12, 1862, 12, 1011, 958, 9, 288, 871, 3146, 26, 355, 327, 32754, 10537, 4252, 1423, 1125, 355, 1177, 275, 291, 423, 6052, 8, 765, 12, 1862, 9, 7846, 327, 4816, 1177, 315, 282, 19768, 2008, 288, 1177, 275, 334, 1310, 4258, 288, 1177, 275, 19122, 14, 4180, 8, 1310, 12, 1083, 1310, 29, 17, 12, 4318, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 221, 4318, 2644, 29, 277, 14, 2991, 9, 267, 871, 31422, 12, 16898, 26, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1177, 275, 19122, 14, 4180, 8, 1879, 12, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 4318, 2644, 29, 277, 14, 2991, 9, 267, 871, 26, 288, 327, 3622, 1919, 1771, 370, 1654, 288, 5190, 14, 1361, 63, 2804, 342, 288, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 275, 984, 14, 2804, 63, 815, 342, 288, 1177, 275, 19122, 14, 4180, 8, 355, 19122, 14, 16665, 8, 17, 12, 2071, 83, 2689, 83, 2, 450, 334, 2804, 63, 466, 12, 3178, 63, 585, 1826, 355, 2644, 29, 277, 14, 2991, 12, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 355, 776, 398, 372, 1177, 2286, 347, 485, 6052, 8, 277, 12, 1083, 12, 1862, 12, 1011, 958, 304, 267, 408, 267, 5289, 11350, 314, 1083, 543, 314, 2633, 370, 314, 8793, 1083, 267, 408, 2728, 2562, 275, 291, 14, 9204, 14, 362, 8, 765, 12, 488, 9, 398, 340, 2562, 365, 440, 488, 26, 288, 340, 822, 8, 958, 9, 690, 378, 26, 355, 372, 2562, 2031, 1162, 12, 1011, 958, 9, 288, 587, 26, 355, 372, 2562, 2031, 1162, 9, 267, 587, 26, 288, 746, 2186, 360, 765, 2071, 83, 2, 365, 440, 3748, 7, 450, 1083, 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 ]
[ 199, 29452, 376, 4692, 8171, 17475, 199, 624, 199, 199, 646, 984, 199, 646, 19122, 199, 504, 19122, 492, 31422, 199, 504, 5870, 27026, 3120, 492, 5870, 27026, 15461, 199, 646, 5190, 199, 199, 533, 4692, 8171, 15461, 8, 3184, 27026, 15461, 304, 272, 408, 272, 3447, 6021, 436, 4849, 83, 4692, 8171, 3788, 12, 7634, 397, 370, 314, 5839, 1083, 272, 436, 2529, 1263, 9320, 503, 2552, 315, 5737, 4692, 14, 2286, 961, 1021, 365, 6042, 687, 314, 6137, 13, 262, 2366, 1015, 880, 626, 652, 883, 272, 2597, 986, 314, 20730, 909, 687, 314, 8793, 1056, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9204, 275, 1052, 267, 291, 14, 842, 275, 488, 267, 291, 14, 3306, 63, 3592, 275, 715, 267, 291, 14, 2991, 275, 488, 25979, 347, 7634, 8, 277, 12, 666, 12, 1011, 958, 304, 267, 408, 267, 12892, 83, 314, 2748, 7557, 4835, 1146, 2633, 436, 1083, 536, 436, 4882, 314, 267, 8793, 1083, 436, 2529, 1902, 376, 2748, 7557, 4835, 1146, 1177, 267, 503, 376, 4692, 8171, 16898, 2728, 4580, 15401, 7437, 8545, 370, 314, 17035, 7, 485, 4584, 4835, 1146, 63, 6052, 12, 642, 267, 1083, 965, 282, 3365, 536, 7037, 370, 314, 3365, 2633, 652, 6181, 267, 687, 314, 17035, 1083, 14, 267, 408, 2728, 862, 26, 288, 1862, 12, 1083, 275, 19122, 14, 3640, 8, 576, 9, 7846, 862, 26, 355, 1177, 275, 291, 423, 6052, 8, 765, 12, 1862, 12, 1011, 958, 9, 288, 871, 3146, 26, 355, 327, 32754, 10537, 4252, 1423, 1125, 355, 1177, 275, 291, 423, 6052, 8, 765, 12, 1862, 9, 7846, 327, 4816, 1177, 315, 282, 19768, 2008, 288, 1177, 275, 334, 1310, 4258, 288, 1177, 275, 19122, 14, 4180, 8, 1310, 12, 1083, 1310, 29, 17, 12, 4318, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 221, 4318, 2644, 29, 277, 14, 2991, 9, 267, 871, 31422, 12, 16898, 26, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1177, 275, 19122, 14, 4180, 8, 1879, 12, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 4318, 2644, 29, 277, 14, 2991, 9, 267, 871, 26, 288, 327, 3622, 1919, 1771, 370, 1654, 288, 5190, 14, 1361, 63, 2804, 342, 288, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 275, 984, 14, 2804, 63, 815, 342, 288, 1177, 275, 19122, 14, 4180, 8, 355, 19122, 14, 16665, 8, 17, 12, 2071, 83, 2689, 83, 2, 450, 334, 2804, 63, 466, 12, 3178, 63, 585, 1826, 355, 2644, 29, 277, 14, 2991, 12, 2040, 63, 3592, 29, 277, 14, 3306, 63, 3592, 12, 355, 776, 398, 372, 1177, 2286, 347, 485, 6052, 8, 277, 12, 1083, 12, 1862, 12, 1011, 958, 304, 267, 408, 267, 5289, 11350, 314, 1083, 543, 314, 2633, 370, 314, 8793, 1083, 267, 408, 2728, 2562, 275, 291, 14, 9204, 14, 362, 8, 765, 12, 488, 9, 398, 340, 2562, 365, 440, 488, 26, 288, 340, 822, 8, 958, 9, 690, 378, 26, 355, 372, 2562, 2031, 1162, 12, 1011, 958, 9, 288, 587, 26, 355, 372, 2562, 2031, 1162, 9, 267, 587, 26, 288, 746, 2186, 360, 765, 2071, 83, 2, 365, 440, 3748, 7, 450, 1083, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rhdedgar/openshift-tools
ansible/roles/lib_openshift_3.2/build/ansible/oc_obj.py
12
4493
# pylint: skip-file # pylint: disable=too-many-branches def main(): ''' ansible oc module for services ''' module = AnsibleModule( argument_spec=dict( kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'), state=dict(default='present', type='str', choices=['present', 'absent', 'list']), debug=dict(default=False, type='bool'), namespace=dict(default='default', type='str'), all_namespaces=dict(defaul=False, type='bool'), name=dict(default=None, type='str'), files=dict(default=None, type='list'), kind=dict(required=True, type='str'), delete_after=dict(default=False, type='bool'), content=dict(default=None, type='dict'), force=dict(default=False, type='bool'), selector=dict(default=None, type='str'), ), mutually_exclusive=[["content", "files"]], supports_check_mode=True, ) ocobj = OCObject(module.params['kind'], module.params['namespace'], module.params['name'], module.params['selector'], kubeconfig=module.params['kubeconfig'], verbose=module.params['debug'], all_namespaces=module.params['all_namespaces']) state = module.params['state'] api_rval = ocobj.get() ##### # Get ##### if state == 'list': module.exit_json(changed=False, results=api_rval, state="list") if not module.params['name']: module.fail_json(msg='Please specify a name when state is absent|present.') ######## # Delete ######## if state == 'absent': if not Utils.exists(api_rval['results'], module.params['name']): module.exit_json(changed=False, state="absent") if module.check_mode: module.exit_json(changed=False, msg='Would have performed a delete.') api_rval = ocobj.delete() module.exit_json(changed=True, results=api_rval, state="absent") if state == 'present': ######## # Create ######## if not Utils.exists(api_rval['results'], module.params['name']): if module.check_mode: module.exit_json(changed=False, msg='Would have performed a create.') # Create it here api_rval = ocobj.create(module.params['files'], module.params['content']) if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) # return the created object api_rval = ocobj.get() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) # Remove files if module.params['files'] and module.params['delete_after']: Utils.cleanup(module.params['files']) module.exit_json(changed=True, results=api_rval, state="present") ######## # Update ######## # if a file path is passed, use it. update = ocobj.needs_update(module.params['files'], module.params['content']) if not isinstance(update, bool): module.fail_json(msg=update) # No changes if not update: if module.params['files'] and module.params['delete_after']: Utils.cleanup(module.params['files']) module.exit_json(changed=False, results=api_rval['results'][0], state="present") if module.check_mode: module.exit_json(changed=False, msg='Would have performed an update.') api_rval = ocobj.update(module.params['files'], module.params['content'], module.params['force']) if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) # return the created object api_rval = ocobj.get() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) module.exit_json(changed=True, results=api_rval, state="present") module.exit_json(failed=True, changed=False, results='Unknown state passed. %s' % state, state="unknown") # pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import, locally-disabled # import module snippets. This are required from ansible.module_utils.basic import * main()
apache-2.0
[ 3, 4287, 26, 3372, 13, 493, 199, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 16896, 199, 318, 2446, 837, 272, 1449, 272, 3242, 4244, 859, 367, 8500, 272, 1449, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 23091, 888, 29, 807, 8, 885, 8805, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 297, 730, 534, 495, 659, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 730, 534, 495, 297, 2432, 3415, 2968, 1881, 297, 283, 5575, 297, 283, 513, 3815, 288, 3105, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 3231, 29, 807, 8, 885, 534, 885, 297, 730, 534, 495, 659, 288, 1006, 63, 9247, 29, 807, 8, 27205, 29, 797, 12, 730, 534, 2245, 659, 288, 536, 29, 807, 8, 885, 29, 403, 12, 730, 534, 495, 659, 288, 1584, 29, 807, 8, 885, 29, 403, 12, 730, 534, 513, 659, 288, 4928, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 288, 3145, 63, 4399, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 1564, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 659, 288, 3542, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 9759, 29, 807, 8, 885, 29, 403, 12, 730, 534, 495, 659, 267, 2318, 267, 16108, 63, 12730, 1524, 905, 1317, 401, 298, 1725, 18396, 398, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 272, 312, 331, 468, 275, 593, 19561, 8, 578, 14, 1162, 459, 5091, 995, 2151, 859, 14, 1162, 459, 3251, 995, 2151, 859, 14, 1162, 459, 354, 995, 2151, 859, 14, 1162, 459, 6662, 995, 2151, 23091, 888, 29, 578, 14, 1162, 459, 29192, 995, 2151, 3376, 29, 578, 14, 1162, 459, 1757, 995, 2151, 1006, 63, 9247, 29, 578, 14, 1162, 459, 452, 63, 9247, 1105, 339, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 339, 22906, 272, 327, 2372, 272, 22906, 272, 340, 1174, 508, 283, 513, 356, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 513, 531, 339, 340, 440, 859, 14, 1162, 459, 354, 2565, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 8254, 4165, 282, 536, 1380, 1174, 365, 9552, 92, 1881, 2659, 272, 21937, 272, 327, 8496, 272, 21937, 272, 340, 1174, 508, 283, 5575, 356, 267, 340, 440, 17397, 14, 2444, 8, 1246, 63, 24530, 459, 2604, 995, 859, 14, 1162, 459, 354, 9090, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1174, 628, 5575, 531, 398, 340, 859, 14, 1074, 63, 632, 26, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 282, 3145, 2659, 398, 2986, 63, 24530, 275, 312, 331, 468, 14, 1807, 342, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 5575, 531, 339, 340, 1174, 508, 283, 1881, 356, 267, 21937, 267, 327, 2790, 267, 21937, 267, 340, 440, 17397, 14, 2444, 8, 1246, 63, 24530, 459, 2604, 995, 859, 14, 1162, 459, 354, 9090, 953, 340, 859, 14, 1074, 63, 632, 26, 355, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 282, 1218, 2659, 953, 327, 2790, 652, 2348, 288, 2986, 63, 24530, 275, 312, 331, 468, 14, 981, 8, 578, 14, 1162, 459, 1725, 995, 859, 14, 1162, 459, 1317, 1105, 288, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 953, 327, 372, 314, 2737, 909, 288, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 953, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 953, 327, 5852, 1584, 288, 340, 859, 14, 1162, 459, 1725, 418, 436, 859, 14, 1162, 459, 1807, 63, 4399, 2565, 355, 17397, 14, 7661, 8, 578, 14, 1162, 459, 1725, 1105, 953, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 1881, 531, 398, 21937, 267, 327, 6162, 267, 21937, 267, 327, 340, 282, 570, 931, 365, 3032, 12, 675, 652, 14, 267, 1678, 275, 312, 331, 468, 14, 10065, 63, 873, 8, 578, 14, 1162, 459, 1725, 995, 859, 14, 1162, 459, 1317, 1105, 267, 340, 440, 1228, 8, 873, 12, 2155, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 873, 9, 398, 327, 3091, 4493, 267, 340, 440, 1678, 26, 288, 340, 859, 14, 1162, 459, 1725, 418, 436, 859, 14, 1162, 459, 1807, 63, 4399, 2565, 355, 17397, 14, 7661, 8, 578, 14, 1162, 459, 1725, 1105, 953, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 2058, 29, 1246, 63, 24530, 459, 2604, 3488, 16, 467, 1174, 628, 1881, 531, 398, 340, 859, 14, 1074, 63, 632, 26, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 376, 1678, 2659, 398, 2986, 63, 24530, 275, 312, 331, 468, 14, 873, 8, 578, 14, 1162, 459, 1725, 995, 1816, 859, 14, 1162, 459, 1317, 995, 1816, 859, 14, 1162, 459, 3990, 1105, 7318, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 398, 327, 372, 314, 2737, 909, 267, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 398, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 1881, 531, 339, 859, 14, 2224, 63, 1001, 8, 4892, 29, 549, 12, 2151, 2896, 29, 797, 12, 2151, 2058, 534, 5912, 1174, 3032, 14, 450, 83, 7, 450, 1174, 12, 2151, 1174, 628, 5187, 531, 199, 199, 3, 4287, 26, 3507, 29 ]
[ 4287, 26, 3372, 13, 493, 199, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 16896, 199, 318, 2446, 837, 272, 1449, 272, 3242, 4244, 859, 367, 8500, 272, 1449, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 23091, 888, 29, 807, 8, 885, 8805, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 297, 730, 534, 495, 659, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 730, 534, 495, 297, 2432, 3415, 2968, 1881, 297, 283, 5575, 297, 283, 513, 3815, 288, 3105, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 3231, 29, 807, 8, 885, 534, 885, 297, 730, 534, 495, 659, 288, 1006, 63, 9247, 29, 807, 8, 27205, 29, 797, 12, 730, 534, 2245, 659, 288, 536, 29, 807, 8, 885, 29, 403, 12, 730, 534, 495, 659, 288, 1584, 29, 807, 8, 885, 29, 403, 12, 730, 534, 513, 659, 288, 4928, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 288, 3145, 63, 4399, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 1564, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 659, 288, 3542, 29, 807, 8, 885, 29, 797, 12, 730, 534, 2245, 659, 288, 9759, 29, 807, 8, 885, 29, 403, 12, 730, 534, 495, 659, 267, 2318, 267, 16108, 63, 12730, 1524, 905, 1317, 401, 298, 1725, 18396, 398, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 272, 312, 331, 468, 275, 593, 19561, 8, 578, 14, 1162, 459, 5091, 995, 2151, 859, 14, 1162, 459, 3251, 995, 2151, 859, 14, 1162, 459, 354, 995, 2151, 859, 14, 1162, 459, 6662, 995, 2151, 23091, 888, 29, 578, 14, 1162, 459, 29192, 995, 2151, 3376, 29, 578, 14, 1162, 459, 1757, 995, 2151, 1006, 63, 9247, 29, 578, 14, 1162, 459, 452, 63, 9247, 1105, 339, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 339, 22906, 272, 327, 2372, 272, 22906, 272, 340, 1174, 508, 283, 513, 356, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 513, 531, 339, 340, 440, 859, 14, 1162, 459, 354, 2565, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 8254, 4165, 282, 536, 1380, 1174, 365, 9552, 92, 1881, 2659, 272, 21937, 272, 327, 8496, 272, 21937, 272, 340, 1174, 508, 283, 5575, 356, 267, 340, 440, 17397, 14, 2444, 8, 1246, 63, 24530, 459, 2604, 995, 859, 14, 1162, 459, 354, 9090, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1174, 628, 5575, 531, 398, 340, 859, 14, 1074, 63, 632, 26, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 282, 3145, 2659, 398, 2986, 63, 24530, 275, 312, 331, 468, 14, 1807, 342, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 5575, 531, 339, 340, 1174, 508, 283, 1881, 356, 267, 21937, 267, 327, 2790, 267, 21937, 267, 340, 440, 17397, 14, 2444, 8, 1246, 63, 24530, 459, 2604, 995, 859, 14, 1162, 459, 354, 9090, 953, 340, 859, 14, 1074, 63, 632, 26, 355, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 282, 1218, 2659, 953, 327, 2790, 652, 2348, 288, 2986, 63, 24530, 275, 312, 331, 468, 14, 981, 8, 578, 14, 1162, 459, 1725, 995, 859, 14, 1162, 459, 1317, 1105, 288, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 953, 327, 372, 314, 2737, 909, 288, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 953, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 953, 327, 5852, 1584, 288, 340, 859, 14, 1162, 459, 1725, 418, 436, 859, 14, 1162, 459, 1807, 63, 4399, 2565, 355, 17397, 14, 7661, 8, 578, 14, 1162, 459, 1725, 1105, 953, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 1881, 531, 398, 21937, 267, 327, 6162, 267, 21937, 267, 327, 340, 282, 570, 931, 365, 3032, 12, 675, 652, 14, 267, 1678, 275, 312, 331, 468, 14, 10065, 63, 873, 8, 578, 14, 1162, 459, 1725, 995, 859, 14, 1162, 459, 1317, 1105, 267, 340, 440, 1228, 8, 873, 12, 2155, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 873, 9, 398, 327, 3091, 4493, 267, 340, 440, 1678, 26, 288, 340, 859, 14, 1162, 459, 1725, 418, 436, 859, 14, 1162, 459, 1807, 63, 4399, 2565, 355, 17397, 14, 7661, 8, 578, 14, 1162, 459, 1725, 1105, 953, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 2058, 29, 1246, 63, 24530, 459, 2604, 3488, 16, 467, 1174, 628, 1881, 531, 398, 340, 859, 14, 1074, 63, 632, 26, 288, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 534, 55, 3857, 1172, 10585, 376, 1678, 2659, 398, 2986, 63, 24530, 275, 312, 331, 468, 14, 873, 8, 578, 14, 1162, 459, 1725, 995, 1816, 859, 14, 1162, 459, 1317, 995, 1816, 859, 14, 1162, 459, 3990, 1105, 7318, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 398, 327, 372, 314, 2737, 909, 267, 2986, 63, 24530, 275, 312, 331, 468, 14, 362, 342, 398, 340, 2986, 63, 24530, 459, 9913, 418, 1137, 378, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 1246, 63, 24530, 9, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 2058, 29, 1246, 63, 24530, 12, 1174, 628, 1881, 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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 ]
dongxingshui/virt-manager
virtinst/snapshot.py
5
2621
# # Copyright 2013-2014 Red Hat, Inc. # Cole Robinson <crobinso@redhat.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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. import libvirt from . import util from .xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty class _SnapshotDisk(XMLBuilder): _XML_ROOT_NAME = "disk" name = XMLProperty("./@name") snapshot = XMLProperty("./@snapshot") class DomainSnapshot(XMLBuilder): @staticmethod def find_free_name(vm, collidelist): return util.generate_name("snapshot", vm.snapshotLookupByName, sep="", start_num=1, force_num=True, collidelist=collidelist) @staticmethod def state_str_to_int(state): statemap = { "nostate": libvirt.VIR_DOMAIN_NOSTATE, "running": libvirt.VIR_DOMAIN_RUNNING, "blocked": libvirt.VIR_DOMAIN_BLOCKED, "paused": libvirt.VIR_DOMAIN_PAUSED, "shutdown": libvirt.VIR_DOMAIN_SHUTDOWN, "shutoff": libvirt.VIR_DOMAIN_SHUTOFF, "crashed": libvirt.VIR_DOMAIN_CRASHED, "pmsuspended": getattr(libvirt, "VIR_DOMAIN_PMSUSPENDED", 7) } if state == "disk-snapshot" or state not in statemap: state = "shutoff" return statemap.get(state, libvirt.VIR_DOMAIN_NOSTATE) _XML_ROOT_NAME = "domainsnapshot" _XML_PROP_ORDER = ["name", "description", "creationTime"] name = XMLProperty("./name") description = XMLProperty("./description") state = XMLProperty("./state") creationTime = XMLProperty("./creationTime", is_int=True) parent = XMLProperty("./parent/name") memory_type = XMLProperty("./memory/@snapshot") disks = XMLChildProperty(_SnapshotDisk, relative_xpath="./disks") ################## # Public helpers # ################## def validate(self): if not self.name: raise RuntimeError(_("A name must be specified."))
gpl-2.0
[ 3, 199, 3, 1898, 6171, 13, 7280, 9572, 13002, 12, 3277, 14, 199, 3, 1849, 274, 6848, 1393, 834, 665, 67, 28191, 1152, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 646, 13108, 199, 199, 504, 1275, 492, 4884, 199, 504, 1275, 1652, 5649, 492, 4692, 6437, 12, 4692, 3493, 3697, 12, 4692, 3697, 421, 199, 533, 485, 12038, 10690, 8, 4317, 6437, 304, 272, 485, 4317, 63, 5441, 63, 2339, 275, 298, 4032, 2, 272, 536, 275, 4692, 3697, 28615, 32, 354, 531, 272, 5740, 275, 4692, 3697, 28615, 32, 4753, 531, 421, 199, 533, 14061, 12038, 8, 4317, 6437, 304, 272, 768, 4639, 272, 347, 2342, 63, 4624, 63, 354, 8, 2611, 12, 1048, 8409, 513, 304, 267, 372, 4884, 14, 4208, 63, 354, 480, 4753, 401, 4169, 14, 4753, 7521, 11190, 12, 3303, 7375, 8772, 1343, 63, 1507, 29, 17, 12, 3542, 63, 1507, 29, 549, 12, 3303, 1048, 8409, 513, 29, 761, 8409, 513, 9, 339, 768, 4639, 272, 347, 1174, 63, 495, 63, 475, 63, 442, 8, 929, 304, 267, 1174, 1130, 275, 469, 288, 298, 889, 929, 582, 13108, 14, 13679, 63, 7378, 63, 2826, 6689, 12, 288, 298, 5720, 582, 13108, 14, 13679, 63, 7378, 63, 17305, 12, 288, 298, 17726, 582, 13108, 14, 13679, 63, 7378, 63, 8475, 1149, 12, 288, 298, 22478, 582, 13108, 14, 13679, 63, 7378, 63, 8470, 8558, 12, 288, 298, 8831, 582, 13108, 14, 13679, 63, 7378, 63, 24340, 8819, 12, 288, 298, 609, 11222, 582, 13108, 14, 13679, 63, 7378, 63, 24340, 7517, 12, 288, 298, 14807, 379, 582, 13108, 14, 13679, 63, 7378, 63, 2944, 8100, 1149, 12, 288, 298, 80, 706, 18559, 582, 2519, 8, 11877, 12, 298, 13679, 63, 7378, 63, 48, 3053, 28011, 25518, 401, 1520, 9, 267, 789, 398, 340, 1174, 508, 298, 4032, 13, 4753, 2, 503, 1174, 440, 315, 1174, 1130, 26, 288, 1174, 275, 298, 609, 11222, 2, 267, 372, 1174, 1130, 14, 362, 8, 929, 12, 13108, 14, 13679, 63, 7378, 63, 2826, 6689, 9, 2378, 485, 4317, 63, 5441, 63, 2339, 275, 298, 2261, 4753, 2, 272, 485, 4317, 63, 19926, 63, 12125, 275, 2097, 354, 401, 298, 1802, 401, 298, 8782, 1366, 937, 339, 536, 275, 4692, 3697, 28615, 354, 531, 272, 1369, 275, 4692, 3697, 28615, 1802, 531, 272, 1174, 275, 4692, 3697, 28615, 929, 531, 272, 7143, 1366, 275, 4692, 3697, 28615, 8782, 1366, 401, 365, 63, 442, 29, 549, 9, 272, 1676, 275, 4692, 3697, 28615, 1708, 15, 354, 531, 339, 4402, 63, 466, 275, 4692, 3697, 28615, 4844, 15, 32, 4753, 531, 339, 17602, 275, 4692, 3493, 3697, 1547, 12038, 10690, 12, 3847, 63, 8006, 628, 13186, 16203, 531, 2378, 21905, 309, 272, 327, 1684, 10897, 327, 272, 21905, 309, 339, 347, 4107, 8, 277, 304, 267, 340, 440, 291, 14, 354, 26, 288, 746, 6064, 6115, 33, 536, 1471, 506, 2013, 13853, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 6171, 13, 7280, 9572, 13002, 12, 3277, 14, 199, 3, 1849, 274, 6848, 1393, 834, 665, 67, 28191, 1152, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 646, 13108, 199, 199, 504, 1275, 492, 4884, 199, 504, 1275, 1652, 5649, 492, 4692, 6437, 12, 4692, 3493, 3697, 12, 4692, 3697, 421, 199, 533, 485, 12038, 10690, 8, 4317, 6437, 304, 272, 485, 4317, 63, 5441, 63, 2339, 275, 298, 4032, 2, 272, 536, 275, 4692, 3697, 28615, 32, 354, 531, 272, 5740, 275, 4692, 3697, 28615, 32, 4753, 531, 421, 199, 533, 14061, 12038, 8, 4317, 6437, 304, 272, 768, 4639, 272, 347, 2342, 63, 4624, 63, 354, 8, 2611, 12, 1048, 8409, 513, 304, 267, 372, 4884, 14, 4208, 63, 354, 480, 4753, 401, 4169, 14, 4753, 7521, 11190, 12, 3303, 7375, 8772, 1343, 63, 1507, 29, 17, 12, 3542, 63, 1507, 29, 549, 12, 3303, 1048, 8409, 513, 29, 761, 8409, 513, 9, 339, 768, 4639, 272, 347, 1174, 63, 495, 63, 475, 63, 442, 8, 929, 304, 267, 1174, 1130, 275, 469, 288, 298, 889, 929, 582, 13108, 14, 13679, 63, 7378, 63, 2826, 6689, 12, 288, 298, 5720, 582, 13108, 14, 13679, 63, 7378, 63, 17305, 12, 288, 298, 17726, 582, 13108, 14, 13679, 63, 7378, 63, 8475, 1149, 12, 288, 298, 22478, 582, 13108, 14, 13679, 63, 7378, 63, 8470, 8558, 12, 288, 298, 8831, 582, 13108, 14, 13679, 63, 7378, 63, 24340, 8819, 12, 288, 298, 609, 11222, 582, 13108, 14, 13679, 63, 7378, 63, 24340, 7517, 12, 288, 298, 14807, 379, 582, 13108, 14, 13679, 63, 7378, 63, 2944, 8100, 1149, 12, 288, 298, 80, 706, 18559, 582, 2519, 8, 11877, 12, 298, 13679, 63, 7378, 63, 48, 3053, 28011, 25518, 401, 1520, 9, 267, 789, 398, 340, 1174, 508, 298, 4032, 13, 4753, 2, 503, 1174, 440, 315, 1174, 1130, 26, 288, 1174, 275, 298, 609, 11222, 2, 267, 372, 1174, 1130, 14, 362, 8, 929, 12, 13108, 14, 13679, 63, 7378, 63, 2826, 6689, 9, 2378, 485, 4317, 63, 5441, 63, 2339, 275, 298, 2261, 4753, 2, 272, 485, 4317, 63, 19926, 63, 12125, 275, 2097, 354, 401, 298, 1802, 401, 298, 8782, 1366, 937, 339, 536, 275, 4692, 3697, 28615, 354, 531, 272, 1369, 275, 4692, 3697, 28615, 1802, 531, 272, 1174, 275, 4692, 3697, 28615, 929, 531, 272, 7143, 1366, 275, 4692, 3697, 28615, 8782, 1366, 401, 365, 63, 442, 29, 549, 9, 272, 1676, 275, 4692, 3697, 28615, 1708, 15, 354, 531, 339, 4402, 63, 466, 275, 4692, 3697, 28615, 4844, 15, 32, 4753, 531, 339, 17602, 275, 4692, 3493, 3697, 1547, 12038, 10690, 12, 3847, 63, 8006, 628, 13186, 16203, 531, 2378, 21905, 309, 272, 327, 1684, 10897, 327, 272, 21905, 309, 339, 347, 4107, 8, 277, 304, 267, 340, 440, 291, 14, 354, 26, 288, 746, 6064, 6115, 33, 536, 1471, 506, 2013, 13853, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
matthieudumont/dipy
tools/pack_examples.py
22
1148
#!/usr/bin/env python """ Script to pack built examples into suitably named archive Usage %s output_dir [doc_dir] """ import os from os.path import join as pjoin import sys import shutil import tarfile import dipy __doc__ = __doc__ % sys.argv[0] EG_BUILT_SDIR = 'examples_built' dpv = 'dipy-' + dipy.__version__ archive_name = dpv + '-doc-examples.tar.gz' try: out_root = sys.argv[1] except IndexError: print __doc__ sys.exit(1) try: os.mkdir(out_root) except OSError: pass try: doc_dir = sys.argv[2] except IndexError: doc_dir = os.getcwd() archive_fname = os.path.join(out_root, archive_name) eg_built_dir = pjoin(doc_dir, EG_BUILT_SDIR) eg_out_base = pjoin(out_root, dpv, 'doc') eg_out_dir = pjoin(eg_out_base, EG_BUILT_SDIR) if os.path.isdir(eg_out_dir): shutil.rmtree(eg_out_dir) def ignorandi(src, names): return [name for name in names if name == 'README' or name == '.gitignore'] shutil.copytree(eg_built_dir, eg_out_dir, ignore=ignorandi) os.chdir(out_root) tar = tarfile.open(archive_fname, 'w|gz') tar.add(dpv) tar.close() shutil.rmtree(pjoin(out_root, dpv)) print("Written " + archive_fname)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 14914, 370, 1706, 6137, 7251, 1901, 308, 4993, 6665, 4310, 6359, 199, 199, 7692, 450, 83, 1072, 63, 694, 359, 1301, 63, 694, 61, 199, 624, 199, 199, 646, 747, 199, 504, 747, 14, 515, 492, 4263, 465, 299, 904, 199, 646, 984, 199, 646, 5145, 199, 646, 13608, 199, 199, 646, 487, 647, 199, 199, 363, 1301, 363, 275, 636, 1301, 363, 450, 984, 14, 3020, 59, 16, 61, 199, 199, 4680, 63, 18637, 52, 63, 51, 3022, 275, 283, 8589, 63, 11730, 7, 199, 68, 1381, 275, 283, 328, 647, 15668, 435, 487, 647, 855, 1023, 363, 199, 6404, 63, 354, 275, 366, 1381, 435, 2475, 1301, 13, 8589, 14, 5369, 14, 6838, 7, 199, 199, 893, 26, 272, 734, 63, 1231, 275, 984, 14, 3020, 59, 17, 61, 199, 2590, 7888, 26, 272, 870, 636, 1301, 363, 272, 984, 14, 2224, 8, 17, 9, 199, 893, 26, 272, 747, 14, 8215, 8, 548, 63, 1231, 9, 199, 2590, 6440, 26, 272, 986, 199, 893, 26, 272, 1382, 63, 694, 275, 984, 14, 3020, 59, 18, 61, 199, 2590, 7888, 26, 272, 1382, 63, 694, 275, 747, 14, 9458, 342, 199, 199, 6404, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 548, 63, 1231, 12, 6359, 63, 354, 9, 199, 199, 5902, 63, 11730, 63, 694, 275, 299, 904, 8, 1301, 63, 694, 12, 662, 39, 63, 18637, 52, 63, 51, 3022, 9, 199, 5902, 63, 548, 63, 1095, 275, 299, 904, 8, 548, 63, 1231, 12, 366, 1381, 12, 283, 1301, 358, 199, 5902, 63, 548, 63, 694, 275, 299, 904, 8, 5902, 63, 548, 63, 1095, 12, 662, 39, 63, 18637, 52, 63, 51, 3022, 9, 199, 692, 747, 14, 515, 14, 6027, 8, 5902, 63, 548, 63, 694, 304, 272, 5145, 14, 9242, 8, 5902, 63, 548, 63, 694, 9, 199, 318, 2646, 269, 290, 328, 8, 2164, 12, 1561, 304, 272, 372, 359, 354, 367, 536, 315, 1561, 340, 536, 508, 283, 18195, 7, 503, 536, 508, 1987, 71, 5277, 7160, 418, 199, 20938, 14, 29296, 8, 5902, 63, 11730, 63, 694, 12, 11837, 63, 548, 63, 694, 12, 3686, 29, 1030, 269, 290, 328, 9, 199, 736, 14, 8563, 8, 548, 63, 1231, 9, 199, 5369, 275, 13608, 14, 1490, 8, 6404, 63, 5252, 12, 283, 87, 92, 6838, 358, 199, 5369, 14, 525, 8, 68, 1381, 9, 199, 5369, 14, 1600, 342, 199, 20938, 14, 9242, 8, 80, 904, 8, 548, 63, 1231, 12, 366, 1381, 430, 199, 1361, 480, 32329, 298, 435, 6359, 63, 5252, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 14914, 370, 1706, 6137, 7251, 1901, 308, 4993, 6665, 4310, 6359, 199, 199, 7692, 450, 83, 1072, 63, 694, 359, 1301, 63, 694, 61, 199, 624, 199, 199, 646, 747, 199, 504, 747, 14, 515, 492, 4263, 465, 299, 904, 199, 646, 984, 199, 646, 5145, 199, 646, 13608, 199, 199, 646, 487, 647, 199, 199, 363, 1301, 363, 275, 636, 1301, 363, 450, 984, 14, 3020, 59, 16, 61, 199, 199, 4680, 63, 18637, 52, 63, 51, 3022, 275, 283, 8589, 63, 11730, 7, 199, 68, 1381, 275, 283, 328, 647, 15668, 435, 487, 647, 855, 1023, 363, 199, 6404, 63, 354, 275, 366, 1381, 435, 2475, 1301, 13, 8589, 14, 5369, 14, 6838, 7, 199, 199, 893, 26, 272, 734, 63, 1231, 275, 984, 14, 3020, 59, 17, 61, 199, 2590, 7888, 26, 272, 870, 636, 1301, 363, 272, 984, 14, 2224, 8, 17, 9, 199, 893, 26, 272, 747, 14, 8215, 8, 548, 63, 1231, 9, 199, 2590, 6440, 26, 272, 986, 199, 893, 26, 272, 1382, 63, 694, 275, 984, 14, 3020, 59, 18, 61, 199, 2590, 7888, 26, 272, 1382, 63, 694, 275, 747, 14, 9458, 342, 199, 199, 6404, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 548, 63, 1231, 12, 6359, 63, 354, 9, 199, 199, 5902, 63, 11730, 63, 694, 275, 299, 904, 8, 1301, 63, 694, 12, 662, 39, 63, 18637, 52, 63, 51, 3022, 9, 199, 5902, 63, 548, 63, 1095, 275, 299, 904, 8, 548, 63, 1231, 12, 366, 1381, 12, 283, 1301, 358, 199, 5902, 63, 548, 63, 694, 275, 299, 904, 8, 5902, 63, 548, 63, 1095, 12, 662, 39, 63, 18637, 52, 63, 51, 3022, 9, 199, 692, 747, 14, 515, 14, 6027, 8, 5902, 63, 548, 63, 694, 304, 272, 5145, 14, 9242, 8, 5902, 63, 548, 63, 694, 9, 199, 318, 2646, 269, 290, 328, 8, 2164, 12, 1561, 304, 272, 372, 359, 354, 367, 536, 315, 1561, 340, 536, 508, 283, 18195, 7, 503, 536, 508, 1987, 71, 5277, 7160, 418, 199, 20938, 14, 29296, 8, 5902, 63, 11730, 63, 694, 12, 11837, 63, 548, 63, 694, 12, 3686, 29, 1030, 269, 290, 328, 9, 199, 736, 14, 8563, 8, 548, 63, 1231, 9, 199, 5369, 275, 13608, 14, 1490, 8, 6404, 63, 5252, 12, 283, 87, 92, 6838, 358, 199, 5369, 14, 525, 8, 68, 1381, 9, 199, 5369, 14, 1600, 342, 199, 20938, 14, 9242, 8, 80, 904, 8, 548, 63, 1231, 12, 366, 1381, 430, 199, 1361, 480, 32329, 298, 435, 6359, 63, 5252, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
VoiDeD/Sick-Beard
sickbeard/databases/mainDB.py
10
31970
# Author: Nic Wolfe <nic@wolfeden.ca> # URL: http://code.google.com/p/sickbeard/ # # This file is part of Sick Beard. # # Sick Beard is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Sick Beard is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. import sickbeard import os.path import sys import re from sickbeard import db, common, helpers, logger from sickbeard import encodingKludge as ek from sickbeard.name_parser.parser import NameParser, InvalidNameException MIN_DB_VERSION = 9 # oldest db version we support migrating from MAX_DB_VERSION = 18 class MainSanityCheck(db.DBSanityCheck): def check(self): self.fix_duplicate_shows() self.fix_duplicate_episodes() self.fix_orphan_episodes() def fix_duplicate_shows(self): sqlResults = self.connection.select("SELECT show_id, tvdb_id, COUNT(tvdb_id) as count FROM tv_shows GROUP BY tvdb_id HAVING count > 1") for cur_duplicate in sqlResults: logger.log(u"Duplicate show detected! tvdb_id: " + str(cur_duplicate["tvdb_id"]) + u" count: " + str(cur_duplicate["count"]), logger.DEBUG) cur_dupe_results = self.connection.select("SELECT show_id, tvdb_id FROM tv_shows WHERE tvdb_id = ? LIMIT ?", [cur_duplicate["tvdb_id"], int(cur_duplicate["count"]) - 1] ) for cur_dupe_id in cur_dupe_results: logger.log(u"Deleting duplicate show with tvdb_id: " + str(cur_dupe_id["tvdb_id"]) + u" show_id: " + str(cur_dupe_id["show_id"])) self.connection.action("DELETE FROM tv_shows WHERE show_id = ?", [cur_dupe_id["show_id"]]) else: logger.log(u"No duplicate show, check passed") def fix_duplicate_episodes(self): sqlResults = self.connection.select("SELECT showid, season, episode, COUNT(showid) as count FROM tv_episodes GROUP BY showid, season, episode HAVING count > 1") for cur_duplicate in sqlResults: logger.log(u"Duplicate episode detected! showid: " + str(cur_duplicate["showid"]) + u" season: " + str(cur_duplicate["season"]) + u" episode: " + str(cur_duplicate["episode"]) + u" count: " + str(cur_duplicate["count"]), logger.DEBUG) cur_dupe_results = self.connection.select("SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? and episode = ? ORDER BY episode_id DESC LIMIT ?", [cur_duplicate["showid"], cur_duplicate["season"], cur_duplicate["episode"], int(cur_duplicate["count"]) - 1] ) for cur_dupe_id in cur_dupe_results: logger.log(u"Deleting duplicate episode with episode_id: " + str(cur_dupe_id["episode_id"])) self.connection.action("DELETE FROM tv_episodes WHERE episode_id = ?", [cur_dupe_id["episode_id"]]) else: logger.log(u"No duplicate episode, check passed") def fix_orphan_episodes(self): sqlResults = self.connection.select("SELECT episode_id, showid, tv_shows.tvdb_id FROM tv_episodes LEFT JOIN tv_shows ON tv_episodes.showid=tv_shows.tvdb_id WHERE tv_shows.tvdb_id is NULL") for cur_orphan in sqlResults: logger.log(u"Orphan episode detected! episode_id: " + str(cur_orphan["episode_id"]) + " showid: " + str(cur_orphan["showid"]), logger.DEBUG) logger.log(u"Deleting orphan episode with episode_id: " + str(cur_orphan["episode_id"])) self.connection.action("DELETE FROM tv_episodes WHERE episode_id = ?", [cur_orphan["episode_id"]]) else: logger.log(u"No orphan episodes, check passed") def backupDatabase(version): logger.log(u"Backing up database before upgrade") if not helpers.backupVersionedFile(db.dbFilename(), version): logger.log_error_and_exit(u"Database backup failed, abort upgrading database") else: logger.log(u"Proceeding with upgrade") # ====================== # = Main DB Migrations = # ====================== # Add new migrations at the bottom of the list; subclass the previous migration. # schema is based off v18 - build 507 class InitialSchema (db.SchemaUpgrade): def test(self): return self.hasTable("tv_shows") and self.hasTable("db_version") and self.checkDBVersion() >= MIN_DB_VERSION and self.checkDBVersion() <= MAX_DB_VERSION def execute(self): if not self.hasTable("tv_shows") and not self.hasTable("db_version"): queries = [ "CREATE TABLE db_version (db_version INTEGER);", "CREATE TABLE history (action NUMERIC, date NUMERIC, showid NUMERIC, season NUMERIC, episode NUMERIC, quality NUMERIC, resource TEXT, provider TEXT, source TEXT);", "CREATE TABLE info (last_backlog NUMERIC, last_tvdb NUMERIC);", "CREATE TABLE tv_episodes (episode_id INTEGER PRIMARY KEY, showid NUMERIC, tvdbid NUMERIC, name TEXT, season NUMERIC, episode NUMERIC, description TEXT, airdate NUMERIC, hasnfo NUMERIC, hastbn NUMERIC, status NUMERIC, location TEXT, file_size NUMERIC, release_name TEXT);", "CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, location TEXT, show_name TEXT, tvdb_id NUMERIC, network TEXT, genre TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, tvr_id NUMERIC, tvr_name TEXT, air_by_date NUMERIC, lang TEXT, last_update_tvdb NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, skip_notices NUMERIC);", "CREATE INDEX idx_tv_episodes_showid_airdate ON tv_episodes (showid,airdate);", "CREATE INDEX idx_showid ON tv_episodes (showid);", "CREATE UNIQUE INDEX idx_tvdb_id ON tv_shows (tvdb_id);", "INSERT INTO db_version (db_version) VALUES (18);" ] for query in queries: self.connection.action(query) else: cur_db_version = self.checkDBVersion() if cur_db_version < MIN_DB_VERSION: logger.log_error_and_exit(u"Your database version (" + str(cur_db_version) + ") is too old to migrate from what this version of Sick Beard supports (" + \ str(MIN_DB_VERSION) + ").\n" + \ "Upgrade using a previous version (tag) build 496 to build 501 of Sick Beard first or remove database file to begin fresh." ) if cur_db_version > MAX_DB_VERSION: logger.log_error_and_exit(u"Your database version (" + str(cur_db_version) + ") has been incremented past what this version of Sick Beard supports (" + \ str(MAX_DB_VERSION) + ").\n" + \ "If you have used other forks of Sick Beard, your database may be unusable due to their modifications." ) # included in build 496 (2012-06-28) class AddSizeAndSceneNameFields(InitialSchema): def test(self): return self.checkDBVersion() >= 10 def execute(self): backupDatabase(10) if not self.hasColumn("tv_episodes", "file_size"): self.addColumn("tv_episodes", "file_size") if not self.hasColumn("tv_episodes", "release_name"): self.addColumn("tv_episodes", "release_name", "TEXT", "") ep_results = self.connection.select("SELECT episode_id, location, file_size FROM tv_episodes") logger.log(u"Adding file size to all episodes in DB, please be patient") for cur_ep in ep_results: if not cur_ep["location"]: continue # if there is no size yet then populate it for us if (not cur_ep["file_size"] or not int(cur_ep["file_size"])) and ek.ek(os.path.isfile, cur_ep["location"]): cur_size = ek.ek(os.path.getsize, cur_ep["location"]) self.connection.action("UPDATE tv_episodes SET file_size = ? WHERE episode_id = ?", [cur_size, int(cur_ep["episode_id"])]) # check each snatch to see if we can use it to get a release name from history_results = self.connection.select("SELECT * FROM history WHERE provider != -1 ORDER BY date ASC") logger.log(u"Adding release name to all episodes still in history") for cur_result in history_results: # find the associated download, if there isn't one then ignore it download_results = self.connection.select("SELECT resource FROM history WHERE provider = -1 AND showid = ? AND season = ? AND episode = ? AND date > ?", [cur_result["showid"], cur_result["season"], cur_result["episode"], cur_result["date"]]) if not download_results: logger.log(u"Found a snatch in the history for " + cur_result["resource"] + " but couldn't find the associated download, skipping it", logger.DEBUG) continue nzb_name = cur_result["resource"] file_name = ek.ek(os.path.basename, download_results[0]["resource"]) # take the extension off the filename, it's not needed if '.' in file_name: file_name = file_name.rpartition('.')[0] # find the associated episode on disk ep_results = self.connection.select("SELECT episode_id, status FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ? AND location != ''", [cur_result["showid"], cur_result["season"], cur_result["episode"]]) if not ep_results: logger.log(u"The episode " + nzb_name + " was found in history but doesn't exist on disk anymore, skipping", logger.DEBUG) continue # get the status/quality of the existing ep and make sure it's what we expect ep_status, ep_quality = common.Quality.splitCompositeStatus(int(ep_results[0]["status"])) if ep_status != common.DOWNLOADED: continue if ep_quality != int(cur_result["quality"]): continue # make sure this is actually a real release name and not a season pack or something for cur_name in (nzb_name, file_name): logger.log(u"Checking if " + cur_name + " is actually a good release name", logger.DEBUG) try: np = NameParser(False) parse_result = np.parse(cur_name) except InvalidNameException: continue if parse_result.series_name and parse_result.season_number is not None and parse_result.episode_numbers and parse_result.release_group: # if all is well by this point we'll just put the release name into the database self.connection.action("UPDATE tv_episodes SET release_name = ? WHERE episode_id = ?", [cur_name, ep_results[0]["episode_id"]]) break # check each snatch to see if we can use it to get a release name from empty_results = self.connection.select("SELECT episode_id, location FROM tv_episodes WHERE release_name = ''") logger.log(u"Adding release name to all episodes with obvious scene filenames") for cur_result in empty_results: ep_file_name = ek.ek(os.path.basename, cur_result["location"]) ep_file_name = os.path.splitext(ep_file_name)[0] # only want to find real scene names here so anything with a space in it is out if ' ' in ep_file_name: continue try: np = NameParser(False) parse_result = np.parse(ep_file_name) except InvalidNameException: continue if not parse_result.release_group: continue logger.log(u"Name " + ep_file_name + " gave release group of " + parse_result.release_group + ", seems valid", logger.DEBUG) self.connection.action("UPDATE tv_episodes SET release_name = ? WHERE episode_id = ?", [ep_file_name, cur_result["episode_id"]]) self.incDBVersion() # included in build 497 (2012-10-16) class RenameSeasonFolders(AddSizeAndSceneNameFields): def test(self): return self.checkDBVersion() >= 11 def execute(self): backupDatabase(11) # rename the column self.connection.action("ALTER TABLE tv_shows RENAME TO tmp_tv_shows") self.connection.action("CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, location TEXT, show_name TEXT, tvdb_id NUMERIC, network TEXT, genre TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, tvr_id NUMERIC, tvr_name TEXT, air_by_date NUMERIC, lang TEXT)") sql = "INSERT INTO tv_shows(show_id, location, show_name, tvdb_id, network, genre, runtime, quality, airs, status, flatten_folders, paused, startyear, tvr_id, tvr_name, air_by_date, lang) SELECT show_id, location, show_name, tvdb_id, network, genre, runtime, quality, airs, status, seasonfolders, paused, startyear, tvr_id, tvr_name, air_by_date, lang FROM tmp_tv_shows" self.connection.action(sql) # flip the values to be opposite of what they were before self.connection.action("UPDATE tv_shows SET flatten_folders = 2 WHERE flatten_folders = 1") self.connection.action("UPDATE tv_shows SET flatten_folders = 1 WHERE flatten_folders = 0") self.connection.action("UPDATE tv_shows SET flatten_folders = 0 WHERE flatten_folders = 2") self.connection.action("DROP TABLE tmp_tv_shows") self.incDBVersion() # included in build 500 (2013-05-11) class Add1080pAndRawHDQualities(RenameSeasonFolders): """Add support for 1080p related qualities along with RawHD Quick overview of what the upgrade needs to do: quality | old | new -------------------------- hdwebdl | 1<<3 | 1<<5 hdbluray | 1<<4 | 1<<7 fullhdbluray | 1<<5 | 1<<8 -------------------------- rawhdtv | | 1<<3 fullhdtv | | 1<<4 fullhdwebdl | | 1<<6 """ def test(self): return self.checkDBVersion() >= 12 def _update_status(self, old_status): (status, quality) = common.Quality.splitCompositeStatus(old_status) return common.Quality.compositeStatus(status, self._update_quality(quality)) def _update_quality(self, old_quality): """Update bitwise flags to reflect new quality values Check flag bits (clear old then set their new locations) starting with the highest bits so we dont overwrite data we need later on """ result = old_quality # move fullhdbluray from 1<<5 to 1<<8 if set if(result & (1<<5)): result = result & ~(1<<5) result = result | (1<<8) # move hdbluray from 1<<4 to 1<<7 if set if(result & (1<<4)): result = result & ~(1<<4) result = result | (1<<7) # move hdwebdl from 1<<3 to 1<<5 if set if(result & (1<<3)): result = result & ~(1<<3) result = result | (1<<5) return result def _update_composite_qualities(self, status): """Unpack, Update, Return new quality values Unpack the composite archive/initial values. Update either qualities if needed. Then return the new compsite quality value. """ best = (status & (0xffff << 16)) >> 16 initial = status & (0xffff) best = self._update_quality(best) initial = self._update_quality(initial) result = ((best << 16) | initial) return result def execute(self): backupDatabase(12) # update the default quality so we dont grab the wrong qualities after migration -- should have really been a config migration sickbeard.QUALITY_DEFAULT = self._update_composite_qualities(sickbeard.QUALITY_DEFAULT) sickbeard.save_config() # upgrade previous HD to HD720p -- shift previous qualities to new placevalues old_hd = common.Quality.combineQualities([common.Quality.HDTV, common.Quality.HDWEBDL >> 2, common.Quality.HDBLURAY >> 3], []) new_hd = common.Quality.combineQualities([common.Quality.HDTV, common.Quality.HDWEBDL, common.Quality.HDBLURAY], []) # update ANY -- shift existing qualities and add new 1080p qualities, note that rawHD was not added to the ANY template old_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.HDWEBDL >> 2, common.Quality.HDBLURAY >> 3, common.Quality.UNKNOWN], []) new_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.FULLHDTV, common.Quality.HDWEBDL, common.Quality.FULLHDWEBDL, common.Quality.HDBLURAY, common.Quality.FULLHDBLURAY, common.Quality.UNKNOWN], []) # update qualities (including templates) logger.log(u"[1/4] Updating pre-defined templates and the quality for each show...", logger.MESSAGE) ql = [] shows = self.connection.select("SELECT * FROM tv_shows") for cur_show in shows: if cur_show["quality"] == old_hd: new_quality = new_hd elif cur_show["quality"] == old_any: new_quality = new_any else: new_quality = self._update_composite_qualities(cur_show["quality"]) ql.append(["UPDATE tv_shows SET quality = ? WHERE show_id = ?", [new_quality, cur_show["show_id"]]]) self.connection.mass_action(ql) # update status that are are within the old hdwebdl (1<<3 which is 8) and better -- exclude unknown (1<<15 which is 32768) logger.log(u"[2/4] Updating the status for the episodes within each show...", logger.MESSAGE) ql = [] episodes = self.connection.select("SELECT * FROM tv_episodes WHERE status < 3276800 AND status >= 800") for cur_episode in episodes: ql.append(["UPDATE tv_episodes SET status = ? WHERE episode_id = ?", [self._update_status(cur_episode["status"]), cur_episode["episode_id"]]]) self.connection.mass_action(ql) # make two separate passes through the history since snatched and downloaded (action & quality) may not always coordinate together # update previous history so it shows the correct action logger.log(u"[3/4] Updating history to reflect the correct action...", logger.MESSAGE) ql = [] historyAction = self.connection.select("SELECT * FROM history WHERE action < 3276800 AND action >= 800") for cur_entry in historyAction: ql.append(["UPDATE history SET action = ? WHERE showid = ? AND date = ?", [self._update_status(cur_entry["action"]), cur_entry["showid"], cur_entry["date"]]]) self.connection.mass_action(ql) # update previous history so it shows the correct quality logger.log(u"[4/4] Updating history to reflect the correct quality...", logger.MESSAGE) ql = [] historyQuality = self.connection.select("SELECT * FROM history WHERE quality < 32768 AND quality >= 8") for cur_entry in historyQuality: ql.append(["UPDATE history SET quality = ? WHERE showid = ? AND date = ?", [self._update_quality(cur_entry["quality"]), cur_entry["showid"], cur_entry["date"]]]) self.connection.mass_action(ql) self.incDBVersion() # cleanup and reduce db if any previous data was removed logger.log(u"Performing a vacuum on the database.", logger.DEBUG) self.connection.action("VACUUM") # included in build 502 (2013-11-24) class AddShowidTvdbidIndex(Add1080pAndRawHDQualities): """ Adding index on tvdb_id (tv_shows) and showid (tv_episodes) to speed up searches/queries """ def test(self): return self.checkDBVersion() >= 13 def execute(self): backupDatabase(13) logger.log(u"Check for duplicate shows before adding unique index.") MainSanityCheck(self.connection).fix_duplicate_shows() logger.log(u"Adding index on tvdb_id (tv_shows) and showid (tv_episodes) to speed up searches/queries.") if not self.hasTable("idx_showid"): self.connection.action("CREATE INDEX idx_showid ON tv_episodes (showid);") if not self.hasTable("idx_tvdb_id"): self.connection.action("CREATE UNIQUE INDEX idx_tvdb_id ON tv_shows (tvdb_id);") self.incDBVersion() # included in build 502 (2013-11-24) class AddLastUpdateTVDB(AddShowidTvdbidIndex): """ Adding column last_update_tvdb to tv_shows for controlling nightly updates """ def test(self): return self.checkDBVersion() >= 14 def execute(self): backupDatabase(14) logger.log(u"Adding column last_update_tvdb to tvshows") if not self.hasColumn("tv_shows", "last_update_tvdb"): self.addColumn("tv_shows", "last_update_tvdb", default=1) self.incDBVersion() # included in build 504 (2014-04-14) class AddRequireAndIgnoreWords(AddLastUpdateTVDB): """ Adding column rls_require_words and rls_ignore_words to tv_shows """ def test(self): return self.checkDBVersion() >= 15 def execute(self): backupDatabase(15) logger.log(u"Adding column rls_require_words to tvshows") if not self.hasColumn("tv_shows", "rls_require_words"): self.addColumn("tv_shows", "rls_require_words", "TEXT", "") logger.log(u"Adding column rls_ignore_words to tvshows") if not self.hasColumn("tv_shows", "rls_ignore_words"): self.addColumn("tv_shows", "rls_ignore_words", "TEXT", "") self.incDBVersion() # included in build 507 (2014-11-16) class CleanupHistoryAndSpecials(AddRequireAndIgnoreWords): """ Cleanup older history entries and set specials from wanted to skipped """ def test(self): return self.checkDBVersion() >= 16 def execute(self): backupDatabase(16) logger.log(u"Setting special episodes status to SKIPPED.") self.connection.action("UPDATE tv_episodes SET status = ? WHERE status = ? AND season = 0", [common.SKIPPED, common.WANTED]) fix_ep_rls_group = [] fix_ep_release_name = [] # re-analyze snatched data logger.log(u"Analyzing history to correct bad data (this could take a moment, be patient)...") history_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 2 ORDER BY date ASC") for cur_result in history_results: # find the associated download, if there isn't one then ignore it download_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 4 AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date > ?", [cur_result["showid"], cur_result["season"], cur_result["episode"], cur_result["quality"], cur_result["date"]]) # only continue if there was a download found (thats newer than the snatched) if not download_results: logger.log(u"Found a snatch in the history for " + cur_result["resource"] + " but couldn't find the associated download, skipping it", logger.DEBUG) continue # take the snatched nzb, clean it up so we can store it for the corresponding tv_episodes entry clean_nzb_name = helpers.remove_non_release_groups(helpers.remove_extension(cur_result["resource"])) # fixed known bad release_group data if download_results[0]["provider"].upper() in ["-1", "RP", "NZBGEEK"] or "." in download_results[0]["provider"]: try: np = NameParser(False) parse_result = np.parse(clean_nzb_name) except InvalidNameException: continue # leave off check for episode number so we can update season rip data as well? if parse_result.series_name and parse_result.season_number is not None and parse_result.release_group: fix_ep_rls_group.append(["UPDATE history SET provider = ? WHERE action = ? AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date = ?", \ [parse_result.release_group, download_results[0]["action"], download_results[0]["showid"], download_results[0]["season"], download_results[0]["episode"], download_results[0]["quality"], download_results[0]["date"]] ]) # find the associated episode on disk ep_results = self.connection.select("SELECT episode_id, status, release_name FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ? AND location != ''", [cur_result["showid"], cur_result["season"], cur_result["episode"]]) if not ep_results: logger.log(u"The episode " + cur_result["resource"] + " was found in history but doesn't exist on disk anymore, skipping", logger.DEBUG) continue # skip items that appears to have a 'scene' name already to avoid replacing locally pp/manually moved items match = re.search(".(xvid|x264|h.?264|mpeg-?2)", ep_results[0]["release_name"], re.I) if match: continue # get the status/quality of the existing ep and make sure it's what we expect ep_status, ep_quality = common.Quality.splitCompositeStatus(int(ep_results[0]["status"])) if ep_status != common.DOWNLOADED: continue if ep_quality != int(cur_result["quality"]): continue # take the extension off the filename, it's not needed file_name = ek.ek(os.path.basename, download_results[0]["resource"]) if '.' in file_name: file_name = file_name.rpartition('.')[0] # make sure this is actually a real release name and not a season pack or something for cur_name in (clean_nzb_name, file_name): logger.log(u"Checking if " + cur_name + " is actually a good release name", logger.DEBUG) try: np = NameParser(False) parse_result = np.parse(cur_name) except InvalidNameException: continue if parse_result.series_name and parse_result.season_number is not None and parse_result.episode_numbers and parse_result.release_group: # if all is well by this point we'll just put the release name into the database fix_ep_release_name.append(["UPDATE tv_episodes SET release_name = ? WHERE episode_id = ?", [cur_name, ep_results[0]["episode_id"]]]) break logger.log(u"Corrected " + str(len(fix_ep_release_name)) + " release names (" + str(len(fix_ep_rls_group)) + " release groups) out of the " + str(len(history_results)) + " releases analyzed.") if len(fix_ep_rls_group) > 0: self.connection.mass_action(fix_ep_rls_group) if len(fix_ep_release_name) > 0: self.connection.mass_action(fix_ep_release_name) # now cleanup all downloaded release groups in the history fix_ep_rls_group = [] logger.log(u"Analyzing downloaded history release groups...") history_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 4 ORDER BY date ASC") for cur_result in history_results: clean_provider = helpers.remove_non_release_groups(helpers.remove_extension(cur_result["provider"])) # take the data on the left of the _, fixes 'LOL_repost' if clean_provider and "_" in clean_provider: clean_provider = clean_provider.rsplit('_', 1)[0] if clean_provider != cur_result["provider"]: fix_ep_rls_group.append(["UPDATE history SET provider = ? WHERE action = ? AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date = ?", \ [clean_provider, cur_result["action"], cur_result["showid"], cur_result["season"], cur_result["episode"], cur_result["quality"], cur_result["date"]] ]) logger.log(u"Corrected " + str(len(fix_ep_rls_group)) + " release groups.") if len(fix_ep_rls_group) > 0: self.connection.mass_action(fix_ep_rls_group) self.incDBVersion() # cleanup and reduce db if any previous data was removed logger.log(u"Performing a vacuum on the database.", logger.DEBUG) self.connection.action("VACUUM") # included in build 507 (2014-11-16) class AddSkipNotifications(CleanupHistoryAndSpecials): """ Adding column skip_notices to tv_shows """ def test(self): return self.checkDBVersion() >= 17 def execute(self): backupDatabase(17) logger.log(u"Adding column skip_notices to tvshows") if not self.hasColumn("tv_shows", "skip_notices"): self.addColumn("tv_shows", "skip_notices") self.incDBVersion() # included in build 507 (2014-11-16) class AddHistorySource(AddSkipNotifications): """ Adding column source to history """ def test(self): return self.checkDBVersion() >= 18 def execute(self): backupDatabase(18) logger.log(u"Adding column source to history") if not self.hasColumn("history", "source"): self.addColumn("history", "source", "TEXT", "") logger.log(u"Analyzing history and setting snatch source...") # set source to nzb by default self.connection.action("UPDATE history SET source = 'nzb' WHERE action % 100 = 2") # set source to torrent where needed set_torrent_source = [] history_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 2 AND provider IN ('BTN', 'HDbits', 'TorrentLeech', 'TvTorrents')") for cur_result in history_results: set_torrent_source.append(["UPDATE history SET source = 'torrent' WHERE action = ? AND date = ? AND showid = ? AND provider = ? AND quality = ?", \ [cur_result["action"], cur_result["date"], cur_result["showid"], cur_result["provider"], cur_result["quality"]] ]) if len(set_torrent_source) > 0: self.connection.mass_action(set_torrent_source) self.incDBVersion()
gpl-3.0
[ 3, 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 202, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 202, 199, 3, 202, 199, 3, 961, 570, 365, 1777, 402, 28964, 6423, 1005, 14, 202, 199, 3, 202, 199, 3, 28964, 6423, 1005, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 202, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 202, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 202, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 28964, 6423, 1005, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 202, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 202, 199, 3, 3180, 543, 28964, 6423, 1005, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 2999, 199, 646, 17898, 202, 199, 646, 747, 14, 515, 202, 199, 646, 984, 202, 199, 646, 295, 2999, 199, 504, 17898, 492, 1592, 12, 2863, 12, 10897, 12, 2512, 2999, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 202, 199, 504, 17898, 14, 354, 63, 2087, 14, 2087, 492, 2812, 2842, 12, 6378, 985, 1726, 2999, 199, 4896, 63, 2846, 63, 4612, 275, 1749, 221, 327, 29493, 1592, 1015, 781, 2291, 3952, 10417, 687, 202, 199, 4283, 63, 2846, 63, 4612, 275, 6155, 8065, 199, 533, 11298, 25901, 1799, 8, 697, 14, 2846, 25901, 1799, 304, 1128, 347, 1104, 8, 277, 304, 1039, 291, 14, 970, 63, 11081, 63, 23866, 342, 1039, 291, 14, 970, 63, 11081, 63, 22027, 342, 1039, 291, 14, 970, 63, 22161, 63, 22027, 342, 2958, 347, 5325, 63, 11081, 63, 23866, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 63, 344, 12, 26905, 63, 344, 12, 24903, 8, 23625, 63, 344, 9, 465, 2338, 4442, 13466, 63, 23866, 15443, 6515, 26905, 63, 344, 869, 6087, 1206, 2338, 690, 413, 531, 4341, 367, 1094, 63, 11081, 315, 3875, 6579, 26, 11556, 2512, 14, 793, 8, 85, 2, 14773, 2498, 10501, 1, 26905, 63, 344, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 23625, 63, 344, 3135, 435, 399, 2, 2338, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 835, 10252, 2512, 14, 5287, 9, 11556, 1094, 63, 30706, 63, 2604, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 63, 344, 12, 26905, 63, 344, 4442, 13466, 63, 23866, 6038, 26905, 63, 344, 275, 5805, 5138, 5805, 401, 202, 5644, 359, 895, 63, 11081, 905, 23625, 63, 344, 2255, 1109, 8, 895, 63, 11081, 905, 835, 3135, 446, 413, 61, 202, 5644, 776, 11556, 367, 1094, 63, 30706, 63, 344, 315, 1094, 63, 30706, 63, 2604, 26, 2628, 2512, 14, 793, 8, 85, 2, 22001, 9250, 2498, 543, 26905, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 23625, 63, 344, 3135, 435, 399, 2, 2498, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 2384, 63, 344, 13045, 2628, 291, 14, 2105, 14, 1287, 480, 7014, 4442, 13466, 63, 23866, 6038, 2498, 63, 344, 275, 5805, 401, 359, 895, 63, 30706, 63, 344, 905, 2384, 63, 344, 937, 566, 4341, 587, 26, 1675, 2512, 14, 793, 8, 85, 2, 1944, 9250, 2498, 12, 1104, 3032, 531, 2958, 347, 5325, 63, 11081, 63, 22027, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 344, 12, 14718, 12, 11052, 12, 24903, 8, 2384, 344, 9, 465, 2338, 4442, 13466, 63, 22027, 15443, 6515, 2498, 344, 12, 14718, 12, 11052, 869, 6087, 1206, 2338, 690, 413, 531, 4341, 367, 1094, 63, 11081, 315, 3875, 6579, 26, 11556, 2512, 14, 793, 8, 85, 2, 14773, 11052, 10501, 1, 2498, 344, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 2384, 344, 3135, 435, 399, 2, 14718, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 12605, 3135, 435, 399, 2, 11052, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 9544, 3135, 435, 399, 2, 2338, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 835, 10252, 2512, 14, 5287, 9, 11556, 1094, 63, 30706, 63, 2604, 275, 291, 14, 2105, 14, 2416, 480, 4859, 11052, 63, 344, 4442, 13466, 63, 22027, 6038, 2498, 344, 275, 5805, 2401, 14718, 275, 5805, 436, 11052, 275, 5805, 16044, 6515, 11052, 63, 344, 23915, 5138, 5805, 401, 202, 5644, 359, 895, 63, 11081, 905, 2384, 344, 2255, 1094, 63, 11081, 905, 12605, 2255, 1094, 63, 11081, 905, 9544, 2255, 1109, 8, 895, 63, 11081, 905, 835, 3135, 446, 413, 61, 202, 5644, 776, 11556, 367, 1094, 63, 30706, 63, 344, 315, 1094, 63, 30706, 63, 2604, 26, 2628, 2512, 14, 793, 8, 85, 2, 22001, 9250, 11052, 543, 11052, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 9544, 63, 344, 13045, 2628, 291, 14, 2105, 14, 1287, 480, 7014, 4442, 13466, 63, 22027, 6038, 11052, 63, 344, 275, 5805, 401, 359, 895, 63, 30706, 63, 344, 905, 9544, 63, 344, 937, 566, 4341, 587, 26, 1675, 2512, 14, 793, 8, 85, 2, 1944, 9250, 11052, 12, 1104, 3032, 531, 2958, 347, 5325, 63, 22161, 63, 22027, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 11052, 63, 344, 12, 2498, 344, 12, 13466, 63, 23866, 14, 23625, 63, 344, 4442, 13466, 63, 22027, 6578, 10593, 13466, 63, 23866, 5258, 13466, 63, 22027, 14, 2384, 344, 29, 6993, 63, 23866, 14, 23625, 63, 344, 6038, 13466, 63, 23866, 14, 23625, 63, 344, 365, 5962, 531, 4341, 367, 1094, 63, 22161, 315, 3875, 6579, 26, 1675, 2512, 14, 793, 8, 85, 2 ]
[ 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 202, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 202, 199, 3, 202, 199, 3, 961, 570, 365, 1777, 402, 28964, 6423, 1005, 14, 202, 199, 3, 202, 199, 3, 28964, 6423, 1005, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 202, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 202, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 202, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 28964, 6423, 1005, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 202, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 202, 199, 3, 3180, 543, 28964, 6423, 1005, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 2999, 199, 646, 17898, 202, 199, 646, 747, 14, 515, 202, 199, 646, 984, 202, 199, 646, 295, 2999, 199, 504, 17898, 492, 1592, 12, 2863, 12, 10897, 12, 2512, 2999, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 202, 199, 504, 17898, 14, 354, 63, 2087, 14, 2087, 492, 2812, 2842, 12, 6378, 985, 1726, 2999, 199, 4896, 63, 2846, 63, 4612, 275, 1749, 221, 327, 29493, 1592, 1015, 781, 2291, 3952, 10417, 687, 202, 199, 4283, 63, 2846, 63, 4612, 275, 6155, 8065, 199, 533, 11298, 25901, 1799, 8, 697, 14, 2846, 25901, 1799, 304, 1128, 347, 1104, 8, 277, 304, 1039, 291, 14, 970, 63, 11081, 63, 23866, 342, 1039, 291, 14, 970, 63, 11081, 63, 22027, 342, 1039, 291, 14, 970, 63, 22161, 63, 22027, 342, 2958, 347, 5325, 63, 11081, 63, 23866, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 63, 344, 12, 26905, 63, 344, 12, 24903, 8, 23625, 63, 344, 9, 465, 2338, 4442, 13466, 63, 23866, 15443, 6515, 26905, 63, 344, 869, 6087, 1206, 2338, 690, 413, 531, 4341, 367, 1094, 63, 11081, 315, 3875, 6579, 26, 11556, 2512, 14, 793, 8, 85, 2, 14773, 2498, 10501, 1, 26905, 63, 344, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 23625, 63, 344, 3135, 435, 399, 2, 2338, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 835, 10252, 2512, 14, 5287, 9, 11556, 1094, 63, 30706, 63, 2604, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 63, 344, 12, 26905, 63, 344, 4442, 13466, 63, 23866, 6038, 26905, 63, 344, 275, 5805, 5138, 5805, 401, 202, 5644, 359, 895, 63, 11081, 905, 23625, 63, 344, 2255, 1109, 8, 895, 63, 11081, 905, 835, 3135, 446, 413, 61, 202, 5644, 776, 11556, 367, 1094, 63, 30706, 63, 344, 315, 1094, 63, 30706, 63, 2604, 26, 2628, 2512, 14, 793, 8, 85, 2, 22001, 9250, 2498, 543, 26905, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 23625, 63, 344, 3135, 435, 399, 2, 2498, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 2384, 63, 344, 13045, 2628, 291, 14, 2105, 14, 1287, 480, 7014, 4442, 13466, 63, 23866, 6038, 2498, 63, 344, 275, 5805, 401, 359, 895, 63, 30706, 63, 344, 905, 2384, 63, 344, 937, 566, 4341, 587, 26, 1675, 2512, 14, 793, 8, 85, 2, 1944, 9250, 2498, 12, 1104, 3032, 531, 2958, 347, 5325, 63, 11081, 63, 22027, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 2498, 344, 12, 14718, 12, 11052, 12, 24903, 8, 2384, 344, 9, 465, 2338, 4442, 13466, 63, 22027, 15443, 6515, 2498, 344, 12, 14718, 12, 11052, 869, 6087, 1206, 2338, 690, 413, 531, 4341, 367, 1094, 63, 11081, 315, 3875, 6579, 26, 11556, 2512, 14, 793, 8, 85, 2, 14773, 11052, 10501, 1, 2498, 344, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 2384, 344, 3135, 435, 399, 2, 14718, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 12605, 3135, 435, 399, 2, 11052, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 9544, 3135, 435, 399, 2, 2338, 26, 298, 435, 620, 8, 895, 63, 11081, 905, 835, 10252, 2512, 14, 5287, 9, 11556, 1094, 63, 30706, 63, 2604, 275, 291, 14, 2105, 14, 2416, 480, 4859, 11052, 63, 344, 4442, 13466, 63, 22027, 6038, 2498, 344, 275, 5805, 2401, 14718, 275, 5805, 436, 11052, 275, 5805, 16044, 6515, 11052, 63, 344, 23915, 5138, 5805, 401, 202, 5644, 359, 895, 63, 11081, 905, 2384, 344, 2255, 1094, 63, 11081, 905, 12605, 2255, 1094, 63, 11081, 905, 9544, 2255, 1109, 8, 895, 63, 11081, 905, 835, 3135, 446, 413, 61, 202, 5644, 776, 11556, 367, 1094, 63, 30706, 63, 344, 315, 1094, 63, 30706, 63, 2604, 26, 2628, 2512, 14, 793, 8, 85, 2, 22001, 9250, 11052, 543, 11052, 63, 344, 26, 298, 435, 620, 8, 895, 63, 30706, 63, 344, 905, 9544, 63, 344, 13045, 2628, 291, 14, 2105, 14, 1287, 480, 7014, 4442, 13466, 63, 22027, 6038, 11052, 63, 344, 275, 5805, 401, 359, 895, 63, 30706, 63, 344, 905, 9544, 63, 344, 937, 566, 4341, 587, 26, 1675, 2512, 14, 793, 8, 85, 2, 1944, 9250, 11052, 12, 1104, 3032, 531, 2958, 347, 5325, 63, 22161, 63, 22027, 8, 277, 304, 1039, 3875, 6579, 275, 291, 14, 2105, 14, 2416, 480, 4859, 11052, 63, 344, 12, 2498, 344, 12, 13466, 63, 23866, 14, 23625, 63, 344, 4442, 13466, 63, 22027, 6578, 10593, 13466, 63, 23866, 5258, 13466, 63, 22027, 14, 2384, 344, 29, 6993, 63, 23866, 14, 23625, 63, 344,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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 ]
zhenzhai/edx-platform
lms/djangoapps/ccx/modulestore.py
13
13391
# -*- coding: utf-8 -*- """A modulestore wrapper It will 'unwrap' ccx keys on the way in and re-wrap them on the way out In practical terms this means that when an object is retrieved from modulestore using a CCXLocator or CCXBlockUsageLocator as the key, the equivalent CourseLocator or BlockUsageLocator will actually be used. And all objects returned from the modulestore will have their keys updated to be the CCX version that was passed in. """ from contextlib import contextmanager from functools import partial from ccx_keys.locator import CCXLocator, CCXBlockUsageLocator from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator from xmodule.modulestore import XMODULE_FIELDS_WITH_USAGE_KEYS def strip_ccx(val): """remove any reference to a CCX from the incoming value return a tuple of the stripped value and the id of the ccx """ retval = val ccx_id = None if isinstance(retval, CCXLocator): ccx_id = retval.ccx retval = retval.to_course_locator() elif isinstance(retval, CCXBlockUsageLocator): ccx_id = retval.course_key.ccx retval = retval.to_block_locator() else: for field_name in XMODULE_FIELDS_WITH_USAGE_KEYS: if hasattr(retval, field_name): stripped_field_value, ccx_id = strip_ccx(getattr(retval, field_name)) setattr(retval, field_name, stripped_field_value) return retval, ccx_id def restore_ccx(val, ccx_id): """restore references to a CCX to the incoming value returns the value converted to a CCX-aware state, using the provided ccx_id """ if isinstance(val, CourseLocator): return CCXLocator.from_course_locator(val, ccx_id) elif isinstance(val, BlockUsageLocator): ccx_key = restore_ccx(val.course_key, ccx_id) val = CCXBlockUsageLocator(ccx_key, val.block_type, val.block_id) for field_name in XMODULE_FIELDS_WITH_USAGE_KEYS: if hasattr(val, field_name): setattr(val, field_name, restore_ccx(getattr(val, field_name), ccx_id)) if hasattr(val, 'children'): val.children = restore_ccx_collection(val.children, ccx_id) return val def restore_ccx_collection(field_value, ccx_id=None): """restore references to a CCX to collections of incoming values returns the original collection with all values converted to a ccx-aware state, using the provided ccx_id """ if ccx_id is None: return field_value if isinstance(field_value, list): field_value = [restore_ccx(fv, ccx_id) for fv in field_value] elif isinstance(field_value, dict): for key, val in field_value.iteritems(): field_value[key] = restore_ccx(val, ccx_id) else: field_value = restore_ccx(field_value, ccx_id) return field_value @contextmanager def remove_ccx(to_strip): """A context manager for wrapping modulestore api methods. yields a stripped value and a function suitable for restoring it """ stripped, ccx = strip_ccx(to_strip) yield stripped, partial(restore_ccx_collection, ccx_id=ccx) class CCXModulestoreWrapper(object): """This class wraps a modulestore The purpose is to remove ccx-specific identifiers during lookup and restore it after retrieval so that data can be stored local to a course, but referenced in app context as ccx-specific """ def __init__(self, modulestore): """wrap the provided modulestore""" self.__dict__['_modulestore'] = modulestore def __getattr__(self, name): """look up missing attributes on the wrapped modulestore""" return getattr(self._modulestore, name) def __setattr__(self, name, value): """set attributes only on the wrapped modulestore""" setattr(self._modulestore, name, value) def __delattr__(self, name): """delete attributes only on the wrapped modulestore""" delattr(self._modulestore, name) def _clean_locator_for_mapping(self, locator): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(locator) as (locator, restore): # pylint: disable=protected-access return restore( self._modulestore._clean_locator_for_mapping(locator) ) def _get_modulestore_for_courselike(self, locator=None): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" if locator is not None: locator, _ = strip_ccx(locator) # pylint: disable=protected-access return self._modulestore._get_modulestore_for_courselike(locator) def fill_in_run(self, course_key): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.fill_in_run(course_key)) def has_item(self, usage_key, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" usage_key, _ = strip_ccx(usage_key) return self._modulestore.has_item(usage_key, **kwargs) def get_item(self, usage_key, depth=0, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(usage_key) as (usage_key, restore): return restore( self._modulestore.get_item(usage_key, depth, **kwargs) ) def get_items(self, course_key, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.get_items(course_key, **kwargs)) def get_course(self, course_key, depth=0, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.get_course( course_key, depth=depth, **kwargs )) def has_course(self, course_id, ignore_case=False, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_id) as (course_id, restore): return restore(self._modulestore.has_course( course_id, ignore_case=ignore_case, **kwargs )) def delete_course(self, course_key, user_id): """ See xmodule.modulestore.__init__.ModuleStoreWrite.delete_course """ course_key, _ = strip_ccx(course_key) return self._modulestore.delete_course(course_key, user_id) def get_parent_location(self, location, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.get_parent_location(location, **kwargs) ) def get_block_original_usage(self, usage_key): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(usage_key) as (usage_key, restore): orig_key, version = self._modulestore.get_block_original_usage(usage_key) return restore(orig_key), version def get_modulestore_type(self, course_id): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_id) as (course_id, restore): return restore(self._modulestore.get_modulestore_type(course_id)) def get_orphans(self, course_key, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.get_orphans(course_key, **kwargs)) def clone_course(self, source_course_id, dest_course_id, user_id, fields=None, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(source_course_id) as (source_course_id, _): with remove_ccx(dest_course_id) as (dest_course_id, dest_restore): return dest_restore(self._modulestore.clone_course( source_course_id, dest_course_id, user_id, fields=fields, **kwargs )) def create_item(self, user_id, course_key, block_type, block_id=None, fields=None, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.create_item( user_id, course_key, block_type, block_id=block_id, fields=fields, **kwargs )) def create_child(self, user_id, parent_usage_key, block_type, block_id=None, fields=None, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(parent_usage_key) as (parent_usage_key, restore): return restore(self._modulestore.create_child( user_id, parent_usage_key, block_type, block_id=block_id, fields=fields, **kwargs )) def import_xblock(self, user_id, course_key, block_type, block_id, fields=None, runtime=None, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.import_xblock( user_id, course_key, block_type, block_id, fields=fields, runtime=runtime, **kwargs )) def copy_from_template(self, source_keys, dest_key, user_id, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(dest_key) as (dest_key, restore): return restore(self._modulestore.copy_from_template( source_keys, dest_key, user_id, **kwargs )) def update_item(self, xblock, user_id, allow_not_found=False, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(xblock) as (xblock, restore): return restore(self._modulestore.update_item( xblock, user_id, allow_not_found=allow_not_found, **kwargs )) def delete_item(self, location, user_id, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.delete_item(location, user_id, **kwargs) ) def revert_to_published(self, location, user_id): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.revert_to_published(location, user_id) ) def create_xblock(self, runtime, course_key, block_type, block_id=None, fields=None, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(course_key) as (course_key, restore): return restore(self._modulestore.create_xblock( runtime, course_key, block_type, block_id=block_id, fields=fields, **kwargs )) def has_published_version(self, xblock): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(xblock) as (xblock, restore): return restore(self._modulestore.has_published_version(xblock)) def publish(self, location, user_id, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.publish(location, user_id, **kwargs) ) def unpublish(self, location, user_id, **kwargs): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.unpublish(location, user_id, **kwargs) ) def convert_to_draft(self, location, user_id): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(location) as (location, restore): return restore( self._modulestore.convert_to_draft(location, user_id) ) def has_changes(self, xblock): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" with remove_ccx(xblock) as (xblock, restore): return restore(self._modulestore.has_changes(xblock)) def check_supports(self, course_key, method): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" course_key, _ = strip_ccx(course_key) return self._modulestore.check_supports(course_key, method) @contextmanager def branch_setting(self, branch_setting, course_id=None): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" course_id, _ = strip_ccx(course_id) with self._modulestore.branch_setting(branch_setting, course_id): yield @contextmanager def bulk_operations(self, course_id, emit_signals=True): """See the docs for xmodule.modulestore.mixed.MixedModuleStore""" course_id, _ = strip_ccx(course_id) with self._modulestore.bulk_operations(course_id, emit_signals=emit_signals): yield
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 33, 10996, 4975, 199, 199, 7940, 911, 283, 28896, 7, 7429, 88, 2883, 641, 314, 4340, 315, 436, 295, 13, 3823, 3062, 641, 314, 4340, 734, 199, 199, 607, 20594, 3294, 2895, 642, 4910, 626, 1380, 376, 909, 365, 12396, 687, 10996, 199, 4941, 282, 17586, 56, 10725, 503, 17586, 24784, 7692, 10725, 465, 314, 790, 12, 314, 7353, 199, 6979, 10725, 503, 8651, 7692, 10725, 911, 5965, 506, 1202, 14, 6061, 1006, 2251, 199, 19065, 687, 314, 10996, 911, 1172, 3932, 2883, 4588, 370, 506, 314, 17586, 56, 199, 1023, 626, 1990, 3032, 315, 14, 199, 624, 199, 504, 15502, 492, 27608, 199, 504, 9143, 492, 7417, 199, 504, 7429, 88, 63, 1612, 14, 6354, 492, 17586, 56, 10725, 12, 17586, 24784, 7692, 10725, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 12, 8651, 7692, 10725, 199, 504, 9872, 14, 10012, 492, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 421, 199, 318, 6202, 63, 19541, 8, 637, 304, 272, 408, 2168, 1263, 3659, 370, 282, 17586, 56, 687, 314, 12467, 574, 339, 372, 282, 2008, 402, 314, 14489, 574, 436, 314, 1305, 402, 314, 7429, 88, 272, 408, 272, 9151, 275, 1139, 272, 7429, 88, 63, 344, 275, 488, 272, 340, 1228, 8, 18476, 12, 17586, 56, 10725, 304, 267, 7429, 88, 63, 344, 275, 9151, 14, 19541, 267, 9151, 275, 9151, 14, 475, 63, 1972, 63, 6354, 342, 272, 916, 1228, 8, 18476, 12, 17586, 24784, 7692, 10725, 304, 267, 7429, 88, 63, 344, 275, 9151, 14, 1972, 63, 498, 14, 19541, 267, 9151, 275, 9151, 14, 475, 63, 1457, 63, 6354, 342, 272, 587, 26, 267, 367, 901, 63, 354, 315, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 26, 288, 340, 2688, 8, 18476, 12, 901, 63, 354, 304, 355, 14489, 63, 698, 63, 585, 12, 7429, 88, 63, 344, 275, 6202, 63, 19541, 8, 5675, 8, 18476, 12, 901, 63, 354, 430, 355, 5371, 8, 18476, 12, 901, 63, 354, 12, 14489, 63, 698, 63, 585, 9, 272, 372, 9151, 12, 7429, 88, 63, 344, 421, 199, 318, 9066, 63, 19541, 8, 637, 12, 7429, 88, 63, 344, 304, 272, 408, 8011, 6941, 370, 282, 17586, 56, 370, 314, 12467, 574, 339, 2529, 314, 574, 6702, 370, 282, 17586, 56, 13, 14600, 1174, 12, 1808, 314, 2741, 7429, 88, 63, 344, 272, 408, 272, 340, 1228, 8, 637, 12, 31480, 304, 267, 372, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 637, 12, 7429, 88, 63, 344, 9, 272, 916, 1228, 8, 637, 12, 8651, 7692, 10725, 304, 267, 7429, 88, 63, 498, 275, 9066, 63, 19541, 8, 637, 14, 1972, 63, 498, 12, 7429, 88, 63, 344, 9, 267, 1139, 275, 17586, 24784, 7692, 10725, 8, 19541, 63, 498, 12, 1139, 14, 1457, 63, 466, 12, 1139, 14, 1457, 63, 344, 9, 272, 367, 901, 63, 354, 315, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 26, 267, 340, 2688, 8, 637, 12, 901, 63, 354, 304, 288, 5371, 8, 637, 12, 901, 63, 354, 12, 9066, 63, 19541, 8, 5675, 8, 637, 12, 901, 63, 354, 395, 7429, 88, 63, 344, 430, 272, 340, 2688, 8, 637, 12, 283, 3223, 735, 267, 1139, 14, 3223, 275, 9066, 63, 19541, 63, 3627, 8, 637, 14, 3223, 12, 7429, 88, 63, 344, 9, 272, 372, 1139, 421, 199, 318, 9066, 63, 19541, 63, 3627, 8, 698, 63, 585, 12, 7429, 88, 63, 344, 29, 403, 304, 272, 408, 8011, 6941, 370, 282, 17586, 56, 370, 5055, 402, 12467, 1338, 339, 2529, 314, 3379, 3245, 543, 1006, 1338, 6702, 370, 282, 7429, 88, 13, 14600, 272, 1174, 12, 1808, 314, 2741, 7429, 88, 63, 344, 272, 408, 272, 340, 7429, 88, 63, 344, 365, 488, 26, 267, 372, 901, 63, 585, 272, 340, 1228, 8, 698, 63, 585, 12, 769, 304, 267, 901, 63, 585, 275, 359, 8011, 63, 19541, 8, 13692, 12, 7429, 88, 63, 344, 9, 367, 289, 86, 315, 901, 63, 585, 61, 272, 916, 1228, 8, 698, 63, 585, 12, 1211, 304, 267, 367, 790, 12, 1139, 315, 901, 63, 585, 14, 4611, 837, 288, 901, 63, 585, 59, 498, 61, 275, 9066, 63, 19541, 8, 637, 12, 7429, 88, 63, 344, 9, 272, 587, 26, 267, 901, 63, 585, 275, 9066, 63, 19541, 8, 698, 63, 585, 12, 7429, 88, 63, 344, 9, 272, 372, 901, 63, 585, 421, 199, 32, 14237, 199, 318, 2813, 63, 19541, 8, 475, 63, 1913, 304, 272, 408, 33, 1067, 5256, 367, 19696, 10996, 2986, 3102, 14, 339, 14801, 282, 14489, 574, 436, 282, 805, 11233, 367, 4618, 6854, 652, 272, 408, 272, 14489, 12, 7429, 88, 275, 6202, 63, 19541, 8, 475, 63, 1913, 9, 272, 1995, 14489, 12, 7417, 8, 8011, 63, 19541, 63, 3627, 12, 7429, 88, 63, 344, 29, 19541, 9, 421, 199, 533, 17586, 56, 2377, 1617, 4590, 8, 785, 304, 272, 408, 2765, 1021, 14018, 282, 10996, 339, 710, 12016, 365, 370, 2813, 7429, 88, 13, 6100, 14154, 5309, 4237, 436, 9066, 272, 652, 2410, 27157, 880, 626, 666, 883, 506, 5489, 2257, 370, 282, 2518, 12, 1325, 272, 11812, 315, 1145, 1067, 465, 7429, 88, 13, 6100, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10996, 304, 267, 408, 3823, 314, 2741, 10996, 624, 267, 291, 855, 807, 363, 8680, 10012, 418, 275, 10996, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 408, 11660, 1536, 4124, 3004, 641, 314, 8072, 10996, 624, 267, 372, 2519, 8, 277, 423, 10012, 12, 536, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 408, 409, 3004, 1454, 641, 314, 8072, 10996, 624, 267, 5371, 8, 277, 423, 10012, 12, 536, 12, 574, 9, 339, 347, 636, 30831, 721, 277, 12, 536, 304, 267, 408, 1807, 3004, 1454, 641, 314, 8072, 10996, 624, 267, 24358, 8, 277, 423, 10012, 12, 536, 9, 339, 347, 485, 3118, 63, 6354, 63, 509, 63, 4745, 8, 277, 12, 14067, 304, 267, 408, 9295, 314, 9149, 367, 9872, 14, 10012, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 33, 10996, 4975, 199, 199, 7940, 911, 283, 28896, 7, 7429, 88, 2883, 641, 314, 4340, 315, 436, 295, 13, 3823, 3062, 641, 314, 4340, 734, 199, 199, 607, 20594, 3294, 2895, 642, 4910, 626, 1380, 376, 909, 365, 12396, 687, 10996, 199, 4941, 282, 17586, 56, 10725, 503, 17586, 24784, 7692, 10725, 465, 314, 790, 12, 314, 7353, 199, 6979, 10725, 503, 8651, 7692, 10725, 911, 5965, 506, 1202, 14, 6061, 1006, 2251, 199, 19065, 687, 314, 10996, 911, 1172, 3932, 2883, 4588, 370, 506, 314, 17586, 56, 199, 1023, 626, 1990, 3032, 315, 14, 199, 624, 199, 504, 15502, 492, 27608, 199, 504, 9143, 492, 7417, 199, 504, 7429, 88, 63, 1612, 14, 6354, 492, 17586, 56, 10725, 12, 17586, 24784, 7692, 10725, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 12, 8651, 7692, 10725, 199, 504, 9872, 14, 10012, 492, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 421, 199, 318, 6202, 63, 19541, 8, 637, 304, 272, 408, 2168, 1263, 3659, 370, 282, 17586, 56, 687, 314, 12467, 574, 339, 372, 282, 2008, 402, 314, 14489, 574, 436, 314, 1305, 402, 314, 7429, 88, 272, 408, 272, 9151, 275, 1139, 272, 7429, 88, 63, 344, 275, 488, 272, 340, 1228, 8, 18476, 12, 17586, 56, 10725, 304, 267, 7429, 88, 63, 344, 275, 9151, 14, 19541, 267, 9151, 275, 9151, 14, 475, 63, 1972, 63, 6354, 342, 272, 916, 1228, 8, 18476, 12, 17586, 24784, 7692, 10725, 304, 267, 7429, 88, 63, 344, 275, 9151, 14, 1972, 63, 498, 14, 19541, 267, 9151, 275, 9151, 14, 475, 63, 1457, 63, 6354, 342, 272, 587, 26, 267, 367, 901, 63, 354, 315, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 26, 288, 340, 2688, 8, 18476, 12, 901, 63, 354, 304, 355, 14489, 63, 698, 63, 585, 12, 7429, 88, 63, 344, 275, 6202, 63, 19541, 8, 5675, 8, 18476, 12, 901, 63, 354, 430, 355, 5371, 8, 18476, 12, 901, 63, 354, 12, 14489, 63, 698, 63, 585, 9, 272, 372, 9151, 12, 7429, 88, 63, 344, 421, 199, 318, 9066, 63, 19541, 8, 637, 12, 7429, 88, 63, 344, 304, 272, 408, 8011, 6941, 370, 282, 17586, 56, 370, 314, 12467, 574, 339, 2529, 314, 574, 6702, 370, 282, 17586, 56, 13, 14600, 1174, 12, 1808, 314, 2741, 7429, 88, 63, 344, 272, 408, 272, 340, 1228, 8, 637, 12, 31480, 304, 267, 372, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 637, 12, 7429, 88, 63, 344, 9, 272, 916, 1228, 8, 637, 12, 8651, 7692, 10725, 304, 267, 7429, 88, 63, 498, 275, 9066, 63, 19541, 8, 637, 14, 1972, 63, 498, 12, 7429, 88, 63, 344, 9, 267, 1139, 275, 17586, 24784, 7692, 10725, 8, 19541, 63, 498, 12, 1139, 14, 1457, 63, 466, 12, 1139, 14, 1457, 63, 344, 9, 272, 367, 901, 63, 354, 315, 1323, 10001, 63, 12767, 63, 9139, 63, 20274, 63, 17434, 26, 267, 340, 2688, 8, 637, 12, 901, 63, 354, 304, 288, 5371, 8, 637, 12, 901, 63, 354, 12, 9066, 63, 19541, 8, 5675, 8, 637, 12, 901, 63, 354, 395, 7429, 88, 63, 344, 430, 272, 340, 2688, 8, 637, 12, 283, 3223, 735, 267, 1139, 14, 3223, 275, 9066, 63, 19541, 63, 3627, 8, 637, 14, 3223, 12, 7429, 88, 63, 344, 9, 272, 372, 1139, 421, 199, 318, 9066, 63, 19541, 63, 3627, 8, 698, 63, 585, 12, 7429, 88, 63, 344, 29, 403, 304, 272, 408, 8011, 6941, 370, 282, 17586, 56, 370, 5055, 402, 12467, 1338, 339, 2529, 314, 3379, 3245, 543, 1006, 1338, 6702, 370, 282, 7429, 88, 13, 14600, 272, 1174, 12, 1808, 314, 2741, 7429, 88, 63, 344, 272, 408, 272, 340, 7429, 88, 63, 344, 365, 488, 26, 267, 372, 901, 63, 585, 272, 340, 1228, 8, 698, 63, 585, 12, 769, 304, 267, 901, 63, 585, 275, 359, 8011, 63, 19541, 8, 13692, 12, 7429, 88, 63, 344, 9, 367, 289, 86, 315, 901, 63, 585, 61, 272, 916, 1228, 8, 698, 63, 585, 12, 1211, 304, 267, 367, 790, 12, 1139, 315, 901, 63, 585, 14, 4611, 837, 288, 901, 63, 585, 59, 498, 61, 275, 9066, 63, 19541, 8, 637, 12, 7429, 88, 63, 344, 9, 272, 587, 26, 267, 901, 63, 585, 275, 9066, 63, 19541, 8, 698, 63, 585, 12, 7429, 88, 63, 344, 9, 272, 372, 901, 63, 585, 421, 199, 32, 14237, 199, 318, 2813, 63, 19541, 8, 475, 63, 1913, 304, 272, 408, 33, 1067, 5256, 367, 19696, 10996, 2986, 3102, 14, 339, 14801, 282, 14489, 574, 436, 282, 805, 11233, 367, 4618, 6854, 652, 272, 408, 272, 14489, 12, 7429, 88, 275, 6202, 63, 19541, 8, 475, 63, 1913, 9, 272, 1995, 14489, 12, 7417, 8, 8011, 63, 19541, 63, 3627, 12, 7429, 88, 63, 344, 29, 19541, 9, 421, 199, 533, 17586, 56, 2377, 1617, 4590, 8, 785, 304, 272, 408, 2765, 1021, 14018, 282, 10996, 339, 710, 12016, 365, 370, 2813, 7429, 88, 13, 6100, 14154, 5309, 4237, 436, 9066, 272, 652, 2410, 27157, 880, 626, 666, 883, 506, 5489, 2257, 370, 282, 2518, 12, 1325, 272, 11812, 315, 1145, 1067, 465, 7429, 88, 13, 6100, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10996, 304, 267, 408, 3823, 314, 2741, 10996, 624, 267, 291, 855, 807, 363, 8680, 10012, 418, 275, 10996, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 408, 11660, 1536, 4124, 3004, 641, 314, 8072, 10996, 624, 267, 372, 2519, 8, 277, 423, 10012, 12, 536, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 408, 409, 3004, 1454, 641, 314, 8072, 10996, 624, 267, 5371, 8, 277, 423, 10012, 12, 536, 12, 574, 9, 339, 347, 636, 30831, 721, 277, 12, 536, 304, 267, 408, 1807, 3004, 1454, 641, 314, 8072, 10996, 624, 267, 24358, 8, 277, 423, 10012, 12, 536, 9, 339, 347, 485, 3118, 63, 6354, 63, 509, 63, 4745, 8, 277, 12, 14067, 304, 267, 408, 9295, 314, 9149, 367, 9872, 14, 10012, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
srvg/ansible
test/integration/targets/var_precedence/ansible-var-precedence-check.py
35
18772
#!/usr/bin/env python # A tool to check the order of precedence for ansible variables # https://github.com/ansible/ansible/blob/devel/test/integration/test_var_precedence.yml from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json import os import sys import shutil import stat import subprocess import tempfile import yaml from pprint import pprint from optparse import OptionParser from jinja2 import Environment ENV = Environment() TESTDIR = tempfile.mkdtemp() def run_command(args, cwd=None): p = subprocess.Popen( args, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, cwd=cwd, ) (so, se) = p.communicate() return (p.returncode, so, se) def clean_test_dir(): if os.path.isdir(TESTDIR): shutil.rmtree(TESTDIR) os.makedirs(TESTDIR) class Role(object): def __init__(self, name): self.name = name self.load = True self.dependencies = [] self.defaults = False self.vars = False self.tasks = [] self.params = dict() def write_role(self): fpath = os.path.join(TESTDIR, 'roles', self.name) if not os.path.isdir(fpath): os.makedirs(fpath) if self.defaults: # roles/x/defaults/main.yml fpath = os.path.join(TESTDIR, 'roles', self.name, 'defaults') if not os.path.isdir(fpath): os.makedirs(fpath) fname = os.path.join(fpath, 'main.yml') with open(fname, 'w') as f: f.write('findme: %s\n' % self.name) if self.vars: # roles/x/vars/main.yml fpath = os.path.join(TESTDIR, 'roles', self.name, 'vars') if not os.path.isdir(fpath): os.makedirs(fpath) fname = os.path.join(fpath, 'main.yml') with open(fname, 'w') as f: f.write('findme: %s\n' % self.name) if self.dependencies: fpath = os.path.join(TESTDIR, 'roles', self.name, 'meta') if not os.path.isdir(fpath): os.makedirs(fpath) fname = os.path.join(fpath, 'main.yml') with open(fname, 'w') as f: f.write('dependencies:\n') for dep in self.dependencies: f.write('- { role: %s }\n' % dep) class DynamicInventory(object): BASESCRIPT = '''#!/usr/bin/python import json data = """{{ data }}""" data = json.loads(data) print(json.dumps(data, indent=2, sort_keys=True)) ''' BASEINV = { '_meta': { 'hostvars': { 'testhost': {} } } } def __init__(self, features): self.ENV = Environment() self.features = features self.fpath = None self.inventory = self.BASEINV.copy() self.build() def build(self): xhost = 'testhost' if 'script_host' in self.features: self.inventory['_meta']['hostvars'][xhost]['findme'] = 'script_host' else: self.inventory['_meta']['hostvars'][xhost] = {} if 'script_child' in self.features: self.inventory['child'] = { 'hosts': [xhost], 'vars': {'findme': 'script_child'} } if 'script_parent' in self.features: self.inventory['parent'] = { 'vars': {'findme': 'script_parent'} } if 'script_child' in self.features: self.inventory['parent']['children'] = ['child'] else: self.inventory['parent']['hosts'] = [xhost] if 'script_all' in self.features: self.inventory['all'] = { 'hosts': [xhost], 'vars': { 'findme': 'script_all' }, } else: self.inventory['all'] = { 'hosts': [xhost], } def write_script(self): fdir = os.path.join(TESTDIR, 'inventory') if not os.path.isdir(fdir): os.makedirs(fdir) fpath = os.path.join(fdir, 'hosts') # fpath = os.path.join(TESTDIR, 'inventory') self.fpath = fpath data = json.dumps(self.inventory) t = self.ENV.from_string(self.BASESCRIPT) fdata = t.render(data=data) with open(fpath, 'w') as f: f.write(fdata + '\n') st = os.stat(fpath) os.chmod(fpath, st.st_mode | stat.S_IEXEC) class VarTestMaker(object): def __init__(self, features, dynamic_inventory=False): clean_test_dir() self.dynamic_inventory = dynamic_inventory self.di = None self.features = features[:] self.inventory = '' self.playvars = dict() self.varsfiles = [] self.playbook = dict(hosts='testhost', gather_facts=False) self.tasks = [] self.roles = [] self.ansible_command = None self.stdout = None def write_playbook(self): fname = os.path.join(TESTDIR, 'site.yml') pb_copy = self.playbook.copy() if self.playvars: pb_copy['vars'] = self.playvars if self.varsfiles: pb_copy['vars_files'] = self.varsfiles if self.roles: pb_copy['roles'] = [] for role in self.roles: role.write_role() role_def = dict(role=role.name) role_def.update(role.params) pb_copy['roles'].append(role_def) if self.tasks: pb_copy['tasks'] = self.tasks with open(fname, 'w') as f: pb_yaml = yaml.dump([pb_copy], f, default_flow_style=False, indent=2) def build(self): if self.dynamic_inventory: # python based inventory file self.di = DynamicInventory(self.features) self.di.write_script() else: # ini based inventory file if 'ini_host' in self.features: self.inventory += 'testhost findme=ini_host\n' else: self.inventory += 'testhost\n' self.inventory += '\n' if 'ini_child' in self.features: self.inventory += '[child]\n' self.inventory += 'testhost\n' self.inventory += '\n' self.inventory += '[child:vars]\n' self.inventory += 'findme=ini_child\n' self.inventory += '\n' if 'ini_parent' in self.features: if 'ini_child' in self.features: self.inventory += '[parent:children]\n' self.inventory += 'child\n' else: self.inventory += '[parent]\n' self.inventory += 'testhost\n' self.inventory += '\n' self.inventory += '[parent:vars]\n' self.inventory += 'findme=ini_parent\n' self.inventory += '\n' if 'ini_all' in self.features: self.inventory += '[all:vars]\n' self.inventory += 'findme=ini_all\n' self.inventory += '\n' # default to a single file called inventory invfile = os.path.join(TESTDIR, 'inventory', 'hosts') ipath = os.path.join(TESTDIR, 'inventory') if not os.path.isdir(ipath): os.makedirs(ipath) with open(invfile, 'w') as f: f.write(self.inventory) hpath = os.path.join(TESTDIR, 'inventory', 'host_vars') if not os.path.isdir(hpath): os.makedirs(hpath) gpath = os.path.join(TESTDIR, 'inventory', 'group_vars') if not os.path.isdir(gpath): os.makedirs(gpath) if 'ini_host_vars_file' in self.features: hfile = os.path.join(hpath, 'testhost') with open(hfile, 'w') as f: f.write('findme: ini_host_vars_file\n') if 'ini_group_vars_file_all' in self.features: hfile = os.path.join(gpath, 'all') with open(hfile, 'w') as f: f.write('findme: ini_group_vars_file_all\n') if 'ini_group_vars_file_child' in self.features: hfile = os.path.join(gpath, 'child') with open(hfile, 'w') as f: f.write('findme: ini_group_vars_file_child\n') if 'ini_group_vars_file_parent' in self.features: hfile = os.path.join(gpath, 'parent') with open(hfile, 'w') as f: f.write('findme: ini_group_vars_file_parent\n') if 'pb_host_vars_file' in self.features: os.makedirs(os.path.join(TESTDIR, 'host_vars')) fname = os.path.join(TESTDIR, 'host_vars', 'testhost') with open(fname, 'w') as f: f.write('findme: pb_host_vars_file\n') if 'pb_group_vars_file_parent' in self.features: if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): os.makedirs(os.path.join(TESTDIR, 'group_vars')) fname = os.path.join(TESTDIR, 'group_vars', 'parent') with open(fname, 'w') as f: f.write('findme: pb_group_vars_file_parent\n') if 'pb_group_vars_file_child' in self.features: if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): os.makedirs(os.path.join(TESTDIR, 'group_vars')) fname = os.path.join(TESTDIR, 'group_vars', 'child') with open(fname, 'w') as f: f.write('findme: pb_group_vars_file_child\n') if 'pb_group_vars_file_all' in self.features: if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): os.makedirs(os.path.join(TESTDIR, 'group_vars')) fname = os.path.join(TESTDIR, 'group_vars', 'all') with open(fname, 'w') as f: f.write('findme: pb_group_vars_file_all\n') if 'play_var' in self.features: self.playvars['findme'] = 'play_var' if 'set_fact' in self.features: self.tasks.append(dict(set_fact='findme="set_fact"')) if 'vars_file' in self.features: self.varsfiles.append('varsfile.yml') fname = os.path.join(TESTDIR, 'varsfile.yml') with open(fname, 'w') as f: f.write('findme: vars_file\n') if 'include_vars' in self.features: self.tasks.append(dict(include_vars='included_vars.yml')) fname = os.path.join(TESTDIR, 'included_vars.yml') with open(fname, 'w') as f: f.write('findme: include_vars\n') if 'role_var' in self.features: role = Role('role_var') role.vars = True role.load = True self.roles.append(role) if 'role_parent_default' in self.features: role = Role('role_default') role.load = False role.defaults = True self.roles.append(role) role = Role('role_parent_default') role.dependencies.append('role_default') role.defaults = True role.load = True if 'role_params' in self.features: role.params = dict(findme='role_params') self.roles.append(role) elif 'role_default' in self.features: role = Role('role_default') role.defaults = True role.load = True if 'role_params' in self.features: role.params = dict(findme='role_params') self.roles.append(role) debug_task = dict(debug='var=findme') test_task = {'assert': dict(that=['findme == "%s"' % self.features[0]])} if 'task_vars' in self.features: test_task['vars'] = dict(findme="task_vars") if 'registered_vars' in self.features: test_task['register'] = 'findme' if 'block_vars' in self.features: block_wrapper = [ debug_task, { 'block': [test_task], 'vars': dict(findme="block_vars"), } ] else: block_wrapper = [debug_task, test_task] if 'include_params' in self.features: self.tasks.append(dict(name='including tasks', include='included_tasks.yml', vars=dict(findme='include_params'))) else: self.tasks.append(dict(include='included_tasks.yml')) fname = os.path.join(TESTDIR, 'included_tasks.yml') with open(fname, 'w') as f: f.write(yaml.dump(block_wrapper)) self.write_playbook() def run(self): ''' if self.dynamic_inventory: cmd = 'ansible-playbook -c local -i inventory/hosts site.yml' else: cmd = 'ansible-playbook -c local -i inventory site.yml' ''' cmd = 'ansible-playbook -c local -i inventory site.yml' if 'extra_vars' in self.features: cmd += ' --extra-vars="findme=extra_vars"' cmd = cmd + ' -vvvvv' self.ansible_command = cmd (rc, so, se) = run_command(cmd, cwd=TESTDIR) self.stdout = so if rc != 0: raise Exception("playbook failed (rc=%s), stdout: '%s' stderr: '%s'" % (rc, so, se)) def show_tree(self): print('## TREE') cmd = 'tree %s' % TESTDIR (rc, so, se) = run_command(cmd) lines = so.split('\n') lines = lines[:-3] print('\n'.join(lines)) def show_content(self): print('## CONTENT') cmd = 'find %s -type f | xargs tail -n +1' % TESTDIR (rc, so, se) = run_command(cmd) print(so) def show_stdout(self): print('## COMMAND') print(self.ansible_command) print('## STDOUT') print(self.stdout) def main(): features = [ 'extra_vars', 'include_params', # 'role_params', # FIXME: we don't yet validate tasks within a role 'set_fact', # 'registered_vars', # FIXME: hard to simulate 'include_vars', # 'role_dep_params', 'task_vars', 'block_vars', 'role_var', 'vars_file', 'play_var', # 'host_facts', # FIXME: hard to simulate 'pb_host_vars_file', 'ini_host_vars_file', 'ini_host', 'pb_group_vars_file_child', # 'ini_group_vars_file_child', #FIXME: this contradicts documented precedence pb group vars files should override inventory ones 'pb_group_vars_file_parent', 'ini_group_vars_file_parent', 'pb_group_vars_file_all', 'ini_group_vars_file_all', 'ini_child', 'ini_parent', 'ini_all', 'role_parent_default', 'role_default', ] parser = OptionParser() parser.add_option('-f', '--feature', action='append') parser.add_option('--use_dynamic_inventory', action='store_true') parser.add_option('--show_tree', action='store_true') parser.add_option('--show_content', action='store_true') parser.add_option('--show_stdout', action='store_true') parser.add_option('--copy_testcases_to_local_dir', action='store_true') (options, args) = parser.parse_args() if options.feature: for f in options.feature: if f not in features: print('%s is not a valid feature' % f) sys.exit(1) features = list(options.feature) fdesc = { 'ini_host': 'host var inside the ini', 'script_host': 'host var inside the script _meta', 'ini_child': 'child group var inside the ini', 'script_child': 'child group var inside the script', 'ini_parent': 'parent group var inside the ini', 'script_parent': 'parent group var inside the script', 'ini_all': 'all group var inside the ini', 'script_all': 'all group var inside the script', 'ini_host_vars_file': 'var in inventory/host_vars/host', 'ini_group_vars_file_parent': 'var in inventory/group_vars/parent', 'ini_group_vars_file_child': 'var in inventory/group_vars/child', 'ini_group_vars_file_all': 'var in inventory/group_vars/all', 'pb_group_vars_file_parent': 'var in playbook/group_vars/parent', 'pb_group_vars_file_child': 'var in playbook/group_vars/child', 'pb_group_vars_file_all': 'var in playbook/group_vars/all', 'pb_host_vars_file': 'var in playbook/host_vars/host', 'play_var': 'var set in playbook header', 'role_parent_default': 'var in roles/role_parent/defaults/main.yml', 'role_default': 'var in roles/role/defaults/main.yml', 'role_var': 'var in ???', 'include_vars': 'var in included file', 'set_fact': 'var made by set_fact', 'vars_file': 'var in file added by vars_file', 'block_vars': 'vars defined on the block', 'task_vars': 'vars defined on the task', 'extra_vars': 'var passed via the cli' } dinv = options.use_dynamic_inventory if dinv: # some features are specific to ini, so swap those for (idx, x) in enumerate(features): if x.startswith('ini_') and 'vars_file' not in x: features[idx] = x.replace('ini_', 'script_') dinv = options.use_dynamic_inventory index = 1 while features: VTM = VarTestMaker(features, dynamic_inventory=dinv) VTM.build() if options.show_tree or options.show_content or options.show_stdout: print('') if options.show_tree: VTM.show_tree() if options.show_content: VTM.show_content() try: print("CHECKING: %s (%s)" % (features[0], fdesc.get(features[0], ''))) res = VTM.run() if options.show_stdout: VTM.show_stdout() features.pop(0) if options.copy_testcases_to_local_dir: topdir = 'testcases' if index == 1 and os.path.isdir(topdir): shutil.rmtree(topdir) if not os.path.isdir(topdir): os.makedirs(topdir) thisindex = str(index) if len(thisindex) == 1: thisindex = '0' + thisindex thisdir = os.path.join(topdir, '%s.%s' % (thisindex, res)) shutil.copytree(TESTDIR, thisdir) except Exception as e: print("ERROR !!!") print(e) print('feature: %s failed' % features[0]) sys.exit(1) finally: shutil.rmtree(TESTDIR) index += 1 if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 437, 4744, 370, 1104, 314, 1865, 402, 13823, 367, 3242, 2860, 199, 3, 4178, 921, 5031, 14, 957, 15, 4853, 15, 4853, 15, 6582, 15, 27870, 15, 396, 15, 15092, 15, 396, 63, 1391, 63, 19571, 14, 11714, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 5145, 199, 646, 5672, 199, 646, 3873, 199, 646, 5549, 199, 646, 8864, 199, 504, 10933, 492, 10933, 199, 504, 8691, 492, 13491, 199, 504, 10321, 18, 492, 9711, 199, 199, 9984, 275, 9711, 342, 199, 2864, 3022, 275, 5549, 14, 11983, 342, 421, 199, 318, 1255, 63, 1531, 8, 589, 12, 8288, 29, 403, 304, 272, 299, 275, 3873, 14, 7942, 8, 267, 1249, 12, 267, 4635, 29, 5781, 14, 6089, 12, 267, 3839, 29, 5781, 14, 6089, 12, 267, 5218, 29, 549, 12, 267, 8288, 29, 6525, 12, 272, 776, 272, 334, 1152, 12, 542, 9, 275, 299, 14, 10664, 342, 272, 372, 334, 80, 14, 9913, 12, 880, 12, 542, 9, 421, 199, 318, 3633, 63, 396, 63, 694, 837, 272, 340, 747, 14, 515, 14, 6027, 8, 2864, 3022, 304, 267, 5145, 14, 9242, 8, 2864, 3022, 9, 272, 747, 14, 8347, 8, 2864, 3022, 9, 421, 199, 533, 18033, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 912, 275, 715, 267, 291, 14, 5714, 275, 942, 267, 291, 14, 4322, 275, 756, 267, 291, 14, 2936, 275, 756, 267, 291, 14, 5054, 275, 942, 267, 291, 14, 1162, 275, 1211, 342, 339, 347, 2218, 63, 3756, 8, 277, 304, 398, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 9, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 288, 747, 14, 8347, 8, 23248, 9, 398, 340, 291, 14, 4322, 26, 288, 327, 11689, 15, 88, 15, 4322, 15, 973, 14, 11714, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 4322, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 1623, 278, 26, 450, 83, 60, 78, 7, 450, 291, 14, 354, 9, 398, 340, 291, 14, 2936, 26, 288, 327, 11689, 15, 88, 15, 2936, 15, 973, 14, 11714, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 2936, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 1623, 278, 26, 450, 83, 60, 78, 7, 450, 291, 14, 354, 9, 398, 340, 291, 14, 5714, 26, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 2024, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 5714, 3427, 78, 358, 355, 367, 2657, 315, 291, 14, 5714, 26, 490, 289, 14, 952, 3654, 469, 4719, 26, 450, 83, 27958, 78, 7, 450, 2657, 9, 421, 199, 533, 21907, 19304, 8, 785, 304, 272, 4147, 654, 4461, 275, 1449, 3381, 2647, 15, 1393, 15, 1548, 199, 646, 2022, 199, 576, 275, 408, 3638, 666, 3586, 624, 199, 576, 275, 2022, 14, 3640, 8, 576, 9, 199, 1361, 8, 1001, 14, 4180, 8, 576, 12, 4363, 29, 18, 12, 4069, 63, 1612, 29, 549, 430, 199, 2344, 339, 19721, 568, 54, 275, 469, 267, 2513, 2024, 356, 469, 288, 283, 23265, 356, 469, 355, 283, 396, 1102, 356, 1052, 288, 789, 267, 789, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4534, 304, 267, 291, 14, 9984, 275, 9711, 342, 267, 291, 14, 3179, 275, 4534, 267, 291, 14, 23248, 275, 488, 267, 291, 14, 7212, 275, 291, 14, 5825, 568, 54, 14, 1574, 342, 267, 291, 14, 1506, 342, 339, 347, 1900, 8, 277, 304, 267, 671, 1102, 275, 283, 396, 1102, 7, 267, 340, 283, 1579, 63, 1102, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 8680, 2024, 2545, 23265, 3488, 88, 1102, 2733, 1623, 278, 418, 275, 283, 1579, 63, 1102, 7, 267, 587, 26, 288, 291, 14, 7212, 8680, 2024, 2545, 23265, 3488, 88, 1102, 61, 275, 1052, 398, 340, 283, 1579, 63, 1739, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 459, 1739, 418, 275, 469, 355, 283, 5146, 356, 359, 88, 1102, 467, 355, 283, 2936, 356, 791, 1623, 278, 356, 283, 1579, 63, 1739, 936, 288, 789, 398, 340, 283, 1579, 63, 1708, 7, 315, 291, 14, 3179, 26, 953, 291, 14, 7212, 459, 1708, 418, 275, 469, 355, 283, 2936, 356, 791, 1623, 278, 356, 283, 1579, 63, 1708, 936, 288, 789, 953, 340, 283, 1579, 63, 1739, 7, 315, 291, 14, 3179, 26, 355, 291, 14, 7212, 459, 1708, 2545, 3223, 418, 275, 788, 1739, 418, 288, 587, 26, 355, 291, 14, 7212, 459, 1708, 2545, 5146, 418, 275, 359, 88, 1102, 61, 398, 340, 283, 1579, 63, 452, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 459, 452, 418, 275, 469, 355, 283, 5146, 356, 359, 88, 1102, 467, 355, 283, 2936, 356, 469, 490, 283, 1623, 278, 356, 283, 1579, 63, 452, 7, 355, 1660, 288, 789, 267, 587, 26, 288 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 437, 4744, 370, 1104, 314, 1865, 402, 13823, 367, 3242, 2860, 199, 3, 4178, 921, 5031, 14, 957, 15, 4853, 15, 4853, 15, 6582, 15, 27870, 15, 396, 15, 15092, 15, 396, 63, 1391, 63, 19571, 14, 11714, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 5145, 199, 646, 5672, 199, 646, 3873, 199, 646, 5549, 199, 646, 8864, 199, 504, 10933, 492, 10933, 199, 504, 8691, 492, 13491, 199, 504, 10321, 18, 492, 9711, 199, 199, 9984, 275, 9711, 342, 199, 2864, 3022, 275, 5549, 14, 11983, 342, 421, 199, 318, 1255, 63, 1531, 8, 589, 12, 8288, 29, 403, 304, 272, 299, 275, 3873, 14, 7942, 8, 267, 1249, 12, 267, 4635, 29, 5781, 14, 6089, 12, 267, 3839, 29, 5781, 14, 6089, 12, 267, 5218, 29, 549, 12, 267, 8288, 29, 6525, 12, 272, 776, 272, 334, 1152, 12, 542, 9, 275, 299, 14, 10664, 342, 272, 372, 334, 80, 14, 9913, 12, 880, 12, 542, 9, 421, 199, 318, 3633, 63, 396, 63, 694, 837, 272, 340, 747, 14, 515, 14, 6027, 8, 2864, 3022, 304, 267, 5145, 14, 9242, 8, 2864, 3022, 9, 272, 747, 14, 8347, 8, 2864, 3022, 9, 421, 199, 533, 18033, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 912, 275, 715, 267, 291, 14, 5714, 275, 942, 267, 291, 14, 4322, 275, 756, 267, 291, 14, 2936, 275, 756, 267, 291, 14, 5054, 275, 942, 267, 291, 14, 1162, 275, 1211, 342, 339, 347, 2218, 63, 3756, 8, 277, 304, 398, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 9, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 288, 747, 14, 8347, 8, 23248, 9, 398, 340, 291, 14, 4322, 26, 288, 327, 11689, 15, 88, 15, 4322, 15, 973, 14, 11714, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 4322, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 1623, 278, 26, 450, 83, 60, 78, 7, 450, 291, 14, 354, 9, 398, 340, 291, 14, 2936, 26, 288, 327, 11689, 15, 88, 15, 2936, 15, 973, 14, 11714, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 2936, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 1623, 278, 26, 450, 83, 60, 78, 7, 450, 291, 14, 354, 9, 398, 340, 291, 14, 5714, 26, 288, 30540, 275, 747, 14, 515, 14, 904, 8, 2864, 3022, 12, 283, 8050, 297, 291, 14, 354, 12, 283, 2024, 358, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 23248, 304, 355, 747, 14, 8347, 8, 23248, 9, 288, 6748, 275, 747, 14, 515, 14, 904, 8, 23248, 12, 283, 973, 14, 11714, 358, 288, 543, 1551, 8, 5252, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 360, 5714, 3427, 78, 358, 355, 367, 2657, 315, 291, 14, 5714, 26, 490, 289, 14, 952, 3654, 469, 4719, 26, 450, 83, 27958, 78, 7, 450, 2657, 9, 421, 199, 533, 21907, 19304, 8, 785, 304, 272, 4147, 654, 4461, 275, 1449, 3381, 2647, 15, 1393, 15, 1548, 199, 646, 2022, 199, 576, 275, 408, 3638, 666, 3586, 624, 199, 576, 275, 2022, 14, 3640, 8, 576, 9, 199, 1361, 8, 1001, 14, 4180, 8, 576, 12, 4363, 29, 18, 12, 4069, 63, 1612, 29, 549, 430, 199, 2344, 339, 19721, 568, 54, 275, 469, 267, 2513, 2024, 356, 469, 288, 283, 23265, 356, 469, 355, 283, 396, 1102, 356, 1052, 288, 789, 267, 789, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4534, 304, 267, 291, 14, 9984, 275, 9711, 342, 267, 291, 14, 3179, 275, 4534, 267, 291, 14, 23248, 275, 488, 267, 291, 14, 7212, 275, 291, 14, 5825, 568, 54, 14, 1574, 342, 267, 291, 14, 1506, 342, 339, 347, 1900, 8, 277, 304, 267, 671, 1102, 275, 283, 396, 1102, 7, 267, 340, 283, 1579, 63, 1102, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 8680, 2024, 2545, 23265, 3488, 88, 1102, 2733, 1623, 278, 418, 275, 283, 1579, 63, 1102, 7, 267, 587, 26, 288, 291, 14, 7212, 8680, 2024, 2545, 23265, 3488, 88, 1102, 61, 275, 1052, 398, 340, 283, 1579, 63, 1739, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 459, 1739, 418, 275, 469, 355, 283, 5146, 356, 359, 88, 1102, 467, 355, 283, 2936, 356, 791, 1623, 278, 356, 283, 1579, 63, 1739, 936, 288, 789, 398, 340, 283, 1579, 63, 1708, 7, 315, 291, 14, 3179, 26, 953, 291, 14, 7212, 459, 1708, 418, 275, 469, 355, 283, 2936, 356, 791, 1623, 278, 356, 283, 1579, 63, 1708, 936, 288, 789, 953, 340, 283, 1579, 63, 1739, 7, 315, 291, 14, 3179, 26, 355, 291, 14, 7212, 459, 1708, 2545, 3223, 418, 275, 788, 1739, 418, 288, 587, 26, 355, 291, 14, 7212, 459, 1708, 2545, 5146, 418, 275, 359, 88, 1102, 61, 398, 340, 283, 1579, 63, 452, 7, 315, 291, 14, 3179, 26, 288, 291, 14, 7212, 459, 452, 418, 275, 469, 355, 283, 5146, 356, 359, 88, 1102, 467, 355, 283, 2936, 356, 469, 490, 283, 1623, 278, 356, 283, 1579, 63, 452, 7, 355, 1660, 288, 789, 267, 587, 26, 288, 0 ]
[ 1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
TheTypoMaster/chromium-crosswalk
chrome/common/extensions/docs/server2/admin_servlets.py
37
4612
# 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 json import logging from appengine_wrappers import memcache from commit_tracker import CommitTracker from environment import IsDevServer from environment_wrappers import CreateUrlFetcher from future import All from object_store_creator import ObjectStoreCreator from servlet import Servlet, Response # This is the service account ID associated with the chrome-apps-doc project in # the Google Developers Console. _SERVICE_ACCOUNT_NAME = '636061184119-compute@developer.gserviceaccount.com' # This is Google's OAuth2 service for retrieving user information from an access # token. It is used to authenticate an incoming access token in the metadata # flush servlet, ensuring that only requests from the above service account are # fulfilled. _ACCOUNT_INFO_URL = ('https://www.googleapis.com/oauth2/v1/userinfo?' 'access_token=%s') class QueryCommitServlet(Servlet): '''Provides read access to the commit ID cache within the server. For example: /_query_commit/master will return the commit ID stored under the commit key "master" within the commit cache. Currently "master" is the only named commit we cache, and it corresponds to the commit ID whose data currently populates the data cache used by live instances. ''' def __init__(self, request): Servlet.__init__(self, request) def Get(self): object_store_creator = ObjectStoreCreator(start_empty=False) commit_tracker = CommitTracker(object_store_creator) def generate_response(result): commit_id, history = result history_log = ''.join('%s: %s<br>' % (entry.datetime, entry.commit_id) for entry in reversed(history)) response = 'Current commit: %s<br><br>Most recent commits:<br>%s' % ( commit_id, history_log) return response commit_name = self._request.path id_future = commit_tracker.Get(commit_name) history_future = commit_tracker.GetHistory(commit_name) return Response.Ok( All((id_future, history_future)).Then(generate_response).Get()) class FlushMemcacheServlet(Servlet): '''Flushes the entire memcache. This requires an access token for the project's main service account. Without said token, the request is considered invalid. ''' class Delegate(object): def IsAuthorized(self, access_token): '''Verifies that a given access_token represents the main service account. ''' fetcher = CreateUrlFetcher() response = fetcher.Fetch(_ACCOUNT_INFO_URL % access_token) if response.status_code != 200: return False try: info = json.loads(response.content) except: return False return info['email'] == _SERVICE_ACCOUNT_NAME def __init__(self, request, delegate=Delegate()): Servlet.__init__(self, request) self._delegate = delegate def GetAccessToken(self): auth_header = self._request.headers.get('Authorization') if not auth_header: return None try: method, token = auth_header.split(' ', 1) except: return None if method != 'Bearer': return None return token def Get(self): access_token = self.GetAccessToken() if not access_token: return Response.Unauthorized('Unauthorized', 'Bearer', 'update') if not self._delegate.IsAuthorized(access_token): return Response.Forbidden('Forbidden') result = memcache.flush_all() return Response.Ok('Flushed: %s' % result) class UpdateCacheServlet(Servlet): '''Devserver-only servlet for pushing local file data into the datastore. This is useful if you've used update_cache.py to build a local datastore for testing. Query: /_update_cache/FOO_DATA to make the devserver read FOO_DATA from its pwd and push all the data into datastore. ''' def __init__(self, request): Servlet.__init__(self, request) def Get(self): if not IsDevServer(): return Response.BadRequest('') import cPickle from persistent_object_store_appengine import PersistentObjectStoreAppengine with open(self._request.path, 'r') as f: data = cPickle.load(f) for namespace, contents in data.iteritems(): store = PersistentObjectStoreAppengine(namespace) for k, v in cPickle.loads(contents).iteritems(): try: store.Set(k, v).Get() except: logging.warn('Skipping entry %s because of errors.' % k) return Response.Ok('Data pushed!')
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, 2022, 199, 646, 2050, 199, 199, 504, 1145, 3908, 63, 21148, 492, 21598, 199, 504, 5532, 63, 8877, 492, 21447, 13652, 199, 504, 3734, 492, 6596, 12680, 3120, 199, 504, 3734, 63, 21148, 492, 2790, 6417, 11135, 281, 199, 504, 6466, 492, 2900, 199, 504, 909, 63, 1617, 63, 9986, 492, 6935, 5502, 17523, 199, 504, 27415, 2723, 492, 3739, 86, 2723, 12, 7232, 421, 199, 3, 961, 365, 314, 2435, 2933, 2870, 4568, 543, 314, 18221, 13, 5181, 13, 1301, 2199, 315, 199, 3, 314, 4475, 23493, 19809, 14, 199, 63, 10486, 63, 18928, 63, 2339, 275, 283, 26654, 1690, 845, 1349, 7119, 13, 3357, 32, 11071, 14, 71, 1364, 2048, 14, 957, 7, 199, 199, 3, 961, 365, 4475, 1159, 11715, 18, 2435, 367, 23812, 922, 2556, 687, 376, 2879, 199, 3, 1526, 14, 2779, 365, 1202, 370, 12895, 376, 12467, 2879, 1526, 315, 314, 3341, 199, 3, 8976, 27415, 2723, 12, 12889, 4039, 626, 1454, 4145, 687, 314, 3432, 2435, 2933, 787, 199, 3, 15632, 276, 14535, 14, 199, 63, 18928, 63, 4531, 63, 2632, 275, 661, 2859, 921, 1544, 14, 17533, 14, 957, 15, 6126, 18, 15, 86, 17, 15, 751, 815, 14069, 2151, 283, 2732, 63, 1418, 2458, 83, 358, 421, 199, 533, 8133, 11421, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 17473, 1586, 2879, 370, 314, 5532, 2870, 2581, 4453, 314, 1654, 14, 2104, 2893, 26, 819, 1182, 63, 1131, 63, 3543, 15, 4133, 819, 911, 372, 314, 5532, 2870, 5489, 1334, 314, 5532, 790, 298, 4133, 2, 4453, 314, 523, 5532, 2581, 14, 13550, 298, 4133, 2, 365, 314, 1454, 4310, 5532, 781, 2581, 12, 436, 652, 523, 13718, 370, 314, 5532, 2870, 7447, 666, 5544, 4560, 15409, 314, 666, 2581, 523, 1202, 701, 12166, 4454, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 1056, 304, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 819, 347, 2372, 8, 277, 304, 272, 909, 63, 1617, 63, 9986, 275, 6935, 5502, 17523, 8, 928, 63, 1667, 29, 797, 9, 272, 5532, 63, 8877, 275, 21447, 13652, 8, 785, 63, 1617, 63, 9986, 9, 339, 347, 3550, 63, 1310, 8, 1099, 304, 489, 5532, 63, 344, 12, 7994, 275, 754, 489, 7994, 63, 793, 275, 6522, 904, 3508, 83, 26, 450, 83, 28, 3289, 3524, 450, 334, 2373, 14, 2083, 12, 2397, 14, 3543, 63, 344, 9, 1169, 367, 2397, 315, 10822, 8, 5570, 430, 489, 1177, 275, 283, 5639, 5532, 26, 450, 83, 28, 3289, 2535, 3289, 30, 24625, 8058, 20835, 16875, 3289, 6598, 83, 7, 450, 334, 881, 5532, 63, 344, 12, 7994, 63, 793, 9, 489, 372, 1177, 339, 5532, 63, 354, 275, 291, 423, 1069, 14, 515, 272, 1305, 63, 2443, 275, 5532, 63, 8877, 14, 1002, 8, 3543, 63, 354, 9, 272, 7994, 63, 2443, 275, 5532, 63, 8877, 14, 1002, 12114, 8, 3543, 63, 354, 9, 272, 372, 7232, 14, 11622, 8, 267, 2900, 1332, 344, 63, 2443, 12, 7994, 63, 2443, 4992, 28226, 8, 4208, 63, 1310, 680, 1002, 1012, 421, 199, 533, 11040, 2084, 14169, 1637, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 20053, 397, 314, 8039, 21598, 14, 819, 961, 5074, 376, 2879, 1526, 367, 314, 2199, 1159, 2446, 2435, 2933, 14, 23952, 523, 25097, 1526, 12, 314, 1056, 365, 8652, 3866, 14, 523, 1449, 819, 1021, 12035, 3237, 8, 785, 304, 272, 347, 6596, 29284, 8, 277, 12, 2879, 63, 1418, 304, 489, 1449, 21168, 626, 282, 1627, 2879, 63, 1418, 8469, 314, 2446, 2435, 2933, 14, 489, 1449, 489, 5267, 281, 275, 2790, 6417, 11135, 281, 342, 489, 1177, 275, 5267, 281, 14, 11135, 1547, 18928, 63, 4531, 63, 2632, 450, 2879, 63, 1418, 9, 489, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 372, 756, 489, 862, 26, 267, 2256, 275, 2022, 14, 3640, 8, 1310, 14, 1317, 9, 489, 871, 26, 267, 372, 756, 489, 372, 2256, 459, 2123, 418, 508, 485, 10486, 63, 18928, 63, 2339, 819, 347, 636, 826, 721, 277, 12, 1056, 12, 13080, 29, 21553, 5109, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 272, 291, 423, 15286, 275, 13080, 819, 347, 2372, 3946, 3264, 8, 277, 304, 272, 1790, 63, 1291, 275, 291, 423, 1069, 14, 2139, 14, 362, 360, 11626, 358, 272, 340, 440, 1790, 63, 1291, 26, 489, 372, 488, 272, 862, 26, 489, 1083, 12, 1526, 275, 1790, 63, 1291, 14, 1294, 360, 1656, 413, 9, 272, 871, 26, 489, 372, 488, 272, 340, 1083, 1137, 283, 3655, 21462, 356, 489, 372, 488, 272, 372, 1526, 819, 347, 2372, 8, 277, 304, 272, 2879, 63, 1418, 275, 291, 14, 1002, 3946, 3264, 342, 272, 340, 440, 2879, 63, 1418, 26, 489, 372, 7232, 14, 28290, 360, 28290, 297, 283, 3655, 21462, 297, 283, 873, 358, 272, 340, 440, 291, 423, 15286, 14, 1831, 29284, 8, 2732, 63, 1418, 304, 489, 372, 7232, 14, 17454, 360, 17454, 358, 272, 754, 275, 21598, 14, 4939, 63, 452, 342, 272, 372, 7232, 14, 11622, 360, 20053, 379, 26, 450, 83, 7, 450, 754, 9, 421, 199, 533, 6162, 4437, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 12680, 1000, 13, 2118, 27415, 2723, 367, 6675, 316, 2257, 570, 666, 1901, 314, 12007, 14, 523, 961, 365, 2997, 340, 1265, 9064, 1202, 1678, 63, 1637, 14, 647, 370, 1900, 282, 2257, 12007, 523, 367, 5343, 14, 8133, 26, 2541, 1182, 63, 873, 63, 1637, 15, 13046, 63, 3998, 819, 370, 1852, 314, 4866, 1000, 1586, 27704, 63, 3998, 687, 2399, 14374, 436, 6675, 1006, 314, 666, 1901, 523, 12007, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 1056, 304, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 819, 347, 2372, 8, 277, 304, 272, 340, 440, 6596, 12680, 3120, 837, 489, 372, 7232, 14, 12380, 8355, 272, 492, 17572, 272 ]
[ 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, 2022, 199, 646, 2050, 199, 199, 504, 1145, 3908, 63, 21148, 492, 21598, 199, 504, 5532, 63, 8877, 492, 21447, 13652, 199, 504, 3734, 492, 6596, 12680, 3120, 199, 504, 3734, 63, 21148, 492, 2790, 6417, 11135, 281, 199, 504, 6466, 492, 2900, 199, 504, 909, 63, 1617, 63, 9986, 492, 6935, 5502, 17523, 199, 504, 27415, 2723, 492, 3739, 86, 2723, 12, 7232, 421, 199, 3, 961, 365, 314, 2435, 2933, 2870, 4568, 543, 314, 18221, 13, 5181, 13, 1301, 2199, 315, 199, 3, 314, 4475, 23493, 19809, 14, 199, 63, 10486, 63, 18928, 63, 2339, 275, 283, 26654, 1690, 845, 1349, 7119, 13, 3357, 32, 11071, 14, 71, 1364, 2048, 14, 957, 7, 199, 199, 3, 961, 365, 4475, 1159, 11715, 18, 2435, 367, 23812, 922, 2556, 687, 376, 2879, 199, 3, 1526, 14, 2779, 365, 1202, 370, 12895, 376, 12467, 2879, 1526, 315, 314, 3341, 199, 3, 8976, 27415, 2723, 12, 12889, 4039, 626, 1454, 4145, 687, 314, 3432, 2435, 2933, 787, 199, 3, 15632, 276, 14535, 14, 199, 63, 18928, 63, 4531, 63, 2632, 275, 661, 2859, 921, 1544, 14, 17533, 14, 957, 15, 6126, 18, 15, 86, 17, 15, 751, 815, 14069, 2151, 283, 2732, 63, 1418, 2458, 83, 358, 421, 199, 533, 8133, 11421, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 17473, 1586, 2879, 370, 314, 5532, 2870, 2581, 4453, 314, 1654, 14, 2104, 2893, 26, 819, 1182, 63, 1131, 63, 3543, 15, 4133, 819, 911, 372, 314, 5532, 2870, 5489, 1334, 314, 5532, 790, 298, 4133, 2, 4453, 314, 523, 5532, 2581, 14, 13550, 298, 4133, 2, 365, 314, 1454, 4310, 5532, 781, 2581, 12, 436, 652, 523, 13718, 370, 314, 5532, 2870, 7447, 666, 5544, 4560, 15409, 314, 666, 2581, 523, 1202, 701, 12166, 4454, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 1056, 304, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 819, 347, 2372, 8, 277, 304, 272, 909, 63, 1617, 63, 9986, 275, 6935, 5502, 17523, 8, 928, 63, 1667, 29, 797, 9, 272, 5532, 63, 8877, 275, 21447, 13652, 8, 785, 63, 1617, 63, 9986, 9, 339, 347, 3550, 63, 1310, 8, 1099, 304, 489, 5532, 63, 344, 12, 7994, 275, 754, 489, 7994, 63, 793, 275, 6522, 904, 3508, 83, 26, 450, 83, 28, 3289, 3524, 450, 334, 2373, 14, 2083, 12, 2397, 14, 3543, 63, 344, 9, 1169, 367, 2397, 315, 10822, 8, 5570, 430, 489, 1177, 275, 283, 5639, 5532, 26, 450, 83, 28, 3289, 2535, 3289, 30, 24625, 8058, 20835, 16875, 3289, 6598, 83, 7, 450, 334, 881, 5532, 63, 344, 12, 7994, 63, 793, 9, 489, 372, 1177, 339, 5532, 63, 354, 275, 291, 423, 1069, 14, 515, 272, 1305, 63, 2443, 275, 5532, 63, 8877, 14, 1002, 8, 3543, 63, 354, 9, 272, 7994, 63, 2443, 275, 5532, 63, 8877, 14, 1002, 12114, 8, 3543, 63, 354, 9, 272, 372, 7232, 14, 11622, 8, 267, 2900, 1332, 344, 63, 2443, 12, 7994, 63, 2443, 4992, 28226, 8, 4208, 63, 1310, 680, 1002, 1012, 421, 199, 533, 11040, 2084, 14169, 1637, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 20053, 397, 314, 8039, 21598, 14, 819, 961, 5074, 376, 2879, 1526, 367, 314, 2199, 1159, 2446, 2435, 2933, 14, 23952, 523, 25097, 1526, 12, 314, 1056, 365, 8652, 3866, 14, 523, 1449, 819, 1021, 12035, 3237, 8, 785, 304, 272, 347, 6596, 29284, 8, 277, 12, 2879, 63, 1418, 304, 489, 1449, 21168, 626, 282, 1627, 2879, 63, 1418, 8469, 314, 2446, 2435, 2933, 14, 489, 1449, 489, 5267, 281, 275, 2790, 6417, 11135, 281, 342, 489, 1177, 275, 5267, 281, 14, 11135, 1547, 18928, 63, 4531, 63, 2632, 450, 2879, 63, 1418, 9, 489, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 372, 756, 489, 862, 26, 267, 2256, 275, 2022, 14, 3640, 8, 1310, 14, 1317, 9, 489, 871, 26, 267, 372, 756, 489, 372, 2256, 459, 2123, 418, 508, 485, 10486, 63, 18928, 63, 2339, 819, 347, 636, 826, 721, 277, 12, 1056, 12, 13080, 29, 21553, 5109, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 272, 291, 423, 15286, 275, 13080, 819, 347, 2372, 3946, 3264, 8, 277, 304, 272, 1790, 63, 1291, 275, 291, 423, 1069, 14, 2139, 14, 362, 360, 11626, 358, 272, 340, 440, 1790, 63, 1291, 26, 489, 372, 488, 272, 862, 26, 489, 1083, 12, 1526, 275, 1790, 63, 1291, 14, 1294, 360, 1656, 413, 9, 272, 871, 26, 489, 372, 488, 272, 340, 1083, 1137, 283, 3655, 21462, 356, 489, 372, 488, 272, 372, 1526, 819, 347, 2372, 8, 277, 304, 272, 2879, 63, 1418, 275, 291, 14, 1002, 3946, 3264, 342, 272, 340, 440, 2879, 63, 1418, 26, 489, 372, 7232, 14, 28290, 360, 28290, 297, 283, 3655, 21462, 297, 283, 873, 358, 272, 340, 440, 291, 423, 15286, 14, 1831, 29284, 8, 2732, 63, 1418, 304, 489, 372, 7232, 14, 17454, 360, 17454, 358, 272, 754, 275, 21598, 14, 4939, 63, 452, 342, 272, 372, 7232, 14, 11622, 360, 20053, 379, 26, 450, 83, 7, 450, 754, 9, 421, 199, 533, 6162, 4437, 1505, 86, 2723, 8, 1505, 86, 2723, 304, 523, 1449, 12680, 1000, 13, 2118, 27415, 2723, 367, 6675, 316, 2257, 570, 666, 1901, 314, 12007, 14, 523, 961, 365, 2997, 340, 1265, 9064, 1202, 1678, 63, 1637, 14, 647, 370, 1900, 282, 2257, 12007, 523, 367, 5343, 14, 8133, 26, 2541, 1182, 63, 873, 63, 1637, 15, 13046, 63, 3998, 819, 370, 1852, 314, 4866, 1000, 1586, 27704, 63, 3998, 687, 2399, 14374, 436, 6675, 1006, 314, 666, 1901, 523, 12007, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 1056, 304, 272, 3739, 86, 2723, 855, 826, 721, 277, 12, 1056, 9, 819, 347, 2372, 8, 277, 304, 272, 340, 440, 6596, 12680, 3120, 837, 489, 372, 7232, 14, 12380, 8355, 272, 492, 17572, 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,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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 ]
szha/mxnet
cpp-package/scripts/lint.py
16
7389
#!/usr/bin/env python # 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. # pylint: disable=protected-access, unused-variable, locally-disabled, redefined-variable-type """Lint helper to generate lint summary of source. Copyright by Contributors """ from __future__ import print_function import codecs import sys import re import os import cpplint from cpplint import _cpplint_state from pylint import epylint CXX_SUFFIX = set(['cc', 'c', 'cpp', 'h', 'cu', 'hpp']) PYTHON_SUFFIX = set(['py']) class LintHelper(object): """Class to help runing the lint and records summary""" @staticmethod def _print_summary_map(strm, result_map, ftype): """Print summary of certain result map.""" if len(result_map) == 0: return 0 npass = len([x for k, x in result_map.iteritems() if len(x) == 0]) strm.write('=====%d/%d %s files passed check=====\n' % (npass, len(result_map), ftype)) for fname, emap in result_map.iteritems(): if len(emap) == 0: continue strm.write('%s: %d Errors of %d Categories map=%s\n' % ( fname, sum(emap.values()), len(emap), str(emap))) return len(result_map) - npass def __init__(self): self.project_name = None self.cpp_header_map = {} self.cpp_src_map = {} self.python_map = {} pylint_disable = ['superfluous-parens', 'too-many-instance-attributes', 'too-few-public-methods'] # setup pylint self.pylint_opts = ['--extension-pkg-whitelist=numpy', '--disable=' + ','.join(pylint_disable)] self.pylint_cats = set(['error', 'warning', 'convention', 'refactor']) # setup cpp lint cpplint_args = ['.', '--extensions=' + (','.join(CXX_SUFFIX))] _ = cpplint.ParseArguments(cpplint_args) cpplint._SetFilters(','.join(['-build/c++11', '-build/namespaces', '-build/include', '-build/header_guard', '+build/include_what_you_use', '+build/include_order'])) cpplint._SetCountingStyle('toplevel') cpplint._line_length = 100 def process_cpp(self, path, suffix): """Process a cpp file.""" _cpplint_state.ResetErrorCounts() cpplint.ProcessFile(str(path), _cpplint_state.verbose_level) _cpplint_state.PrintErrorCounts() errors = _cpplint_state.errors_by_category.copy() if suffix == 'h': self.cpp_header_map[str(path)] = errors else: self.cpp_src_map[str(path)] = errors def process_python(self, path): """Process a python file.""" (pylint_stdout, pylint_stderr) = epylint.py_run( ' '.join([str(path)] + self.pylint_opts), return_std=True) emap = {} print(pylint_stderr.read()) for line in pylint_stdout: sys.stderr.write(line) key = line.split(':')[-1].split('(')[0].strip() if key not in self.pylint_cats: continue if key not in emap: emap[key] = 1 else: emap[key] += 1 sys.stderr.write('\n') self.python_map[str(path)] = emap def print_summary(self, strm): """Print summary of lint.""" nerr = 0 nerr += LintHelper._print_summary_map(strm, self.cpp_header_map, 'cpp-header') nerr += LintHelper._print_summary_map(strm, self.cpp_src_map, 'cpp-soruce') nerr += LintHelper._print_summary_map(strm, self.python_map, 'python') if nerr == 0: strm.write('All passed!\n') else: strm.write('%d files failed lint\n' % nerr) return nerr # singleton helper for lint check _HELPER = LintHelper() def get_header_guard_dmlc(filename): """Get Header Guard Convention for DMLC Projects. For headers in include, directly use the path For headers in src, use project name plus path Examples: with project-name = dmlc include/dmlc/timer.h -> DMLC_TIMTER_H_ src/io/libsvm_parser.h -> DMLC_IO_LIBSVM_PARSER_H_ """ fileinfo = cpplint.FileInfo(filename) file_path_from_root = fileinfo.RepositoryName() inc_list = ['include', 'api', 'wrapper'] if file_path_from_root.find('src/') != -1 and _HELPER.project_name is not None: idx = file_path_from_root.find('src/') file_path_from_root = _HELPER.project_name + file_path_from_root[idx + 3:] else: for spath in inc_list: prefix = spath + os.sep if file_path_from_root.startswith(prefix): file_path_from_root = re.sub('^' + prefix, '', file_path_from_root) break return re.sub(r'[-./\s]', '_', file_path_from_root).upper() + '_' cpplint.GetHeaderGuardCPPVariable = get_header_guard_dmlc def process(fname, allow_type): """Process a file.""" fname = str(fname) # HACK: ignore op.h which is automatically generated if fname.endswith('op.h'): return arr = fname.rsplit('.', 1) if fname.find('#') != -1 or arr[-1] not in allow_type: return if arr[-1] in CXX_SUFFIX: _HELPER.process_cpp(fname, arr[-1]) if arr[-1] in PYTHON_SUFFIX: _HELPER.process_python(fname) def main(): """Main entry function.""" if len(sys.argv) < 3: print('Usage: <project-name> <filetype> <list-of-path to traverse>') print('\tfiletype can be python/cpp/all') exit(-1) _HELPER.project_name = sys.argv[1] file_type = sys.argv[2] allow_type = [] if file_type == 'python' or file_type == 'all': allow_type += [x for x in PYTHON_SUFFIX] if file_type == 'cpp' or file_type == 'all': allow_type += [x for x in CXX_SUFFIX] allow_type = set(allow_type) if os.name != 'nt': sys.stderr = codecs.StreamReaderWriter(sys.stderr, codecs.getreader('utf8'), codecs.getwriter('utf8'), 'replace') for path in sys.argv[3:]: if os.path.isfile(path): process(path, allow_type) else: for root, dirs, files in os.walk(path): for name in files: process(os.path.join(root, name), allow_type) nerr = _HELPER.print_summary(sys.stderr) sys.exit(nerr > 0) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 12, 9563, 13, 1975, 12, 17738, 13, 7011, 12, 295, 4037, 13, 1975, 13, 466, 199, 624, 44, 442, 5922, 370, 3550, 24620, 6212, 402, 1350, 14, 199, 7384, 701, 23212, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 6010, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 7246, 3854, 199, 504, 7246, 3854, 492, 485, 5910, 3854, 63, 929, 199, 504, 4287, 492, 325, 26324, 199, 199, 12206, 63, 12273, 275, 663, 2941, 2055, 297, 283, 67, 297, 283, 5910, 297, 283, 72, 297, 283, 15140, 297, 283, 72, 802, 1105, 199, 11720, 63, 12273, 275, 663, 2941, 647, 1105, 199, 199, 533, 491, 442, 4433, 8, 785, 304, 272, 408, 2543, 370, 1720, 1255, 316, 314, 24620, 436, 5767, 6212, 624, 339, 768, 4639, 272, 347, 485, 1361, 63, 4705, 63, 1130, 8, 495, 77, 12, 754, 63, 1130, 12, 8570, 304, 267, 408, 5375, 6212, 402, 9842, 754, 2341, 1041, 267, 340, 822, 8, 1099, 63, 1130, 9, 508, 378, 26, 288, 372, 378, 267, 980, 405, 275, 822, 779, 88, 367, 1022, 12, 671, 315, 754, 63, 1130, 14, 4611, 342, 340, 822, 8, 88, 9, 508, 378, 566, 267, 620, 77, 14, 952, 360, 532, 2458, 68, 3149, 68, 450, 83, 1584, 3032, 1104, 532, 9529, 78, 7, 450, 334, 78, 1529, 12, 822, 8, 1099, 63, 1130, 395, 8570, 430, 267, 367, 6748, 12, 325, 1130, 315, 754, 63, 1130, 14, 4611, 837, 288, 340, 822, 8, 69, 1130, 9, 508, 378, 26, 355, 1980, 288, 620, 77, 14, 952, 3508, 83, 26, 450, 68, 20456, 402, 450, 68, 23995, 6112, 2341, 2458, 83, 60, 78, 7, 450, 334, 355, 6748, 12, 3089, 8, 69, 1130, 14, 1459, 4000, 822, 8, 69, 1130, 395, 620, 8, 69, 1130, 1724, 267, 372, 822, 8, 1099, 63, 1130, 9, 446, 980, 405, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1715, 63, 354, 275, 488, 267, 291, 14, 5910, 63, 1291, 63, 1130, 275, 1052, 267, 291, 14, 5910, 63, 2164, 63, 1130, 275, 1052, 267, 291, 14, 1548, 63, 1130, 275, 1052, 267, 4287, 63, 5993, 275, 788, 4792, 2327, 7514, 13, 31910, 297, 2079, 283, 7354, 13, 3479, 13, 842, 13, 2987, 297, 2079, 283, 7354, 13, 70, 546, 13, 3455, 13, 2474, 418, 267, 327, 3272, 4287, 267, 291, 14, 26324, 63, 3291, 275, 14574, 3435, 13, 4600, 13, 14189, 29, 4714, 297, 1169, 2850, 5993, 534, 435, 12814, 904, 8, 26324, 63, 5993, 1874, 398, 291, 14, 26324, 63, 25729, 275, 663, 2941, 705, 297, 283, 3764, 297, 283, 388, 18803, 297, 283, 264, 4778, 1105, 267, 327, 3272, 7246, 24620, 267, 7246, 3854, 63, 589, 275, 788, 3130, 2850, 5359, 534, 435, 334, 26409, 904, 8, 12206, 63, 12273, 10524, 267, 485, 275, 7246, 3854, 14, 4003, 14517, 8, 5910, 3854, 63, 589, 9, 267, 7246, 3854, 423, 1084, 18053, 5102, 1370, 904, 24829, 1506, 15, 67, 4176, 845, 297, 4228, 2475, 1506, 15, 9247, 297, 4228, 2475, 1506, 15, 2613, 297, 4228, 2475, 1506, 15, 1291, 63, 15606, 297, 4228, 6681, 1506, 15, 2613, 63, 10058, 63, 13297, 63, 1180, 297, 4228, 6681, 1506, 15, 2613, 63, 1648, 5156, 267, 7246, 3854, 423, 1084, 2353, 316, 6609, 360, 13517, 358, 267, 7246, 3854, 423, 604, 63, 1267, 275, 2948, 339, 347, 2112, 63, 5910, 8, 277, 12, 931, 12, 4739, 304, 267, 408, 3498, 282, 7246, 570, 1041, 267, 485, 5910, 3854, 63, 929, 14, 9637, 547, 23209, 342, 267, 7246, 3854, 14, 3498, 1173, 8, 495, 8, 515, 395, 485, 5910, 3854, 63, 929, 14, 3832, 63, 1896, 9, 267, 485, 5910, 3854, 63, 929, 14, 5375, 547, 23209, 342, 267, 2552, 275, 485, 5910, 3854, 63, 929, 14, 2550, 63, 991, 63, 3710, 14, 1574, 342, 398, 340, 4739, 508, 283, 72, 356, 288, 291, 14, 5910, 63, 1291, 63, 1130, 59, 495, 8, 515, 1874, 275, 2552, 267, 587, 26, 288, 291, 14, 5910, 63, 2164, 63, 1130, 59, 495, 8, 515, 1874, 275, 2552, 339, 347, 2112, 63, 1548, 8, 277, 12, 931, 304, 267, 408, 3498, 282, 2366, 570, 1041, 267, 334, 26324, 63, 2703, 12, 4287, 63, 3083, 9, 275, 325, 26324, 14, 647, 63, 1065, 8, 288, 283, 1987, 904, 779, 495, 8, 515, 1874, 435, 291, 14, 26324, 63, 3291, 395, 372, 63, 1516, 29, 549, 9, 267, 325, 1130, 275, 1052, 267, 870, 8, 26324, 63, 3083, 14, 739, 1012, 267, 367, 1004, 315, 4287, 63, 2703, 26, 288, 984, 14, 3083, 14, 952, 8, 604, 9, 288, 790, 275, 1004, 14, 1294, 32694, 17, 1055, 1294, 14097, 5832, 16, 1055, 1913, 342, 288, 340, 790, 440, 315, 291, 14, 26324, 63, 25729, 26, 355, 1980, 288, 340, 790, 440, 315, 325, 1130, 26, 355, 325, 1130, 59, 498, 61, 275, 413, 288, 587, 26, 355, 325, 1130, 59, 498, 61, 847, 413, 267, 984, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 12, 9563, 13, 1975, 12, 17738, 13, 7011, 12, 295, 4037, 13, 1975, 13, 466, 199, 624, 44, 442, 5922, 370, 3550, 24620, 6212, 402, 1350, 14, 199, 7384, 701, 23212, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 6010, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 7246, 3854, 199, 504, 7246, 3854, 492, 485, 5910, 3854, 63, 929, 199, 504, 4287, 492, 325, 26324, 199, 199, 12206, 63, 12273, 275, 663, 2941, 2055, 297, 283, 67, 297, 283, 5910, 297, 283, 72, 297, 283, 15140, 297, 283, 72, 802, 1105, 199, 11720, 63, 12273, 275, 663, 2941, 647, 1105, 199, 199, 533, 491, 442, 4433, 8, 785, 304, 272, 408, 2543, 370, 1720, 1255, 316, 314, 24620, 436, 5767, 6212, 624, 339, 768, 4639, 272, 347, 485, 1361, 63, 4705, 63, 1130, 8, 495, 77, 12, 754, 63, 1130, 12, 8570, 304, 267, 408, 5375, 6212, 402, 9842, 754, 2341, 1041, 267, 340, 822, 8, 1099, 63, 1130, 9, 508, 378, 26, 288, 372, 378, 267, 980, 405, 275, 822, 779, 88, 367, 1022, 12, 671, 315, 754, 63, 1130, 14, 4611, 342, 340, 822, 8, 88, 9, 508, 378, 566, 267, 620, 77, 14, 952, 360, 532, 2458, 68, 3149, 68, 450, 83, 1584, 3032, 1104, 532, 9529, 78, 7, 450, 334, 78, 1529, 12, 822, 8, 1099, 63, 1130, 395, 8570, 430, 267, 367, 6748, 12, 325, 1130, 315, 754, 63, 1130, 14, 4611, 837, 288, 340, 822, 8, 69, 1130, 9, 508, 378, 26, 355, 1980, 288, 620, 77, 14, 952, 3508, 83, 26, 450, 68, 20456, 402, 450, 68, 23995, 6112, 2341, 2458, 83, 60, 78, 7, 450, 334, 355, 6748, 12, 3089, 8, 69, 1130, 14, 1459, 4000, 822, 8, 69, 1130, 395, 620, 8, 69, 1130, 1724, 267, 372, 822, 8, 1099, 63, 1130, 9, 446, 980, 405, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1715, 63, 354, 275, 488, 267, 291, 14, 5910, 63, 1291, 63, 1130, 275, 1052, 267, 291, 14, 5910, 63, 2164, 63, 1130, 275, 1052, 267, 291, 14, 1548, 63, 1130, 275, 1052, 267, 4287, 63, 5993, 275, 788, 4792, 2327, 7514, 13, 31910, 297, 2079, 283, 7354, 13, 3479, 13, 842, 13, 2987, 297, 2079, 283, 7354, 13, 70, 546, 13, 3455, 13, 2474, 418, 267, 327, 3272, 4287, 267, 291, 14, 26324, 63, 3291, 275, 14574, 3435, 13, 4600, 13, 14189, 29, 4714, 297, 1169, 2850, 5993, 534, 435, 12814, 904, 8, 26324, 63, 5993, 1874, 398, 291, 14, 26324, 63, 25729, 275, 663, 2941, 705, 297, 283, 3764, 297, 283, 388, 18803, 297, 283, 264, 4778, 1105, 267, 327, 3272, 7246, 24620, 267, 7246, 3854, 63, 589, 275, 788, 3130, 2850, 5359, 534, 435, 334, 26409, 904, 8, 12206, 63, 12273, 10524, 267, 485, 275, 7246, 3854, 14, 4003, 14517, 8, 5910, 3854, 63, 589, 9, 267, 7246, 3854, 423, 1084, 18053, 5102, 1370, 904, 24829, 1506, 15, 67, 4176, 845, 297, 4228, 2475, 1506, 15, 9247, 297, 4228, 2475, 1506, 15, 2613, 297, 4228, 2475, 1506, 15, 1291, 63, 15606, 297, 4228, 6681, 1506, 15, 2613, 63, 10058, 63, 13297, 63, 1180, 297, 4228, 6681, 1506, 15, 2613, 63, 1648, 5156, 267, 7246, 3854, 423, 1084, 2353, 316, 6609, 360, 13517, 358, 267, 7246, 3854, 423, 604, 63, 1267, 275, 2948, 339, 347, 2112, 63, 5910, 8, 277, 12, 931, 12, 4739, 304, 267, 408, 3498, 282, 7246, 570, 1041, 267, 485, 5910, 3854, 63, 929, 14, 9637, 547, 23209, 342, 267, 7246, 3854, 14, 3498, 1173, 8, 495, 8, 515, 395, 485, 5910, 3854, 63, 929, 14, 3832, 63, 1896, 9, 267, 485, 5910, 3854, 63, 929, 14, 5375, 547, 23209, 342, 267, 2552, 275, 485, 5910, 3854, 63, 929, 14, 2550, 63, 991, 63, 3710, 14, 1574, 342, 398, 340, 4739, 508, 283, 72, 356, 288, 291, 14, 5910, 63, 1291, 63, 1130, 59, 495, 8, 515, 1874, 275, 2552, 267, 587, 26, 288, 291, 14, 5910, 63, 2164, 63, 1130, 59, 495, 8, 515, 1874, 275, 2552, 339, 347, 2112, 63, 1548, 8, 277, 12, 931, 304, 267, 408, 3498, 282, 2366, 570, 1041, 267, 334, 26324, 63, 2703, 12, 4287, 63, 3083, 9, 275, 325, 26324, 14, 647, 63, 1065, 8, 288, 283, 1987, 904, 779, 495, 8, 515, 1874, 435, 291, 14, 26324, 63, 3291, 395, 372, 63, 1516, 29, 549, 9, 267, 325, 1130, 275, 1052, 267, 870, 8, 26324, 63, 3083, 14, 739, 1012, 267, 367, 1004, 315, 4287, 63, 2703, 26, 288, 984, 14, 3083, 14, 952, 8, 604, 9, 288, 790, 275, 1004, 14, 1294, 32694, 17, 1055, 1294, 14097, 5832, 16, 1055, 1913, 342, 288, 340, 790, 440, 315, 291, 14, 26324, 63, 25729, 26, 355, 1980, 288, 340, 790, 440, 315, 325, 1130, 26, 355, 325, 1130, 59, 498, 61, 275, 413, 288, 587, 26, 355, 325, 1130, 59, 498, 61, 847, 413, 267, 984, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
llvm-mirror/lldb
packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
5
2614
"""Test calling functions in static methods.""" from __future__ import print_function import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class TestObjCStaticMethod(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "static.m" self.break_line = line_number( self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) #<rdar://problem/9745789> "expression" can't call functions in class methods def test_with_python_api(self): """Test calling functions in static methods.""" self.build() exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) bpt = target.BreakpointCreateByLocation( self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. process = target.LaunchSimple( None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. self.assertTrue( len(thread_list) != 0, "No thread stopped at our breakpoint.") self.assertTrue(len(thread_list) == 1, "More than one thread stopped at our breakpoint.") # Now make sure we can call a function in the static method we've # stopped in. frame = thread_list[0].GetFrameAtIndex(0) self.assertTrue(frame, "Got a valid frame 0 frame.") cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)") self.assertTrue(cmd_value.IsValid()) sel_name = cmd_value.GetSummary() self.assertTrue( sel_name == "\"doSomethingWithString:\"", "Got the right value for the selector as string.") cmd_value = frame.EvaluateExpression( "[self doSomethingElseWithString:string]") self.assertTrue(cmd_value.IsValid()) string_length = cmd_value.GetValueAsUnsigned() self.assertTrue( string_length == 27, "Got the right value from another class method on the same class.")
apache-2.0
[ 624, 774, 6358, 3423, 315, 2955, 3102, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 646, 634, 15793, 199, 504, 634, 15793, 5768, 14, 396, 14, 11582, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 14, 914, 697, 396, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 492, 634, 1447, 464, 2270, 421, 199, 533, 1379, 5665, 3298, 502, 764, 3767, 8, 14440, 304, 339, 3002, 694, 275, 1379, 1563, 14, 3357, 63, 1662, 694, 3460, 493, 3368, 339, 347, 3613, 8, 277, 304, 267, 327, 6523, 1613, 1159, 3613, 1252, 267, 1379, 1563, 14, 5996, 8, 277, 9, 267, 327, 6668, 314, 1004, 5579, 370, 2059, 6272, 2446, 1252, 267, 291, 14, 973, 63, 1365, 275, 298, 1986, 14, 77, 2, 267, 291, 14, 4785, 63, 604, 275, 1004, 63, 1955, 8, 288, 291, 14, 973, 63, 1365, 12, 18290, 2494, 17944, 2348, 2659, 339, 768, 11278, 31065, 272, 768, 525, 63, 396, 63, 8906, 2941, 647, 1246, 1105, 272, 327, 28, 82, 4460, 921, 6462, 15, 31125, 1641, 1407, 30, 298, 5599, 2, 883, 1133, 1240, 3423, 315, 1021, 3102, 272, 347, 511, 63, 1045, 63, 1548, 63, 1246, 8, 277, 304, 267, 408, 774, 6358, 3423, 315, 2955, 3102, 1041, 267, 291, 14, 1506, 342, 267, 14778, 275, 291, 14, 362, 3425, 1596, 10048, 480, 65, 14, 548, 531, 398, 1347, 275, 291, 14, 16310, 14, 2499, 4277, 8, 5803, 9, 267, 291, 14, 1815, 8, 1375, 12, 22049, 63, 9268, 9, 398, 330, 541, 275, 1347, 14, 28944, 2499, 2175, 6592, 8, 288, 291, 14, 973, 63, 1365, 12, 291, 14, 4785, 63, 604, 9, 267, 291, 14, 1815, 8, 66, 541, 12, 22049, 63, 14731, 7217, 9, 398, 327, 7356, 10623, 314, 2112, 12, 436, 886, 440, 3631, 737, 2397, 2376, 14, 267, 2112, 275, 1347, 14, 18543, 3184, 8, 288, 488, 12, 488, 12, 291, 14, 362, 63, 1412, 63, 9818, 63, 3619, 1012, 398, 291, 14, 1815, 8, 1412, 12, 3611, 35, 1608, 63, 1311, 63, 5600, 9, 398, 327, 710, 3631, 4499, 402, 314, 2462, 1077, 506, 17944, 14, 267, 2462, 63, 513, 275, 634, 1447, 464, 2270, 14, 362, 63, 6962, 63, 14661, 63, 292, 63, 20081, 8, 1412, 12, 330, 541, 9, 398, 327, 4155, 3238, 781, 15248, 737, 314, 1642, 17944, 14, 267, 291, 14, 1815, 8, 288, 822, 8, 2671, 63, 513, 9, 1137, 378, 12, 288, 298, 1944, 2462, 15248, 737, 4154, 17944, 2685, 267, 291, 14, 1815, 8, 552, 8, 2671, 63, 513, 9, 508, 413, 12, 717, 298, 11053, 2419, 1373, 2462, 15248, 737, 4154, 17944, 2685, 398, 327, 7356, 1852, 3238, 781, 883, 1240, 282, 805, 315, 314, 2955, 1083, 781, 9064, 267, 327, 15248, 315, 14, 267, 2787, 275, 2462, 63, 513, 59, 16, 1055, 1002, 3160, 1271, 2681, 8, 16, 9, 267, 291, 14, 1815, 8, 1943, 12, 298, 13662, 282, 1686, 2787, 378, 2787, 2685, 398, 2088, 63, 585, 275, 2787, 14, 25002, 9093, 18353, 1560, 24104, 13680, 63, 16405, 6110, 1760, 6320, 267, 291, 14, 1815, 8, 1760, 63, 585, 14, 1831, 3490, 1012, 267, 13680, 63, 354, 275, 2088, 63, 585, 14, 1002, 10407, 342, 267, 291, 14, 1815, 8, 288, 13680, 63, 354, 508, 30768, 1117, 20641, 3007, 1558, 3427, 5151, 288, 298, 13662, 314, 2451, 574, 367, 314, 9759, 465, 1059, 2685, 398, 2088, 63, 585, 275, 2787, 14, 25002, 9093, 8, 288, 7369, 277, 886, 20641, 26836, 3007, 1558, 26, 875, 12523, 267, 291, 14, 1815, 8, 1760, 63, 585, 14, 1831, 3490, 1012, 267, 1059, 63, 1267, 275, 2088, 63, 585, 14, 9334, 2822, 25269, 342, 267, 291, 14, 1815, 8, 288, 1059, 63, 1267, 508, 8087, 12, 288, 298, 13662, 314, 2451, 574, 687, 4573, 1021, 1083, 641, 314, 2011, 1021, 2685, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 774, 6358, 3423, 315, 2955, 3102, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 646, 634, 15793, 199, 504, 634, 15793, 5768, 14, 396, 14, 11582, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 14, 914, 697, 396, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 492, 634, 1447, 464, 2270, 421, 199, 533, 1379, 5665, 3298, 502, 764, 3767, 8, 14440, 304, 339, 3002, 694, 275, 1379, 1563, 14, 3357, 63, 1662, 694, 3460, 493, 3368, 339, 347, 3613, 8, 277, 304, 267, 327, 6523, 1613, 1159, 3613, 1252, 267, 1379, 1563, 14, 5996, 8, 277, 9, 267, 327, 6668, 314, 1004, 5579, 370, 2059, 6272, 2446, 1252, 267, 291, 14, 973, 63, 1365, 275, 298, 1986, 14, 77, 2, 267, 291, 14, 4785, 63, 604, 275, 1004, 63, 1955, 8, 288, 291, 14, 973, 63, 1365, 12, 18290, 2494, 17944, 2348, 2659, 339, 768, 11278, 31065, 272, 768, 525, 63, 396, 63, 8906, 2941, 647, 1246, 1105, 272, 327, 28, 82, 4460, 921, 6462, 15, 31125, 1641, 1407, 30, 298, 5599, 2, 883, 1133, 1240, 3423, 315, 1021, 3102, 272, 347, 511, 63, 1045, 63, 1548, 63, 1246, 8, 277, 304, 267, 408, 774, 6358, 3423, 315, 2955, 3102, 1041, 267, 291, 14, 1506, 342, 267, 14778, 275, 291, 14, 362, 3425, 1596, 10048, 480, 65, 14, 548, 531, 398, 1347, 275, 291, 14, 16310, 14, 2499, 4277, 8, 5803, 9, 267, 291, 14, 1815, 8, 1375, 12, 22049, 63, 9268, 9, 398, 330, 541, 275, 1347, 14, 28944, 2499, 2175, 6592, 8, 288, 291, 14, 973, 63, 1365, 12, 291, 14, 4785, 63, 604, 9, 267, 291, 14, 1815, 8, 66, 541, 12, 22049, 63, 14731, 7217, 9, 398, 327, 7356, 10623, 314, 2112, 12, 436, 886, 440, 3631, 737, 2397, 2376, 14, 267, 2112, 275, 1347, 14, 18543, 3184, 8, 288, 488, 12, 488, 12, 291, 14, 362, 63, 1412, 63, 9818, 63, 3619, 1012, 398, 291, 14, 1815, 8, 1412, 12, 3611, 35, 1608, 63, 1311, 63, 5600, 9, 398, 327, 710, 3631, 4499, 402, 314, 2462, 1077, 506, 17944, 14, 267, 2462, 63, 513, 275, 634, 1447, 464, 2270, 14, 362, 63, 6962, 63, 14661, 63, 292, 63, 20081, 8, 1412, 12, 330, 541, 9, 398, 327, 4155, 3238, 781, 15248, 737, 314, 1642, 17944, 14, 267, 291, 14, 1815, 8, 288, 822, 8, 2671, 63, 513, 9, 1137, 378, 12, 288, 298, 1944, 2462, 15248, 737, 4154, 17944, 2685, 267, 291, 14, 1815, 8, 552, 8, 2671, 63, 513, 9, 508, 413, 12, 717, 298, 11053, 2419, 1373, 2462, 15248, 737, 4154, 17944, 2685, 398, 327, 7356, 1852, 3238, 781, 883, 1240, 282, 805, 315, 314, 2955, 1083, 781, 9064, 267, 327, 15248, 315, 14, 267, 2787, 275, 2462, 63, 513, 59, 16, 1055, 1002, 3160, 1271, 2681, 8, 16, 9, 267, 291, 14, 1815, 8, 1943, 12, 298, 13662, 282, 1686, 2787, 378, 2787, 2685, 398, 2088, 63, 585, 275, 2787, 14, 25002, 9093, 18353, 1560, 24104, 13680, 63, 16405, 6110, 1760, 6320, 267, 291, 14, 1815, 8, 1760, 63, 585, 14, 1831, 3490, 1012, 267, 13680, 63, 354, 275, 2088, 63, 585, 14, 1002, 10407, 342, 267, 291, 14, 1815, 8, 288, 13680, 63, 354, 508, 30768, 1117, 20641, 3007, 1558, 3427, 5151, 288, 298, 13662, 314, 2451, 574, 367, 314, 9759, 465, 1059, 2685, 398, 2088, 63, 585, 275, 2787, 14, 25002, 9093, 8, 288, 7369, 277, 886, 20641, 26836, 3007, 1558, 26, 875, 12523, 267, 291, 14, 1815, 8, 1760, 63, 585, 14, 1831, 3490, 1012, 267, 1059, 63, 1267, 275, 2088, 63, 585, 14, 9334, 2822, 25269, 342, 267, 291, 14, 1815, 8, 288, 1059, 63, 1267, 508, 8087, 12, 288, 298, 13662, 314, 2451, 574, 687, 4573, 1021, 1083, 641, 314, 2011, 1021, 2685, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
chyeh727/django
django/db/migrations/operations/models.py
290
21735
from __future__ import unicode_literals from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.state import ModelState from django.db.models.options import normalize_together from django.utils import six from django.utils.functional import cached_property class CreateModel(Operation): """ Create a model's table. """ serialization_expand_args = ['fields', 'options', 'managers'] def __init__(self, name, fields, options=None, bases=None, managers=None): self.name = name self.fields = fields self.options = options or {} self.bases = bases or (models.Model,) self.managers = managers or [] @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'fields': self.fields, } if self.options: kwargs['options'] = self.options if self.bases and self.bases != (models.Model,): kwargs['bases'] = self.bases if self.managers and self.managers != [('objects', models.Manager())]: kwargs['managers'] = self.managers return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): state.add_model(ModelState( app_label, self.name, list(self.fields), dict(self.options), tuple(self.bases), list(self.managers), )) def database_forwards(self, app_label, schema_editor, from_state, to_state): model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, model): schema_editor.create_model(model) def database_backwards(self, app_label, schema_editor, from_state, to_state): model = from_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, model): schema_editor.delete_model(model) def describe(self): return "Create %smodel %s" % ("proxy " if self.options.get("proxy", False) else "", self.name) def references_model(self, name, app_label=None): strings_to_check = [self.name] # Check we didn't inherit from the model for base in self.bases: if isinstance(base, six.string_types): strings_to_check.append(base.split(".")[-1]) # Check we have no FKs/M2Ms with it for fname, field in self.fields: if field.remote_field: if isinstance(field.remote_field.model, six.string_types): strings_to_check.append(field.remote_field.model.split(".")[-1]) # Now go over all the strings and compare them for string in strings_to_check: if string.lower() == name.lower(): return True return False class DeleteModel(Operation): """ Drops a model's table. """ def __init__(self, name): self.name = name @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): state.remove_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): model = from_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, model): schema_editor.delete_model(model) def database_backwards(self, app_label, schema_editor, from_state, to_state): model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, model): schema_editor.create_model(model) def references_model(self, name, app_label=None): return name.lower() == self.name_lower def describe(self): return "Delete model %s" % (self.name, ) class RenameModel(Operation): """ Renames a model. """ def __init__(self, old_name, new_name): self.old_name = old_name self.new_name = new_name @cached_property def old_name_lower(self): return self.old_name.lower() @cached_property def new_name_lower(self): return self.new_name.lower() def deconstruct(self): kwargs = { 'old_name': self.old_name, 'new_name': self.new_name, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): apps = state.apps model = apps.get_model(app_label, self.old_name) model._meta.apps = apps # Get all of the related objects we need to repoint all_related_objects = ( f for f in model._meta.get_fields(include_hidden=True) if f.auto_created and not f.concrete and (not f.hidden or f.many_to_many) ) # Rename the model state.models[app_label, self.new_name_lower] = state.models[app_label, self.old_name_lower] state.models[app_label, self.new_name_lower].name = self.new_name state.remove_model(app_label, self.old_name_lower) # Repoint the FKs and M2Ms pointing to us for related_object in all_related_objects: if related_object.model is not model: # The model being renamed does not participate in this relation # directly. Rather, a superclass does. continue # Use the new related key for self referential related objects. if related_object.related_model == model: related_key = (app_label, self.new_name_lower) else: related_key = ( related_object.related_model._meta.app_label, related_object.related_model._meta.model_name, ) new_fields = [] for name, field in state.models[related_key].fields: if name == related_object.field.name: field = field.clone() field.remote_field.model = "%s.%s" % (app_label, self.new_name) new_fields.append((name, field)) state.models[related_key].fields = new_fields state.reload_model(*related_key) state.reload_model(app_label, self.new_name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model = to_state.apps.get_model(app_label, self.new_name) if self.allow_migrate_model(schema_editor.connection.alias, new_model): old_model = from_state.apps.get_model(app_label, self.old_name) # Move the main table schema_editor.alter_db_table( new_model, old_model._meta.db_table, new_model._meta.db_table, ) # Alter the fields pointing to us for related_object in old_model._meta.related_objects: if related_object.related_model == old_model: model = new_model related_key = (app_label, self.new_name_lower) else: model = related_object.related_model related_key = ( related_object.related_model._meta.app_label, related_object.related_model._meta.model_name, ) to_field = to_state.apps.get_model( *related_key )._meta.get_field(related_object.field.name) schema_editor.alter_field( model, related_object.field, to_field, ) # Rename M2M fields whose name is based on this model's name. fields = zip(old_model._meta.local_many_to_many, new_model._meta.local_many_to_many) for (old_field, new_field) in fields: # Skip self-referential fields as these are renamed above. if new_field.model == new_field.related_model or not new_field.remote_field.through._meta.auto_created: continue # Rename the M2M table that's based on this model's name. old_m2m_model = old_field.remote_field.through new_m2m_model = new_field.remote_field.through schema_editor.alter_db_table( new_m2m_model, old_m2m_model._meta.db_table, new_m2m_model._meta.db_table, ) # Rename the column in the M2M table that's based on this # model's name. schema_editor.alter_field( new_m2m_model, old_m2m_model._meta.get_field(old_model._meta.model_name), new_m2m_model._meta.get_field(new_model._meta.model_name), ) def database_backwards(self, app_label, schema_editor, from_state, to_state): self.new_name_lower, self.old_name_lower = self.old_name_lower, self.new_name_lower self.new_name, self.old_name = self.old_name, self.new_name self.database_forwards(app_label, schema_editor, from_state, to_state) self.new_name_lower, self.old_name_lower = self.old_name_lower, self.new_name_lower self.new_name, self.old_name = self.old_name, self.new_name def references_model(self, name, app_label=None): return ( name.lower() == self.old_name_lower or name.lower() == self.new_name_lower ) def describe(self): return "Rename model %s to %s" % (self.old_name, self.new_name) class AlterModelTable(Operation): """ Renames a model's table """ def __init__(self, name, table): self.name = name self.table = table @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'table': self.table, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): state.models[app_label, self.name_lower].options["db_table"] = self.table state.reload_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, new_model): old_model = from_state.apps.get_model(app_label, self.name) schema_editor.alter_db_table( new_model, old_model._meta.db_table, new_model._meta.db_table, ) # Rename M2M fields whose name is based on this model's db_table for (old_field, new_field) in zip(old_model._meta.local_many_to_many, new_model._meta.local_many_to_many): if new_field.remote_field.through._meta.auto_created: schema_editor.alter_db_table( new_field.remote_field.through, old_field.remote_field.through._meta.db_table, new_field.remote_field.through._meta.db_table, ) def database_backwards(self, app_label, schema_editor, from_state, to_state): return self.database_forwards(app_label, schema_editor, from_state, to_state) def references_model(self, name, app_label=None): return name.lower() == self.name_lower def describe(self): return "Rename table for %s to %s" % (self.name, self.table) class AlterUniqueTogether(Operation): """ Changes the value of unique_together to the target one. Input value of unique_together must be a set of tuples. """ option_name = "unique_together" def __init__(self, name, unique_together): self.name = name unique_together = normalize_together(unique_together) self.unique_together = set(tuple(cons) for cons in unique_together) @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'unique_together': self.unique_together, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): model_state = state.models[app_label, self.name_lower] model_state.options[self.option_name] = self.unique_together state.reload_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, new_model): old_model = from_state.apps.get_model(app_label, self.name) schema_editor.alter_unique_together( new_model, getattr(old_model._meta, self.option_name, set()), getattr(new_model._meta, self.option_name, set()), ) def database_backwards(self, app_label, schema_editor, from_state, to_state): return self.database_forwards(app_label, schema_editor, from_state, to_state) def references_model(self, name, app_label=None): return name.lower() == self.name_lower def references_field(self, model_name, name, app_label=None): return ( self.references_model(model_name, app_label) and ( not self.unique_together or any((name in together) for together in self.unique_together) ) ) def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.unique_together or '')) class AlterIndexTogether(Operation): """ Changes the value of index_together to the target one. Input value of index_together must be a set of tuples. """ option_name = "index_together" def __init__(self, name, index_together): self.name = name index_together = normalize_together(index_together) self.index_together = set(tuple(cons) for cons in index_together) @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'index_together': self.index_together, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): model_state = state.models[app_label, self.name_lower] model_state.options[self.option_name] = self.index_together state.reload_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, new_model): old_model = from_state.apps.get_model(app_label, self.name) schema_editor.alter_index_together( new_model, getattr(old_model._meta, self.option_name, set()), getattr(new_model._meta, self.option_name, set()), ) def database_backwards(self, app_label, schema_editor, from_state, to_state): return self.database_forwards(app_label, schema_editor, from_state, to_state) def references_model(self, name, app_label=None): return name.lower() == self.name_lower def references_field(self, model_name, name, app_label=None): return ( self.references_model(model_name, app_label) and ( not self.index_together or any((name in together) for together in self.index_together) ) ) def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.index_together or '')) class AlterOrderWithRespectTo(Operation): """ Represents a change with the order_with_respect_to option. """ def __init__(self, name, order_with_respect_to): self.name = name self.order_with_respect_to = order_with_respect_to @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'order_with_respect_to': self.order_with_respect_to, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): model_state = state.models[app_label, self.name_lower] model_state.options['order_with_respect_to'] = self.order_with_respect_to state.reload_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): to_model = to_state.apps.get_model(app_label, self.name) if self.allow_migrate_model(schema_editor.connection.alias, to_model): from_model = from_state.apps.get_model(app_label, self.name) # Remove a field if we need to if from_model._meta.order_with_respect_to and not to_model._meta.order_with_respect_to: schema_editor.remove_field(from_model, from_model._meta.get_field("_order")) # Add a field if we need to (altering the column is untouched as # it's likely a rename) elif to_model._meta.order_with_respect_to and not from_model._meta.order_with_respect_to: field = to_model._meta.get_field("_order") if not field.has_default(): field.default = 0 schema_editor.add_field( from_model, field, ) def database_backwards(self, app_label, schema_editor, from_state, to_state): self.database_forwards(app_label, schema_editor, from_state, to_state) def references_model(self, name, app_label=None): return name.lower() == self.name_lower def references_field(self, model_name, name, app_label=None): return ( self.references_model(model_name, app_label) and ( self.order_with_respect_to is None or name == self.order_with_respect_to ) ) def describe(self): return "Set order_with_respect_to on %s to %s" % (self.name, self.order_with_respect_to) class AlterModelOptions(Operation): """ Sets new model options that don't directly affect the database schema (like verbose_name, permissions, ordering). Python code in migrations may still need them. """ # Model options we want to compare and preserve in an AlterModelOptions op ALTER_OPTION_KEYS = [ "get_latest_by", "managed", "ordering", "permissions", "default_permissions", "select_on_save", "verbose_name", "verbose_name_plural", ] def __init__(self, name, options): self.name = name self.options = options @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): kwargs = { 'name': self.name, 'options': self.options, } return ( self.__class__.__name__, [], kwargs ) def state_forwards(self, app_label, state): model_state = state.models[app_label, self.name_lower] model_state.options = dict(model_state.options) model_state.options.update(self.options) for key in self.ALTER_OPTION_KEYS: if key not in self.options and key in model_state.options: del model_state.options[key] state.reload_model(app_label, self.name_lower) def database_forwards(self, app_label, schema_editor, from_state, to_state): pass def database_backwards(self, app_label, schema_editor, from_state, to_state): pass def references_model(self, name, app_label=None): return name.lower() == self.name_lower def describe(self): return "Change Meta options on %s" % (self.name, ) class AlterModelManagers(Operation): """ Alters the model's managers """ serialization_expand_args = ['managers'] def __init__(self, name, managers): self.name = name self.managers = managers @cached_property def name_lower(self): return self.name.lower() def deconstruct(self): return ( self.__class__.__name__, [self.name, self.managers], {} ) def state_forwards(self, app_label, state): model_state = state.models[app_label, self.name_lower] model_state.managers = list(self.managers) def database_forwards(self, app_label, schema_editor, from_state, to_state): pass def database_backwards(self, app_label, schema_editor, from_state, to_state): pass def references_model(self, name, app_label=None): return name.lower() == self.name_lower def describe(self): return "Change managers on %s" % (self.name, )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 1095, 492, 17954, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 5822, 2223, 199, 504, 1639, 14, 697, 14, 992, 14, 1419, 492, 7666, 63, 6314, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 421, 199, 533, 2790, 1685, 8, 6044, 304, 272, 408, 272, 2790, 282, 1402, 1159, 1817, 14, 272, 408, 339, 16953, 63, 4441, 63, 589, 275, 788, 955, 297, 283, 1419, 297, 283, 16259, 418, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1504, 12, 1511, 29, 403, 12, 9768, 29, 403, 12, 19680, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 955, 275, 1504, 267, 291, 14, 1419, 275, 1511, 503, 1052, 267, 291, 14, 12087, 275, 9768, 503, 334, 992, 14, 1685, 4258, 267, 291, 14, 16259, 275, 19680, 503, 942, 339, 768, 5245, 63, 1829, 272, 347, 536, 63, 2325, 8, 277, 304, 267, 372, 291, 14, 354, 14, 2325, 342, 339, 347, 477, 8514, 8, 277, 304, 267, 2074, 275, 469, 288, 283, 354, 356, 291, 14, 354, 12, 288, 283, 955, 356, 291, 14, 955, 12, 267, 789, 267, 340, 291, 14, 1419, 26, 288, 2074, 459, 1419, 418, 275, 291, 14, 1419, 267, 340, 291, 14, 12087, 436, 291, 14, 12087, 1137, 334, 992, 14, 1685, 16095, 288, 2074, 459, 12087, 418, 275, 291, 14, 12087, 267, 340, 291, 14, 16259, 436, 291, 14, 16259, 1137, 4274, 1462, 297, 1709, 14, 2988, 1012, 2189, 288, 2074, 459, 16259, 418, 275, 291, 14, 16259, 267, 372, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 990, 288, 2074, 267, 776, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 1174, 14, 525, 63, 1238, 8, 1685, 2223, 8, 288, 1145, 63, 1302, 12, 288, 291, 14, 354, 12, 288, 769, 8, 277, 14, 955, 395, 288, 1211, 8, 277, 14, 1419, 395, 288, 2008, 8, 277, 14, 12087, 395, 288, 769, 8, 277, 14, 16259, 395, 267, 5082, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 370, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 981, 63, 1238, 8, 1238, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 687, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 2499, 450, 83, 1238, 450, 83, 2, 450, 1689, 3280, 298, 340, 291, 14, 1419, 14, 362, 480, 3280, 401, 756, 9, 587, 4873, 291, 14, 354, 9, 339, 347, 6941, 63, 1238, 8, 277, 12, 536, 12, 1145, 63, 1302, 29, 403, 304, 267, 3326, 63, 475, 63, 1074, 275, 359, 277, 14, 354, 61, 267, 327, 2670, 781, 9980, 1133, 8287, 687, 314, 1402, 267, 367, 1300, 315, 291, 14, 12087, 26, 288, 340, 1228, 8, 1095, 12, 3816, 14, 875, 63, 1313, 304, 355, 3326, 63, 475, 63, 1074, 14, 740, 8, 1095, 14, 1294, 15857, 1988, 17, 566, 267, 327, 2670, 781, 1172, 949, 18821, 83, 15, 45, 18, 13586, 543, 652, 267, 367, 6748, 12, 901, 315, 291, 14, 955, 26, 288, 340, 901, 14, 3846, 63, 698, 26, 355, 340, 1228, 8, 698, 14, 3846, 63, 698, 14, 1238, 12, 3816, 14, 875, 63, 1313, 304, 490, 3326, 63, 475, 63, 1074, 14, 740, 8, 698, 14, 3846, 63, 698, 14, 1238, 14, 1294, 15857, 1988, 17, 566, 267, 327, 7356, 2621, 1806, 1006, 314, 3326, 436, 6540, 3062, 267, 367, 1059, 315, 3326, 63, 475, 63, 1074, 26, 288, 340, 1059, 14, 2325, 342, 508, 536, 14, 2325, 837, 355, 372, 715, 267, 372, 756, 421, 199, 533, 8496, 1685, 8, 6044, 304, 272, 408, 272, 577, 26307, 282, 1402, 1159, 1817, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 768, 5245, 63, 1829, 272, 347, 536, 63, 2325, 8, 277, 304, 267, 372, 291, 14, 354, 14, 2325, 342, 339, 347, 477, 8514, 8, 277, 304, 267, 2074, 275, 469, 288, 283, 354, 356, 291, 14, 354, 12, 267, 789, 267, 372, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 990, 288, 2074, 267, 776, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 1174, 14, 2168, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 63, 2325, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 687, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 370, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 981, 63, 1238, 8, 1238, 9, 339, 347, 6941, 63, 1238, 8, 277, 12, 536 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 1095, 492, 17954, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 5822, 2223, 199, 504, 1639, 14, 697, 14, 992, 14, 1419, 492, 7666, 63, 6314, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 421, 199, 533, 2790, 1685, 8, 6044, 304, 272, 408, 272, 2790, 282, 1402, 1159, 1817, 14, 272, 408, 339, 16953, 63, 4441, 63, 589, 275, 788, 955, 297, 283, 1419, 297, 283, 16259, 418, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1504, 12, 1511, 29, 403, 12, 9768, 29, 403, 12, 19680, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 955, 275, 1504, 267, 291, 14, 1419, 275, 1511, 503, 1052, 267, 291, 14, 12087, 275, 9768, 503, 334, 992, 14, 1685, 4258, 267, 291, 14, 16259, 275, 19680, 503, 942, 339, 768, 5245, 63, 1829, 272, 347, 536, 63, 2325, 8, 277, 304, 267, 372, 291, 14, 354, 14, 2325, 342, 339, 347, 477, 8514, 8, 277, 304, 267, 2074, 275, 469, 288, 283, 354, 356, 291, 14, 354, 12, 288, 283, 955, 356, 291, 14, 955, 12, 267, 789, 267, 340, 291, 14, 1419, 26, 288, 2074, 459, 1419, 418, 275, 291, 14, 1419, 267, 340, 291, 14, 12087, 436, 291, 14, 12087, 1137, 334, 992, 14, 1685, 16095, 288, 2074, 459, 12087, 418, 275, 291, 14, 12087, 267, 340, 291, 14, 16259, 436, 291, 14, 16259, 1137, 4274, 1462, 297, 1709, 14, 2988, 1012, 2189, 288, 2074, 459, 16259, 418, 275, 291, 14, 16259, 267, 372, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 990, 288, 2074, 267, 776, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 1174, 14, 525, 63, 1238, 8, 1685, 2223, 8, 288, 1145, 63, 1302, 12, 288, 291, 14, 354, 12, 288, 769, 8, 277, 14, 955, 395, 288, 1211, 8, 277, 14, 1419, 395, 288, 2008, 8, 277, 14, 12087, 395, 288, 769, 8, 277, 14, 16259, 395, 267, 5082, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 370, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 981, 63, 1238, 8, 1238, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 687, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 2499, 450, 83, 1238, 450, 83, 2, 450, 1689, 3280, 298, 340, 291, 14, 1419, 14, 362, 480, 3280, 401, 756, 9, 587, 4873, 291, 14, 354, 9, 339, 347, 6941, 63, 1238, 8, 277, 12, 536, 12, 1145, 63, 1302, 29, 403, 304, 267, 3326, 63, 475, 63, 1074, 275, 359, 277, 14, 354, 61, 267, 327, 2670, 781, 9980, 1133, 8287, 687, 314, 1402, 267, 367, 1300, 315, 291, 14, 12087, 26, 288, 340, 1228, 8, 1095, 12, 3816, 14, 875, 63, 1313, 304, 355, 3326, 63, 475, 63, 1074, 14, 740, 8, 1095, 14, 1294, 15857, 1988, 17, 566, 267, 327, 2670, 781, 1172, 949, 18821, 83, 15, 45, 18, 13586, 543, 652, 267, 367, 6748, 12, 901, 315, 291, 14, 955, 26, 288, 340, 901, 14, 3846, 63, 698, 26, 355, 340, 1228, 8, 698, 14, 3846, 63, 698, 14, 1238, 12, 3816, 14, 875, 63, 1313, 304, 490, 3326, 63, 475, 63, 1074, 14, 740, 8, 698, 14, 3846, 63, 698, 14, 1238, 14, 1294, 15857, 1988, 17, 566, 267, 327, 7356, 2621, 1806, 1006, 314, 3326, 436, 6540, 3062, 267, 367, 1059, 315, 3326, 63, 475, 63, 1074, 26, 288, 340, 1059, 14, 2325, 342, 508, 536, 14, 2325, 837, 355, 372, 715, 267, 372, 756, 421, 199, 533, 8496, 1685, 8, 6044, 304, 272, 408, 272, 577, 26307, 282, 1402, 1159, 1817, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 768, 5245, 63, 1829, 272, 347, 536, 63, 2325, 8, 277, 304, 267, 372, 291, 14, 354, 14, 2325, 342, 339, 347, 477, 8514, 8, 277, 304, 267, 2074, 275, 469, 288, 283, 354, 356, 291, 14, 354, 12, 267, 789, 267, 372, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 990, 288, 2074, 267, 776, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 1174, 14, 2168, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 63, 2325, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 687, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1402, 275, 370, 63, 929, 14, 5181, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 291, 14, 354, 9, 267, 340, 291, 14, 3306, 63, 8462, 63, 1238, 8, 3629, 63, 7515, 14, 2105, 14, 3620, 12, 1402, 304, 288, 4177, 63, 7515, 14, 981, 63, 1238, 8, 1238, 9, 339, 347, 6941, 63, 1238, 8, 277, 12, 536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zenlambda/pip
pip/_vendor/requests/cookies.py
413
17191
# -*- coding: utf-8 -*- """ Compatibility code to be able to use `cookielib.CookieJar` with requests. requests.utils imports from here, so be careful with imports. """ import copy import time import collections from .compat import cookielib, urlparse, urlunparse, Morsel try: import threading # grr, pyflakes: this fixes "redefinition of unused 'threading'" threading except ImportError: import dummy_threading as threading class MockRequest(object): """Wraps a `requests.Request` to mimic a `urllib2.Request`. The code in `cookielib.CookieJar` expects this interface in order to correctly manage cookie policies, i.e., determine whether a cookie can be set, given the domains of the request and the cookie. The original request object is read-only. The client is responsible for collecting the new headers via `get_new_headers()` and interpreting them appropriately. You probably want `get_cookie_header`, defined below. """ def __init__(self, request): self._r = request self._new_headers = {} self.type = urlparse(self._r.url).scheme def get_type(self): return self.type def get_host(self): return urlparse(self._r.url).netloc def get_origin_req_host(self): return self.get_host() def get_full_url(self): # Only return the response's URL if the user hadn't set the Host # header if not self._r.headers.get('Host'): return self._r.url # If they did set it, retrieve it and reconstruct the expected domain host = self._r.headers['Host'] parsed = urlparse(self._r.url) # Reconstruct the URL as we expect it return urlunparse([ parsed.scheme, host, parsed.path, parsed.params, parsed.query, parsed.fragment ]) def is_unverifiable(self): return True def has_header(self, name): return name in self._r.headers or name in self._new_headers def get_header(self, name, default=None): return self._r.headers.get(name, self._new_headers.get(name, default)) def add_header(self, key, val): """cookielib has no legitimate use for this method; add it back if you find one.""" raise NotImplementedError("Cookie headers should be added with add_unredirected_header()") def add_unredirected_header(self, name, value): self._new_headers[name] = value def get_new_headers(self): return self._new_headers @property def unverifiable(self): return self.is_unverifiable() @property def origin_req_host(self): return self.get_origin_req_host() @property def host(self): return self.get_host() class MockResponse(object): """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`. ...what? Basically, expose the parsed HTTP headers from the server response the way `cookielib` expects to see them. """ def __init__(self, headers): """Make a MockResponse for `cookielib` to read. :param headers: a httplib.HTTPMessage or analogous carrying the headers """ self._headers = headers def info(self): return self._headers def getheaders(self, name): self._headers.getheaders(name) def extract_cookies_to_jar(jar, request, response): """Extract the cookies from the response into a CookieJar. :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object """ if not (hasattr(response, '_original_response') and response._original_response): return # the _original_response field is the wrapped httplib.HTTPResponse object, req = MockRequest(request) # pull out the HTTPMessage with the headers and put it in the mock: res = MockResponse(response._original_response.msg) jar.extract_cookies(res, req) def get_cookie_header(jar, request): """Produce an appropriate Cookie header string to be sent with `request`, or None.""" r = MockRequest(request) jar.add_cookie_header(r) return r.get_new_headers().get('Cookie') def remove_cookie_by_name(cookiejar, name, domain=None, path=None): """Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n). """ clearables = [] for cookie in cookiejar: if cookie.name == name: if domain is None or domain == cookie.domain: if path is None or path == cookie.path: clearables.append((cookie.domain, cookie.path, cookie.name)) for domain, path, name in clearables: cookiejar.clear(domain, path, name) class CookieConflictError(RuntimeError): """There are two cookies that meet the criteria specified in the cookie jar. Use .get and .set and include domain and path args in order to be more specific.""" class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): """Compatibility class; is a cookielib.CookieJar, but exposes a dict interface. This is the CookieJar we create by default for requests and sessions that don't specify one, since some clients may expect response.cookies and session.cookies to support dict operations. Requests does not use the dict interface internally; it's just for compatibility with external client code. All requests code should work out of the box with externally provided instances of ``CookieJar``, e.g. ``LWPCookieJar`` and ``FileCookieJar``. Unlike a regular CookieJar, this class is pickleable. .. warning:: dictionary operations that are normally O(1) may be O(n). """ def get(self, name, default=None, domain=None, path=None): """Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. .. warning:: operation is O(n), not O(1).""" try: return self._find_no_duplicates(name, domain, path) except KeyError: return default def set(self, name, value, **kwargs): """Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.""" # support client code that unsets cookies by assignment of a None value: if value is None: remove_cookie_by_name(self, name, domain=kwargs.get('domain'), path=kwargs.get('path')) return if isinstance(value, Morsel): c = morsel_to_cookie(value) else: c = create_cookie(name, value, **kwargs) self.set_cookie(c) return c def iterkeys(self): """Dict-like iterkeys() that returns an iterator of names of cookies from the jar. See itervalues() and iteritems().""" for cookie in iter(self): yield cookie.name def keys(self): """Dict-like keys() that returns a list of names of cookies from the jar. See values() and items().""" return list(self.iterkeys()) def itervalues(self): """Dict-like itervalues() that returns an iterator of values of cookies from the jar. See iterkeys() and iteritems().""" for cookie in iter(self): yield cookie.value def values(self): """Dict-like values() that returns a list of values of cookies from the jar. See keys() and items().""" return list(self.itervalues()) def iteritems(self): """Dict-like iteritems() that returns an iterator of name-value tuples from the jar. See iterkeys() and itervalues().""" for cookie in iter(self): yield cookie.name, cookie.value def items(self): """Dict-like items() that returns a list of name-value tuples from the jar. See keys() and values(). Allows client-code to call ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value pairs.""" return list(self.iteritems()) def list_domains(self): """Utility method to list all the domains in the jar.""" domains = [] for cookie in iter(self): if cookie.domain not in domains: domains.append(cookie.domain) return domains def list_paths(self): """Utility method to list all the paths in the jar.""" paths = [] for cookie in iter(self): if cookie.path not in paths: paths.append(cookie.path) return paths def multiple_domains(self): """Returns True if there are multiple domains in the jar. Returns False otherwise.""" domains = [] for cookie in iter(self): if cookie.domain is not None and cookie.domain in domains: return True domains.append(cookie.domain) return False # there is only one domain in jar def get_dict(self, domain=None, path=None): """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements.""" dictionary = {} for cookie in iter(self): if (domain is None or cookie.domain == domain) and (path is None or cookie.path == path): dictionary[cookie.name] = cookie.value return dictionary def __getitem__(self, name): """Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. .. warning:: operation is O(n), not O(1).""" return self._find_no_duplicates(name) def __setitem__(self, name, value): """Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead.""" self.set(name, value) def __delitem__(self, name): """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``.""" remove_cookie_by_name(self, name) def set_cookie(self, cookie, *args, **kwargs): if hasattr(cookie.value, 'startswith') and cookie.value.startswith('"') and cookie.value.endswith('"'): cookie.value = cookie.value.replace('\\"', '') return super(RequestsCookieJar, self).set_cookie(cookie, *args, **kwargs) def update(self, other): """Updates this jar with cookies from another CookieJar or dict-like""" if isinstance(other, cookielib.CookieJar): for cookie in other: self.set_cookie(copy.copy(cookie)) else: super(RequestsCookieJar, self).update(other) def _find(self, name, domain=None, path=None): """Requests uses this method internally to get cookie values. Takes as args name and optional domain and path. Returns a cookie.value. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies.""" for cookie in iter(self): if cookie.name == name: if domain is None or cookie.domain == domain: if path is None or cookie.path == path: return cookie.value raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) def _find_no_duplicates(self, name, domain=None, path=None): """Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. Takes as args name and optional domain and path. Returns a cookie.value. Throws KeyError if cookie is not found and CookieConflictError if there are multiple cookies that match name and optionally domain and path.""" toReturn = None for cookie in iter(self): if cookie.name == name: if domain is None or cookie.domain == domain: if path is None or cookie.path == path: if toReturn is not None: # if there are multiple cookies that meet passed in criteria raise CookieConflictError('There are multiple cookies with name, %r' % (name)) toReturn = cookie.value # we will eventually return this as long as no cookie conflict if toReturn: return toReturn raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) def __getstate__(self): """Unlike a normal CookieJar, this class is pickleable.""" state = self.__dict__.copy() # remove the unpickleable RLock object state.pop('_cookies_lock') return state def __setstate__(self, state): """Unlike a normal CookieJar, this class is pickleable.""" self.__dict__.update(state) if '_cookies_lock' not in self.__dict__: self._cookies_lock = threading.RLock() def copy(self): """Return a copy of this RequestsCookieJar.""" new_cj = RequestsCookieJar() new_cj.update(self) return new_cj def _copy_cookie_jar(jar): if jar is None: return None if hasattr(jar, 'copy'): # We're dealing with an instane of RequestsCookieJar return jar.copy() # We're dealing with a generic CookieJar instance new_jar = copy.copy(jar) new_jar.clear() for cookie in jar: new_jar.set_cookie(copy.copy(cookie)) return new_jar def create_cookie(name, value, **kwargs): """Make a cookie from underspecified parameters. By default, the pair of `name` and `value` will be set for the domain '' and sent on every request (this is sometimes called a "supercookie"). """ result = dict( version=0, name=name, value=value, port=None, domain='', path='/', secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False,) badargs = set(kwargs) - set(result) if badargs: err = 'create_cookie() got unexpected keyword arguments: %s' raise TypeError(err % list(badargs)) result.update(kwargs) result['port_specified'] = bool(result['port']) result['domain_specified'] = bool(result['domain']) result['domain_initial_dot'] = result['domain'].startswith('.') result['path_specified'] = bool(result['path']) return cookielib.Cookie(**result) def morsel_to_cookie(morsel): """Convert a Morsel object into a Cookie containing the one k/v pair.""" expires = None if morsel['max-age']: expires = time.time() + morsel['max-age'] elif morsel['expires']: time_template = '%a, %d-%b-%Y %H:%M:%S GMT' expires = time.mktime( time.strptime(morsel['expires'], time_template)) - time.timezone return create_cookie( comment=morsel['comment'], comment_url=bool(morsel['comment']), discard=False, domain=morsel['domain'], expires=expires, name=morsel.key, path=morsel['path'], port=None, rest={'HttpOnly': morsel['httponly']}, rfc2109=False, secure=bool(morsel['secure']), value=morsel.value, version=morsel['version'] or 0, ) def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True): """Returns a CookieJar from a key/value dictionary. :param cookie_dict: Dict of key/values to insert into CookieJar. :param cookiejar: (optional) A cookiejar to add the cookies to. :param overwrite: (optional) If False, will not replace cookies already in the jar with new ones. """ if cookiejar is None: cookiejar = RequestsCookieJar() if cookie_dict is not None: names_from_jar = [cookie.name for cookie in cookiejar] for name in cookie_dict: if overwrite or (name not in names_from_jar): cookiejar.set_cookie(create_cookie(name, cookie_dict[name])) return cookiejar def merge_cookies(cookiejar, cookies): """Add cookies to cookiejar and returns a merged CookieJar. :param cookiejar: CookieJar object to add the cookies to. :param cookies: Dictionary or CookieJar object to be added. """ if not isinstance(cookiejar, cookielib.CookieJar): raise ValueError('You can only merge into CookieJar') if isinstance(cookies, dict): cookiejar = cookiejar_from_dict( cookies, cookiejar=cookiejar, overwrite=False) elif isinstance(cookies, cookielib.CookieJar): try: cookiejar.update(cookies) except AttributeError: for cookie_in_jar in cookies: cookiejar.set_cookie(cookie_in_jar) return cookiejar
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2404, 5880, 1233, 370, 506, 7688, 370, 675, 658, 5306, 773, 14, 21315, 64, 543, 4145, 14, 199, 199, 6615, 14, 1208, 8925, 687, 2348, 12, 880, 506, 25082, 543, 8925, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 900, 199, 646, 5055, 199, 504, 1275, 5819, 492, 26234, 12, 7097, 12, 30111, 12, 603, 269, 5891, 199, 199, 893, 26, 272, 492, 5796, 272, 327, 31118, 12, 1134, 29677, 26, 642, 25079, 298, 264, 7463, 402, 9563, 283, 12562, 4065, 272, 5796, 199, 2590, 3545, 26, 272, 492, 7283, 63, 12562, 465, 5796, 421, 199, 533, 4420, 2017, 8, 785, 304, 272, 408, 55, 8146, 282, 658, 6615, 14, 2017, 64, 370, 24102, 530, 282, 658, 4078, 18, 14, 2017, 2313, 339, 710, 1233, 315, 658, 5306, 773, 14, 21315, 64, 14292, 642, 3217, 315, 1865, 370, 6657, 272, 9635, 5494, 14118, 12, 284, 14, 69, 2020, 6705, 3775, 282, 5494, 883, 506, 663, 12, 1627, 314, 272, 14006, 402, 314, 1056, 436, 314, 5494, 14, 339, 710, 3379, 1056, 909, 365, 1586, 13, 2118, 14, 710, 1890, 365, 17845, 367, 32223, 272, 314, 892, 2323, 4799, 658, 362, 63, 1222, 63, 2139, 11995, 436, 6421, 1337, 3062, 22497, 14, 2047, 272, 8646, 2934, 658, 362, 63, 5306, 63, 1291, 3559, 3247, 5084, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 423, 82, 275, 1056, 267, 291, 423, 1222, 63, 2139, 275, 1052, 267, 291, 14, 466, 275, 7097, 8, 277, 423, 82, 14, 633, 680, 5512, 339, 347, 664, 63, 466, 8, 277, 304, 267, 372, 291, 14, 466, 339, 347, 664, 63, 1102, 8, 277, 304, 267, 372, 7097, 8, 277, 423, 82, 14, 633, 680, 12652, 339, 347, 664, 63, 6493, 63, 2103, 63, 1102, 8, 277, 304, 267, 372, 291, 14, 362, 63, 1102, 342, 339, 347, 664, 63, 2861, 63, 633, 8, 277, 304, 267, 327, 5972, 372, 314, 1177, 1159, 2851, 340, 314, 922, 10530, 78, 1133, 663, 314, 10891, 267, 327, 1406, 267, 340, 440, 291, 423, 82, 14, 2139, 14, 362, 360, 4965, 735, 288, 372, 291, 423, 82, 14, 633, 267, 327, 982, 2985, 8103, 663, 652, 12, 8044, 652, 436, 28462, 314, 1420, 2881, 267, 1591, 275, 291, 423, 82, 14, 2139, 459, 4965, 418, 267, 4565, 275, 7097, 8, 277, 423, 82, 14, 633, 9, 267, 327, 799, 8514, 314, 2851, 465, 781, 4282, 652, 267, 372, 30111, 779, 288, 4565, 14, 5512, 12, 1591, 12, 4565, 14, 515, 12, 4565, 14, 1162, 12, 4565, 14, 1131, 12, 288, 4565, 14, 7677, 267, 4794, 339, 347, 365, 63, 324, 422, 1903, 461, 8, 277, 304, 267, 372, 715, 339, 347, 965, 63, 1291, 8, 277, 12, 536, 304, 267, 372, 536, 315, 291, 423, 82, 14, 2139, 503, 536, 315, 291, 423, 1222, 63, 2139, 339, 347, 664, 63, 1291, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 372, 291, 423, 82, 14, 2139, 14, 362, 8, 354, 12, 291, 423, 1222, 63, 2139, 14, 362, 8, 354, 12, 849, 430, 339, 347, 1050, 63, 1291, 8, 277, 12, 790, 12, 1139, 304, 267, 408, 5306, 773, 965, 949, 1026, 6153, 2906, 323, 675, 367, 642, 1083, 27, 1050, 652, 1771, 340, 1265, 2342, 1373, 1041, 267, 746, 4279, 480, 7810, 2323, 1077, 506, 3483, 543, 1050, 63, 324, 264, 12080, 63, 1291, 16060, 339, 347, 1050, 63, 324, 264, 12080, 63, 1291, 8, 277, 12, 536, 12, 574, 304, 267, 291, 423, 1222, 63, 2139, 59, 354, 61, 275, 574, 339, 347, 664, 63, 1222, 63, 2139, 8, 277, 304, 267, 372, 291, 423, 1222, 63, 2139, 339, 768, 1829, 272, 347, 625, 422, 1903, 461, 8, 277, 304, 267, 372, 291, 14, 374, 63, 324, 422, 1903, 461, 342, 339, 768, 1829, 272, 347, 6330, 63, 2103, 63, 1102, 8, 277, 304, 267, 372, 291, 14, 362, 63, 6493, 63, 2103, 63, 1102, 342, 339, 768, 1829, 272, 347, 1591, 8, 277, 304, 267, 372, 291, 14, 362, 63, 1102, 342, 421, 199, 533, 4420, 2364, 8, 785, 304, 272, 408, 55, 8146, 282, 658, 12942, 14, 2856, 2209, 64, 370, 24102, 530, 282, 658, 4078, 14, 525, 815, 633, 2313, 339, 2263, 10058, 31, 10082, 1183, 12, 23705, 314, 4565, 3101, 2323, 687, 314, 1654, 1177, 272, 314, 4340, 658, 5306, 773, 64, 14292, 370, 1937, 3062, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323, 304, 267, 408, 5483, 282, 4420, 2364, 367, 658, 5306, 773, 64, 370, 1586, 14, 398, 520, 635, 2323, 26, 282, 8809, 14, 2856, 2209, 503, 20439, 1785, 25176, 316, 314, 2323, 267, 408, 267, 291, 423, 2139, 275, 2323, 339, 347, 2256, 8, 277, 304, 267, 372, 291, 423, 2139, 339, 347, 2312, 16946, 83, 8, 277, 12, 536, 304, 267, 291, 423, 2139, 14, 19958, 83, 8, 354, 9, 421, 199, 318, 5536, 63, 7792, 63, 475, 63, 7338, 8, 7338, 12, 1056, 12, 1177, 304, 272, 408, 12147, 314, 10049, 687, 314, 1177, 1901, 282, 25143, 14, 339, 520, 635, 16290, 26, 26234, 14, 21315, 334, 1397, 20513, 282, 20260, 21315, 9, 272, 520, 635, 1056, 26, 4154, 5705, 4145, 14, 2017, 909, 272, 520, 635, 1177, 26, 4011, 19, 14, 27068, 909, 272, 408, 272, 340, 440, 334, 11161, 8, 1310, 12, 2513, 5043, 63, 1310, 358, 436, 288, 1177, 423, 5043, 63, 1310, 304, 267, 372, 272, 327, 314, 485, 5043, 63, 1310, 901, 365, 314, 8072, 8809, 14, 27068, 909, 12, 272, 2648, 275, 4420, 2017, 8, 1069, 9, 272, 327, 10299, 734, 314, 3101, 2209, 543, 314, 2323, 436, 5324, 652, 315, 314, 1683, 26, 272, 522, 275, 4420, 2364, 8, 1310, 423, 5043, 63, 1310, 14, 1328, 9, 272, 16290, 14, 5005, 63, 7792, 8, 470, 12, 2648, 9, 421, 199, 318, 664, 63, 5306, 63, 1291, 8, 7338, 12, 1056, 304, 272, 408, 24391, 376, 5827, 14798, 1406, 1059, 370, 506, 4847, 543, 658, 1069, 3559, 503, 488, 1041, 272, 519, 275, 4420, 2017, 8, 1069, 9, 272, 16290, 14, 525 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2404, 5880, 1233, 370, 506, 7688, 370, 675, 658, 5306, 773, 14, 21315, 64, 543, 4145, 14, 199, 199, 6615, 14, 1208, 8925, 687, 2348, 12, 880, 506, 25082, 543, 8925, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 900, 199, 646, 5055, 199, 504, 1275, 5819, 492, 26234, 12, 7097, 12, 30111, 12, 603, 269, 5891, 199, 199, 893, 26, 272, 492, 5796, 272, 327, 31118, 12, 1134, 29677, 26, 642, 25079, 298, 264, 7463, 402, 9563, 283, 12562, 4065, 272, 5796, 199, 2590, 3545, 26, 272, 492, 7283, 63, 12562, 465, 5796, 421, 199, 533, 4420, 2017, 8, 785, 304, 272, 408, 55, 8146, 282, 658, 6615, 14, 2017, 64, 370, 24102, 530, 282, 658, 4078, 18, 14, 2017, 2313, 339, 710, 1233, 315, 658, 5306, 773, 14, 21315, 64, 14292, 642, 3217, 315, 1865, 370, 6657, 272, 9635, 5494, 14118, 12, 284, 14, 69, 2020, 6705, 3775, 282, 5494, 883, 506, 663, 12, 1627, 314, 272, 14006, 402, 314, 1056, 436, 314, 5494, 14, 339, 710, 3379, 1056, 909, 365, 1586, 13, 2118, 14, 710, 1890, 365, 17845, 367, 32223, 272, 314, 892, 2323, 4799, 658, 362, 63, 1222, 63, 2139, 11995, 436, 6421, 1337, 3062, 22497, 14, 2047, 272, 8646, 2934, 658, 362, 63, 5306, 63, 1291, 3559, 3247, 5084, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 423, 82, 275, 1056, 267, 291, 423, 1222, 63, 2139, 275, 1052, 267, 291, 14, 466, 275, 7097, 8, 277, 423, 82, 14, 633, 680, 5512, 339, 347, 664, 63, 466, 8, 277, 304, 267, 372, 291, 14, 466, 339, 347, 664, 63, 1102, 8, 277, 304, 267, 372, 7097, 8, 277, 423, 82, 14, 633, 680, 12652, 339, 347, 664, 63, 6493, 63, 2103, 63, 1102, 8, 277, 304, 267, 372, 291, 14, 362, 63, 1102, 342, 339, 347, 664, 63, 2861, 63, 633, 8, 277, 304, 267, 327, 5972, 372, 314, 1177, 1159, 2851, 340, 314, 922, 10530, 78, 1133, 663, 314, 10891, 267, 327, 1406, 267, 340, 440, 291, 423, 82, 14, 2139, 14, 362, 360, 4965, 735, 288, 372, 291, 423, 82, 14, 633, 267, 327, 982, 2985, 8103, 663, 652, 12, 8044, 652, 436, 28462, 314, 1420, 2881, 267, 1591, 275, 291, 423, 82, 14, 2139, 459, 4965, 418, 267, 4565, 275, 7097, 8, 277, 423, 82, 14, 633, 9, 267, 327, 799, 8514, 314, 2851, 465, 781, 4282, 652, 267, 372, 30111, 779, 288, 4565, 14, 5512, 12, 1591, 12, 4565, 14, 515, 12, 4565, 14, 1162, 12, 4565, 14, 1131, 12, 288, 4565, 14, 7677, 267, 4794, 339, 347, 365, 63, 324, 422, 1903, 461, 8, 277, 304, 267, 372, 715, 339, 347, 965, 63, 1291, 8, 277, 12, 536, 304, 267, 372, 536, 315, 291, 423, 82, 14, 2139, 503, 536, 315, 291, 423, 1222, 63, 2139, 339, 347, 664, 63, 1291, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 372, 291, 423, 82, 14, 2139, 14, 362, 8, 354, 12, 291, 423, 1222, 63, 2139, 14, 362, 8, 354, 12, 849, 430, 339, 347, 1050, 63, 1291, 8, 277, 12, 790, 12, 1139, 304, 267, 408, 5306, 773, 965, 949, 1026, 6153, 2906, 323, 675, 367, 642, 1083, 27, 1050, 652, 1771, 340, 1265, 2342, 1373, 1041, 267, 746, 4279, 480, 7810, 2323, 1077, 506, 3483, 543, 1050, 63, 324, 264, 12080, 63, 1291, 16060, 339, 347, 1050, 63, 324, 264, 12080, 63, 1291, 8, 277, 12, 536, 12, 574, 304, 267, 291, 423, 1222, 63, 2139, 59, 354, 61, 275, 574, 339, 347, 664, 63, 1222, 63, 2139, 8, 277, 304, 267, 372, 291, 423, 1222, 63, 2139, 339, 768, 1829, 272, 347, 625, 422, 1903, 461, 8, 277, 304, 267, 372, 291, 14, 374, 63, 324, 422, 1903, 461, 342, 339, 768, 1829, 272, 347, 6330, 63, 2103, 63, 1102, 8, 277, 304, 267, 372, 291, 14, 362, 63, 6493, 63, 2103, 63, 1102, 342, 339, 768, 1829, 272, 347, 1591, 8, 277, 304, 267, 372, 291, 14, 362, 63, 1102, 342, 421, 199, 533, 4420, 2364, 8, 785, 304, 272, 408, 55, 8146, 282, 658, 12942, 14, 2856, 2209, 64, 370, 24102, 530, 282, 658, 4078, 14, 525, 815, 633, 2313, 339, 2263, 10058, 31, 10082, 1183, 12, 23705, 314, 4565, 3101, 2323, 687, 314, 1654, 1177, 272, 314, 4340, 658, 5306, 773, 64, 14292, 370, 1937, 3062, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323, 304, 267, 408, 5483, 282, 4420, 2364, 367, 658, 5306, 773, 64, 370, 1586, 14, 398, 520, 635, 2323, 26, 282, 8809, 14, 2856, 2209, 503, 20439, 1785, 25176, 316, 314, 2323, 267, 408, 267, 291, 423, 2139, 275, 2323, 339, 347, 2256, 8, 277, 304, 267, 372, 291, 423, 2139, 339, 347, 2312, 16946, 83, 8, 277, 12, 536, 304, 267, 291, 423, 2139, 14, 19958, 83, 8, 354, 9, 421, 199, 318, 5536, 63, 7792, 63, 475, 63, 7338, 8, 7338, 12, 1056, 12, 1177, 304, 272, 408, 12147, 314, 10049, 687, 314, 1177, 1901, 282, 25143, 14, 339, 520, 635, 16290, 26, 26234, 14, 21315, 334, 1397, 20513, 282, 20260, 21315, 9, 272, 520, 635, 1056, 26, 4154, 5705, 4145, 14, 2017, 909, 272, 520, 635, 1177, 26, 4011, 19, 14, 27068, 909, 272, 408, 272, 340, 440, 334, 11161, 8, 1310, 12, 2513, 5043, 63, 1310, 358, 436, 288, 1177, 423, 5043, 63, 1310, 304, 267, 372, 272, 327, 314, 485, 5043, 63, 1310, 901, 365, 314, 8072, 8809, 14, 27068, 909, 12, 272, 2648, 275, 4420, 2017, 8, 1069, 9, 272, 327, 10299, 734, 314, 3101, 2209, 543, 314, 2323, 436, 5324, 652, 315, 314, 1683, 26, 272, 522, 275, 4420, 2364, 8, 1310, 423, 5043, 63, 1310, 14, 1328, 9, 272, 16290, 14, 5005, 63, 7792, 8, 470, 12, 2648, 9, 421, 199, 318, 664, 63, 5306, 63, 1291, 8, 7338, 12, 1056, 304, 272, 408, 24391, 376, 5827, 14798, 1406, 1059, 370, 506, 4847, 543, 658, 1069, 3559, 503, 488, 1041, 272, 519, 275, 4420, 2017, 8, 1069, 9, 272, 16290, 14, 525, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
enricobacis/cineca-scopus
src/cineca3.py
1
3928
#!/usr/bin/env python #coding: utf-8 from contextlib import closing from operator import itemgetter from datetime import datetime from argparse import ArgumentParser from unicodecsv import DictWriter from utils import read_cineca_file, csv_to_db import sqlite3 import json import re FIELDS = ['Ateneo', 'Facoltà', 'Fascia', 'Genere', 'S.C.', 'Servizio prestato in altro ateneo', 'Struttura di afferenza', 'author', 'identifier', 'eid', 'title', 'aggregationType', 'citedby-count', 'publicationName', 'isbn', 'issn', 'volume', 'issueIdentifier', 'pageRange', 'pageNum', 'coverDate', 'coverDisplayDate', 'doi', 'numAuthors'] QUERY = 'SELECT entries FROM articles WHERE author = ? AND ateneo = ?' def pagenum(pageRange): try: page = list(map(int, pageRange.split('-'))) return 1 if len(page) == 1 else page[1] - page[0] except: return None def process(entry): for key, value in list(entry.items()): if ':' in key: del entry[key] key = key.partition(':')[2] entry[key] = value match = re.match('Author list of (\d+)', entry.get('message', '')) if match: entry['numAuthors'] = int(match.group(1)) else: entry['numAuthors'] = len(entry.get('author', [])) or None # eid and identifier default to 0 entry['eid'] = entry.get('eid', 0) entry['identifier'] = entry.get('identifier', 0) # validate coverDate (or default to 1900-01-01) date = entry.get('coverDate', '') try: datesplit = list(map(int, date.split('-'))) if len(datesplit) == 3 and datesplit[1] == 0: date = '%d-%d-%s' % (datesplit[0], datesplit[1]+1, datesplit[2]) datetime.strptime(date, '%Y-%m-%d') except: entry['coverDate'] = '1900-01-01' entry['author'] = entry['Cognome e Nome'] entry['pageNum'] = pagenum(entry.get('pageRange', None)) return entry def mergedicts(*dicts): return {k:v for d in dicts for k,v in d.items()} if __name__ == '__main__': from config import FILENAME, DBFILE, OUTFILE, PRODUCTSDB parser = ArgumentParser('convert scopus db to csv') parser.add_argument('--input', default=FILENAME, help='cineca input file') parser.add_argument('--db', default=DBFILE, help='database file') parser.add_argument('--output', default=OUTFILE, help='output csv file') parser.add_argument('--outdb', default=PRODUCTSDB, help='output db file') args = parser.parse_args() with open(args.output, 'wb') as outfile: csvreader = [row.to_dict() for row in read_cineca_file(args.input)] authors = [(row['Cognome e Nome'], row['Ateneo'], row) for row in csvreader] authors.sort(key=itemgetter(0, 1)) csvwriter = DictWriter(outfile, FIELDS, extrasaction='ignore', encoding='utf-8') csvwriter.writeheader() with sqlite3.connect(args.db) as connection: with closing(connection.cursor()) as cursor: for author, ateneo, authordata in authors: entries = cursor.execute(QUERY, (author,ateneo)).fetchall() if not entries: print('Empty entry added for %s' % author) csvwriter.writerow(process(authordata)) else: inserted = set() for entry in json.loads(entries[0][0]): ID = entry.get('dc:identifier', '') print('%s\t%s' % (author, ID)) if ID in inserted: print(' * duplicate ignored *') else: inserted.add(ID) csvwriter.writerow(process(mergedicts(authordata, entry))) print('\n[*] Converting csv to sqlite3db ...') csv_to_db(args.output, args.outdb, 'products')
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1523, 26, 2774, 13, 24, 199, 199, 504, 15502, 492, 11261, 199, 504, 4182, 492, 1242, 7416, 199, 504, 2197, 492, 2197, 199, 504, 7534, 492, 27615, 199, 504, 2649, 4737, 492, 7448, 6261, 199, 504, 3778, 492, 1586, 63, 67, 1132, 696, 63, 493, 12, 7392, 63, 475, 63, 697, 199, 646, 11723, 19, 199, 646, 2022, 199, 646, 295, 199, 199, 12767, 275, 788, 33, 266, 685, 79, 297, 283, 1906, 761, 84, 26482, 297, 283, 38, 305, 16521, 297, 283, 39, 6349, 264, 297, 283, 51, 14, 35, 3130, 881, 283, 1505, 17249, 2308, 876, 3736, 79, 315, 741, 1374, 282, 266, 685, 79, 297, 283, 2848, 337, 84, 12417, 487, 282, 2026, 828, 8076, 297, 881, 283, 2502, 297, 283, 5364, 297, 283, 30065, 297, 283, 1213, 297, 283, 21016, 804, 297, 881, 283, 29989, 991, 13, 835, 297, 283, 22678, 985, 297, 283, 374, 10472, 297, 283, 374, 5167, 297, 283, 2405, 297, 881, 283, 5237, 7544, 297, 283, 1606, 4709, 297, 283, 1606, 5667, 297, 283, 5899, 2506, 297, 881, 283, 5899, 7687, 2506, 297, 283, 27334, 297, 283, 1507, 2817, 1384, 418, 199, 199, 11938, 275, 283, 4859, 4811, 4442, 23242, 6038, 4132, 275, 5805, 2401, 282, 266, 685, 79, 275, 5805, 7, 199, 199, 318, 9881, 4869, 8, 1606, 4709, 304, 272, 862, 26, 267, 2034, 275, 769, 8, 1130, 8, 442, 12, 2034, 4709, 14, 1294, 3654, 7058, 267, 372, 413, 340, 822, 8, 1606, 9, 508, 413, 587, 2034, 59, 17, 61, 446, 2034, 59, 16, 61, 272, 871, 26, 267, 372, 488, 199, 199, 318, 2112, 8, 2373, 304, 272, 367, 790, 12, 574, 315, 769, 8, 2373, 14, 1744, 5109, 267, 340, 10871, 315, 790, 26, 288, 2150, 2397, 59, 498, 61, 288, 790, 275, 790, 14, 5312, 24050, 18, 61, 288, 2397, 59, 498, 61, 275, 574, 339, 1336, 275, 295, 14, 1431, 360, 5949, 769, 402, 14749, 68, 14705, 2397, 14, 362, 360, 1188, 297, 12381, 272, 340, 1336, 26, 2397, 459, 1507, 2817, 1384, 418, 275, 1109, 8, 1431, 14, 923, 8, 17, 430, 272, 587, 26, 2397, 459, 1507, 2817, 1384, 418, 275, 822, 8, 2373, 14, 362, 360, 2502, 297, 15927, 503, 488, 339, 327, 325, 344, 436, 5148, 849, 370, 378, 272, 2397, 459, 30065, 418, 275, 2397, 14, 362, 360, 30065, 297, 378, 9, 272, 2397, 459, 5364, 418, 275, 2397, 14, 362, 360, 5364, 297, 378, 9, 339, 327, 4107, 8486, 2506, 334, 269, 849, 370, 5851, 383, 13, 614, 13, 614, 9, 272, 1434, 275, 2397, 14, 362, 360, 5899, 2506, 297, 4074, 272, 862, 26, 267, 1434, 1294, 275, 769, 8, 1130, 8, 442, 12, 1434, 14, 1294, 3654, 7058, 267, 340, 822, 8, 602, 1294, 9, 508, 650, 436, 1434, 1294, 59, 17, 61, 508, 378, 26, 288, 1434, 275, 1543, 68, 3295, 68, 3295, 83, 7, 450, 334, 602, 1294, 59, 16, 467, 1434, 1294, 59, 17, 2807, 17, 12, 1434, 1294, 59, 18, 566, 267, 2197, 14, 9866, 8, 602, 12, 1543, 57, 3295, 77, 3295, 68, 358, 272, 871, 26, 2397, 459, 5899, 2506, 418, 275, 283, 26631, 13, 614, 13, 614, 7, 339, 2397, 459, 2502, 418, 275, 2397, 459, 967, 784, 1377, 325, 653, 1377, 418, 272, 2397, 459, 1606, 5667, 418, 275, 9881, 4869, 8, 2373, 14, 362, 360, 1606, 4709, 297, 488, 430, 272, 372, 2397, 421, 199, 318, 5389, 7892, 2031, 7892, 304, 272, 372, 469, 75, 26, 86, 367, 366, 315, 10809, 367, 1022, 12, 86, 315, 366, 14, 1744, 12737, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 687, 1101, 492, 16444, 11536, 12, 6249, 3817, 12, 5738, 3817, 12, 3611, 13461, 51, 2846, 339, 1798, 275, 27615, 360, 3916, 27748, 8843, 1592, 370, 7392, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1210, 297, 849, 29, 15440, 12, 1720, 534, 67, 1132, 696, 1324, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 697, 297, 849, 29, 2846, 3817, 12, 1720, 534, 4659, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1199, 297, 849, 29, 1877, 3817, 12, 1720, 534, 1199, 7392, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 548, 697, 297, 849, 29, 14853, 51, 2846, 12, 1720, 534, 1199, 1592, 570, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 543, 1551, 8, 589, 14, 1199, 12, 283, 6603, 358, 465, 4386, 26, 267, 7392, 5503, 275, 359, 1143, 14, 475, 63, 807, 342, 367, 1962, 315, 1586, 63, 67, 1132, 696, 63, 493, 8, 589, 14, 1210, 1874, 267, 11462, 275, 3842, 1143, 459, 967, 784, 1377, 325, 653, 1377, 995, 1962, 459, 33, 266, 685, 79, 995, 1962, 9, 367, 1962, 315, 7392, 5503, 61, 267, 11462, 14, 3191, 8, 498, 29, 20832, 8, 16, 12, 413, 430, 398, 7392, 5491, 275, 7448, 6261, 8, 4984, 12, 15435, 2901, 3177, 12, 13751, 1287, 534, 4247, 297, 2644, 534, 1624, 13, 24, 358, 267, 7392, 5491, 14, 952, 1291, 342, 398, 543, 11723, 19, 14, 2242, 8, 589, 14, 697, 9, 465, 1950, 26, 288, 543, 11261, 8, 2105, 14, 3937, 1012, 465, 3920, 26, 355, 367, 4132, 12, 282, 266, 685, 79, 12, 4132, 576, 315, 11462, 26, 490, 4811, 275, 3920, 14, 2526, 8, 11938, 12, 334, 2502, 12, 323, 685, 79, 4992, 10174, 342, 490, 340, 440, 4811, 26, 717, 870, 360, 4699, 2397, 3483, 367, 450, 83, 7, 450, 4132, 9, 717, 7392, 5491, 14, 22686, 8, 1412, 8, 2502, 576, 430, 490, 587, 26, 717, 11788, 275, 663, 342, 717, 367, 2397, 315, 2022, 14, 3640, 8, 3189, 59, 16, 1527, 16, 4682, 1169, 2870, 275, 2397, 14, 362, 360, 3833, 26, 5364, 297, 4074, 1169, 870, 3508, 83, 60, 84, 5, 83, 7, 450, 334, 2502, 12, 2870, 430, 1169, 340, 2870, 315, 11788, 26, 1816, 870, 360, 627, 9250, 5525, 627, 358, 1169, 587, 26, 1816, 11788, 14, 525, 8, 998, 9, 1816, 7392, 5491, 14, 22686, 8, 1412, 8, 5628, 7892, 8, 2502, 576, 12, 2397, 1724, 339, 870, 2258, 78, 59 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1523, 26, 2774, 13, 24, 199, 199, 504, 15502, 492, 11261, 199, 504, 4182, 492, 1242, 7416, 199, 504, 2197, 492, 2197, 199, 504, 7534, 492, 27615, 199, 504, 2649, 4737, 492, 7448, 6261, 199, 504, 3778, 492, 1586, 63, 67, 1132, 696, 63, 493, 12, 7392, 63, 475, 63, 697, 199, 646, 11723, 19, 199, 646, 2022, 199, 646, 295, 199, 199, 12767, 275, 788, 33, 266, 685, 79, 297, 283, 1906, 761, 84, 26482, 297, 283, 38, 305, 16521, 297, 283, 39, 6349, 264, 297, 283, 51, 14, 35, 3130, 881, 283, 1505, 17249, 2308, 876, 3736, 79, 315, 741, 1374, 282, 266, 685, 79, 297, 283, 2848, 337, 84, 12417, 487, 282, 2026, 828, 8076, 297, 881, 283, 2502, 297, 283, 5364, 297, 283, 30065, 297, 283, 1213, 297, 283, 21016, 804, 297, 881, 283, 29989, 991, 13, 835, 297, 283, 22678, 985, 297, 283, 374, 10472, 297, 283, 374, 5167, 297, 283, 2405, 297, 881, 283, 5237, 7544, 297, 283, 1606, 4709, 297, 283, 1606, 5667, 297, 283, 5899, 2506, 297, 881, 283, 5899, 7687, 2506, 297, 283, 27334, 297, 283, 1507, 2817, 1384, 418, 199, 199, 11938, 275, 283, 4859, 4811, 4442, 23242, 6038, 4132, 275, 5805, 2401, 282, 266, 685, 79, 275, 5805, 7, 199, 199, 318, 9881, 4869, 8, 1606, 4709, 304, 272, 862, 26, 267, 2034, 275, 769, 8, 1130, 8, 442, 12, 2034, 4709, 14, 1294, 3654, 7058, 267, 372, 413, 340, 822, 8, 1606, 9, 508, 413, 587, 2034, 59, 17, 61, 446, 2034, 59, 16, 61, 272, 871, 26, 267, 372, 488, 199, 199, 318, 2112, 8, 2373, 304, 272, 367, 790, 12, 574, 315, 769, 8, 2373, 14, 1744, 5109, 267, 340, 10871, 315, 790, 26, 288, 2150, 2397, 59, 498, 61, 288, 790, 275, 790, 14, 5312, 24050, 18, 61, 288, 2397, 59, 498, 61, 275, 574, 339, 1336, 275, 295, 14, 1431, 360, 5949, 769, 402, 14749, 68, 14705, 2397, 14, 362, 360, 1188, 297, 12381, 272, 340, 1336, 26, 2397, 459, 1507, 2817, 1384, 418, 275, 1109, 8, 1431, 14, 923, 8, 17, 430, 272, 587, 26, 2397, 459, 1507, 2817, 1384, 418, 275, 822, 8, 2373, 14, 362, 360, 2502, 297, 15927, 503, 488, 339, 327, 325, 344, 436, 5148, 849, 370, 378, 272, 2397, 459, 30065, 418, 275, 2397, 14, 362, 360, 30065, 297, 378, 9, 272, 2397, 459, 5364, 418, 275, 2397, 14, 362, 360, 5364, 297, 378, 9, 339, 327, 4107, 8486, 2506, 334, 269, 849, 370, 5851, 383, 13, 614, 13, 614, 9, 272, 1434, 275, 2397, 14, 362, 360, 5899, 2506, 297, 4074, 272, 862, 26, 267, 1434, 1294, 275, 769, 8, 1130, 8, 442, 12, 1434, 14, 1294, 3654, 7058, 267, 340, 822, 8, 602, 1294, 9, 508, 650, 436, 1434, 1294, 59, 17, 61, 508, 378, 26, 288, 1434, 275, 1543, 68, 3295, 68, 3295, 83, 7, 450, 334, 602, 1294, 59, 16, 467, 1434, 1294, 59, 17, 2807, 17, 12, 1434, 1294, 59, 18, 566, 267, 2197, 14, 9866, 8, 602, 12, 1543, 57, 3295, 77, 3295, 68, 358, 272, 871, 26, 2397, 459, 5899, 2506, 418, 275, 283, 26631, 13, 614, 13, 614, 7, 339, 2397, 459, 2502, 418, 275, 2397, 459, 967, 784, 1377, 325, 653, 1377, 418, 272, 2397, 459, 1606, 5667, 418, 275, 9881, 4869, 8, 2373, 14, 362, 360, 1606, 4709, 297, 488, 430, 272, 372, 2397, 421, 199, 318, 5389, 7892, 2031, 7892, 304, 272, 372, 469, 75, 26, 86, 367, 366, 315, 10809, 367, 1022, 12, 86, 315, 366, 14, 1744, 12737, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 687, 1101, 492, 16444, 11536, 12, 6249, 3817, 12, 5738, 3817, 12, 3611, 13461, 51, 2846, 339, 1798, 275, 27615, 360, 3916, 27748, 8843, 1592, 370, 7392, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1210, 297, 849, 29, 15440, 12, 1720, 534, 67, 1132, 696, 1324, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 697, 297, 849, 29, 2846, 3817, 12, 1720, 534, 4659, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1199, 297, 849, 29, 1877, 3817, 12, 1720, 534, 1199, 7392, 570, 358, 272, 1798, 14, 525, 63, 2094, 4517, 548, 697, 297, 849, 29, 14853, 51, 2846, 12, 1720, 534, 1199, 1592, 570, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 543, 1551, 8, 589, 14, 1199, 12, 283, 6603, 358, 465, 4386, 26, 267, 7392, 5503, 275, 359, 1143, 14, 475, 63, 807, 342, 367, 1962, 315, 1586, 63, 67, 1132, 696, 63, 493, 8, 589, 14, 1210, 1874, 267, 11462, 275, 3842, 1143, 459, 967, 784, 1377, 325, 653, 1377, 995, 1962, 459, 33, 266, 685, 79, 995, 1962, 9, 367, 1962, 315, 7392, 5503, 61, 267, 11462, 14, 3191, 8, 498, 29, 20832, 8, 16, 12, 413, 430, 398, 7392, 5491, 275, 7448, 6261, 8, 4984, 12, 15435, 2901, 3177, 12, 13751, 1287, 534, 4247, 297, 2644, 534, 1624, 13, 24, 358, 267, 7392, 5491, 14, 952, 1291, 342, 398, 543, 11723, 19, 14, 2242, 8, 589, 14, 697, 9, 465, 1950, 26, 288, 543, 11261, 8, 2105, 14, 3937, 1012, 465, 3920, 26, 355, 367, 4132, 12, 282, 266, 685, 79, 12, 4132, 576, 315, 11462, 26, 490, 4811, 275, 3920, 14, 2526, 8, 11938, 12, 334, 2502, 12, 323, 685, 79, 4992, 10174, 342, 490, 340, 440, 4811, 26, 717, 870, 360, 4699, 2397, 3483, 367, 450, 83, 7, 450, 4132, 9, 717, 7392, 5491, 14, 22686, 8, 1412, 8, 2502, 576, 430, 490, 587, 26, 717, 11788, 275, 663, 342, 717, 367, 2397, 315, 2022, 14, 3640, 8, 3189, 59, 16, 1527, 16, 4682, 1169, 2870, 275, 2397, 14, 362, 360, 3833, 26, 5364, 297, 4074, 1169, 870, 3508, 83, 60, 84, 5, 83, 7, 450, 334, 2502, 12, 2870, 430, 1169, 340, 2870, 315, 11788, 26, 1816, 870, 360, 627, 9250, 5525, 627, 358, 1169, 587, 26, 1816, 11788, 14, 525, 8, 998, 9, 1816, 7392, 5491, 14, 22686, 8, 1412, 8, 5628, 7892, 8, 2502, 576, 12, 2397, 1724, 339, 870, 2258, 78, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ar7z1/ansible
lib/ansible/modules/storage/netapp/na_elementsw_ldap.py
9
8686
#!/usr/bin/python # (c) 2017, NetApp, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified'} DOCUMENTATION = ''' module: na_elementsw_ldap short_description: NetApp Element Software Manage ldap admin users extends_documentation_fragment: - netapp.solidfire version_added: '2.7' author: NetApp Ansible Team (ng-ansibleteam@netapp.com) description: - Enable, disable ldap, and add ldap users options: state: description: - Whether the specified volume should exist or not. required: true choices: ['present', 'absent'] authType: description: - Identifies which user authentication method to use. choices: ['DirectBind', 'SearchAndBind'] groupSearchBaseDn: description: - The base DN of the tree to start the group search (will do a subtree search from here) groupSearchType: description: - Controls the default group search filter used choices: ['NoGroup', 'ActiveDirectory', 'MemberDN'] serverURIs: description: - A comma-separated list of LDAP server URIs userSearchBaseDN: description: - The base DN of the tree to start the search (will do a subtree search from here) searchBindDN: description: - A dully qualified DN to log in with to perform an LDAp search for the user (needs read access to the LDAP directory). searchBindPassword: description: - The password for the searchBindDN account used for searching userSearchFilter: description: - the LDAP Filter to use userDNTemplate: description: - A string that is used form a fully qualified user DN. groupSearchCustomFilter: description: - For use with the CustomFilter Search type ''' EXAMPLES = """ - name: disable ldap authentication na_elementsw_ldap: state: absent username: "{{ admin username }}" password: "{{ admin password }}" hostname: "{{ hostname }}" - name: Enable ldap authentication na_elementsw_ldap: state: present username: "{{ admin username }}" password: "{{ admin password }}" hostname: "{{ hostname }}" authType: DirectBind serverURIs: ldap://svmdurlabesx01spd_ldapclnt groupSearchType: MemberDN userDNTemplate: uid=%USERNAME%,cn=users,cn=accounts,dc=corp,dc="{{ company name }}",dc=com """ RETURN = """ """ import traceback from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native import ansible.module_utils.netapp as netapp_utils HAS_SF_SDK = netapp_utils.has_sf_sdk() try: import solidfire.common except: HAS_SF_SDK = False class NetappElementLdap(object): def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update(dict( state=dict(required=True, choices=['present', 'absent']), authType=dict(required=False, choices=['DirectBind', 'SearchAndBind']), groupSearchBaseDn=dict(required=False, type=str), groupSearchType=dict(required=False, choices=['NoGroup', 'ActiveDirectory', 'MemberDN']), serverURIs=dict(required=False, type=str), userSearchBaseDN=dict(required=False, type=str), searchBindDN=dict(required=False, type=str), searchBindPassword=dict(required=False, type=str, no_log=True), userSearchFilter=dict(required=False, type=str), userDNTemplate=dict(required=False, type=str), groupSearchCustomFilter=dict(required=False, type=str) )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) param = self.module.params # set up state variables self.state = param['state'] self.authType = param['authType'] self.groupSearchBaseDn = param['groupSearchBaseDn'] self.groupSearchType = param['groupSearchType'] self.serverURIs = param['serverURIs'] if self.serverURIs is not None: self.serverURIs = self.serverURIs.split(',') self.userSearchBaseDN = param['userSearchBaseDN'] self.searchBindDN = param['searchBindDN'] self.searchBindPassword = param['searchBindPassword'] self.userSearchFilter = param['userSearchFilter'] self.userDNTemplate = param['userDNTemplate'] self.groupSearchCustomFilter = param['groupSearchCustomFilter'] if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module) def get_ldap_configuration(self): """ Return ldap configuration if found :return: Details about the ldap configuration. None if not found. :rtype: solidfire.models.GetLdapConfigurationResult """ ldap_config = self.sfe.get_ldap_configuration() return ldap_config def enable_ldap(self): """ Enable LDAP :return: nothing """ try: self.sfe.enable_ldap_authentication(self.serverURIs, auth_type=self.authType, group_search_base_dn=self.groupSearchBaseDn, group_search_type=self.groupSearchType, group_search_custom_filter=self.groupSearchCustomFilter, search_bind_dn=self.searchBindDN, search_bind_password=self.searchBindPassword, user_search_base_dn=self.userSearchBaseDN, user_search_filter=self.userSearchFilter, user_dntemplate=self.userDNTemplate) except solidfire.common.ApiServerError as error: self.module.fail_json(msg='Error enabling LDAP %s: %s' % (self.account_id, to_native(error)), exception=traceback.format_exc()) def check_config(self, ldap_config): """ Check to see if the ldap config has been modified. :param ldap_config: The LDAP configuration :return: False if the config is the same as the playbook, True if it is not """ if self.authType != ldap_config.ldap_configuration.auth_type: return True if self.serverURIs != ldap_config.ldap_configuration.server_uris: return True if self.groupSearchBaseDn != ldap_config.ldap_configuration.group_search_base_dn: return True if self.groupSearchType != ldap_config.ldap_configuration.group_search_type: return True if self.groupSearchCustomFilter != ldap_config.ldap_configuration.group_search_custom_filter: return True if self.searchBindDN != ldap_config.ldap_configuration.search_bind_dn: return True if self.searchBindPassword != ldap_config.ldap_configuration.search_bind_password: return True if self.userSearchBaseDN != ldap_config.ldap_configuration.user_search_base_dn: return True if self.userSearchFilter != ldap_config.ldap_configuration.user_search_filter: return True if self.userDNTemplate != ldap_config.ldap_configuration.user_dntemplate: return True return False def apply(self): changed = False ldap_config = self.get_ldap_configuration() if self.state == 'absent': if ldap_config and ldap_config.ldap_configuration.enabled: changed = True if self.state == 'present' and self.check_config(ldap_config): changed = True if changed: if self.module.check_mode: pass else: if self.state == 'present': self.enable_ldap() elif self.state == 'absent': self.sfe.disable_ldap_authentication() self.module.exit_json(changed=changed) def main(): v = NetappElementLdap() v.apply() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 9708, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 11802, 63, 2108, 3519, 63, 9642, 199, 199, 3612, 63, 1802, 26, 28076, 6566, 2290, 14944, 13727, 4628, 4390, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 18533, 8935, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 28076, 2622, 11682, 334, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 9, 199, 1802, 26, 199, 13, 12030, 12, 3507, 13727, 12, 436, 1050, 13727, 4390, 199, 199, 1419, 26, 339, 1174, 26, 267, 1369, 26, 267, 446, 7480, 314, 2013, 3301, 1077, 2187, 503, 440, 14, 267, 1415, 26, 2549, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 339, 1790, 804, 26, 267, 1369, 26, 267, 446, 473, 2433, 397, 1314, 922, 6299, 1083, 370, 675, 14, 267, 3415, 26, 788, 16281, 8198, 297, 283, 5278, 3325, 8198, 418, 339, 1572, 5278, 1563, 36, 78, 26, 267, 1369, 26, 267, 446, 710, 1300, 24842, 402, 314, 3123, 370, 1343, 314, 1572, 2754, 334, 14117, 886, 282, 26897, 2754, 687, 2348, 9, 339, 1572, 5278, 804, 26, 267, 1369, 26, 267, 446, 29001, 314, 849, 1572, 2754, 2457, 1202, 267, 3415, 26, 788, 1944, 2448, 297, 283, 7472, 6231, 297, 283, 7021, 10872, 418, 339, 1654, 1230, 1831, 26, 267, 1369, 26, 267, 446, 437, 10029, 13, 12794, 769, 402, 20717, 1654, 30143, 339, 922, 5278, 1563, 10872, 26, 267, 1369, 26, 267, 446, 710, 1300, 24842, 402, 314, 3123, 370, 1343, 314, 2754, 334, 14117, 886, 282, 26897, 2754, 687, 2348, 9, 339, 2754, 8198, 10872, 26, 267, 1369, 26, 267, 446, 437, 366, 8525, 12313, 24842, 370, 943, 315, 543, 370, 5147, 376, 491, 8980, 80, 2754, 367, 314, 922, 334, 10065, 1586, 2879, 370, 314, 20717, 2082, 680, 339, 2754, 8198, 6139, 26, 267, 1369, 26, 267, 446, 710, 2505, 367, 314, 2754, 8198, 10872, 2933, 1202, 367, 18112, 339, 922, 5278, 4131, 26, 267, 1369, 26, 267, 446, 314, 20717, 9388, 370, 675, 339, 922, 10872, 4231, 26, 267, 1369, 26, 267, 446, 437, 1059, 626, 365, 1202, 1824, 282, 9999, 12313, 922, 24842, 14, 339, 1572, 5278, 7223, 4131, 26, 267, 1369, 26, 267, 446, 2104, 675, 543, 314, 8388, 4131, 8730, 730, 199, 2344, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 3507, 13727, 6299, 489, 11802, 63, 2108, 3519, 63, 9642, 26, 267, 1174, 26, 9552, 267, 3434, 26, 7370, 4628, 3434, 7820, 267, 2505, 26, 7370, 4628, 2505, 7820, 267, 6246, 26, 7370, 6246, 7820, 339, 446, 536, 26, 12030, 13727, 6299, 489, 11802, 63, 2108, 3519, 63, 9642, 26, 267, 1174, 26, 3451, 267, 3434, 26, 7370, 4628, 3434, 7820, 267, 2505, 26, 7370, 4628, 2505, 7820, 267, 6246, 26, 7370, 6246, 7820, 267, 1790, 804, 26, 21128, 8198, 267, 1654, 1230, 1831, 26, 13727, 921, 2772, 1064, 633, 371, 397, 88, 614, 681, 68, 63, 9642, 429, 343, 267, 1572, 5278, 804, 26, 14409, 10872, 267, 922, 10872, 4231, 26, 221, 1747, 2458, 11958, 5, 12, 6413, 29, 3707, 12, 6413, 29, 8370, 12, 3833, 29, 989, 80, 12, 3833, 628, 3638, 7233, 536, 3586, 401, 3833, 29, 957, 421, 199, 624, 199, 199, 9677, 275, 408, 199, 199, 624, 199, 646, 5190, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 13107, 63, 14939, 275, 15742, 63, 1208, 14, 1989, 63, 7646, 63, 9277, 342, 199, 893, 26, 272, 492, 18609, 8935, 14, 2330, 199, 2590, 26, 272, 7509, 63, 13107, 63, 14939, 275, 756, 421, 199, 533, 5365, 571, 2162, 30251, 439, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 1888, 439, 63, 7646, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 1881, 297, 283, 5575, 3815, 288, 1790, 804, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 16281, 8198, 297, 283, 5278, 3325, 8198, 3815, 288, 1572, 5278, 1563, 36, 78, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 1572, 5278, 804, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1944, 2448, 297, 283, 7472, 6231, 297, 283, 7021, 10872, 3815, 288, 1654, 1230, 1831, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 922, 5278, 1563, 10872, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 2754, 8198, 10872, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 2754, 8198, 6139, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 12, 949, 63, 793, 29, 549, 395, 288, 922, 5278, 4131, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 922, 10872, 4231, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 1572, 5278, 7223, 4131, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 9, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 1215, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 1215, 459, 929, 418, 267, 291, 14, 1178, 804, 275, 1215, 459, 1178 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 9708, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 11802, 63, 2108, 3519, 63, 9642, 199, 199, 3612, 63, 1802, 26, 28076, 6566, 2290, 14944, 13727, 4628, 4390, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 18533, 8935, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 28076, 2622, 11682, 334, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 9, 199, 1802, 26, 199, 13, 12030, 12, 3507, 13727, 12, 436, 1050, 13727, 4390, 199, 199, 1419, 26, 339, 1174, 26, 267, 1369, 26, 267, 446, 7480, 314, 2013, 3301, 1077, 2187, 503, 440, 14, 267, 1415, 26, 2549, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 339, 1790, 804, 26, 267, 1369, 26, 267, 446, 473, 2433, 397, 1314, 922, 6299, 1083, 370, 675, 14, 267, 3415, 26, 788, 16281, 8198, 297, 283, 5278, 3325, 8198, 418, 339, 1572, 5278, 1563, 36, 78, 26, 267, 1369, 26, 267, 446, 710, 1300, 24842, 402, 314, 3123, 370, 1343, 314, 1572, 2754, 334, 14117, 886, 282, 26897, 2754, 687, 2348, 9, 339, 1572, 5278, 804, 26, 267, 1369, 26, 267, 446, 29001, 314, 849, 1572, 2754, 2457, 1202, 267, 3415, 26, 788, 1944, 2448, 297, 283, 7472, 6231, 297, 283, 7021, 10872, 418, 339, 1654, 1230, 1831, 26, 267, 1369, 26, 267, 446, 437, 10029, 13, 12794, 769, 402, 20717, 1654, 30143, 339, 922, 5278, 1563, 10872, 26, 267, 1369, 26, 267, 446, 710, 1300, 24842, 402, 314, 3123, 370, 1343, 314, 2754, 334, 14117, 886, 282, 26897, 2754, 687, 2348, 9, 339, 2754, 8198, 10872, 26, 267, 1369, 26, 267, 446, 437, 366, 8525, 12313, 24842, 370, 943, 315, 543, 370, 5147, 376, 491, 8980, 80, 2754, 367, 314, 922, 334, 10065, 1586, 2879, 370, 314, 20717, 2082, 680, 339, 2754, 8198, 6139, 26, 267, 1369, 26, 267, 446, 710, 2505, 367, 314, 2754, 8198, 10872, 2933, 1202, 367, 18112, 339, 922, 5278, 4131, 26, 267, 1369, 26, 267, 446, 314, 20717, 9388, 370, 675, 339, 922, 10872, 4231, 26, 267, 1369, 26, 267, 446, 437, 1059, 626, 365, 1202, 1824, 282, 9999, 12313, 922, 24842, 14, 339, 1572, 5278, 7223, 4131, 26, 267, 1369, 26, 267, 446, 2104, 675, 543, 314, 8388, 4131, 8730, 730, 199, 2344, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 3507, 13727, 6299, 489, 11802, 63, 2108, 3519, 63, 9642, 26, 267, 1174, 26, 9552, 267, 3434, 26, 7370, 4628, 3434, 7820, 267, 2505, 26, 7370, 4628, 2505, 7820, 267, 6246, 26, 7370, 6246, 7820, 339, 446, 536, 26, 12030, 13727, 6299, 489, 11802, 63, 2108, 3519, 63, 9642, 26, 267, 1174, 26, 3451, 267, 3434, 26, 7370, 4628, 3434, 7820, 267, 2505, 26, 7370, 4628, 2505, 7820, 267, 6246, 26, 7370, 6246, 7820, 267, 1790, 804, 26, 21128, 8198, 267, 1654, 1230, 1831, 26, 13727, 921, 2772, 1064, 633, 371, 397, 88, 614, 681, 68, 63, 9642, 429, 343, 267, 1572, 5278, 804, 26, 14409, 10872, 267, 922, 10872, 4231, 26, 221, 1747, 2458, 11958, 5, 12, 6413, 29, 3707, 12, 6413, 29, 8370, 12, 3833, 29, 989, 80, 12, 3833, 628, 3638, 7233, 536, 3586, 401, 3833, 29, 957, 421, 199, 624, 199, 199, 9677, 275, 408, 199, 199, 624, 199, 646, 5190, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 13107, 63, 14939, 275, 15742, 63, 1208, 14, 1989, 63, 7646, 63, 9277, 342, 199, 893, 26, 272, 492, 18609, 8935, 14, 2330, 199, 2590, 26, 272, 7509, 63, 13107, 63, 14939, 275, 756, 421, 199, 533, 5365, 571, 2162, 30251, 439, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 1888, 439, 63, 7646, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 1881, 297, 283, 5575, 3815, 288, 1790, 804, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 16281, 8198, 297, 283, 5278, 3325, 8198, 3815, 288, 1572, 5278, 1563, 36, 78, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 1572, 5278, 804, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1944, 2448, 297, 283, 7472, 6231, 297, 283, 7021, 10872, 3815, 288, 1654, 1230, 1831, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 922, 5278, 1563, 10872, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 2754, 8198, 10872, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 2754, 8198, 6139, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 12, 949, 63, 793, 29, 549, 395, 288, 922, 5278, 4131, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 922, 10872, 4231, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 395, 288, 1572, 5278, 7223, 4131, 29, 807, 8, 2427, 29, 797, 12, 730, 29, 495, 9, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 1215, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 1215, 459, 929, 418, 267, 291, 14, 1178, 804, 275, 1215, 459, 1178, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chewing/chewing-editor
gmock/gtest/scripts/fuse_gtest_files.py
2577
8813
#!/usr/bin/env python # # Copyright 2009, 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. """fuse_gtest_files.py v0.2.0 Fuses Google Test source code into a .h file and a .cc file. SYNOPSIS fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR Scans GTEST_ROOT_DIR for Google Test source code, and generates two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc. Then you can build your tests by adding OUTPUT_DIR to the include search path and linking with OUTPUT_DIR/gtest/gtest-all.cc. These two files contain everything you need to use Google Test. Hence you can "install" Google Test by copying them to wherever you want. GTEST_ROOT_DIR can be omitted and defaults to the parent directory of the directory holding this script. EXAMPLES ./fuse_gtest_files.py fused_gtest ./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest This tool is experimental. In particular, it assumes that there is no conditional inclusion of Google Test headers. Please report any problems to googletestframework@googlegroups.com. You can read http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for more information. """ __author__ = 'wan@google.com (Zhanyong Wan)' import os import re import sets import sys # We assume that this file is in the scripts/ directory in the Google # Test root directory. DEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..') # Regex for matching '#include "gtest/..."'. INCLUDE_GTEST_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(gtest/.+)"') # Regex for matching '#include "src/..."'. INCLUDE_SRC_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(src/.+)"') # Where to find the source seed files. GTEST_H_SEED = 'include/gtest/gtest.h' GTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h' GTEST_ALL_CC_SEED = 'src/gtest-all.cc' # Where to put the generated files. GTEST_H_OUTPUT = 'gtest/gtest.h' GTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc' def VerifyFileExists(directory, relative_path): """Verifies that the given file exists; aborts on failure. relative_path is the file path relative to the given directory. """ if not os.path.isfile(os.path.join(directory, relative_path)): print 'ERROR: Cannot find %s in directory %s.' % (relative_path, directory) print ('Please either specify a valid project root directory ' 'or omit it on the command line.') sys.exit(1) def ValidateGTestRootDir(gtest_root): """Makes sure gtest_root points to a valid gtest root directory. The function aborts the program on failure. """ VerifyFileExists(gtest_root, GTEST_H_SEED) VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED) def VerifyOutputFile(output_dir, relative_path): """Verifies that the given output file path is valid. relative_path is relative to the output_dir directory. """ # Makes sure the output file either doesn't exist or can be overwritten. output_file = os.path.join(output_dir, relative_path) if os.path.exists(output_file): # TODO(wan@google.com): The following user-interaction doesn't # work with automated processes. We should provide a way for the # Makefile to force overwriting the files. print ('%s already exists in directory %s - overwrite it? (y/N) ' % (relative_path, output_dir)) answer = sys.stdin.readline().strip() if answer not in ['y', 'Y']: print 'ABORTED.' sys.exit(1) # Makes sure the directory holding the output file exists; creates # it and all its ancestors if necessary. parent_directory = os.path.dirname(output_file) if not os.path.isdir(parent_directory): os.makedirs(parent_directory) def ValidateOutputDir(output_dir): """Makes sure output_dir points to a valid output directory. The function aborts the program on failure. """ VerifyOutputFile(output_dir, GTEST_H_OUTPUT) VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT) def FuseGTestH(gtest_root, output_dir): """Scans folder gtest_root to generate gtest/gtest.h in output_dir.""" output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w') processed_files = sets.Set() # Holds all gtest headers we've processed. def ProcessFile(gtest_header_path): """Processes the given gtest header file.""" # We don't process the same header twice. if gtest_header_path in processed_files: return processed_files.add(gtest_header_path) # Reads each line in the given gtest header. for line in file(os.path.join(gtest_root, gtest_header_path), 'r'): m = INCLUDE_GTEST_FILE_REGEX.match(line) if m: # It's '#include "gtest/..."' - let's process it recursively. ProcessFile('include/' + m.group(1)) else: # Otherwise we copy the line unchanged to the output file. output_file.write(line) ProcessFile(GTEST_H_SEED) output_file.close() def FuseGTestAllCcToFile(gtest_root, output_file): """Scans folder gtest_root to generate gtest/gtest-all.cc in output_file.""" processed_files = sets.Set() def ProcessFile(gtest_source_file): """Processes the given gtest source file.""" # We don't process the same #included file twice. if gtest_source_file in processed_files: return processed_files.add(gtest_source_file) # Reads each line in the given gtest source file. for line in file(os.path.join(gtest_root, gtest_source_file), 'r'): m = INCLUDE_GTEST_FILE_REGEX.match(line) if m: if 'include/' + m.group(1) == GTEST_SPI_H_SEED: # It's '#include "gtest/gtest-spi.h"'. This file is not # #included by "gtest/gtest.h", so we need to process it. ProcessFile(GTEST_SPI_H_SEED) else: # It's '#include "gtest/foo.h"' where foo is not gtest-spi. # We treat it as '#include "gtest/gtest.h"', as all other # gtest headers are being fused into gtest.h and cannot be # #included directly. # There is no need to #include "gtest/gtest.h" more than once. if not GTEST_H_SEED in processed_files: processed_files.add(GTEST_H_SEED) output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,)) else: m = INCLUDE_SRC_FILE_REGEX.match(line) if m: # It's '#include "src/foo"' - let's process it recursively. ProcessFile(m.group(1)) else: output_file.write(line) ProcessFile(GTEST_ALL_CC_SEED) def FuseGTestAllCc(gtest_root, output_dir): """Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir.""" output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w') FuseGTestAllCcToFile(gtest_root, output_file) output_file.close() def FuseGTest(gtest_root, output_dir): """Fuses gtest.h and gtest-all.cc.""" ValidateGTestRootDir(gtest_root) ValidateOutputDir(output_dir) FuseGTestH(gtest_root, output_dir) FuseGTestAllCc(gtest_root, output_dir) def main(): argc = len(sys.argv) if argc == 2: # fuse_gtest_files.py OUTPUT_DIR FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1]) elif argc == 3: # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR FuseGTest(sys.argv[1], sys.argv[2]) else: print __doc__ sys.exit(1) if __name__ == '__main__': main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 70, 1180, 63, 8385, 63, 1725, 14, 647, 373, 16, 14, 18, 14, 16, 199, 38, 5589, 4475, 1379, 1350, 1233, 1901, 282, 1275, 72, 570, 436, 282, 1275, 2055, 570, 14, 199, 199, 31802, 21665, 1311, 2126, 289, 1180, 63, 8385, 63, 1725, 14, 647, 359, 16151, 63, 5441, 63, 3022, 61, 18746, 63, 3022, 10817, 13916, 796, 18652, 63, 5441, 63, 3022, 367, 4475, 1379, 1350, 1233, 12, 436, 12821, 2126, 2877, 1584, 26, 18746, 63, 3022, 15, 8385, 15, 8385, 14, 72, 436, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 2126, 9442, 1265, 883, 1900, 2195, 2295, 701, 7791, 18746, 63, 3022, 370, 314, 2387, 2126, 2754, 931, 436, 25833, 543, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 221, 5723, 2126, 2877, 1584, 1395, 8137, 1265, 1929, 370, 675, 4475, 1379, 14, 221, 869, 4894, 2126, 1265, 883, 298, 3174, 2, 4475, 1379, 701, 16743, 3062, 370, 2382, 422, 1265, 2934, 14, 10817, 18652, 63, 5441, 63, 3022, 883, 506, 11684, 436, 4243, 370, 314, 1676, 2126, 2082, 402, 314, 2082, 17573, 642, 2884, 14, 199, 199, 8918, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 28580, 63, 8385, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 931, 15, 475, 15, 24497, 15, 8385, 28580, 63, 8385, 199, 199, 2765, 4744, 365, 22820, 14, 221, 1010, 6770, 12, 652, 15194, 626, 2337, 365, 949, 199, 14353, 20396, 402, 4475, 1379, 2323, 14, 221, 7754, 3622, 1263, 199, 22959, 370, 31141, 4857, 32, 3098, 2634, 14, 957, 14, 221, 2047, 883, 1586, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 13266, 774, 23613, 4324, 271, 367, 199, 6878, 2556, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5951, 199, 646, 984, 199, 199, 3, 2136, 5534, 626, 642, 570, 365, 315, 314, 10554, 15, 2082, 315, 314, 4475, 199, 3, 1379, 1738, 2082, 14, 199, 3472, 63, 16151, 63, 5441, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 11541, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 8385, 15, 11500, 1370, 199, 18171, 63, 16151, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 8385, 15, 6977, 2924, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 2164, 15, 11500, 1370, 199, 18171, 63, 12447, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 2164, 15, 6977, 2924, 358, 199, 199, 3, 17685, 370, 2342, 314, 1350, 6347, 1584, 14, 199, 16151, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 20495, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 13, 8721, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 25508, 275, 283, 2164, 15, 8385, 13, 452, 14, 2055, 7, 199, 199, 3, 17685, 370, 5324, 314, 4046, 1584, 14, 199, 16151, 63, 40, 63, 8414, 275, 283, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 8414, 275, 283, 8385, 15, 8385, 13, 452, 14, 2055, 7, 421, 199, 318, 7635, 1173, 7965, 8, 3619, 12, 3847, 63, 515, 304, 523, 408, 21168, 626, 314, 1627, 570, 3495, 27, 12004, 83, 641, 5988, 14, 819, 3847, 63, 515, 365, 314, 570, 931, 3847, 370, 314, 1627, 2082, 14, 523, 408, 819, 340, 440, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 3619, 12, 3847, 63, 515, 2298, 272, 870, 283, 3170, 26, 18435, 2342, 450, 83, 315, 2082, 450, 83, 3530, 450, 334, 6188, 63, 515, 12, 10028, 2082, 9, 272, 870, 661, 8254, 1902, 4165, 282, 1686, 2199, 1738, 2082, 283, 1779, 283, 269, 19413, 652, 641, 314, 1414, 1004, 2659, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 12134, 39, 774 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 70, 1180, 63, 8385, 63, 1725, 14, 647, 373, 16, 14, 18, 14, 16, 199, 38, 5589, 4475, 1379, 1350, 1233, 1901, 282, 1275, 72, 570, 436, 282, 1275, 2055, 570, 14, 199, 199, 31802, 21665, 1311, 2126, 289, 1180, 63, 8385, 63, 1725, 14, 647, 359, 16151, 63, 5441, 63, 3022, 61, 18746, 63, 3022, 10817, 13916, 796, 18652, 63, 5441, 63, 3022, 367, 4475, 1379, 1350, 1233, 12, 436, 12821, 2126, 2877, 1584, 26, 18746, 63, 3022, 15, 8385, 15, 8385, 14, 72, 436, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 2126, 9442, 1265, 883, 1900, 2195, 2295, 701, 7791, 18746, 63, 3022, 370, 314, 2387, 2126, 2754, 931, 436, 25833, 543, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 221, 5723, 2126, 2877, 1584, 1395, 8137, 1265, 1929, 370, 675, 4475, 1379, 14, 221, 869, 4894, 2126, 1265, 883, 298, 3174, 2, 4475, 1379, 701, 16743, 3062, 370, 2382, 422, 1265, 2934, 14, 10817, 18652, 63, 5441, 63, 3022, 883, 506, 11684, 436, 4243, 370, 314, 1676, 2126, 2082, 402, 314, 2082, 17573, 642, 2884, 14, 199, 199, 8918, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 28580, 63, 8385, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 931, 15, 475, 15, 24497, 15, 8385, 28580, 63, 8385, 199, 199, 2765, 4744, 365, 22820, 14, 221, 1010, 6770, 12, 652, 15194, 626, 2337, 365, 949, 199, 14353, 20396, 402, 4475, 1379, 2323, 14, 221, 7754, 3622, 1263, 199, 22959, 370, 31141, 4857, 32, 3098, 2634, 14, 957, 14, 221, 2047, 883, 1586, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 13266, 774, 23613, 4324, 271, 367, 199, 6878, 2556, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5951, 199, 646, 984, 199, 199, 3, 2136, 5534, 626, 642, 570, 365, 315, 314, 10554, 15, 2082, 315, 314, 4475, 199, 3, 1379, 1738, 2082, 14, 199, 3472, 63, 16151, 63, 5441, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 11541, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 8385, 15, 11500, 1370, 199, 18171, 63, 16151, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 8385, 15, 6977, 2924, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 2164, 15, 11500, 1370, 199, 18171, 63, 12447, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 2164, 15, 6977, 2924, 358, 199, 199, 3, 17685, 370, 2342, 314, 1350, 6347, 1584, 14, 199, 16151, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 20495, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 13, 8721, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 25508, 275, 283, 2164, 15, 8385, 13, 452, 14, 2055, 7, 199, 199, 3, 17685, 370, 5324, 314, 4046, 1584, 14, 199, 16151, 63, 40, 63, 8414, 275, 283, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 8414, 275, 283, 8385, 15, 8385, 13, 452, 14, 2055, 7, 421, 199, 318, 7635, 1173, 7965, 8, 3619, 12, 3847, 63, 515, 304, 523, 408, 21168, 626, 314, 1627, 570, 3495, 27, 12004, 83, 641, 5988, 14, 819, 3847, 63, 515, 365, 314, 570, 931, 3847, 370, 314, 1627, 2082, 14, 523, 408, 819, 340, 440, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 3619, 12, 3847, 63, 515, 2298, 272, 870, 283, 3170, 26, 18435, 2342, 450, 83, 315, 2082, 450, 83, 3530, 450, 334, 6188, 63, 515, 12, 10028, 2082, 9, 272, 870, 661, 8254, 1902, 4165, 282, 1686, 2199, 1738, 2082, 283, 1779, 283, 269, 19413, 652, 641, 314, 1414, 1004, 2659, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 12134, 39, 774, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vmax-feihu/hue
desktop/core/ext-py/Django-1.6.10/tests/sites_framework/tests.py
150
1800
from __future__ import absolute_import from django.conf import settings from django.contrib.sites.models import Site from django.test import TestCase from .models import (SyndicatedArticle, ExclusiveArticle, CustomArticle, InvalidArticle, ConfusedArticle) class SitesFrameworkTestCase(TestCase): def setUp(self): Site.objects.get_or_create(id=settings.SITE_ID, domain="example.com", name="example.com") Site.objects.create(id=settings.SITE_ID+1, domain="example2.com", name="example2.com") def test_site_fk(self): article = ExclusiveArticle.objects.create(title="Breaking News!", site_id=settings.SITE_ID) self.assertEqual(ExclusiveArticle.on_site.all().get(), article) def test_sites_m2m(self): article = SyndicatedArticle.objects.create(title="Fresh News!") article.sites.add(Site.objects.get(id=settings.SITE_ID)) article.sites.add(Site.objects.get(id=settings.SITE_ID+1)) article2 = SyndicatedArticle.objects.create(title="More News!") article2.sites.add(Site.objects.get(id=settings.SITE_ID+1)) self.assertEqual(SyndicatedArticle.on_site.all().get(), article) def test_custom_named_field(self): article = CustomArticle.objects.create(title="Tantalizing News!", places_this_article_should_appear_id=settings.SITE_ID) self.assertEqual(CustomArticle.on_site.all().get(), article) def test_invalid_name(self): article = InvalidArticle.objects.create(title="Bad News!", site_id=settings.SITE_ID) self.assertRaises(ValueError, InvalidArticle.on_site.all) def test_invalid_field_type(self): article = ConfusedArticle.objects.create(title="More Bad News!", site=settings.SITE_ID) self.assertRaises(TypeError, ConfusedArticle.on_site.all)
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 17746, 24489, 7221, 12, 1316, 6563, 7221, 12, 8388, 7221, 12, 272, 6378, 7221, 12, 1448, 30032, 7221, 9, 421, 199, 533, 428, 4033, 16442, 1746, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 11666, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 344, 29, 1751, 14, 7917, 63, 998, 12, 2881, 628, 2694, 14, 957, 401, 536, 628, 2694, 14, 957, 531, 267, 11666, 14, 1462, 14, 981, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 12, 2881, 628, 2694, 18, 14, 957, 401, 536, 628, 2694, 18, 14, 957, 531, 339, 347, 511, 63, 2124, 63, 9010, 8, 277, 304, 267, 9772, 275, 1316, 6563, 7221, 14, 1462, 14, 981, 8, 1213, 628, 13948, 316, 30951, 17716, 4770, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 629, 8, 26281, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 8619, 63, 77, 18, 77, 8, 277, 304, 267, 9772, 275, 29988, 24489, 7221, 14, 1462, 14, 981, 8, 1213, 628, 38, 2107, 30951, 9124, 267, 9772, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 430, 267, 9772, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 430, 267, 9772, 18, 275, 29988, 24489, 7221, 14, 1462, 14, 981, 8, 1213, 628, 11053, 30951, 9124, 267, 9772, 18, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 430, 267, 291, 14, 629, 8, 17746, 24489, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 4229, 63, 4579, 63, 698, 8, 277, 304, 267, 9772, 275, 8388, 7221, 14, 1462, 14, 981, 8, 1213, 628, 52, 867, 279, 9147, 30951, 17716, 9825, 63, 3749, 63, 6934, 63, 5626, 63, 27307, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 629, 8, 7223, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 3197, 63, 354, 8, 277, 304, 267, 9772, 275, 6378, 7221, 14, 1462, 14, 981, 8, 1213, 628, 5725, 30951, 17716, 4770, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 1855, 8, 3393, 12, 6378, 7221, 14, 265, 63, 2124, 14, 452, 9, 339, 347, 511, 63, 3197, 63, 698, 63, 466, 8, 277, 304, 267, 9772, 275, 1448, 30032, 7221, 14, 1462, 14, 981, 8, 1213, 628, 11053, 8857, 30951, 17716, 4770, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 1855, 8, 4333, 12, 1448, 30032, 7221, 14, 265, 63, 2124, 14, 452, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 17746, 24489, 7221, 12, 1316, 6563, 7221, 12, 8388, 7221, 12, 272, 6378, 7221, 12, 1448, 30032, 7221, 9, 421, 199, 533, 428, 4033, 16442, 1746, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 11666, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 344, 29, 1751, 14, 7917, 63, 998, 12, 2881, 628, 2694, 14, 957, 401, 536, 628, 2694, 14, 957, 531, 267, 11666, 14, 1462, 14, 981, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 12, 2881, 628, 2694, 18, 14, 957, 401, 536, 628, 2694, 18, 14, 957, 531, 339, 347, 511, 63, 2124, 63, 9010, 8, 277, 304, 267, 9772, 275, 1316, 6563, 7221, 14, 1462, 14, 981, 8, 1213, 628, 13948, 316, 30951, 17716, 4770, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 629, 8, 26281, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 8619, 63, 77, 18, 77, 8, 277, 304, 267, 9772, 275, 29988, 24489, 7221, 14, 1462, 14, 981, 8, 1213, 628, 38, 2107, 30951, 9124, 267, 9772, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 430, 267, 9772, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 430, 267, 9772, 18, 275, 29988, 24489, 7221, 14, 1462, 14, 981, 8, 1213, 628, 11053, 30951, 9124, 267, 9772, 18, 14, 8619, 14, 525, 8, 8972, 14, 1462, 14, 362, 8, 344, 29, 1751, 14, 7917, 63, 998, 11, 17, 430, 267, 291, 14, 629, 8, 17746, 24489, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 4229, 63, 4579, 63, 698, 8, 277, 304, 267, 9772, 275, 8388, 7221, 14, 1462, 14, 981, 8, 1213, 628, 52, 867, 279, 9147, 30951, 17716, 9825, 63, 3749, 63, 6934, 63, 5626, 63, 27307, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 629, 8, 7223, 7221, 14, 265, 63, 2124, 14, 452, 1252, 362, 1062, 9772, 9, 339, 347, 511, 63, 3197, 63, 354, 8, 277, 304, 267, 9772, 275, 6378, 7221, 14, 1462, 14, 981, 8, 1213, 628, 5725, 30951, 17716, 4770, 63, 344, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 1855, 8, 3393, 12, 6378, 7221, 14, 265, 63, 2124, 14, 452, 9, 339, 347, 511, 63, 3197, 63, 698, 63, 466, 8, 277, 304, 267, 9772, 275, 1448, 30032, 7221, 14, 1462, 14, 981, 8, 1213, 628, 11053, 8857, 30951, 17716, 4770, 29, 1751, 14, 7917, 63, 998, 9, 267, 291, 14, 1855, 8, 4333, 12, 1448, 30032, 7221, 14, 265, 63, 2124, 14, 452, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
SerCeMan/intellij-community
python/lib/Lib/select.py
79
9130
""" This is an select module for use on JVMs > 1.5. It is documented, along with known issues and workarounds, on the jython wiki. http://wiki.python.org/jython/SelectModule """ import java.nio.channels.SelectableChannel import java.nio.channels.SelectionKey import java.nio.channels.Selector from java.nio.channels.SelectionKey import OP_ACCEPT, OP_CONNECT, OP_WRITE, OP_READ import errno import os import Queue import socket class error(Exception): pass ALL = None _exception_map = { # (<javaexception>, <circumstance>) : lambda: <code that raises the python equivalent> (java.nio.channels.IllegalBlockingModeException, ALL) : error(errno.ESOCKISBLOCKING, 'socket must be in non-blocking mode'), } def _map_exception(exc, circumstance=ALL): try: mapped_exception = _exception_map[(exc.__class__, circumstance)] mapped_exception.java_exception = exc return mapped_exception except KeyError: return error(-1, 'Unmapped java exception: <%s:%s>' % (exc.toString(), circumstance)) POLLIN = 1 POLLOUT = 2 # The following event types are completely ignored on jython # Java does not support them, AFAICT # They are declared only to support code compatibility with cpython POLLPRI = 4 POLLERR = 8 POLLHUP = 16 POLLNVAL = 32 def _getselectable(selectable_object): try: channel = selectable_object.getchannel() except: try: channel = selectable_object.fileno().getChannel() except: raise TypeError("Object '%s' is not watchable" % selectable_object, errno.ENOTSOCK) if channel and not isinstance(channel, java.nio.channels.SelectableChannel): raise TypeError("Object '%s' is not watchable" % selectable_object, errno.ENOTSOCK) return channel class poll: def __init__(self): self.selector = java.nio.channels.Selector.open() self.chanmap = {} self.unconnected_sockets = [] def _register_channel(self, socket_object, channel, mask): jmask = 0 if mask & POLLIN: # Note that OP_READ is NOT a valid event on server socket channels. if channel.validOps() & OP_ACCEPT: jmask = OP_ACCEPT else: jmask = OP_READ if mask & POLLOUT: if channel.validOps() & OP_WRITE: jmask |= OP_WRITE if channel.validOps() & OP_CONNECT: jmask |= OP_CONNECT selectionkey = channel.register(self.selector, jmask) self.chanmap[channel] = (socket_object, selectionkey) def _check_unconnected_sockets(self): temp_list = [] for socket_object, mask in self.unconnected_sockets: channel = _getselectable(socket_object) if channel is not None: self._register_channel(socket_object, channel, mask) else: temp_list.append( (socket_object, mask) ) self.unconnected_sockets = temp_list def register(self, socket_object, mask = POLLIN|POLLOUT|POLLPRI): try: channel = _getselectable(socket_object) if channel is None: # The socket is not yet connected, and thus has no channel # Add it to a pending list, and return self.unconnected_sockets.append( (socket_object, mask) ) return self._register_channel(socket_object, channel, mask) except java.lang.Exception, jlx: raise _map_exception(jlx) def unregister(self, socket_object): try: channel = _getselectable(socket_object) self.chanmap[channel][1].cancel() del self.chanmap[channel] except java.lang.Exception, jlx: raise _map_exception(jlx) def _dopoll(self, timeout): if timeout is None or timeout < 0: self.selector.select() else: try: timeout = int(timeout) if not timeout: self.selector.selectNow() else: # No multiplication required: both cpython and java use millisecond timeouts self.selector.select(timeout) except ValueError, vx: raise error("poll timeout must be a number of milliseconds or None", errno.EINVAL) # The returned selectedKeys cannot be used from multiple threads! return self.selector.selectedKeys() def poll(self, timeout=None): try: self._check_unconnected_sockets() selectedkeys = self._dopoll(timeout) results = [] for k in selectedkeys.iterator(): jmask = k.readyOps() pymask = 0 if jmask & OP_READ: pymask |= POLLIN if jmask & OP_WRITE: pymask |= POLLOUT if jmask & OP_ACCEPT: pymask |= POLLIN if jmask & OP_CONNECT: pymask |= POLLOUT # Now return the original userobject, and the return event mask results.append( (self.chanmap[k.channel()][0], pymask) ) return results except java.lang.Exception, jlx: raise _map_exception(jlx) def _deregister_all(self): try: for k in self.selector.keys(): k.cancel() # Keys are not actually removed from the selector until the next select operation. self.selector.selectNow() except java.lang.Exception, jlx: raise _map_exception(jlx) def close(self): try: self._deregister_all() self.selector.close() except java.lang.Exception, jlx: raise _map_exception(jlx) def _calcselecttimeoutvalue(value): if value is None: return None try: floatvalue = float(value) except Exception, x: raise TypeError("Select timeout value must be a number or None") if value < 0: raise error("Select timeout value cannot be negative", errno.EINVAL) if floatvalue < 0.000001: return 0 return int(floatvalue * 1000) # Convert to milliseconds # This cache for poll objects is required because of a bug in java on MS Windows # http://bugs.jython.org/issue1291 class poll_object_cache: def __init__(self): self.is_windows = os._name == 'nt' if self.is_windows: self.poll_object_queue = Queue.Queue() import atexit atexit.register(self.finalize) def get_poll_object(self): if not self.is_windows: return poll() try: return self.poll_object_queue.get(False) except Queue.Empty: return poll() def release_poll_object(self, pobj): if self.is_windows: pobj._deregister_all() self.poll_object_queue.put(pobj) else: pobj.close() def finalize(self): if self.is_windows: while True: try: p = self.poll_object_queue.get(False) p.close() except Queue.Empty: return _poll_object_cache = poll_object_cache() def native_select(read_fd_list, write_fd_list, outofband_fd_list, timeout=None): timeout = _calcselecttimeoutvalue(timeout) # First create a poll object to do the actual watching. pobj = _poll_object_cache.get_poll_object() try: registered_for_read = {} # Check the read list for fd in read_fd_list: pobj.register(fd, POLLIN) registered_for_read[fd] = 1 # And now the write list for fd in write_fd_list: if fd in registered_for_read: # registering a second time overwrites the first pobj.register(fd, POLLIN|POLLOUT) else: pobj.register(fd, POLLOUT) results = pobj.poll(timeout) # Now start preparing the results read_ready_list, write_ready_list, oob_ready_list = [], [], [] for fd, mask in results: if mask & POLLIN: read_ready_list.append(fd) if mask & POLLOUT: write_ready_list.append(fd) return read_ready_list, write_ready_list, oob_ready_list finally: _poll_object_cache.release_poll_object(pobj) select = native_select def cpython_compatible_select(read_fd_list, write_fd_list, outofband_fd_list, timeout=None): # First turn all sockets to non-blocking # keeping track of which ones have changed modified_channels = [] try: for socket_list in [read_fd_list, write_fd_list, outofband_fd_list]: for s in socket_list: channel = _getselectable(s) if channel.isBlocking(): modified_channels.append(channel) channel.configureBlocking(0) return native_select(read_fd_list, write_fd_list, outofband_fd_list, timeout) finally: for channel in modified_channels: channel.configureBlocking(1)
apache-2.0
[ 624, 199, 2765, 365, 376, 3504, 859, 367, 675, 641, 1603, 6849, 83, 690, 413, 14, 21, 14, 199, 7940, 365, 22751, 12, 3180, 543, 6040, 10876, 436, 18092, 83, 12, 641, 314, 1335, 11361, 17195, 14, 199, 1014, 921, 6797, 14, 1548, 14, 1308, 15, 27179, 15, 5446, 2377, 199, 624, 199, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 5446, 461, 5358, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 7713, 1197, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 11212, 199, 504, 12120, 14, 78, 2308, 14, 6324, 14, 7713, 1197, 492, 9827, 63, 13089, 12, 9827, 63, 14657, 12, 9827, 63, 10387, 12, 9827, 63, 5670, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 10703, 199, 646, 2838, 199, 199, 533, 1125, 8, 1726, 304, 986, 199, 199, 1761, 275, 488, 199, 199, 63, 1971, 63, 1130, 275, 469, 199, 199, 3, 8642, 6138, 1971, 6244, 665, 6092, 453, 611, 18956, 520, 2400, 26, 665, 600, 626, 6534, 314, 2366, 7353, 30, 199, 199, 8, 6138, 14, 78, 2308, 14, 6324, 14, 25501, 27132, 1385, 1726, 12, 11727, 9, 520, 1125, 8, 7931, 14, 654, 47, 2504, 1311, 8475, 1206, 12, 283, 3450, 1471, 506, 315, 2222, 13, 13091, 818, 659, 199, 93, 199, 199, 318, 485, 1130, 63, 1971, 8, 2804, 12, 27027, 611, 29, 1761, 304, 272, 862, 26, 267, 9994, 63, 1971, 275, 485, 1971, 63, 1130, 7528, 2804, 855, 533, 3108, 27027, 611, 1874, 267, 9994, 63, 1971, 14, 6138, 63, 1971, 275, 3178, 267, 372, 9994, 63, 1971, 272, 871, 4067, 26, 267, 372, 1125, 2801, 17, 12, 283, 1358, 11663, 12120, 1919, 26, 21808, 83, 2689, 83, 3524, 450, 334, 2804, 14, 16695, 1062, 27027, 611, 430, 199, 199, 16428, 568, 257, 275, 413, 199, 32713, 1484, 934, 221, 275, 499, 199, 199, 3, 710, 2569, 1566, 2943, 787, 14793, 5525, 641, 1335, 11361, 199, 3, 9586, 1630, 440, 2291, 3062, 12, 437, 2078, 6196, 199, 3, 9322, 787, 14290, 1454, 370, 2291, 1233, 7163, 543, 286, 1548, 199, 199, 16428, 20076, 221, 275, 841, 199, 16428, 2666, 221, 275, 1695, 199, 16428, 40, 2160, 221, 275, 3193, 199, 16428, 46, 3204, 275, 4337, 199, 199, 318, 485, 362, 18837, 8, 18837, 63, 785, 304, 272, 862, 26, 267, 3623, 275, 23378, 63, 785, 14, 362, 2775, 342, 272, 871, 26, 267, 862, 26, 288, 3623, 275, 23378, 63, 785, 14, 9843, 1252, 362, 5358, 342, 267, 871, 26, 288, 746, 3146, 480, 1692, 1543, 83, 7, 365, 440, 9626, 461, 2, 450, 23378, 63, 785, 12, 1169, 7554, 14, 32710, 9469, 9, 2286, 340, 3623, 436, 440, 1228, 8, 2775, 12, 12120, 14, 78, 2308, 14, 6324, 14, 5446, 461, 5358, 304, 267, 746, 3146, 480, 1692, 1543, 83, 7, 365, 440, 9626, 461, 2, 450, 23378, 63, 785, 12, 717, 7554, 14, 32710, 9469, 9, 272, 372, 3623, 199, 199, 533, 11271, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 6662, 275, 12120, 14, 78, 2308, 14, 6324, 14, 11212, 14, 1490, 342, 267, 291, 14, 11984, 1130, 275, 1052, 267, 291, 14, 324, 7113, 63, 20517, 275, 942, 339, 347, 485, 2683, 63, 2775, 8, 277, 12, 2838, 63, 785, 12, 3623, 12, 3656, 304, 267, 1335, 2629, 275, 378, 267, 340, 3656, 1253, 25480, 6143, 26, 288, 327, 3390, 626, 9827, 63, 5670, 365, 2845, 282, 1686, 1566, 641, 1654, 2838, 9245, 14, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 13089, 26, 355, 1335, 2629, 275, 9827, 63, 13089, 288, 587, 26, 355, 1335, 2629, 275, 9827, 63, 5670, 267, 340, 3656, 1253, 25480, 1484, 934, 26, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 10387, 26, 355, 1335, 2629, 8901, 9827, 63, 10387, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 14657, 26, 355, 1335, 2629, 8901, 9827, 63, 14657, 267, 7267, 498, 275, 3623, 14, 2683, 8, 277, 14, 6662, 12, 1335, 2629, 9, 267, 291, 14, 11984, 1130, 59, 2775, 61, 275, 334, 3450, 63, 785, 12, 7267, 498, 9, 339, 347, 485, 1074, 63, 324, 7113, 63, 20517, 8, 277, 304, 267, 2388, 63, 513, 275, 942, 267, 367, 2838, 63, 785, 12, 3656, 315, 291, 14, 324, 7113, 63, 20517, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 340, 3623, 365, 440, 488, 26, 355, 291, 423, 2683, 63, 2775, 8, 3450, 63, 785, 12, 3623, 12, 3656, 9, 288, 587, 26, 355, 2388, 63, 513, 14, 740, 8, 334, 3450, 63, 785, 12, 3656, 9, 776, 267, 291, 14, 324, 7113, 63, 20517, 275, 2388, 63, 513, 339, 347, 2274, 8, 277, 12, 2838, 63, 785, 12, 3656, 275, 25480, 6143, 92, 32713, 1484, 934, 92, 16428, 20076, 304, 267, 862, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 340, 3623, 365, 488, 26, 355, 327, 710, 2838, 365, 440, 5966, 8539, 12, 436, 12850, 965, 949, 3623, 355, 327, 2654, 652, 370, 282, 9413, 769, 12, 436, 372, 355, 291, 14, 324, 7113, 63, 20517, 14, 740, 8, 334, 3450, 63, 785, 12, 3656, 9, 776, 355, 372, 288, 291, 423, 2683, 63, 2775, 8, 3450, 63, 785, 12, 3623, 12, 3656, 9, 267, 871, 12120, 14, 4159, 14, 1726, 12, 1335, 23605, 26, 288, 746, 485, 1130, 63, 1971, 8, 74, 23605, 9, 339, 347, 24369, 8, 277, 12, 2838, 63, 785, 304, 267, 862, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 291, 14, 11984, 1130, 59, 2775, 1527, 17, 1055, 6406, 342, 288, 2150, 291, 14, 11984, 1130, 59, 2775, 61, 267, 871, 12120, 14, 4159, 14, 1726, 12, 1335, 23605, 26, 288, 746, 485, 1130, 63, 1971, 8, 74, 23605, 9, 339, 347, 485, 68, 411, 14385, 8, 277, 12, 2653, 304, 267, 340, 2653, 365, 488, 503, 2653, 665, 378, 26, 288, 291, 14, 6662, 14, 2416, 342, 267, 587, 26, 288, 862, 26, 355, 2653, 275, 1109, 8, 2593, 9, 355, 340, 440, 2653, 26, 490, 291, 14, 6662, 14, 2416, 14351, 342, 355, 587, 26, 490, 327 ]
[ 199, 2765, 365, 376, 3504, 859, 367, 675, 641, 1603, 6849, 83, 690, 413, 14, 21, 14, 199, 7940, 365, 22751, 12, 3180, 543, 6040, 10876, 436, 18092, 83, 12, 641, 314, 1335, 11361, 17195, 14, 199, 1014, 921, 6797, 14, 1548, 14, 1308, 15, 27179, 15, 5446, 2377, 199, 624, 199, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 5446, 461, 5358, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 7713, 1197, 199, 646, 12120, 14, 78, 2308, 14, 6324, 14, 11212, 199, 504, 12120, 14, 78, 2308, 14, 6324, 14, 7713, 1197, 492, 9827, 63, 13089, 12, 9827, 63, 14657, 12, 9827, 63, 10387, 12, 9827, 63, 5670, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 10703, 199, 646, 2838, 199, 199, 533, 1125, 8, 1726, 304, 986, 199, 199, 1761, 275, 488, 199, 199, 63, 1971, 63, 1130, 275, 469, 199, 199, 3, 8642, 6138, 1971, 6244, 665, 6092, 453, 611, 18956, 520, 2400, 26, 665, 600, 626, 6534, 314, 2366, 7353, 30, 199, 199, 8, 6138, 14, 78, 2308, 14, 6324, 14, 25501, 27132, 1385, 1726, 12, 11727, 9, 520, 1125, 8, 7931, 14, 654, 47, 2504, 1311, 8475, 1206, 12, 283, 3450, 1471, 506, 315, 2222, 13, 13091, 818, 659, 199, 93, 199, 199, 318, 485, 1130, 63, 1971, 8, 2804, 12, 27027, 611, 29, 1761, 304, 272, 862, 26, 267, 9994, 63, 1971, 275, 485, 1971, 63, 1130, 7528, 2804, 855, 533, 3108, 27027, 611, 1874, 267, 9994, 63, 1971, 14, 6138, 63, 1971, 275, 3178, 267, 372, 9994, 63, 1971, 272, 871, 4067, 26, 267, 372, 1125, 2801, 17, 12, 283, 1358, 11663, 12120, 1919, 26, 21808, 83, 2689, 83, 3524, 450, 334, 2804, 14, 16695, 1062, 27027, 611, 430, 199, 199, 16428, 568, 257, 275, 413, 199, 32713, 1484, 934, 221, 275, 499, 199, 199, 3, 710, 2569, 1566, 2943, 787, 14793, 5525, 641, 1335, 11361, 199, 3, 9586, 1630, 440, 2291, 3062, 12, 437, 2078, 6196, 199, 3, 9322, 787, 14290, 1454, 370, 2291, 1233, 7163, 543, 286, 1548, 199, 199, 16428, 20076, 221, 275, 841, 199, 16428, 2666, 221, 275, 1695, 199, 16428, 40, 2160, 221, 275, 3193, 199, 16428, 46, 3204, 275, 4337, 199, 199, 318, 485, 362, 18837, 8, 18837, 63, 785, 304, 272, 862, 26, 267, 3623, 275, 23378, 63, 785, 14, 362, 2775, 342, 272, 871, 26, 267, 862, 26, 288, 3623, 275, 23378, 63, 785, 14, 9843, 1252, 362, 5358, 342, 267, 871, 26, 288, 746, 3146, 480, 1692, 1543, 83, 7, 365, 440, 9626, 461, 2, 450, 23378, 63, 785, 12, 1169, 7554, 14, 32710, 9469, 9, 2286, 340, 3623, 436, 440, 1228, 8, 2775, 12, 12120, 14, 78, 2308, 14, 6324, 14, 5446, 461, 5358, 304, 267, 746, 3146, 480, 1692, 1543, 83, 7, 365, 440, 9626, 461, 2, 450, 23378, 63, 785, 12, 717, 7554, 14, 32710, 9469, 9, 272, 372, 3623, 199, 199, 533, 11271, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 6662, 275, 12120, 14, 78, 2308, 14, 6324, 14, 11212, 14, 1490, 342, 267, 291, 14, 11984, 1130, 275, 1052, 267, 291, 14, 324, 7113, 63, 20517, 275, 942, 339, 347, 485, 2683, 63, 2775, 8, 277, 12, 2838, 63, 785, 12, 3623, 12, 3656, 304, 267, 1335, 2629, 275, 378, 267, 340, 3656, 1253, 25480, 6143, 26, 288, 327, 3390, 626, 9827, 63, 5670, 365, 2845, 282, 1686, 1566, 641, 1654, 2838, 9245, 14, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 13089, 26, 355, 1335, 2629, 275, 9827, 63, 13089, 288, 587, 26, 355, 1335, 2629, 275, 9827, 63, 5670, 267, 340, 3656, 1253, 25480, 1484, 934, 26, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 10387, 26, 355, 1335, 2629, 8901, 9827, 63, 10387, 288, 340, 3623, 14, 1078, 16452, 342, 1253, 9827, 63, 14657, 26, 355, 1335, 2629, 8901, 9827, 63, 14657, 267, 7267, 498, 275, 3623, 14, 2683, 8, 277, 14, 6662, 12, 1335, 2629, 9, 267, 291, 14, 11984, 1130, 59, 2775, 61, 275, 334, 3450, 63, 785, 12, 7267, 498, 9, 339, 347, 485, 1074, 63, 324, 7113, 63, 20517, 8, 277, 304, 267, 2388, 63, 513, 275, 942, 267, 367, 2838, 63, 785, 12, 3656, 315, 291, 14, 324, 7113, 63, 20517, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 340, 3623, 365, 440, 488, 26, 355, 291, 423, 2683, 63, 2775, 8, 3450, 63, 785, 12, 3623, 12, 3656, 9, 288, 587, 26, 355, 2388, 63, 513, 14, 740, 8, 334, 3450, 63, 785, 12, 3656, 9, 776, 267, 291, 14, 324, 7113, 63, 20517, 275, 2388, 63, 513, 339, 347, 2274, 8, 277, 12, 2838, 63, 785, 12, 3656, 275, 25480, 6143, 92, 32713, 1484, 934, 92, 16428, 20076, 304, 267, 862, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 340, 3623, 365, 488, 26, 355, 327, 710, 2838, 365, 440, 5966, 8539, 12, 436, 12850, 965, 949, 3623, 355, 327, 2654, 652, 370, 282, 9413, 769, 12, 436, 372, 355, 291, 14, 324, 7113, 63, 20517, 14, 740, 8, 334, 3450, 63, 785, 12, 3656, 9, 776, 355, 372, 288, 291, 423, 2683, 63, 2775, 8, 3450, 63, 785, 12, 3623, 12, 3656, 9, 267, 871, 12120, 14, 4159, 14, 1726, 12, 1335, 23605, 26, 288, 746, 485, 1130, 63, 1971, 8, 74, 23605, 9, 339, 347, 24369, 8, 277, 12, 2838, 63, 785, 304, 267, 862, 26, 288, 3623, 275, 485, 362, 18837, 8, 3450, 63, 785, 9, 288, 291, 14, 11984, 1130, 59, 2775, 1527, 17, 1055, 6406, 342, 288, 2150, 291, 14, 11984, 1130, 59, 2775, 61, 267, 871, 12120, 14, 4159, 14, 1726, 12, 1335, 23605, 26, 288, 746, 485, 1130, 63, 1971, 8, 74, 23605, 9, 339, 347, 485, 68, 411, 14385, 8, 277, 12, 2653, 304, 267, 340, 2653, 365, 488, 503, 2653, 665, 378, 26, 288, 291, 14, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TathagataChakraborti/resource-conflicts
PLANROB-2015/seq-sat-lama/Python-2.5.2/Lib/pstats.py
94
25940
"""Class for printing reports on profiled python code.""" # Class for printing reports on profiled python code. rev 1.0 4/1/94 # # Based on prior profile module by Sjoerd Mullender... # which was hacked somewhat by: Guido van Rossum # # see profile.doc and profile.py for more info. # Copyright 1994, by InfoSeek Corporation, all rights reserved. # Written by James Roskind # # Permission to use, copy, modify, and distribute this Python software # and its associated documentation for any purpose (subject to the # restriction in the following sentence) without fee is hereby granted, # provided that the above copyright notice appears in all copies, and # that both that copyright notice and this permission notice appear in # supporting documentation, and that the name of InfoSeek not be used in # advertising or publicity pertaining to distribution of the software # without specific, written prior permission. This permission is # explicitly restricted to the copying and modification of the software # to remain in Python, compiled Python, or other languages (such as C) # wherein the modified or derived code is exclusively imported into a # Python module. # # INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS # SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY # SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import sys import os import time import marshal import re __all__ = ["Stats"] class Stats: """This class is used for creating reports from data generated by the Profile class. It is a "friend" of that class, and imports data either by direct access to members of Profile class, or by reading in a dictionary that was emitted (via marshal) from the Profile class. The big change from the previous Profiler (in terms of raw functionality) is that an "add()" method has been provided to combine Stats from several distinct profile runs. Both the constructor and the add() method now take arbitrarily many file names as arguments. All the print methods now take an argument that indicates how many lines to print. If the arg is a floating point number between 0 and 1.0, then it is taken as a decimal percentage of the available lines to be printed (e.g., .1 means print 10% of all available lines). If it is an integer, it is taken to mean the number of lines of data that you wish to have printed. The sort_stats() method now processes some additional options (i.e., in addition to the old -1, 0, 1, or 2). It takes an arbitrary number of quoted strings to select the sort order. For example sort_stats('time', 'name') sorts on the major key of 'internal function time', and on the minor key of 'the name of the function'. Look at the two tables in sort_stats() and get_sort_arg_defs(self) for more examples. All methods return self, so you can string together commands like: Stats('foo', 'goo').strip_dirs().sort_stats('calls').\ print_stats(5).print_callers(5) """ def __init__(self, *args, **kwds): # I can't figure out how to explictly specify a stream keyword arg # with *args: # def __init__(self, *args, stream=sys.stdout): ... # so I use **kwds and sqauwk if something unexpected is passed in. self.stream = sys.stdout if "stream" in kwds: self.stream = kwds["stream"] del kwds["stream"] if kwds: keys = kwds.keys() keys.sort() extras = ", ".join(["%s=%s" % (k, kwds[k]) for k in keys]) raise ValueError, "unrecognized keyword args: %s" % extras if not len(args): arg = None else: arg = args[0] args = args[1:] self.init(arg) self.add(*args) def init(self, arg): self.all_callees = None # calc only if needed self.files = [] self.fcn_list = None self.total_tt = 0 self.total_calls = 0 self.prim_calls = 0 self.max_name_len = 0 self.top_level = {} self.stats = {} self.sort_arg_dict = {} self.load_stats(arg) trouble = 1 try: self.get_top_level_stats() trouble = 0 finally: if trouble: print >> self.stream, "Invalid timing data", if self.files: print >> self.stream, self.files[-1], print >> self.stream def load_stats(self, arg): if not arg: self.stats = {} elif isinstance(arg, basestring): f = open(arg, 'rb') self.stats = marshal.load(f) f.close() try: file_stats = os.stat(arg) arg = time.ctime(file_stats.st_mtime) + " " + arg except: # in case this is not unix pass self.files = [ arg ] elif hasattr(arg, 'create_stats'): arg.create_stats() self.stats = arg.stats arg.stats = {} if not self.stats: raise TypeError, "Cannot create or construct a %r object from '%r''" % ( self.__class__, arg) return def get_top_level_stats(self): for func, (cc, nc, tt, ct, callers) in self.stats.items(): self.total_calls += nc self.prim_calls += cc self.total_tt += tt if callers.has_key(("jprofile", 0, "profiler")): self.top_level[func] = None if len(func_std_string(func)) > self.max_name_len: self.max_name_len = len(func_std_string(func)) def add(self, *arg_list): if not arg_list: return self if len(arg_list) > 1: self.add(*arg_list[1:]) other = arg_list[0] if type(self) != type(other) or self.__class__ != other.__class__: other = Stats(other) self.files += other.files self.total_calls += other.total_calls self.prim_calls += other.prim_calls self.total_tt += other.total_tt for func in other.top_level: self.top_level[func] = None if self.max_name_len < other.max_name_len: self.max_name_len = other.max_name_len self.fcn_list = None for func, stat in other.stats.iteritems(): if func in self.stats: old_func_stat = self.stats[func] else: old_func_stat = (0, 0, 0, 0, {},) self.stats[func] = add_func_stats(old_func_stat, stat) return self def dump_stats(self, filename): """Write the profile data to a file we know how to load back.""" f = file(filename, 'wb') try: marshal.dump(self.stats, f) finally: f.close() # list the tuple indices and directions for sorting, # along with some printable description sort_arg_dict_default = { "calls" : (((1,-1), ), "call count"), "cumulative": (((3,-1), ), "cumulative time"), "file" : (((4, 1), ), "file name"), "line" : (((5, 1), ), "line number"), "module" : (((4, 1), ), "file name"), "name" : (((6, 1), ), "function name"), "nfl" : (((6, 1),(4, 1),(5, 1),), "name/file/line"), "pcalls" : (((0,-1), ), "call count"), "stdname" : (((7, 1), ), "standard name"), "time" : (((2,-1), ), "internal time"), } def get_sort_arg_defs(self): """Expand all abbreviations that are unique.""" if not self.sort_arg_dict: self.sort_arg_dict = dict = {} bad_list = {} for word, tup in self.sort_arg_dict_default.iteritems(): fragment = word while fragment: if not fragment: break if fragment in dict: bad_list[fragment] = 0 break dict[fragment] = tup fragment = fragment[:-1] for word in bad_list: del dict[word] return self.sort_arg_dict def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and type(field[0]) == type(1): # Be compatible with old profiler field = [ {-1: "stdname", 0:"calls", 1:"time", 2: "cumulative" } [ field[0] ] ] sort_arg_defs = self.get_sort_arg_defs() sort_tuple = () self.sort_type = "" connector = "" for word in field: sort_tuple = sort_tuple + sort_arg_defs[word][0] self.sort_type += connector + sort_arg_defs[word][1] connector = ", " stats_list = [] for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): stats_list.append((cc, nc, tt, ct) + func + (func_std_string(func), func)) stats_list.sort(TupleComp(sort_tuple).compare) self.fcn_list = fcn_list = [] for tuple in stats_list: fcn_list.append(tuple[-1]) return self def reverse_order(self): if self.fcn_list: self.fcn_list.reverse() return self def strip_dirs(self): oldstats = self.stats self.stats = newstats = {} max_name_len = 0 for func, (cc, nc, tt, ct, callers) in oldstats.iteritems(): newfunc = func_strip_path(func) if len(func_std_string(newfunc)) > max_name_len: max_name_len = len(func_std_string(newfunc)) newcallers = {} for func2, caller in callers.iteritems(): newcallers[func_strip_path(func2)] = caller if newfunc in newstats: newstats[newfunc] = add_func_stats( newstats[newfunc], (cc, nc, tt, ct, newcallers)) else: newstats[newfunc] = (cc, nc, tt, ct, newcallers) old_top = self.top_level self.top_level = new_top = {} for func in old_top: new_top[func_strip_path(func)] = None self.max_name_len = max_name_len self.fcn_list = None self.all_callees = None return self def calc_callees(self): if self.all_callees: return self.all_callees = all_callees = {} for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): if not func in all_callees: all_callees[func] = {} for func2, caller in callers.iteritems(): if not func2 in all_callees: all_callees[func2] = {} all_callees[func2][func] = caller return #****************************************************************** # The following functions support actual printing of reports #****************************************************************** # Optional "amount" is either a line count, or a percentage of lines. def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(sel) == type(1) and 0 <= sel < count: count = sel new_list = list[:count] if len(list) != len(new_list): msg = msg + " List reduced from %r to %r due to restriction <%r>\n" % ( len(list), len(new_list), sel) return new_list, msg def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n" for selection in sel_list: list, msg = self.eval_print_amount(selection, list, msg) count = len(list) if not list: return 0, list print >> self.stream, msg if count < len(self.stats): width = 0 for func in list: if len(func_std_string(func)) > width: width = len(func_std_string(func)) return width+2, list def print_stats(self, *amount): for filename in self.files: print >> self.stream, filename if self.files: print >> self.stream indent = ' ' * 8 for func in self.top_level: print >> self.stream, indent, func_get_function_name(func) print >> self.stream, indent, self.total_calls, "function calls", if self.total_calls != self.prim_calls: print >> self.stream, "(%d primitive calls)" % self.prim_calls, print >> self.stream, "in %.3f CPU seconds" % self.total_tt print >> self.stream width, list = self.get_print_list(amount) if list: self.print_title() for func in list: self.print_line(func) print >> self.stream print >> self.stream return self def print_callees(self, *amount): width, list = self.get_print_list(amount) if list: self.calc_callees() self.print_call_heading(width, "called...") for func in list: if func in self.all_callees: self.print_call_line(width, func, self.all_callees[func]) else: self.print_call_line(width, func, {}) print >> self.stream print >> self.stream return self def print_callers(self, *amount): width, list = self.get_print_list(amount) if list: self.print_call_heading(width, "was called by...") for func in list: cc, nc, tt, ct, callers = self.stats[func] self.print_call_line(width, func, callers, "<-") print >> self.stream print >> self.stream return self def print_call_heading(self, name_size, column_title): print >> self.stream, "Function ".ljust(name_size) + column_title # print sub-header only if we have new-style callers subheader = False for cc, nc, tt, ct, callers in self.stats.itervalues(): if callers: value = callers.itervalues().next() subheader = isinstance(value, tuple) break if subheader: print >> self.stream, " "*name_size + " ncalls tottime cumtime" def print_call_line(self, name_size, source, call_dict, arrow="->"): print >> self.stream, func_std_string(source).ljust(name_size) + arrow, if not call_dict: print >> self.stream return clist = call_dict.keys() clist.sort() indent = "" for func in clist: name = func_std_string(func) value = call_dict[func] if isinstance(value, tuple): nc, cc, tt, ct = value if nc != cc: substats = '%d/%d' % (nc, cc) else: substats = '%d' % (nc,) substats = '%s %s %s %s' % (substats.rjust(7+2*len(indent)), f8(tt), f8(ct), name) left_width = name_size + 1 else: substats = '%s(%r) %s' % (name, value, f8(self.stats[func][3])) left_width = name_size + 3 print >> self.stream, indent*left_width + substats indent = " " def print_title(self): print >> self.stream, ' ncalls tottime percall cumtime percall', print >> self.stream, 'filename:lineno(function)' def print_line(self, func): # hack : should print percentages cc, nc, tt, ct, callers = self.stats[func] c = str(nc) if nc != cc: c = c + '/' + str(cc) print >> self.stream, c.rjust(9), print >> self.stream, f8(tt), if nc == 0: print >> self.stream, ' '*8, else: print >> self.stream, f8(tt/nc), print >> self.stream, f8(ct), if cc == 0: print >> self.stream, ' '*8, else: print >> self.stream, f8(ct/cc), print >> self.stream, func_std_string(func) class TupleComp: """This class provides a generic function for comparing any two tuples. Each instance records a list of tuple-indices (from most significant to least significant), and sort direction (ascending or decending) for each tuple-index. The compare functions can then be used as the function argument to the system sort() function when a list of tuples need to be sorted in the instances order.""" def __init__(self, comp_select_list): self.comp_select_list = comp_select_list def compare (self, left, right): for index, direction in self.comp_select_list: l = left[index] r = right[index] if l < r: return -direction if l > r: return direction return 0 #************************************************************************** # func_name is a triple (file:string, line:int, name:string) def func_strip_path(func_name): filename, line, name = func_name return os.path.basename(filename), line, name def func_get_function_name(func): return func[2] def func_std_string(func_name): # match what old profile produced if func_name[:2] == ('~', 0): # special case for built-in functions name = func_name[2] if name.startswith('<') and name.endswith('>'): return '{%s}' % name[1:-1] else: return name else: return "%s:%d(%s)" % func_name #************************************************************************** # The following functions combine statists for pairs functions. # The bulk of the processing involves correctly handling "call" lists, # such as callers and callees. #************************************************************************** def add_func_stats(target, source): """Add together all the stats for two profile entries.""" cc, nc, tt, ct, callers = source t_cc, t_nc, t_tt, t_ct, t_callers = target return (cc+t_cc, nc+t_nc, tt+t_tt, ct+t_ct, add_callers(t_callers, callers)) def add_callers(target, source): """Combine two caller lists in a single list.""" new_callers = {} for func, caller in target.iteritems(): new_callers[func] = caller for func, caller in source.iteritems(): if func in new_callers: new_callers[func] = caller + new_callers[func] else: new_callers[func] = caller return new_callers def count_calls(callers): """Sum the caller statistics to get total number of calls received.""" nc = 0 for calls in callers.itervalues(): nc += calls return nc #************************************************************************** # The following functions support printing of reports #************************************************************************** def f8(x): return "%8.3f" % x #************************************************************************** # Statistics browser added by ESR, April 2001 #************************************************************************** if __name__ == '__main__': import cmd try: import readline except ImportError: pass class ProfileBrowser(cmd.Cmd): def __init__(self, profile=None): cmd.Cmd.__init__(self) self.prompt = "% " if profile is not None: self.stats = Stats(profile) self.stream = self.stats.stream else: self.stats = None self.stream = sys.stdout def generic(self, fn, line): args = line.split() processed = [] for term in args: try: processed.append(int(term)) continue except ValueError: pass try: frac = float(term) if frac > 1 or frac < 0: print >> self.stream, "Fraction argument must be in [0, 1]" continue processed.append(frac) continue except ValueError: pass processed.append(term) if self.stats: getattr(self.stats, fn)(*processed) else: print >> self.stream, "No statistics object is loaded." return 0 def generic_help(self): print >> self.stream, "Arguments may be:" print >> self.stream, "* An integer maximum number of entries to print." print >> self.stream, "* A decimal fractional number between 0 and 1, controlling" print >> self.stream, " what fraction of selected entries to print." print >> self.stream, "* A regular expression; only entries with function names" print >> self.stream, " that match it are printed." def do_add(self, line): self.stats.add(line) return 0 def help_add(self): print >> self.stream, "Add profile info from given file to current statistics object." def do_callees(self, line): return self.generic('print_callees', line) def help_callees(self): print >> self.stream, "Print callees statistics from the current stat object." self.generic_help() def do_callers(self, line): return self.generic('print_callers', line) def help_callers(self): print >> self.stream, "Print callers statistics from the current stat object." self.generic_help() def do_EOF(self, line): print >> self.stream, "" return 1 def help_EOF(self): print >> self.stream, "Leave the profile brower." def do_quit(self, line): return 1 def help_quit(self): print >> self.stream, "Leave the profile brower." def do_read(self, line): if line: try: self.stats = Stats(line) except IOError, args: print >> self.stream, args[1] return self.prompt = line + "% " elif len(self.prompt) > 2: line = self.prompt[-2:] else: print >> self.stream, "No statistics object is current -- cannot reload." return 0 def help_read(self): print >> self.stream, "Read in profile data from a specified file." def do_reverse(self, line): self.stats.reverse_order() return 0 def help_reverse(self): print >> self.stream, "Reverse the sort order of the profiling report." def do_sort(self, line): abbrevs = self.stats.get_sort_arg_defs() if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): self.stats.sort_stats(*line.split()) else: print >> self.stream, "Valid sort keys (unique prefixes are accepted):" for (key, value) in Stats.sort_arg_dict_default.iteritems(): print >> self.stream, "%s -- %s" % (key, value[1]) return 0 def help_sort(self): print >> self.stream, "Sort profile data according to specified keys." print >> self.stream, "(Typing `sort' without arguments lists valid keys.)" def complete_sort(self, text, *args): return [a for a in Stats.sort_arg_dict_default if a.startswith(text)] def do_stats(self, line): return self.generic('print_stats', line) def help_stats(self): print >> self.stream, "Print statistics from the current stat object." self.generic_help() def do_strip(self, line): self.stats.strip_dirs() return 0 def help_strip(self): print >> self.stream, "Strip leading path information from filenames in the report." def postcmd(self, stop, line): if stop: return stop return None import sys if len(sys.argv) > 1: initprofile = sys.argv[1] else: initprofile = None try: browser = ProfileBrowser(initprofile) print >> browser.stream, "Welcome to the profile statistics browser." browser.cmdloop() print >> browser.stream, "Goodbye." except KeyboardInterrupt: pass # That's all, folks.
mit
[ 624, 2543, 367, 16116, 13924, 641, 4690, 68, 2366, 1233, 1041, 199, 199, 3, 8089, 367, 16116, 13924, 641, 4690, 68, 2366, 1233, 14, 6822, 413, 14, 16, 221, 841, 15, 17, 15, 2635, 199, 3, 199, 3, 21311, 641, 6791, 4690, 859, 701, 428, 743, 281, 68, 22578, 24912, 1396, 199, 3, 257, 1314, 1990, 11176, 379, 30362, 701, 26, 598, 1535, 79, 20744, 6848, 385, 453, 199, 3, 199, 3, 1937, 4690, 14, 1301, 436, 4690, 14, 647, 367, 1655, 2256, 14, 199, 199, 3, 1898, 9013, 20, 12, 701, 10332, 19168, 11098, 12, 1006, 4481, 4644, 14, 199, 3, 27694, 701, 1603, 14015, 820, 736, 5091, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2018, 2032, 199, 3, 436, 2399, 4568, 3794, 367, 1263, 12016, 334, 5875, 370, 314, 199, 3, 10588, 315, 314, 2569, 14537, 9, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 1006, 6866, 12, 436, 199, 3, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 199, 3, 21038, 3794, 12, 436, 626, 314, 536, 402, 10332, 19168, 440, 506, 1202, 315, 199, 3, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 4084, 402, 314, 2032, 199, 3, 1928, 2488, 12, 5313, 6791, 4983, 14, 221, 961, 4983, 365, 199, 3, 7662, 15297, 370, 314, 16743, 436, 7100, 402, 314, 2032, 199, 3, 370, 5706, 315, 2018, 12, 10311, 2018, 12, 503, 1163, 10815, 334, 10180, 465, 445, 9, 199, 3, 2382, 262, 314, 6042, 503, 7131, 1233, 365, 444, 1016, 9840, 8439, 1901, 282, 199, 3, 2018, 859, 14, 199, 3, 199, 3, 24008, 18439, 27072, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 2401, 199, 3, 3092, 14, 1621, 4825, 6461, 7000, 24008, 18439, 27072, 6262, 7024, 2381, 1821, 199, 3, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 28752, 4118, 27362, 199, 3, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 9612, 1634, 199, 3, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 421, 199, 646, 984, 199, 646, 747, 199, 646, 900, 199, 646, 21985, 199, 646, 295, 199, 199, 363, 452, 363, 275, 2097, 8257, 937, 199, 199, 533, 29062, 26, 272, 408, 2765, 1021, 365, 1202, 367, 6425, 13924, 687, 666, 4046, 701, 314, 272, 14386, 1021, 14, 221, 2779, 365, 282, 298, 23472, 2, 402, 626, 1021, 12, 436, 8925, 666, 1902, 272, 701, 4125, 2879, 370, 7556, 402, 14386, 1021, 12, 503, 701, 7664, 315, 282, 2600, 272, 626, 1990, 19515, 334, 12897, 21985, 9, 687, 314, 14386, 1021, 14, 339, 710, 7282, 1570, 687, 314, 4136, 14386, 82, 334, 262, 2895, 402, 3066, 9330, 9, 272, 365, 626, 376, 298, 525, 16493, 1083, 965, 2757, 2741, 370, 13323, 29062, 687, 272, 9978, 15392, 4690, 7858, 14, 221, 17650, 314, 3787, 436, 314, 1050, 342, 272, 1083, 3063, 5452, 601, 2075, 82, 11406, 5002, 570, 1561, 465, 2368, 14, 339, 2900, 314, 870, 3102, 3063, 5452, 376, 1423, 626, 9126, 4212, 5002, 2385, 272, 370, 870, 14, 221, 982, 314, 1680, 365, 282, 8402, 2376, 1329, 3382, 378, 436, 413, 14, 16, 12, 2066, 272, 652, 365, 9394, 465, 282, 6107, 16327, 402, 314, 2808, 2385, 370, 506, 12487, 272, 334, 69, 14, 71, 2020, 1275, 17, 4910, 870, 1616, 5, 402, 1006, 2808, 2385, 680, 221, 982, 652, 365, 376, 3000, 12, 272, 652, 365, 9394, 370, 4615, 314, 1329, 402, 2385, 402, 666, 626, 1265, 13809, 370, 1172, 272, 12487, 14, 339, 710, 4069, 63, 3200, 342, 1083, 3063, 10358, 2005, 4722, 1511, 334, 73, 14, 69, 2020, 315, 272, 10234, 370, 314, 2269, 446, 17, 12, 378, 12, 413, 12, 503, 499, 680, 221, 2779, 6181, 376, 9697, 1329, 402, 272, 10999, 3326, 370, 3504, 314, 4069, 1865, 14, 221, 2104, 2893, 4069, 63, 3200, 360, 521, 297, 272, 283, 354, 358, 30313, 641, 314, 12160, 790, 402, 283, 4672, 805, 900, 297, 436, 641, 314, 272, 12612, 790, 402, 283, 1589, 536, 402, 314, 805, 1370, 221, 12077, 737, 314, 2877, 6716, 315, 272, 4069, 63, 3200, 342, 436, 664, 63, 3191, 63, 1273, 63, 8710, 8, 277, 9, 367, 1655, 7251, 14, 339, 2900, 3102, 372, 291, 12, 221, 880, 1265, 883, 1059, 10451, 3718, 2839, 26, 267, 29062, 360, 1421, 297, 283, 29546, 1959, 1913, 63, 3220, 1252, 3191, 63, 3200, 360, 5352, 1959, 60, 1169, 870, 63, 3200, 8, 21, 680, 1361, 63, 11219, 83, 8, 21, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 327, 473, 883, 1133, 9658, 734, 4212, 370, 1437, 6960, 590, 4165, 282, 2547, 4252, 1680, 267, 327, 543, 627, 589, 26, 267, 327, 257, 347, 636, 826, 721, 277, 12, 627, 589, 12, 2547, 29, 1274, 14, 2703, 304, 2263, 267, 327, 880, 473, 675, 1011, 10340, 436, 5295, 3844, 14947, 340, 6020, 10537, 365, 3032, 315, 14, 267, 291, 14, 1745, 275, 984, 14, 2703, 267, 340, 298, 1745, 2, 315, 16286, 26, 288, 291, 14, 1745, 275, 16286, 905, 1745, 937, 288, 2150, 16286, 905, 1745, 937, 267, 340, 16286, 26, 288, 2883, 275, 16286, 14, 1612, 342, 288, 2883, 14, 3191, 342, 288, 13751, 275, 3872, 3680, 904, 30387, 83, 2458, 83, 2, 450, 334, 75, 12, 16286, 59, 75, 566, 367, 1022, 315, 2883, 566, 288, 746, 1722, 12, 298, 324, 13221, 4252, 1249, 26, 450, 83, 2, 450, 13751, 267, 340, 440, 822, 8, 589, 304, 288, 1680, 275, 488, 267, 587, 26, 288, 1680, 275, 1249, 59, 16, 61, 288, 1249, 275, 1249, 59, 17, 2938, 267, 291, 14, 826, 8, 1273, 9, 267, 291, 14, 525, 2031, 589, 9, 339, 347, 4205, 8, 277, 12, 1680, 304, 267, 291, 14, 452, 63, 915, 274, 397, 275, 488, 221, 327, 12831, 1454, 340, 4346, 267, 291, 14, 1725, 275, 942, 267, 291, 14, 26554, 63, 513, 275 ]
[ 2543, 367, 16116, 13924, 641, 4690, 68, 2366, 1233, 1041, 199, 199, 3, 8089, 367, 16116, 13924, 641, 4690, 68, 2366, 1233, 14, 6822, 413, 14, 16, 221, 841, 15, 17, 15, 2635, 199, 3, 199, 3, 21311, 641, 6791, 4690, 859, 701, 428, 743, 281, 68, 22578, 24912, 1396, 199, 3, 257, 1314, 1990, 11176, 379, 30362, 701, 26, 598, 1535, 79, 20744, 6848, 385, 453, 199, 3, 199, 3, 1937, 4690, 14, 1301, 436, 4690, 14, 647, 367, 1655, 2256, 14, 199, 199, 3, 1898, 9013, 20, 12, 701, 10332, 19168, 11098, 12, 1006, 4481, 4644, 14, 199, 3, 27694, 701, 1603, 14015, 820, 736, 5091, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2018, 2032, 199, 3, 436, 2399, 4568, 3794, 367, 1263, 12016, 334, 5875, 370, 314, 199, 3, 10588, 315, 314, 2569, 14537, 9, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 1006, 6866, 12, 436, 199, 3, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 199, 3, 21038, 3794, 12, 436, 626, 314, 536, 402, 10332, 19168, 440, 506, 1202, 315, 199, 3, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 4084, 402, 314, 2032, 199, 3, 1928, 2488, 12, 5313, 6791, 4983, 14, 221, 961, 4983, 365, 199, 3, 7662, 15297, 370, 314, 16743, 436, 7100, 402, 314, 2032, 199, 3, 370, 5706, 315, 2018, 12, 10311, 2018, 12, 503, 1163, 10815, 334, 10180, 465, 445, 9, 199, 3, 2382, 262, 314, 6042, 503, 7131, 1233, 365, 444, 1016, 9840, 8439, 1901, 282, 199, 3, 2018, 859, 14, 199, 3, 199, 3, 24008, 18439, 27072, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 2401, 199, 3, 3092, 14, 1621, 4825, 6461, 7000, 24008, 18439, 27072, 6262, 7024, 2381, 1821, 199, 3, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 28752, 4118, 27362, 199, 3, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 9612, 1634, 199, 3, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 421, 199, 646, 984, 199, 646, 747, 199, 646, 900, 199, 646, 21985, 199, 646, 295, 199, 199, 363, 452, 363, 275, 2097, 8257, 937, 199, 199, 533, 29062, 26, 272, 408, 2765, 1021, 365, 1202, 367, 6425, 13924, 687, 666, 4046, 701, 314, 272, 14386, 1021, 14, 221, 2779, 365, 282, 298, 23472, 2, 402, 626, 1021, 12, 436, 8925, 666, 1902, 272, 701, 4125, 2879, 370, 7556, 402, 14386, 1021, 12, 503, 701, 7664, 315, 282, 2600, 272, 626, 1990, 19515, 334, 12897, 21985, 9, 687, 314, 14386, 1021, 14, 339, 710, 7282, 1570, 687, 314, 4136, 14386, 82, 334, 262, 2895, 402, 3066, 9330, 9, 272, 365, 626, 376, 298, 525, 16493, 1083, 965, 2757, 2741, 370, 13323, 29062, 687, 272, 9978, 15392, 4690, 7858, 14, 221, 17650, 314, 3787, 436, 314, 1050, 342, 272, 1083, 3063, 5452, 601, 2075, 82, 11406, 5002, 570, 1561, 465, 2368, 14, 339, 2900, 314, 870, 3102, 3063, 5452, 376, 1423, 626, 9126, 4212, 5002, 2385, 272, 370, 870, 14, 221, 982, 314, 1680, 365, 282, 8402, 2376, 1329, 3382, 378, 436, 413, 14, 16, 12, 2066, 272, 652, 365, 9394, 465, 282, 6107, 16327, 402, 314, 2808, 2385, 370, 506, 12487, 272, 334, 69, 14, 71, 2020, 1275, 17, 4910, 870, 1616, 5, 402, 1006, 2808, 2385, 680, 221, 982, 652, 365, 376, 3000, 12, 272, 652, 365, 9394, 370, 4615, 314, 1329, 402, 2385, 402, 666, 626, 1265, 13809, 370, 1172, 272, 12487, 14, 339, 710, 4069, 63, 3200, 342, 1083, 3063, 10358, 2005, 4722, 1511, 334, 73, 14, 69, 2020, 315, 272, 10234, 370, 314, 2269, 446, 17, 12, 378, 12, 413, 12, 503, 499, 680, 221, 2779, 6181, 376, 9697, 1329, 402, 272, 10999, 3326, 370, 3504, 314, 4069, 1865, 14, 221, 2104, 2893, 4069, 63, 3200, 360, 521, 297, 272, 283, 354, 358, 30313, 641, 314, 12160, 790, 402, 283, 4672, 805, 900, 297, 436, 641, 314, 272, 12612, 790, 402, 283, 1589, 536, 402, 314, 805, 1370, 221, 12077, 737, 314, 2877, 6716, 315, 272, 4069, 63, 3200, 342, 436, 664, 63, 3191, 63, 1273, 63, 8710, 8, 277, 9, 367, 1655, 7251, 14, 339, 2900, 3102, 372, 291, 12, 221, 880, 1265, 883, 1059, 10451, 3718, 2839, 26, 267, 29062, 360, 1421, 297, 283, 29546, 1959, 1913, 63, 3220, 1252, 3191, 63, 3200, 360, 5352, 1959, 60, 1169, 870, 63, 3200, 8, 21, 680, 1361, 63, 11219, 83, 8, 21, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 327, 473, 883, 1133, 9658, 734, 4212, 370, 1437, 6960, 590, 4165, 282, 2547, 4252, 1680, 267, 327, 543, 627, 589, 26, 267, 327, 257, 347, 636, 826, 721, 277, 12, 627, 589, 12, 2547, 29, 1274, 14, 2703, 304, 2263, 267, 327, 880, 473, 675, 1011, 10340, 436, 5295, 3844, 14947, 340, 6020, 10537, 365, 3032, 315, 14, 267, 291, 14, 1745, 275, 984, 14, 2703, 267, 340, 298, 1745, 2, 315, 16286, 26, 288, 291, 14, 1745, 275, 16286, 905, 1745, 937, 288, 2150, 16286, 905, 1745, 937, 267, 340, 16286, 26, 288, 2883, 275, 16286, 14, 1612, 342, 288, 2883, 14, 3191, 342, 288, 13751, 275, 3872, 3680, 904, 30387, 83, 2458, 83, 2, 450, 334, 75, 12, 16286, 59, 75, 566, 367, 1022, 315, 2883, 566, 288, 746, 1722, 12, 298, 324, 13221, 4252, 1249, 26, 450, 83, 2, 450, 13751, 267, 340, 440, 822, 8, 589, 304, 288, 1680, 275, 488, 267, 587, 26, 288, 1680, 275, 1249, 59, 16, 61, 288, 1249, 275, 1249, 59, 17, 2938, 267, 291, 14, 826, 8, 1273, 9, 267, 291, 14, 525, 2031, 589, 9, 339, 347, 4205, 8, 277, 12, 1680, 304, 267, 291, 14, 452, 63, 915, 274, 397, 275, 488, 221, 327, 12831, 1454, 340, 4346, 267, 291, 14, 1725, 275, 942, 267, 291, 14, 26554, 63, 513, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
MJuddBooth/pandas
pandas/tests/series/test_block_internals.py
2
1472
# -*- coding: utf-8 -*- import pandas as pd # Segregated collection of methods that require the BlockManager internal data # structure class TestSeriesBlockInternals(object): def test_setitem_invalidates_datetime_index_freq(self): # GH#24096 altering a datetime64tz Series inplace invalidates the # `freq` attribute on the underlying DatetimeIndex dti = pd.date_range('20130101', periods=3, tz='US/Eastern') ts = dti[1] ser = pd.Series(dti) assert ser._values is not dti assert ser._values._data.base is not dti._data._data.base assert dti.freq == 'D' ser.iloc[1] = pd.NaT assert ser._values.freq is None # check that the DatetimeIndex was not altered in place assert ser._values is not dti assert ser._values._data.base is not dti._data._data.base assert dti[1] == ts assert dti.freq == 'D' def test_dt64tz_setitem_does_not_mutate_dti(self): # GH#21907, GH#24096 dti = pd.date_range('2016-01-01', periods=10, tz='US/Pacific') ts = dti[0] ser = pd.Series(dti) assert ser._values is not dti assert ser._values._data.base is not dti._data._data.base assert ser._data.blocks[0].values is not dti assert (ser._data.blocks[0].values._data.base is not dti._data._data.base) ser[::3] = pd.NaT assert ser[0] is pd.NaT assert dti[0] == ts
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 10634, 465, 6454, 199, 199, 3, 3240, 3939, 972, 3245, 402, 3102, 626, 4409, 314, 8651, 2988, 5007, 666, 199, 3, 5523, 421, 199, 533, 1379, 9641, 3142, 8405, 83, 8, 785, 304, 339, 347, 511, 63, 8617, 63, 3197, 2335, 63, 2083, 63, 1080, 63, 5646, 8, 277, 304, 267, 327, 20321, 3, 1194, 9211, 17355, 316, 282, 2197, 772, 3903, 12403, 16304, 3866, 2335, 314, 267, 327, 221, 658, 5646, 64, 2225, 641, 314, 8793, 29825, 2681, 398, 366, 280, 275, 6454, 14, 602, 63, 1842, 360, 6965, 11502, 297, 17382, 29, 19, 12, 5823, 534, 1668, 15, 32661, 358, 267, 6714, 275, 366, 280, 59, 17, 61, 267, 8926, 275, 6454, 14, 9641, 8, 68, 280, 9, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 366, 280, 14, 5646, 508, 283, 36, 7, 267, 8926, 14, 21104, 59, 17, 61, 275, 6454, 14, 25638, 267, 702, 8926, 423, 1459, 14, 5646, 365, 488, 398, 327, 1104, 626, 314, 29825, 2681, 1990, 440, 29815, 315, 4192, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 366, 280, 59, 17, 61, 508, 6714, 267, 702, 366, 280, 14, 5646, 508, 283, 36, 7, 339, 347, 511, 63, 3583, 772, 3903, 63, 8617, 63, 9105, 63, 1397, 63, 6552, 323, 63, 68, 280, 8, 277, 304, 267, 327, 20321, 3, 8867, 1780, 12, 20321, 3, 1194, 9211, 267, 366, 280, 275, 6454, 14, 602, 63, 1842, 360, 9261, 13, 614, 13, 614, 297, 17382, 29, 709, 12, 5823, 534, 1668, 15, 20687, 358, 267, 6714, 275, 366, 280, 59, 16, 61, 267, 8926, 275, 6454, 14, 9641, 8, 68, 280, 9, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 8926, 423, 576, 14, 4166, 59, 16, 1055, 1459, 365, 440, 366, 280, 267, 702, 334, 332, 423, 576, 14, 4166, 59, 16, 1055, 1459, 423, 576, 14, 1095, 355, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 9, 398, 8926, 10345, 19, 61, 275, 6454, 14, 25638, 267, 702, 8926, 59, 16, 61, 365, 6454, 14, 25638, 267, 702, 366, 280, 59, 16, 61, 508, 6714, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 10634, 465, 6454, 199, 199, 3, 3240, 3939, 972, 3245, 402, 3102, 626, 4409, 314, 8651, 2988, 5007, 666, 199, 3, 5523, 421, 199, 533, 1379, 9641, 3142, 8405, 83, 8, 785, 304, 339, 347, 511, 63, 8617, 63, 3197, 2335, 63, 2083, 63, 1080, 63, 5646, 8, 277, 304, 267, 327, 20321, 3, 1194, 9211, 17355, 316, 282, 2197, 772, 3903, 12403, 16304, 3866, 2335, 314, 267, 327, 221, 658, 5646, 64, 2225, 641, 314, 8793, 29825, 2681, 398, 366, 280, 275, 6454, 14, 602, 63, 1842, 360, 6965, 11502, 297, 17382, 29, 19, 12, 5823, 534, 1668, 15, 32661, 358, 267, 6714, 275, 366, 280, 59, 17, 61, 267, 8926, 275, 6454, 14, 9641, 8, 68, 280, 9, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 366, 280, 14, 5646, 508, 283, 36, 7, 267, 8926, 14, 21104, 59, 17, 61, 275, 6454, 14, 25638, 267, 702, 8926, 423, 1459, 14, 5646, 365, 488, 398, 327, 1104, 626, 314, 29825, 2681, 1990, 440, 29815, 315, 4192, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 366, 280, 59, 17, 61, 508, 6714, 267, 702, 366, 280, 14, 5646, 508, 283, 36, 7, 339, 347, 511, 63, 3583, 772, 3903, 63, 8617, 63, 9105, 63, 1397, 63, 6552, 323, 63, 68, 280, 8, 277, 304, 267, 327, 20321, 3, 8867, 1780, 12, 20321, 3, 1194, 9211, 267, 366, 280, 275, 6454, 14, 602, 63, 1842, 360, 9261, 13, 614, 13, 614, 297, 17382, 29, 709, 12, 5823, 534, 1668, 15, 20687, 358, 267, 6714, 275, 366, 280, 59, 16, 61, 267, 8926, 275, 6454, 14, 9641, 8, 68, 280, 9, 267, 702, 8926, 423, 1459, 365, 440, 366, 280, 267, 702, 8926, 423, 1459, 423, 576, 14, 1095, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 267, 702, 8926, 423, 576, 14, 4166, 59, 16, 1055, 1459, 365, 440, 366, 280, 267, 702, 334, 332, 423, 576, 14, 4166, 59, 16, 1055, 1459, 423, 576, 14, 1095, 355, 365, 440, 366, 280, 423, 576, 423, 576, 14, 1095, 9, 398, 8926, 10345, 19, 61, 275, 6454, 14, 25638, 267, 702, 8926, 59, 16, 61, 365, 6454, 14, 25638, 267, 702, 366, 280, 59, 16, 61, 508, 6714, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
j-rock/cs598ps
src/py/main.py
1
4059
import sys import time from cssigps.offlineclassifier import * from cssigps.dataset import * from cssigps.feature import * from cssigps.experiments import * from get_dropbox_path import * def print_usage(): """ Print the usage for the main script. """ print("USAGE: use the run.sh or the main.py directly.") print("") print(" run.sh <EXPERIMENT_NUMBER>") print(" python main.py <EXPERIMENT_NUMBER>") if __name__ == '__main__': # decide which experiment to run based on the command line or user-input response = "" if len(sys.argv) >= 2: response=sys.argv[1] if response in ["-h","--help"]: print_usage() quit() else: prompt = "Which experiment would you like to run? [0-2]" response = raw_input(prompt) # run experiment if response == "0": path=get_dropbox_path()+"old-test/" run_experiment_0(path) elif response == "1": run_experiment_1(include_none=True) elif response == "2": run_experiment_2() elif response == "3": run_experiment_3() elif response == "4": run_experiment_4() elif response == "5": path=get_dropbox_path()+"vowels-test/" run_offline_svm(path) elif response == "S": # run single class classifier c = sys.argv[2] f = sys.argv[3] classes=["NONE"] path=get_dropbox_path()+"yes-no-test/" factory = FBankFeature() # select the class if c == "Y": path=get_dropbox_path()+"yes-no-test/" classes.append("Y") elif c=="N": path=get_dropbox_path()+"yes-no-test/" classes.append("N") elif c=="A": path=get_dropbox_path()+"vowels-test/" classes=["A","NONE"] elif c=="E": path=get_dropbox_path()+"vowels-test/" classes=["E","NONE"] elif c=="I": path=get_dropbox_path()+"vowels-test/" classes=["I","NONE"] elif c=="O": path=get_dropbox_path()+"vowels-test/" classes=["O","NONE"] elif c=="U": path=get_dropbox_path()+"vowels-test/" classes=["U","NONE"] else: print("class argument invalid") quit() # select the feature if f == "fbank": factory=FBankFeature() elif f == "m" or f == "magnitude": factory=MagnitudeFeature() elif f == "t" or f == "template": factory=MultiTemplateFeature(SampleSet(find_testsamples(path),classes=classes).class_rep()) else: print("feature argument invalid") samples = find_testsamples(path) sample_set = SampleSet(samples,classes=classes) sample_set.stats() run_sample_experiment(sample_set,feat_factory=factory) elif response == "M": # run multi class classifier c = sys.argv[2] f = sys.argv[3] classes=["NONE"] path=get_dropbox_path()+"yes-no-test/" factory = FBankFeature() # select the class if c == "Y": path=get_dropbox_path()+"yes-no-test/" classes=["Y","N","NONE"] elif c=="A": path=get_dropbox_path()+"vowels-test/" classes=["A","E","I","O","U","NONE"] else: print("class argument invalid") quit() samples = find_testsamples(path) sample_set = SampleSet(samples,classes=classes) sample_set.stats() # select the feature if f == "fbank": factory=FBankFeature() elif f == "m" or f == "magnitude": factory=MagnitudeFeature() elif f == "t" or f == "template": factory=MultiTemplateFeature(SampleSet(find_testsamples(path),classes=classes).class_rep()) else: print("feature argument invalid") run_sample_experiment(sample_set,feat_factory=factory) else: print("Invalid option. Aborting..")
mit
[ 646, 984, 199, 646, 900, 199, 199, 504, 7117, 4093, 1190, 14, 18430, 14720, 492, 627, 199, 504, 7117, 4093, 1190, 14, 5214, 492, 627, 199, 504, 7117, 4093, 1190, 14, 4445, 492, 627, 199, 504, 7117, 4093, 1190, 14, 476, 22263, 492, 627, 199, 504, 664, 63, 32118, 63, 515, 492, 627, 199, 199, 318, 870, 63, 3807, 837, 272, 408, 272, 9101, 314, 4503, 367, 314, 2446, 2884, 14, 272, 408, 272, 870, 480, 20274, 26, 675, 314, 1255, 14, 609, 503, 314, 2446, 14, 647, 5370, 2685, 272, 870, 10804, 272, 870, 480, 221, 1255, 14, 609, 665, 28722, 1309, 63, 9190, 9579, 272, 870, 480, 221, 2366, 2446, 14, 647, 665, 28722, 1309, 63, 9190, 9579, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 327, 19822, 1314, 11805, 370, 1255, 4079, 641, 314, 1414, 1004, 503, 922, 13, 1210, 272, 1177, 275, 3087, 272, 340, 822, 8, 1274, 14, 3020, 9, 2356, 499, 26, 267, 1177, 29, 1274, 14, 3020, 59, 17, 61, 267, 340, 1177, 315, 16984, 72, 2266, 306, 3437, 6229, 1467, 870, 63, 3807, 342, 1467, 17242, 342, 272, 587, 26, 267, 8457, 275, 298, 31619, 11805, 3955, 1265, 2839, 370, 1255, 31, 359, 16, 13, 18, 8480, 267, 1177, 275, 3066, 63, 1210, 8, 7650, 9, 339, 327, 1255, 11805, 272, 340, 1177, 508, 298, 16, 582, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 1753, 13, 396, 6687, 267, 1255, 63, 10873, 63, 16, 8, 515, 9, 272, 916, 1177, 508, 298, 17, 582, 267, 1255, 63, 10873, 63, 17, 8, 2613, 63, 3592, 29, 549, 9, 272, 916, 1177, 508, 298, 18, 582, 267, 1255, 63, 10873, 63, 18, 342, 272, 916, 1177, 508, 298, 19, 582, 267, 1255, 63, 10873, 63, 19, 342, 272, 916, 1177, 508, 298, 20, 582, 267, 1255, 63, 10873, 63, 20, 342, 272, 916, 1177, 508, 298, 21, 582, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 267, 1255, 63, 18430, 63, 16820, 8, 515, 9, 272, 916, 1177, 508, 298, 51, 582, 267, 327, 1255, 2849, 1021, 12429, 267, 286, 275, 984, 14, 3020, 59, 18, 61, 267, 289, 275, 984, 14, 3020, 59, 19, 61, 267, 3992, 6270, 9185, 937, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 267, 6434, 275, 481, 14814, 5968, 342, 398, 327, 3504, 314, 1021, 267, 340, 286, 508, 298, 57, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 14, 740, 480, 57, 531, 267, 916, 286, 11800, 46, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 14, 740, 480, 46, 531, 267, 916, 286, 11800, 33, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 33, 2266, 9185, 937, 267, 916, 286, 11800, 37, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 37, 2266, 9185, 937, 267, 916, 286, 11800, 41, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 41, 2266, 9185, 937, 267, 916, 286, 11800, 47, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 47, 2266, 9185, 937, 267, 916, 286, 11800, 53, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 53, 2266, 9185, 937, 267, 587, 26, 288, 870, 480, 533, 1423, 3866, 531, 288, 17242, 342, 398, 327, 3504, 314, 3878, 267, 340, 289, 508, 298, 4675, 3580, 582, 288, 6434, 29, 8223, 3580, 5968, 342, 267, 916, 289, 508, 298, 77, 2, 503, 289, 508, 298, 32167, 582, 288, 6434, 29, 22745, 78, 7779, 5968, 342, 267, 916, 289, 508, 298, 84, 2, 503, 289, 508, 298, 1160, 582, 288, 6434, 29, 3947, 4231, 5968, 8, 8176, 1084, 8, 1623, 63, 2219, 1889, 8, 515, 395, 2888, 29, 2888, 680, 533, 63, 1155, 1012, 267, 587, 26, 288, 870, 480, 4445, 1423, 3866, 531, 7318, 5845, 275, 2342, 63, 2219, 1889, 8, 515, 9, 267, 2690, 63, 409, 275, 15227, 1084, 8, 3356, 12, 2888, 29, 2888, 9, 267, 2690, 63, 409, 14, 3200, 342, 267, 1255, 63, 3271, 63, 10873, 8, 3271, 63, 409, 12, 11873, 63, 3702, 29, 3702, 9, 272, 916, 1177, 508, 298, 45, 582, 267, 327, 1255, 3510, 1021, 12429, 267, 286, 275, 984, 14, 3020, 59, 18, 61, 267, 289, 275, 984, 14, 3020, 59, 19, 61, 267, 3992, 6270, 9185, 937, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 267, 6434, 275, 481, 14814, 5968, 342, 398, 327, 3504, 314, 1021, 267, 340, 286, 508, 298, 57, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 6270, 57, 2266, 46, 2266, 9185, 937, 267, 916, 286, 11800, 33, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 33, 2266, 37, 2266, 41, 2266, 47, 2266, 53, 2266, 9185, 937, 267, 587, 26, 288, 870, 480, 533, 1423, 3866, 531, 288, 17242, 342, 398, 5845, 275, 2342, 63, 2219, 1889, 8, 515, 9, 267, 2690, 63, 409, 275, 15227, 1084, 8, 3356, 12, 2888, 29, 2888, 9, 267, 2690, 63, 409, 14, 3200, 342, 398, 327, 3504, 314, 3878, 267, 340, 289, 508, 298, 4675, 3580, 582, 288, 6434, 29, 8223, 3580, 5968, 342, 267, 916, 289, 508, 298, 77, 2, 503, 289, 508, 298, 32167, 582, 288, 6434, 29, 22745, 78, 7779, 5968, 342, 267, 916, 289, 508, 298, 84, 2, 503, 289, 508, 298, 1160, 582, 288, 6434, 29, 3947, 4231, 5968, 8, 8176, 1084, 8, 1623, 63, 2219, 1889, 8, 515, 395, 2888, 29, 2888, 680, 533, 63, 1155, 1012, 267, 587, 26, 288, 870, 480, 4445, 1423, 3866, 531, 398, 1255 ]
[ 984, 199, 646, 900, 199, 199, 504, 7117, 4093, 1190, 14, 18430, 14720, 492, 627, 199, 504, 7117, 4093, 1190, 14, 5214, 492, 627, 199, 504, 7117, 4093, 1190, 14, 4445, 492, 627, 199, 504, 7117, 4093, 1190, 14, 476, 22263, 492, 627, 199, 504, 664, 63, 32118, 63, 515, 492, 627, 199, 199, 318, 870, 63, 3807, 837, 272, 408, 272, 9101, 314, 4503, 367, 314, 2446, 2884, 14, 272, 408, 272, 870, 480, 20274, 26, 675, 314, 1255, 14, 609, 503, 314, 2446, 14, 647, 5370, 2685, 272, 870, 10804, 272, 870, 480, 221, 1255, 14, 609, 665, 28722, 1309, 63, 9190, 9579, 272, 870, 480, 221, 2366, 2446, 14, 647, 665, 28722, 1309, 63, 9190, 9579, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 327, 19822, 1314, 11805, 370, 1255, 4079, 641, 314, 1414, 1004, 503, 922, 13, 1210, 272, 1177, 275, 3087, 272, 340, 822, 8, 1274, 14, 3020, 9, 2356, 499, 26, 267, 1177, 29, 1274, 14, 3020, 59, 17, 61, 267, 340, 1177, 315, 16984, 72, 2266, 306, 3437, 6229, 1467, 870, 63, 3807, 342, 1467, 17242, 342, 272, 587, 26, 267, 8457, 275, 298, 31619, 11805, 3955, 1265, 2839, 370, 1255, 31, 359, 16, 13, 18, 8480, 267, 1177, 275, 3066, 63, 1210, 8, 7650, 9, 339, 327, 1255, 11805, 272, 340, 1177, 508, 298, 16, 582, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 1753, 13, 396, 6687, 267, 1255, 63, 10873, 63, 16, 8, 515, 9, 272, 916, 1177, 508, 298, 17, 582, 267, 1255, 63, 10873, 63, 17, 8, 2613, 63, 3592, 29, 549, 9, 272, 916, 1177, 508, 298, 18, 582, 267, 1255, 63, 10873, 63, 18, 342, 272, 916, 1177, 508, 298, 19, 582, 267, 1255, 63, 10873, 63, 19, 342, 272, 916, 1177, 508, 298, 20, 582, 267, 1255, 63, 10873, 63, 20, 342, 272, 916, 1177, 508, 298, 21, 582, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 267, 1255, 63, 18430, 63, 16820, 8, 515, 9, 272, 916, 1177, 508, 298, 51, 582, 267, 327, 1255, 2849, 1021, 12429, 267, 286, 275, 984, 14, 3020, 59, 18, 61, 267, 289, 275, 984, 14, 3020, 59, 19, 61, 267, 3992, 6270, 9185, 937, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 267, 6434, 275, 481, 14814, 5968, 342, 398, 327, 3504, 314, 1021, 267, 340, 286, 508, 298, 57, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 14, 740, 480, 57, 531, 267, 916, 286, 11800, 46, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 14, 740, 480, 46, 531, 267, 916, 286, 11800, 33, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 33, 2266, 9185, 937, 267, 916, 286, 11800, 37, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 37, 2266, 9185, 937, 267, 916, 286, 11800, 41, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 41, 2266, 9185, 937, 267, 916, 286, 11800, 47, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 47, 2266, 9185, 937, 267, 916, 286, 11800, 53, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 53, 2266, 9185, 937, 267, 587, 26, 288, 870, 480, 533, 1423, 3866, 531, 288, 17242, 342, 398, 327, 3504, 314, 3878, 267, 340, 289, 508, 298, 4675, 3580, 582, 288, 6434, 29, 8223, 3580, 5968, 342, 267, 916, 289, 508, 298, 77, 2, 503, 289, 508, 298, 32167, 582, 288, 6434, 29, 22745, 78, 7779, 5968, 342, 267, 916, 289, 508, 298, 84, 2, 503, 289, 508, 298, 1160, 582, 288, 6434, 29, 3947, 4231, 5968, 8, 8176, 1084, 8, 1623, 63, 2219, 1889, 8, 515, 395, 2888, 29, 2888, 680, 533, 63, 1155, 1012, 267, 587, 26, 288, 870, 480, 4445, 1423, 3866, 531, 7318, 5845, 275, 2342, 63, 2219, 1889, 8, 515, 9, 267, 2690, 63, 409, 275, 15227, 1084, 8, 3356, 12, 2888, 29, 2888, 9, 267, 2690, 63, 409, 14, 3200, 342, 267, 1255, 63, 3271, 63, 10873, 8, 3271, 63, 409, 12, 11873, 63, 3702, 29, 3702, 9, 272, 916, 1177, 508, 298, 45, 582, 267, 327, 1255, 3510, 1021, 12429, 267, 286, 275, 984, 14, 3020, 59, 18, 61, 267, 289, 275, 984, 14, 3020, 59, 19, 61, 267, 3992, 6270, 9185, 937, 267, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 267, 6434, 275, 481, 14814, 5968, 342, 398, 327, 3504, 314, 1021, 267, 340, 286, 508, 298, 57, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 5066, 13, 889, 13, 396, 6687, 288, 3992, 6270, 57, 2266, 46, 2266, 9185, 937, 267, 916, 286, 11800, 33, 582, 288, 931, 29, 362, 63, 32118, 63, 515, 342, 5207, 28597, 83, 13, 396, 6687, 288, 3992, 6270, 33, 2266, 37, 2266, 41, 2266, 47, 2266, 53, 2266, 9185, 937, 267, 587, 26, 288, 870, 480, 533, 1423, 3866, 531, 288, 17242, 342, 398, 5845, 275, 2342, 63, 2219, 1889, 8, 515, 9, 267, 2690, 63, 409, 275, 15227, 1084, 8, 3356, 12, 2888, 29, 2888, 9, 267, 2690, 63, 409, 14, 3200, 342, 398, 327, 3504, 314, 3878, 267, 340, 289, 508, 298, 4675, 3580, 582, 288, 6434, 29, 8223, 3580, 5968, 342, 267, 916, 289, 508, 298, 77, 2, 503, 289, 508, 298, 32167, 582, 288, 6434, 29, 22745, 78, 7779, 5968, 342, 267, 916, 289, 508, 298, 84, 2, 503, 289, 508, 298, 1160, 582, 288, 6434, 29, 3947, 4231, 5968, 8, 8176, 1084, 8, 1623, 63, 2219, 1889, 8, 515, 395, 2888, 29, 2888, 680, 533, 63, 1155, 1012, 267, 587, 26, 288, 870, 480, 4445, 1423, 3866, 531, 398, 1255, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
StefanRijnhart/OpenUpgrade
addons/account_followup/tests/__init__.py
175
1128
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from . import test_account_followup checks = [ test_account_followup, ] # 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, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 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, 504, 1275, 492, 511, 63, 2048, 63, 25872, 199, 199, 8625, 275, 359, 272, 511, 63, 2048, 63, 25872, 12, 199, 61, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 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, 504, 1275, 492, 511, 63, 2048, 63, 25872, 199, 199, 8625, 275, 359, 272, 511, 63, 2048, 63, 25872, 12, 199, 61, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
valentinas/mediaBam
bs4/dammit.py
36
29653
# -*- coding: utf-8 -*- """Beautiful Soup bonus library: Unicode, Dammit This class forces XML data into a standard format (usually to UTF-8 or Unicode). It is heavily based on code from Mark Pilgrim's Universal Feed Parser. It does not rewrite the XML or HTML to reflect a new encoding; that's the tree builder's job. """ import codecs from htmlentitydefs import codepoint2name import re import warnings # Autodetects character encodings. Very useful. # Download from http://chardet.feedparser.org/ # or 'apt-get install python-chardet' # or 'easy_install chardet' try: import chardet #import chardet.constants #chardet.constants._debug = 1 except ImportError: chardet = None # Available from http://cjkpython.i18n.org/. try: import iconv_codec except ImportError: pass xml_encoding_re = re.compile( '^<\?.*encoding=[\'"](.*?)[\'"].*\?>'.encode(), re.I) html_meta_re = re.compile( '<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I) class EntitySubstitution(object): """Substitute XML or HTML entities for the corresponding characters.""" def _populate_class_variables(): lookup = {} reverse_lookup = {} characters_for_re = [] for codepoint, name in list(codepoint2name.items()): character = unichr(codepoint) if codepoint != 34: # There's no point in turning the quotation mark into # &quot;, unless it happens within an attribute value, which # is handled elsewhere. characters_for_re.append(character) lookup[character] = name # But we do want to turn &quot; into the quotation mark. reverse_lookup[name] = character re_definition = "[%s]" % "".join(characters_for_re) return lookup, reverse_lookup, re.compile(re_definition) (CHARACTER_TO_HTML_ENTITY, HTML_ENTITY_TO_CHARACTER, CHARACTER_TO_HTML_ENTITY_RE) = _populate_class_variables() CHARACTER_TO_XML_ENTITY = { "'": "apos", '"': "quot", "&": "amp", "<": "lt", ">": "gt", } BARE_AMPERSAND_OR_BRACKET = re.compile("([<>]|" "&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)" ")") @classmethod def _substitute_html_entity(cls, matchobj): entity = cls.CHARACTER_TO_HTML_ENTITY.get(matchobj.group(0)) return "&%s;" % entity @classmethod def _substitute_xml_entity(cls, matchobj): """Used with a regular expression to substitute the appropriate XML entity for an XML special character.""" entity = cls.CHARACTER_TO_XML_ENTITY[matchobj.group(0)] return "&%s;" % entity @classmethod def quoted_attribute_value(self, value): """Make a value into a quoted XML attribute, possibly escaping it. Most strings will be quoted using double quotes. Bob's Bar -> "Bob's Bar" If a string contains double quotes, it will be quoted using single quotes. Welcome to "my bar" -> 'Welcome to "my bar"' If a string contains both single and double quotes, the double quotes will be escaped, and the string will be quoted using double quotes. Welcome to "Bob's Bar" -> "Welcome to &quot;Bob's bar&quot; """ quote_with = '"' if '"' in value: if "'" in value: # The string contains both single and double # quotes. Turn the double quotes into # entities. We quote the double quotes rather than # the single quotes because the entity name is # "&quot;" whether this is HTML or XML. If we # quoted the single quotes, we'd have to decide # between &apos; and &squot;. replace_with = "&quot;" value = value.replace('"', replace_with) else: # There are double quotes but no single quotes. # We can use single quotes to quote the attribute. quote_with = "'" return quote_with + value + quote_with @classmethod def substitute_xml(cls, value, make_quoted_attribute=False): """Substitute XML entities for special XML characters. :param value: A string to be substituted. The less-than sign will become &lt;, the greater-than sign will become &gt;, and any ampersands that are not part of an entity defition will become &amp;. :param make_quoted_attribute: If True, then the string will be quoted, as befits an attribute value. """ # Escape angle brackets, and ampersands that aren't part of # entities. value = cls.BARE_AMPERSAND_OR_BRACKET.sub( cls._substitute_xml_entity, value) if make_quoted_attribute: value = cls.quoted_attribute_value(value) return value @classmethod def substitute_html(cls, s): """Replace certain Unicode characters with named HTML entities. This differs from data.encode(encoding, 'xmlcharrefreplace') in that the goal is to make the result more readable (to those with ASCII displays) rather than to recover from errors. There's absolutely nothing wrong with a UTF-8 string containg a LATIN SMALL LETTER E WITH ACUTE, but replacing that character with "&eacute;" will make it more readable to some people. """ return cls.CHARACTER_TO_HTML_ENTITY_RE.sub( cls._substitute_html_entity, s) class UnicodeDammit: """A class for detecting the encoding of a *ML document and converting it to a Unicode string. If the source encoding is windows-1252, can replace MS smart quotes with their HTML or XML equivalents.""" # This dictionary maps commonly seen values for "charset" in HTML # meta tags to the corresponding Python codec names. It only covers # values that aren't in Python's aliases and can't be determined # by the heuristics in find_codec. CHARSET_ALIASES = {"macintosh": "mac-roman", "x-sjis": "shift-jis"} ENCODINGS_WITH_SMART_QUOTES = [ "windows-1252", "iso-8859-1", "iso-8859-2", ] def __init__(self, markup, override_encodings=[], smart_quotes_to=None, is_html=False): self.declared_html_encoding = None self.smart_quotes_to = smart_quotes_to self.tried_encodings = [] self.contains_replacement_characters = False if markup == '' or isinstance(markup, unicode): self.markup = markup self.unicode_markup = unicode(markup) self.original_encoding = None return new_markup, document_encoding, sniffed_encoding = \ self._detectEncoding(markup, is_html) self.markup = new_markup u = None if new_markup != markup: # _detectEncoding modified the markup, then converted it to # Unicode and then to UTF-8. So convert it from UTF-8. u = self._convert_from("utf8") self.original_encoding = sniffed_encoding if not u: for proposed_encoding in ( override_encodings + [document_encoding, sniffed_encoding]): if proposed_encoding is not None: u = self._convert_from(proposed_encoding) if u: break # If no luck and we have auto-detection library, try that: if not u and chardet and not isinstance(self.markup, unicode): u = self._convert_from(chardet.detect(self.markup)['encoding']) # As a last resort, try utf-8 and windows-1252: if not u: for proposed_encoding in ("utf-8", "windows-1252"): u = self._convert_from(proposed_encoding) if u: break # As an absolute last resort, try the encodings again with # character replacement. if not u: for proposed_encoding in ( override_encodings + [ document_encoding, sniffed_encoding, "utf-8", "windows-1252"]): if proposed_encoding != "ascii": u = self._convert_from(proposed_encoding, "replace") if u is not None: warnings.warn( UnicodeWarning( "Some characters could not be decoded, and were " "replaced with REPLACEMENT CHARACTER.")) self.contains_replacement_characters = True break # We could at this point force it to ASCII, but that would # destroy so much data that I think giving up is better self.unicode_markup = u if not u: self.original_encoding = None def _sub_ms_char(self, match): """Changes a MS smart quote character to an XML or HTML entity, or an ASCII character.""" orig = match.group(1) if self.smart_quotes_to == 'ascii': sub = self.MS_CHARS_TO_ASCII.get(orig).encode() else: sub = self.MS_CHARS.get(orig) if type(sub) == tuple: if self.smart_quotes_to == 'xml': sub = '&#x'.encode() + sub[1].encode() + ';'.encode() else: sub = '&'.encode() + sub[0].encode() + ';'.encode() else: sub = sub.encode() return sub def _convert_from(self, proposed, errors="strict"): proposed = self.find_codec(proposed) if not proposed or (proposed, errors) in self.tried_encodings: return None self.tried_encodings.append((proposed, errors)) markup = self.markup # Convert smart quotes to HTML if coming from an encoding # that might have them. if (self.smart_quotes_to is not None and proposed.lower() in self.ENCODINGS_WITH_SMART_QUOTES): smart_quotes_re = b"([\x80-\x9f])" smart_quotes_compiled = re.compile(smart_quotes_re) markup = smart_quotes_compiled.sub(self._sub_ms_char, markup) try: #print "Trying to convert document to %s (errors=%s)" % ( # proposed, errors) u = self._to_unicode(markup, proposed, errors) self.markup = u self.original_encoding = proposed except Exception as e: #print "That didn't work!" #print e return None #print "Correct encoding: %s" % proposed return self.markup def _to_unicode(self, data, encoding, errors="strict"): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' # strip Byte Order Mark (if present) if (len(data) >= 4) and (data[:2] == '\xfe\xff') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16be' data = data[2:] elif (len(data) >= 4) and (data[:2] == '\xff\xfe') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16le' data = data[2:] elif data[:3] == '\xef\xbb\xbf': encoding = 'utf-8' data = data[3:] elif data[:4] == '\x00\x00\xfe\xff': encoding = 'utf-32be' data = data[4:] elif data[:4] == '\xff\xfe\x00\x00': encoding = 'utf-32le' data = data[4:] newdata = unicode(data, encoding, errors) return newdata def _detectEncoding(self, xml_data, is_html=False): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == b'\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) elif xml_data[:4] == b'\x00\x3c\x00\x3f': # UTF-16BE sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data, 'utf-16be').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == b'\xfe\xff') \ and (xml_data[2:4] != b'\x00\x00'): # UTF-16BE with BOM sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data[2:], 'utf-16be').encode('utf-8') elif xml_data[:4] == b'\x3c\x00\x3f\x00': # UTF-16LE sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data, 'utf-16le').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == b'\xff\xfe') and \ (xml_data[2:4] != b'\x00\x00'): # UTF-16LE with BOM sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data[2:], 'utf-16le').encode('utf-8') elif xml_data[:4] == b'\x00\x00\x00\x3c': # UTF-32BE sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data, 'utf-32be').encode('utf-8') elif xml_data[:4] == b'\x3c\x00\x00\x00': # UTF-32LE sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data, 'utf-32le').encode('utf-8') elif xml_data[:4] == b'\x00\x00\xfe\xff': # UTF-32BE with BOM sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data[4:], 'utf-32be').encode('utf-8') elif xml_data[:4] == b'\xff\xfe\x00\x00': # UTF-32LE with BOM sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data[4:], 'utf-32le').encode('utf-8') elif xml_data[:3] == b'\xef\xbb\xbf': # UTF-8 with BOM sniffed_xml_encoding = 'utf-8' xml_data = unicode(xml_data[3:], 'utf-8').encode('utf-8') else: sniffed_xml_encoding = 'ascii' pass except: xml_encoding_match = None xml_encoding_match = xml_encoding_re.match(xml_data) if not xml_encoding_match and is_html: xml_encoding_match = html_meta_re.search(xml_data) if xml_encoding_match is not None: xml_encoding = xml_encoding_match.groups()[0].decode( 'ascii').lower() if is_html: self.declared_html_encoding = xml_encoding if sniffed_xml_encoding and \ (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode', 'iso-10646-ucs-4', 'ucs-4', 'csucs4', 'utf-16', 'utf-32', 'utf_16', 'utf_32', 'utf16', 'u16')): xml_encoding = sniffed_xml_encoding return xml_data, xml_encoding, sniffed_xml_encoding def find_codec(self, charset): return self._codec(self.CHARSET_ALIASES.get(charset, charset)) \ or (charset and self._codec(charset.replace("-", ""))) \ or (charset and self._codec(charset.replace("-", "_"))) \ or charset def _codec(self, charset): if not charset: return charset codec = None try: codecs.lookup(charset) codec = charset except (LookupError, ValueError): pass return codec EBCDIC_TO_ASCII_MAP = None def _ebcdic_to_ascii(self, s): c = self.__class__ if not c.EBCDIC_TO_ASCII_MAP: emap = (0,1,2,3,156,9,134,127,151,141,142,11,12,13,14,15, 16,17,18,19,157,133,8,135,24,25,146,143,28,29,30,31, 128,129,130,131,132,10,23,27,136,137,138,139,140,5,6,7, 144,145,22,147,148,149,150,4,152,153,154,155,20,21,158,26, 32,160,161,162,163,164,165,166,167,168,91,46,60,40,43,33, 38,169,170,171,172,173,174,175,176,177,93,36,42,41,59,94, 45,47,178,179,180,181,182,183,184,185,124,44,37,95,62,63, 186,187,188,189,190,191,192,193,194,96,58,35,64,39,61,34, 195,97,98,99,100,101,102,103,104,105,196,197,198,199,200, 201,202,106,107,108,109,110,111,112,113,114,203,204,205, 206,207,208,209,126,115,116,117,118,119,120,121,122,210, 211,212,213,214,215,216,217,218,219,220,221,222,223,224, 225,226,227,228,229,230,231,123,65,66,67,68,69,70,71,72, 73,232,233,234,235,236,237,125,74,75,76,77,78,79,80,81, 82,238,239,240,241,242,243,92,159,83,84,85,86,87,88,89, 90,244,245,246,247,248,249,48,49,50,51,52,53,54,55,56,57, 250,251,252,253,254,255) import string c.EBCDIC_TO_ASCII_MAP = string.maketrans( ''.join(map(chr, list(range(256)))), ''.join(map(chr, emap))) return s.translate(c.EBCDIC_TO_ASCII_MAP) # A partial mapping of ISO-Latin-1 to HTML entities/XML numeric entities. MS_CHARS = {b'\x80': ('euro', '20AC'), b'\x81': ' ', b'\x82': ('sbquo', '201A'), b'\x83': ('fnof', '192'), b'\x84': ('bdquo', '201E'), b'\x85': ('hellip', '2026'), b'\x86': ('dagger', '2020'), b'\x87': ('Dagger', '2021'), b'\x88': ('circ', '2C6'), b'\x89': ('permil', '2030'), b'\x8A': ('Scaron', '160'), b'\x8B': ('lsaquo', '2039'), b'\x8C': ('OElig', '152'), b'\x8D': '?', b'\x8E': ('#x17D', '17D'), b'\x8F': '?', b'\x90': '?', b'\x91': ('lsquo', '2018'), b'\x92': ('rsquo', '2019'), b'\x93': ('ldquo', '201C'), b'\x94': ('rdquo', '201D'), b'\x95': ('bull', '2022'), b'\x96': ('ndash', '2013'), b'\x97': ('mdash', '2014'), b'\x98': ('tilde', '2DC'), b'\x99': ('trade', '2122'), b'\x9a': ('scaron', '161'), b'\x9b': ('rsaquo', '203A'), b'\x9c': ('oelig', '153'), b'\x9d': '?', b'\x9e': ('#x17E', '17E'), b'\x9f': ('Yuml', ''),} # A parochial partial mapping of ISO-Latin-1 to ASCII. Contains # horrors like stripping diacritical marks to turn á into a, but also # contains non-horrors like turning “ into ". MS_CHARS_TO_ASCII = { b'\x80' : 'EUR', b'\x81' : ' ', b'\x82' : ',', b'\x83' : 'f', b'\x84' : ',,', b'\x85' : '...', b'\x86' : '+', b'\x87' : '++', b'\x88' : '^', b'\x89' : '%', b'\x8a' : 'S', b'\x8b' : '<', b'\x8c' : 'OE', b'\x8d' : '?', b'\x8e' : 'Z', b'\x8f' : '?', b'\x90' : '?', b'\x91' : "'", b'\x92' : "'", b'\x93' : '"', b'\x94' : '"', b'\x95' : '*', b'\x96' : '-', b'\x97' : '--', b'\x98' : '~', b'\x99' : '(TM)', b'\x9a' : 's', b'\x9b' : '>', b'\x9c' : 'oe', b'\x9d' : '?', b'\x9e' : 'z', b'\x9f' : 'Y', b'\xa0' : ' ', b'\xa1' : '!', b'\xa2' : 'c', b'\xa3' : 'GBP', b'\xa4' : '$', #This approximation is especially parochial--this is the #generic currency symbol. b'\xa5' : 'YEN', b'\xa6' : '|', b'\xa7' : 'S', b'\xa8' : '..', b'\xa9' : '', b'\xaa' : '(th)', b'\xab' : '<<', b'\xac' : '!', b'\xad' : ' ', b'\xae' : '(R)', b'\xaf' : '-', b'\xb0' : 'o', b'\xb1' : '+-', b'\xb2' : '2', b'\xb3' : '3', b'\xb4' : ("'", 'acute'), b'\xb5' : 'u', b'\xb6' : 'P', b'\xb7' : '*', b'\xb8' : ',', b'\xb9' : '1', b'\xba' : '(th)', b'\xbb' : '>>', b'\xbc' : '1/4', b'\xbd' : '1/2', b'\xbe' : '3/4', b'\xbf' : '?', b'\xc0' : 'A', b'\xc1' : 'A', b'\xc2' : 'A', b'\xc3' : 'A', b'\xc4' : 'A', b'\xc5' : 'A', b'\xc6' : 'AE', b'\xc7' : 'C', b'\xc8' : 'E', b'\xc9' : 'E', b'\xca' : 'E', b'\xcb' : 'E', b'\xcc' : 'I', b'\xcd' : 'I', b'\xce' : 'I', b'\xcf' : 'I', b'\xd0' : 'D', b'\xd1' : 'N', b'\xd2' : 'O', b'\xd3' : 'O', b'\xd4' : 'O', b'\xd5' : 'O', b'\xd6' : 'O', b'\xd7' : '*', b'\xd8' : 'O', b'\xd9' : 'U', b'\xda' : 'U', b'\xdb' : 'U', b'\xdc' : 'U', b'\xdd' : 'Y', b'\xde' : 'b', b'\xdf' : 'B', b'\xe0' : 'a', b'\xe1' : 'a', b'\xe2' : 'a', b'\xe3' : 'a', b'\xe4' : 'a', b'\xe5' : 'a', b'\xe6' : 'ae', b'\xe7' : 'c', b'\xe8' : 'e', b'\xe9' : 'e', b'\xea' : 'e', b'\xeb' : 'e', b'\xec' : 'i', b'\xed' : 'i', b'\xee' : 'i', b'\xef' : 'i', b'\xf0' : 'o', b'\xf1' : 'n', b'\xf2' : 'o', b'\xf3' : 'o', b'\xf4' : 'o', b'\xf5' : 'o', b'\xf6' : 'o', b'\xf7' : '/', b'\xf8' : 'o', b'\xf9' : 'u', b'\xfa' : 'u', b'\xfb' : 'u', b'\xfc' : 'u', b'\xfd' : 'y', b'\xfe' : 'b', b'\xff' : 'y', } # A map used when removing rogue Windows-1252/ISO-8859-1 # characters in otherwise UTF-8 documents. # # Note that \x81, \x8d, \x8f, \x90, and \x9d are undefined in # Windows-1252. WINDOWS_1252_TO_UTF8 = { 0x80 : b'\xe2\x82\xac', # € 0x82 : b'\xe2\x80\x9a', # ‚ 0x83 : b'\xc6\x92', # ƒ 0x84 : b'\xe2\x80\x9e', # „ 0x85 : b'\xe2\x80\xa6', # … 0x86 : b'\xe2\x80\xa0', # † 0x87 : b'\xe2\x80\xa1', # ‡ 0x88 : b'\xcb\x86', # ˆ 0x89 : b'\xe2\x80\xb0', # ‰ 0x8a : b'\xc5\xa0', # Š 0x8b : b'\xe2\x80\xb9', # ‹ 0x8c : b'\xc5\x92', # Œ 0x8e : b'\xc5\xbd', # Ž 0x91 : b'\xe2\x80\x98', # ‘ 0x92 : b'\xe2\x80\x99', # ’ 0x93 : b'\xe2\x80\x9c', # “ 0x94 : b'\xe2\x80\x9d', # ” 0x95 : b'\xe2\x80\xa2', # • 0x96 : b'\xe2\x80\x93', # – 0x97 : b'\xe2\x80\x94', # — 0x98 : b'\xcb\x9c', # ˜ 0x99 : b'\xe2\x84\xa2', # ™ 0x9a : b'\xc5\xa1', # š 0x9b : b'\xe2\x80\xba', # › 0x9c : b'\xc5\x93', # œ 0x9e : b'\xc5\xbe', # ž 0x9f : b'\xc5\xb8', # Ÿ 0xa0 : b'\xc2\xa0', #   0xa1 : b'\xc2\xa1', # ¡ 0xa2 : b'\xc2\xa2', # ¢ 0xa3 : b'\xc2\xa3', # £ 0xa4 : b'\xc2\xa4', # ¤ 0xa5 : b'\xc2\xa5', # ¥ 0xa6 : b'\xc2\xa6', # ¦ 0xa7 : b'\xc2\xa7', # § 0xa8 : b'\xc2\xa8', # ¨ 0xa9 : b'\xc2\xa9', # © 0xaa : b'\xc2\xaa', # ª 0xab : b'\xc2\xab', # « 0xac : b'\xc2\xac', # ¬ 0xad : b'\xc2\xad', # ­ 0xae : b'\xc2\xae', # ® 0xaf : b'\xc2\xaf', # ¯ 0xb0 : b'\xc2\xb0', # ° 0xb1 : b'\xc2\xb1', # ± 0xb2 : b'\xc2\xb2', # ² 0xb3 : b'\xc2\xb3', # ³ 0xb4 : b'\xc2\xb4', # ´ 0xb5 : b'\xc2\xb5', # µ 0xb6 : b'\xc2\xb6', # ¶ 0xb7 : b'\xc2\xb7', # · 0xb8 : b'\xc2\xb8', # ¸ 0xb9 : b'\xc2\xb9', # ¹ 0xba : b'\xc2\xba', # º 0xbb : b'\xc2\xbb', # » 0xbc : b'\xc2\xbc', # ¼ 0xbd : b'\xc2\xbd', # ½ 0xbe : b'\xc2\xbe', # ¾ 0xbf : b'\xc2\xbf', # ¿ 0xc0 : b'\xc3\x80', # À 0xc1 : b'\xc3\x81', # Á 0xc2 : b'\xc3\x82', #  0xc3 : b'\xc3\x83', # à 0xc4 : b'\xc3\x84', # Ä 0xc5 : b'\xc3\x85', # Å 0xc6 : b'\xc3\x86', # Æ 0xc7 : b'\xc3\x87', # Ç 0xc8 : b'\xc3\x88', # È 0xc9 : b'\xc3\x89', # É 0xca : b'\xc3\x8a', # Ê 0xcb : b'\xc3\x8b', # Ë 0xcc : b'\xc3\x8c', # Ì 0xcd : b'\xc3\x8d', # Í 0xce : b'\xc3\x8e', # Î 0xcf : b'\xc3\x8f', # Ï 0xd0 : b'\xc3\x90', # Ð 0xd1 : b'\xc3\x91', # Ñ 0xd2 : b'\xc3\x92', # Ò 0xd3 : b'\xc3\x93', # Ó 0xd4 : b'\xc3\x94', # Ô 0xd5 : b'\xc3\x95', # Õ 0xd6 : b'\xc3\x96', # Ö 0xd7 : b'\xc3\x97', # × 0xd8 : b'\xc3\x98', # Ø 0xd9 : b'\xc3\x99', # Ù 0xda : b'\xc3\x9a', # Ú 0xdb : b'\xc3\x9b', # Û 0xdc : b'\xc3\x9c', # Ü 0xdd : b'\xc3\x9d', # Ý 0xde : b'\xc3\x9e', # Þ 0xdf : b'\xc3\x9f', # ß 0xe0 : b'\xc3\xa0', # à 0xe1 : b'\xa1', # á 0xe2 : b'\xc3\xa2', # â 0xe3 : b'\xc3\xa3', # ã 0xe4 : b'\xc3\xa4', # ä 0xe5 : b'\xc3\xa5', # å 0xe6 : b'\xc3\xa6', # æ 0xe7 : b'\xc3\xa7', # ç 0xe8 : b'\xc3\xa8', # è 0xe9 : b'\xc3\xa9', # é 0xea : b'\xc3\xaa', # ê 0xeb : b'\xc3\xab', # ë 0xec : b'\xc3\xac', # ì 0xed : b'\xc3\xad', # í 0xee : b'\xc3\xae', # î 0xef : b'\xc3\xaf', # ï 0xf0 : b'\xc3\xb0', # ð 0xf1 : b'\xc3\xb1', # ñ 0xf2 : b'\xc3\xb2', # ò 0xf3 : b'\xc3\xb3', # ó 0xf4 : b'\xc3\xb4', # ô 0xf5 : b'\xc3\xb5', # õ 0xf6 : b'\xc3\xb6', # ö 0xf7 : b'\xc3\xb7', # ÷ 0xf8 : b'\xc3\xb8', # ø 0xf9 : b'\xc3\xb9', # ù 0xfa : b'\xc3\xba', # ú 0xfb : b'\xc3\xbb', # û 0xfc : b'\xc3\xbc', # ü 0xfd : b'\xc3\xbd', # ý 0xfe : b'\xc3\xbe', # þ } MULTIBYTE_MARKERS_AND_SIZES = [ (0xc2, 0xdf, 2), # 2-byte characters start with a byte C2-DF (0xe0, 0xef, 3), # 3-byte characters start with E0-EF (0xf0, 0xf4, 4), # 4-byte characters start with F0-F4 ] FIRST_MULTIBYTE_MARKER = MULTIBYTE_MARKERS_AND_SIZES[0][0] LAST_MULTIBYTE_MARKER = MULTIBYTE_MARKERS_AND_SIZES[-1][1] @classmethod def detwingle(cls, in_bytes, main_encoding="utf8", embedded_encoding="windows-1252"): """Fix characters from one encoding embedded in some other encoding. Currently the only situation supported is Windows-1252 (or its subset ISO-8859-1), embedded in UTF-8. The input must be a bytestring. If you've already converted the document to Unicode, you're too late. The output is a bytestring in which `embedded_encoding` characters have been converted to their `main_encoding` equivalents. """ if embedded_encoding.replace('_', '-').lower() not in ( 'windows-1252', 'windows_1252'): raise NotImplementedError( "Windows-1252 and ISO-8859-1 are the only currently supported " "embedded encodings.") if main_encoding.lower() not in ('utf8', 'utf-8'): raise NotImplementedError( "UTF-8 is the only currently supported main encoding.") byte_chunks = [] chunk_start = 0 pos = 0 while pos < len(in_bytes): byte = in_bytes[pos] if not isinstance(byte, int): # Python 2.x byte = ord(byte) if (byte >= cls.FIRST_MULTIBYTE_MARKER and byte <= cls.LAST_MULTIBYTE_MARKER): # This is the start of a UTF-8 multibyte character. Skip # to the end. for start, end, size in cls.MULTIBYTE_MARKERS_AND_SIZES: if byte >= start and byte <= end: pos += size break elif byte >= 0x80 and byte in cls.WINDOWS_1252_TO_UTF8: # We found a Windows-1252 character! # Save the string up to this point as a chunk. byte_chunks.append(in_bytes[chunk_start:pos]) # Now translate the Windows-1252 character into UTF-8 # and add it as another, one-byte chunk. byte_chunks.append(cls.WINDOWS_1252_TO_UTF8[byte]) pos += 1 chunk_start = pos else: # Go on to the next character. pos += 1 if chunk_start == 0: # The string is unchanged. return in_bytes else: # Store the final chunk. byte_chunks.append(in_bytes[chunk_start:]) return b''.join(byte_chunks)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 30117, 28028, 23672, 527, 3555, 26, 6140, 12, 577, 28980, 199, 199, 2765, 1021, 25983, 4692, 666, 1901, 282, 4465, 1475, 334, 25118, 370, 9094, 13, 24, 503, 199, 7087, 680, 221, 2779, 365, 946, 1214, 3444, 4079, 641, 1233, 687, 7173, 19641, 1159, 29347, 199, 7658, 10191, 14, 2779, 1630, 440, 19913, 314, 4692, 503, 4163, 370, 16806, 282, 892, 199, 2991, 27, 626, 1159, 314, 3123, 6545, 1159, 3906, 14, 199, 624, 199, 199, 646, 6010, 199, 504, 30010, 552, 1701, 8710, 492, 1233, 1403, 18, 354, 199, 646, 295, 199, 646, 3598, 199, 199, 3, 27722, 380, 28853, 4528, 14134, 14, 812, 994, 2997, 14, 199, 3, 17955, 687, 1455, 921, 1560, 9886, 14, 3871, 2087, 14, 1308, 15, 199, 3, 221, 503, 283, 6182, 13, 362, 3907, 2366, 13, 1560, 9886, 7, 199, 3, 221, 503, 283, 13581, 63, 3174, 28470, 7, 199, 893, 26, 272, 492, 28470, 272, 327, 646, 28470, 14, 5559, 272, 327, 1560, 9886, 14, 5559, 423, 1757, 275, 413, 199, 2590, 3545, 26, 272, 28470, 275, 488, 199, 199, 3, 23840, 687, 1455, 921, 67, 17421, 1548, 14, 73, 1085, 78, 14, 1308, 8083, 199, 893, 26, 272, 492, 284, 5598, 63, 9276, 199, 2590, 3545, 26, 272, 986, 199, 199, 1652, 63, 2991, 63, 264, 275, 295, 14, 2014, 8, 272, 14452, 28, 29635, 2795, 2991, 1524, 3985, 937, 17140, 2788, 3985, 937, 17910, 31, 22936, 2143, 1062, 295, 14, 41, 9, 199, 1360, 63, 2024, 63, 264, 275, 295, 14, 2014, 8, 272, 2650, 60, 83, 10, 2024, 25524, 6043, 60, 83, 23440, 83, 10, 905, 26889, 31, 7059, 30, 3672, 31, 2788, 1182, 3779, 7, 1743, 61, 1370, 2143, 1062, 295, 14, 41, 9, 199, 199, 533, 17680, 2610, 26575, 8, 785, 304, 339, 408, 2610, 25585, 4692, 503, 4163, 9045, 367, 314, 5226, 4110, 1041, 339, 347, 485, 13817, 63, 533, 63, 3669, 837, 267, 4237, 275, 1052, 267, 3837, 63, 3892, 275, 1052, 267, 4110, 63, 509, 63, 264, 275, 942, 267, 367, 1233, 1403, 12, 536, 315, 769, 8, 19300, 18, 354, 14, 1744, 5109, 288, 4528, 275, 17742, 8, 19300, 9, 288, 340, 1233, 1403, 1137, 8177, 26, 355, 327, 6006, 1159, 949, 2376, 315, 7485, 316, 314, 25101, 2216, 1901, 355, 327, 1253, 5184, 27031, 7444, 652, 10986, 4453, 376, 2225, 574, 12, 1314, 355, 327, 365, 8860, 25320, 14, 355, 4110, 63, 509, 63, 264, 14, 740, 8, 10856, 9, 355, 4237, 59, 10856, 61, 275, 536, 288, 327, 11017, 781, 886, 2934, 370, 7485, 1253, 5184, 27, 1901, 314, 25101, 2216, 14, 288, 3837, 63, 3892, 59, 354, 61, 275, 4528, 267, 295, 63, 7463, 275, 26503, 83, 8480, 450, 10587, 904, 8, 16516, 63, 509, 63, 264, 9, 267, 372, 4237, 12, 3837, 63, 3892, 12, 295, 14, 2014, 8, 264, 63, 7463, 9, 272, 334, 29007, 63, 2566, 63, 4943, 63, 13630, 12, 4163, 63, 13630, 63, 2566, 63, 29007, 12, 1362, 9502, 63, 2566, 63, 4943, 63, 13630, 63, 907, 9, 275, 485, 13817, 63, 533, 63, 3669, 342, 339, 9502, 63, 2566, 63, 4317, 63, 13630, 275, 469, 267, 3546, 582, 298, 439, 736, 401, 267, 24536, 298, 5184, 401, 267, 11746, 582, 298, 5282, 401, 267, 3886, 582, 298, 4116, 401, 267, 25366, 298, 3308, 401, 267, 789, 339, 699, 8693, 63, 7089, 29298, 63, 726, 63, 25950, 275, 295, 14, 2014, 480, 779, 16137, 11752, 2, 5644, 11746, 26313, 20262, 68, 11, 27, 92, 3, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 27, 6113, 87, 11, 32750, 5644, 6099, 531, 339, 768, 3744, 272, 347, 485, 20374, 63, 1360, 63, 4502, 8, 1886, 12, 1336, 1113, 304, 267, 4642, 275, 843, 14, 29007, 63, 2566, 63, 4943, 63, 13630, 14, 362, 8, 1431, 1113, 14, 923, 8, 16, 430, 267, 372, 11746, 5, 83, 9426, 450, 4642, 339, 768, 3744, 272, 347, 485, 20374, 63, 1652, 63, 4502, 8, 1886, 12, 1336, 1113, 304, 267, 408, 9167, 543, 282, 5578, 3965, 370, 23080, 314, 267, 5827, 4692, 4642, 367, 376, 4692, 4539, 4528, 1041, 267, 4642, 275, 843, 14, 29007, 63, 2566, 63, 4317, 63, 13630, 59, 1431, 1113, 14, 923, 8, 16, 1874, 267, 372, 11746, 5, 83, 9426, 450, 4642, 339, 768, 3744, 272, 347, 10999, 63, 3215, 63, 585, 8, 277, 12, 574, 304, 267, 408, 5483, 282, 574, 1901, 282, 10999, 4692, 2225, 12, 12570, 21375, 652, 14, 13359, 17536, 3326, 911, 506, 10999, 1808, 4270, 9344, 14, 8592, 699, 2873, 1159, 12377, 1035, 298, 22593, 1159, 12377, 2, 13359, 982, 282, 1059, 3509, 4270, 9344, 12, 652, 911, 506, 10999, 1808, 268, 2849, 9344, 14, 8592, 644, 14628, 370, 298, 1662, 4681, 2, 1035, 283, 24679, 370, 298, 1662, 4681, 4507, 13359, 982, 282, 1059, 3509, 3865, 2849, 436, 4270, 9344, 12, 314, 268, 4270, 9344, 911, 506, 11077, 12, 436, 314, 1059, 911, 506, 10999, 268, 1808, 4270, 9344, 14, 8592, 644, 14628, 370, 298, 22593, 1159, 12377, 2, 1035, 298, 24679, 370, 1253, 5184, 27, 22593, 1159, 4681, 6, 5184, 27, 267, 408, 267, 6313, 63, 1045, 275, 14788, 267, 340, 14788, 315, 574, 26, 288, 340, 21673, 315, 574, 26, 355, 327, 710, 1059, 3509, 3865, 2849, 436, 4270, 355, 327, 9344, 14, 221, 16147, 314, 4270, 9344, 1901, 355, 327, 9045, 14, 2136, 6313, 314, 4270, 9344, 7830, 2419, 355, 327, 314, 2849, 9344, 2952, 314, 4642, 536, 365, 355, 327, 11746, 5184, 9426, 3775, 642, 365, 4163, 503, 4692, 14, 221, 982, 781, 355, 327, 10999, 314, 2849, 9344, 12, 781, 5121, 1172, 370, 19822, 355, 327, 3382, 1253, 439, 736, 27, 436, 1253, 83, 5184, 27, 14, 355, 3350, 63, 1045, 275, 11746, 5184, 9426, 355, 574, 275, 574, 14, 1814, 20630, 3350, 63, 1045, 9, 288, 587, 26, 355, 327, 6006, 787, 4270, 9344, 1325, 949, 2849, 9344, 14, 355, 327, 2136, 883, 675, 2849, 9344, 370, 6313, 314, 2225, 14, 355, 6313, 63, 1045, 275, 21673, 267, 372, 6313, 63, 1045, 435, 574, 435, 6313, 63, 1045, 339, 768, 3744, 272, 347 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 30117, 28028, 23672, 527, 3555, 26, 6140, 12, 577, 28980, 199, 199, 2765, 1021, 25983, 4692, 666, 1901, 282, 4465, 1475, 334, 25118, 370, 9094, 13, 24, 503, 199, 7087, 680, 221, 2779, 365, 946, 1214, 3444, 4079, 641, 1233, 687, 7173, 19641, 1159, 29347, 199, 7658, 10191, 14, 2779, 1630, 440, 19913, 314, 4692, 503, 4163, 370, 16806, 282, 892, 199, 2991, 27, 626, 1159, 314, 3123, 6545, 1159, 3906, 14, 199, 624, 199, 199, 646, 6010, 199, 504, 30010, 552, 1701, 8710, 492, 1233, 1403, 18, 354, 199, 646, 295, 199, 646, 3598, 199, 199, 3, 27722, 380, 28853, 4528, 14134, 14, 812, 994, 2997, 14, 199, 3, 17955, 687, 1455, 921, 1560, 9886, 14, 3871, 2087, 14, 1308, 15, 199, 3, 221, 503, 283, 6182, 13, 362, 3907, 2366, 13, 1560, 9886, 7, 199, 3, 221, 503, 283, 13581, 63, 3174, 28470, 7, 199, 893, 26, 272, 492, 28470, 272, 327, 646, 28470, 14, 5559, 272, 327, 1560, 9886, 14, 5559, 423, 1757, 275, 413, 199, 2590, 3545, 26, 272, 28470, 275, 488, 199, 199, 3, 23840, 687, 1455, 921, 67, 17421, 1548, 14, 73, 1085, 78, 14, 1308, 8083, 199, 893, 26, 272, 492, 284, 5598, 63, 9276, 199, 2590, 3545, 26, 272, 986, 199, 199, 1652, 63, 2991, 63, 264, 275, 295, 14, 2014, 8, 272, 14452, 28, 29635, 2795, 2991, 1524, 3985, 937, 17140, 2788, 3985, 937, 17910, 31, 22936, 2143, 1062, 295, 14, 41, 9, 199, 1360, 63, 2024, 63, 264, 275, 295, 14, 2014, 8, 272, 2650, 60, 83, 10, 2024, 25524, 6043, 60, 83, 23440, 83, 10, 905, 26889, 31, 7059, 30, 3672, 31, 2788, 1182, 3779, 7, 1743, 61, 1370, 2143, 1062, 295, 14, 41, 9, 199, 199, 533, 17680, 2610, 26575, 8, 785, 304, 339, 408, 2610, 25585, 4692, 503, 4163, 9045, 367, 314, 5226, 4110, 1041, 339, 347, 485, 13817, 63, 533, 63, 3669, 837, 267, 4237, 275, 1052, 267, 3837, 63, 3892, 275, 1052, 267, 4110, 63, 509, 63, 264, 275, 942, 267, 367, 1233, 1403, 12, 536, 315, 769, 8, 19300, 18, 354, 14, 1744, 5109, 288, 4528, 275, 17742, 8, 19300, 9, 288, 340, 1233, 1403, 1137, 8177, 26, 355, 327, 6006, 1159, 949, 2376, 315, 7485, 316, 314, 25101, 2216, 1901, 355, 327, 1253, 5184, 27031, 7444, 652, 10986, 4453, 376, 2225, 574, 12, 1314, 355, 327, 365, 8860, 25320, 14, 355, 4110, 63, 509, 63, 264, 14, 740, 8, 10856, 9, 355, 4237, 59, 10856, 61, 275, 536, 288, 327, 11017, 781, 886, 2934, 370, 7485, 1253, 5184, 27, 1901, 314, 25101, 2216, 14, 288, 3837, 63, 3892, 59, 354, 61, 275, 4528, 267, 295, 63, 7463, 275, 26503, 83, 8480, 450, 10587, 904, 8, 16516, 63, 509, 63, 264, 9, 267, 372, 4237, 12, 3837, 63, 3892, 12, 295, 14, 2014, 8, 264, 63, 7463, 9, 272, 334, 29007, 63, 2566, 63, 4943, 63, 13630, 12, 4163, 63, 13630, 63, 2566, 63, 29007, 12, 1362, 9502, 63, 2566, 63, 4943, 63, 13630, 63, 907, 9, 275, 485, 13817, 63, 533, 63, 3669, 342, 339, 9502, 63, 2566, 63, 4317, 63, 13630, 275, 469, 267, 3546, 582, 298, 439, 736, 401, 267, 24536, 298, 5184, 401, 267, 11746, 582, 298, 5282, 401, 267, 3886, 582, 298, 4116, 401, 267, 25366, 298, 3308, 401, 267, 789, 339, 699, 8693, 63, 7089, 29298, 63, 726, 63, 25950, 275, 295, 14, 2014, 480, 779, 16137, 11752, 2, 5644, 11746, 26313, 20262, 68, 11, 27, 92, 3, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 27, 6113, 87, 11, 32750, 5644, 6099, 531, 339, 768, 3744, 272, 347, 485, 20374, 63, 1360, 63, 4502, 8, 1886, 12, 1336, 1113, 304, 267, 4642, 275, 843, 14, 29007, 63, 2566, 63, 4943, 63, 13630, 14, 362, 8, 1431, 1113, 14, 923, 8, 16, 430, 267, 372, 11746, 5, 83, 9426, 450, 4642, 339, 768, 3744, 272, 347, 485, 20374, 63, 1652, 63, 4502, 8, 1886, 12, 1336, 1113, 304, 267, 408, 9167, 543, 282, 5578, 3965, 370, 23080, 314, 267, 5827, 4692, 4642, 367, 376, 4692, 4539, 4528, 1041, 267, 4642, 275, 843, 14, 29007, 63, 2566, 63, 4317, 63, 13630, 59, 1431, 1113, 14, 923, 8, 16, 1874, 267, 372, 11746, 5, 83, 9426, 450, 4642, 339, 768, 3744, 272, 347, 10999, 63, 3215, 63, 585, 8, 277, 12, 574, 304, 267, 408, 5483, 282, 574, 1901, 282, 10999, 4692, 2225, 12, 12570, 21375, 652, 14, 13359, 17536, 3326, 911, 506, 10999, 1808, 4270, 9344, 14, 8592, 699, 2873, 1159, 12377, 1035, 298, 22593, 1159, 12377, 2, 13359, 982, 282, 1059, 3509, 4270, 9344, 12, 652, 911, 506, 10999, 1808, 268, 2849, 9344, 14, 8592, 644, 14628, 370, 298, 1662, 4681, 2, 1035, 283, 24679, 370, 298, 1662, 4681, 4507, 13359, 982, 282, 1059, 3509, 3865, 2849, 436, 4270, 9344, 12, 314, 268, 4270, 9344, 911, 506, 11077, 12, 436, 314, 1059, 911, 506, 10999, 268, 1808, 4270, 9344, 14, 8592, 644, 14628, 370, 298, 22593, 1159, 12377, 2, 1035, 298, 24679, 370, 1253, 5184, 27, 22593, 1159, 4681, 6, 5184, 27, 267, 408, 267, 6313, 63, 1045, 275, 14788, 267, 340, 14788, 315, 574, 26, 288, 340, 21673, 315, 574, 26, 355, 327, 710, 1059, 3509, 3865, 2849, 436, 4270, 355, 327, 9344, 14, 221, 16147, 314, 4270, 9344, 1901, 355, 327, 9045, 14, 2136, 6313, 314, 4270, 9344, 7830, 2419, 355, 327, 314, 2849, 9344, 2952, 314, 4642, 536, 365, 355, 327, 11746, 5184, 9426, 3775, 642, 365, 4163, 503, 4692, 14, 221, 982, 781, 355, 327, 10999, 314, 2849, 9344, 12, 781, 5121, 1172, 370, 19822, 355, 327, 3382, 1253, 439, 736, 27, 436, 1253, 83, 5184, 27, 14, 355, 3350, 63, 1045, 275, 11746, 5184, 9426, 355, 574, 275, 574, 14, 1814, 20630, 3350, 63, 1045, 9, 288, 587, 26, 355, 327, 6006, 787, 4270, 9344, 1325, 949, 2849, 9344, 14, 355, 327, 2136, 883, 675, 2849, 9344, 370, 6313, 314, 2225, 14, 355, 6313, 63, 1045, 275, 21673, 267, 372, 6313, 63, 1045, 435, 574, 435, 6313, 63, 1045, 339, 768, 3744, 272, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
seemoo-lab/nexmon
buildtools/gcc-arm-none-eabi-5_4-2016q2-osx/arm-none-eabi/lib/armv7e-m/fpu/fpv5-sp-d16/libstdc++.a-gdb.py
6
2626
# -*- python -*- # Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import gdb import os import os.path pythondir = '/Users/build/workspace/GCC-5-0-build_build-toolchain-mac/gcc-arm-none-eabi-5_4-2016q2-20160622/install-native/share/gcc-arm-none-eabi' libdir = '/Users/build/workspace/GCC-5-0-build_build-toolchain-mac/gcc-arm-none-eabi-5_4-2016q2-20160622/install-native/arm-none-eabi/lib/armv7e-m/fpu/fpv5-sp-d16' # This file might be loaded when there is no current objfile. This # can happen if the user loads it manually. In this case we don't # update sys.path; instead we just hope the user managed to do that # beforehand. if gdb.current_objfile () is not None: # Update module path. We want to find the relative path from libdir # to pythondir, and then we want to apply that relative path to the # directory holding the objfile with which this file is associated. # This preserves relocatability of the gcc tree. # Do a simple normalization that removes duplicate separators. pythondir = os.path.normpath (pythondir) libdir = os.path.normpath (libdir) prefix = os.path.commonprefix ([libdir, pythondir]) # In some bizarre configuration we might have found a match in the # middle of a directory name. if prefix[-1] != '/': prefix = os.path.dirname (prefix) + '/' # Strip off the prefix. pythondir = pythondir[len (prefix):] libdir = libdir[len (prefix):] # Compute the ".."s needed to get from libdir to the prefix. dotdots = ('..' + os.sep) * len (libdir.split (os.sep)) objfile = gdb.current_objfile ().filename dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir) if not dir_ in sys.path: sys.path.insert(0, dir_) # Call a function as a plain import would not execute body of the included file # on repeated reloads of this object file. from libstdcxx.v6 import register_libstdcxx_printers register_libstdcxx_printers(gdb.current_objfile())
gpl-3.0
[ 3, 1882, 2366, 1882, 199, 3, 1898, 334, 35, 9, 8937, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 646, 12124, 199, 646, 747, 199, 646, 747, 14, 515, 199, 199, 1548, 694, 275, 1994, 12117, 15, 1506, 15, 13249, 15, 10566, 13, 21, 13, 16, 13, 1506, 63, 1506, 13, 22572, 13, 3088, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 13, 21, 63, 20, 13, 9261, 81, 18, 13, 9261, 1690, 1081, 15, 3174, 13, 6106, 15, 6251, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 7, 199, 30789, 275, 1994, 12117, 15, 1506, 15, 13249, 15, 10566, 13, 21, 13, 16, 13, 1506, 63, 1506, 13, 22572, 13, 3088, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 13, 21, 63, 20, 13, 9261, 81, 18, 13, 9261, 1690, 1081, 15, 3174, 13, 6106, 15, 5362, 13, 3592, 13, 69, 14677, 15, 773, 15, 5362, 86, 23, 69, 13, 77, 15, 70, 3165, 15, 70, 1381, 21, 13, 681, 13, 68, 975, 7, 199, 199, 3, 961, 570, 5594, 506, 6511, 1380, 2337, 365, 949, 1453, 1559, 493, 14, 221, 961, 199, 3, 883, 5992, 340, 314, 922, 14404, 652, 10250, 14, 221, 1010, 642, 1930, 781, 2793, 1133, 199, 3, 1678, 984, 14, 515, 27, 3140, 781, 2951, 3661, 314, 922, 12883, 370, 886, 626, 199, 3, 2544, 6868, 14, 199, 692, 12124, 14, 1818, 63, 1113, 493, 6248, 365, 440, 488, 26, 272, 327, 6162, 859, 931, 14, 221, 2136, 2934, 370, 2342, 314, 3847, 931, 687, 1973, 694, 272, 327, 370, 2366, 694, 12, 436, 2066, 781, 2934, 370, 4838, 626, 3847, 931, 370, 314, 272, 327, 2082, 17573, 314, 1559, 493, 543, 1314, 642, 570, 365, 4568, 14, 272, 327, 961, 876, 20603, 295, 2102, 1936, 2012, 402, 314, 19443, 3123, 14, 339, 327, 4226, 282, 3486, 16973, 626, 14185, 9250, 17658, 14, 272, 2366, 694, 275, 747, 14, 515, 14, 9267, 334, 1548, 694, 9, 272, 1973, 694, 275, 747, 14, 515, 14, 9267, 334, 30789, 9, 339, 2403, 275, 747, 14, 515, 14, 2330, 1861, 7287, 30789, 12, 2366, 694, 566, 272, 327, 1010, 2005, 330, 565, 285, 264, 2897, 781, 5594, 1172, 1911, 282, 1336, 315, 314, 272, 327, 12180, 402, 282, 2082, 536, 14, 272, 340, 2403, 1988, 17, 61, 1137, 20549, 267, 2403, 275, 747, 14, 515, 14, 3475, 334, 1861, 9, 435, 7324, 339, 327, 19828, 2331, 314, 2403, 14, 272, 2366, 694, 275, 2366, 694, 59, 552, 334, 1861, 15405, 272, 1973, 694, 275, 1973, 694, 59, 552, 334, 1861, 15405, 339, 327, 8354, 314, 21777, 2, 83, 4346, 370, 664, 687, 1973, 694, 370, 314, 2403, 14, 272, 6308, 25310, 275, 661, 703, 7, 435, 747, 14, 4127, 9, 627, 822, 334, 30789, 14, 1294, 334, 736, 14, 4127, 430, 339, 1559, 493, 275, 12124, 14, 1818, 63, 1113, 493, 334, 680, 1501, 272, 2935, 63, 275, 747, 14, 515, 14, 904, 334, 736, 14, 515, 14, 3475, 334, 1113, 493, 395, 6308, 25310, 12, 2366, 694, 9, 339, 340, 440, 2935, 63, 315, 984, 14, 515, 26, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 2935, 4602, 199, 199, 3, 6523, 282, 805, 465, 282, 8971, 492, 3955, 440, 5341, 2396, 402, 314, 5120, 570, 199, 3, 641, 10877, 295, 3640, 402, 642, 909, 570, 14, 199, 504, 1973, 1516, 9634, 14, 86, 22, 492, 2274, 63, 773, 1516, 9634, 63, 24858, 199, 2683, 63, 773, 1516, 9634, 63, 24858, 8, 17119, 14, 1818, 63, 1113, 493, 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 ]
[ 1882, 2366, 1882, 199, 3, 1898, 334, 35, 9, 8937, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 646, 12124, 199, 646, 747, 199, 646, 747, 14, 515, 199, 199, 1548, 694, 275, 1994, 12117, 15, 1506, 15, 13249, 15, 10566, 13, 21, 13, 16, 13, 1506, 63, 1506, 13, 22572, 13, 3088, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 13, 21, 63, 20, 13, 9261, 81, 18, 13, 9261, 1690, 1081, 15, 3174, 13, 6106, 15, 6251, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 7, 199, 30789, 275, 1994, 12117, 15, 1506, 15, 13249, 15, 10566, 13, 21, 13, 16, 13, 1506, 63, 1506, 13, 22572, 13, 3088, 15, 13112, 13, 5362, 13, 3592, 13, 69, 14677, 13, 21, 63, 20, 13, 9261, 81, 18, 13, 9261, 1690, 1081, 15, 3174, 13, 6106, 15, 5362, 13, 3592, 13, 69, 14677, 15, 773, 15, 5362, 86, 23, 69, 13, 77, 15, 70, 3165, 15, 70, 1381, 21, 13, 681, 13, 68, 975, 7, 199, 199, 3, 961, 570, 5594, 506, 6511, 1380, 2337, 365, 949, 1453, 1559, 493, 14, 221, 961, 199, 3, 883, 5992, 340, 314, 922, 14404, 652, 10250, 14, 221, 1010, 642, 1930, 781, 2793, 1133, 199, 3, 1678, 984, 14, 515, 27, 3140, 781, 2951, 3661, 314, 922, 12883, 370, 886, 626, 199, 3, 2544, 6868, 14, 199, 692, 12124, 14, 1818, 63, 1113, 493, 6248, 365, 440, 488, 26, 272, 327, 6162, 859, 931, 14, 221, 2136, 2934, 370, 2342, 314, 3847, 931, 687, 1973, 694, 272, 327, 370, 2366, 694, 12, 436, 2066, 781, 2934, 370, 4838, 626, 3847, 931, 370, 314, 272, 327, 2082, 17573, 314, 1559, 493, 543, 1314, 642, 570, 365, 4568, 14, 272, 327, 961, 876, 20603, 295, 2102, 1936, 2012, 402, 314, 19443, 3123, 14, 339, 327, 4226, 282, 3486, 16973, 626, 14185, 9250, 17658, 14, 272, 2366, 694, 275, 747, 14, 515, 14, 9267, 334, 1548, 694, 9, 272, 1973, 694, 275, 747, 14, 515, 14, 9267, 334, 30789, 9, 339, 2403, 275, 747, 14, 515, 14, 2330, 1861, 7287, 30789, 12, 2366, 694, 566, 272, 327, 1010, 2005, 330, 565, 285, 264, 2897, 781, 5594, 1172, 1911, 282, 1336, 315, 314, 272, 327, 12180, 402, 282, 2082, 536, 14, 272, 340, 2403, 1988, 17, 61, 1137, 20549, 267, 2403, 275, 747, 14, 515, 14, 3475, 334, 1861, 9, 435, 7324, 339, 327, 19828, 2331, 314, 2403, 14, 272, 2366, 694, 275, 2366, 694, 59, 552, 334, 1861, 15405, 272, 1973, 694, 275, 1973, 694, 59, 552, 334, 1861, 15405, 339, 327, 8354, 314, 21777, 2, 83, 4346, 370, 664, 687, 1973, 694, 370, 314, 2403, 14, 272, 6308, 25310, 275, 661, 703, 7, 435, 747, 14, 4127, 9, 627, 822, 334, 30789, 14, 1294, 334, 736, 14, 4127, 430, 339, 1559, 493, 275, 12124, 14, 1818, 63, 1113, 493, 334, 680, 1501, 272, 2935, 63, 275, 747, 14, 515, 14, 904, 334, 736, 14, 515, 14, 3475, 334, 1113, 493, 395, 6308, 25310, 12, 2366, 694, 9, 339, 340, 440, 2935, 63, 315, 984, 14, 515, 26, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 2935, 4602, 199, 199, 3, 6523, 282, 805, 465, 282, 8971, 492, 3955, 440, 5341, 2396, 402, 314, 5120, 570, 199, 3, 641, 10877, 295, 3640, 402, 642, 909, 570, 14, 199, 504, 1973, 1516, 9634, 14, 86, 22, 492, 2274, 63, 773, 1516, 9634, 63, 24858, 199, 2683, 63, 773, 1516, 9634, 63, 24858, 8, 17119, 14, 1818, 63, 1113, 493, 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, 0 ]
[ 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Antiun/odoo
addons/event/__openerp__.py
261
2296
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Events Organisation', 'version': '0.1', 'website' : 'https://www.odoo.com/page/events', 'category': 'Tools', 'summary': 'Trainings, Conferences, Meetings, Exhibitions, Registrations', 'description': """ Organization and management of Events. ====================================== The event module allows you to efficiently organise events and all related tasks: planification, registration tracking, attendances, etc. Key Features ------------ * Manage your Events and Registrations * Use emails to automatically confirm and send acknowledgements for any event registration """, 'author': 'OpenERP SA', 'depends': ['base_setup', 'board', 'email_template', 'marketing'], 'data': [ 'security/event_security.xml', 'security/ir.model.access.csv', 'wizard/event_confirm_view.xml', 'event_view.xml', 'event_data.xml', 'report/report_event_registration_view.xml', 'res_partner_view.xml', 'email_template.xml', 'views/event.xml', ], 'demo': [ 'event_demo.xml', ], 'test': [ 'test/ui/event_users.yml', 'test/process/event_draft2done.yml' ], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 91, 272, 283, 354, 356, 283, 11770, 13125, 13181, 297, 272, 283, 1023, 356, 283, 16, 14, 17, 297, 272, 283, 7360, 7, 520, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 4368, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 4705, 356, 283, 18591, 780, 12, 1448, 4023, 12, 3194, 386, 780, 12, 1316, 20215, 73, 852, 12, 5044, 631, 3801, 297, 272, 283, 1802, 356, 408, 199, 15928, 436, 10041, 402, 27982, 14, 199, 2486, 23476, 199, 199, 1918, 1566, 859, 6127, 1265, 370, 30427, 20765, 572, 4474, 436, 1006, 4048, 6527, 26, 8683, 7313, 12, 10991, 15161, 12, 199, 4867, 68, 13236, 12, 5423, 14, 199, 199, 1197, 7949, 2093, 199, 4559, 199, 10, 14944, 2195, 27982, 436, 5044, 631, 3801, 199, 10, 3645, 14931, 370, 5847, 12679, 436, 3222, 19807, 23504, 1470, 367, 1263, 1566, 10991, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1095, 63, 2758, 297, 283, 3576, 297, 283, 2123, 63, 1160, 297, 283, 1657, 13800, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 1430, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 9819, 15, 1430, 63, 9548, 63, 1345, 14, 1652, 297, 267, 283, 1430, 63, 1345, 14, 1652, 297, 267, 283, 1430, 63, 576, 14, 1652, 297, 267, 283, 3070, 15, 3070, 63, 1430, 63, 8054, 63, 1345, 14, 1652, 297, 267, 283, 470, 63, 3899, 63, 1345, 14, 1652, 297, 267, 283, 2123, 63, 1160, 14, 1652, 297, 267, 283, 4196, 15, 1430, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 359, 267, 283, 1430, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 359, 267, 283, 396, 15, 1907, 15, 1430, 63, 3707, 14, 11714, 297, 267, 283, 396, 15, 1412, 15, 1430, 63, 7185, 18, 4456, 14, 11714, 7, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 91, 272, 283, 354, 356, 283, 11770, 13125, 13181, 297, 272, 283, 1023, 356, 283, 16, 14, 17, 297, 272, 283, 7360, 7, 520, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 4368, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 4705, 356, 283, 18591, 780, 12, 1448, 4023, 12, 3194, 386, 780, 12, 1316, 20215, 73, 852, 12, 5044, 631, 3801, 297, 272, 283, 1802, 356, 408, 199, 15928, 436, 10041, 402, 27982, 14, 199, 2486, 23476, 199, 199, 1918, 1566, 859, 6127, 1265, 370, 30427, 20765, 572, 4474, 436, 1006, 4048, 6527, 26, 8683, 7313, 12, 10991, 15161, 12, 199, 4867, 68, 13236, 12, 5423, 14, 199, 199, 1197, 7949, 2093, 199, 4559, 199, 10, 14944, 2195, 27982, 436, 5044, 631, 3801, 199, 10, 3645, 14931, 370, 5847, 12679, 436, 3222, 19807, 23504, 1470, 367, 1263, 1566, 10991, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1095, 63, 2758, 297, 283, 3576, 297, 283, 2123, 63, 1160, 297, 283, 1657, 13800, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 1430, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 9819, 15, 1430, 63, 9548, 63, 1345, 14, 1652, 297, 267, 283, 1430, 63, 1345, 14, 1652, 297, 267, 283, 1430, 63, 576, 14, 1652, 297, 267, 283, 3070, 15, 3070, 63, 1430, 63, 8054, 63, 1345, 14, 1652, 297, 267, 283, 470, 63, 3899, 63, 1345, 14, 1652, 297, 267, 283, 2123, 63, 1160, 14, 1652, 297, 267, 283, 4196, 15, 1430, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 359, 267, 283, 1430, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 359, 267, 283, 396, 15, 1907, 15, 1430, 63, 3707, 14, 11714, 297, 267, 283, 396, 15, 1412, 15, 1430, 63, 7185, 18, 4456, 14, 11714, 7, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AnhellO/DAS_Sistemas
Ago-Dic-2017/Enrique Castillo/Ordinario/test/Lib/site-packages/pip/commands/search.py
343
4502
from __future__ import absolute_import import logging import sys import textwrap from pip.basecommand import Command, SUCCESS from pip.compat import OrderedDict from pip.download import PipXmlrpcTransport from pip.models import PyPI from pip.utils import get_terminal_size from pip.utils.logging import indent_log from pip.exceptions import CommandError from pip.status_codes import NO_MATCHES_FOUND from pip._vendor.packaging.version import parse as parse_version from pip._vendor import pkg_resources from pip._vendor.six.moves import xmlrpc_client logger = logging.getLogger(__name__) class SearchCommand(Command): """Search for PyPI packages whose name or summary contains <query>.""" name = 'search' usage = """ %prog [options] <query>""" summary = 'Search PyPI for packages.' def __init__(self, *args, **kw): super(SearchCommand, self).__init__(*args, **kw) self.cmd_opts.add_option( '-i', '--index', dest='index', metavar='URL', default=PyPI.pypi_url, help='Base URL of Python Package Index (default %default)') self.parser.insert_option_group(0, self.cmd_opts) def run(self, options, args): if not args: raise CommandError('Missing required argument (search query).') query = args pypi_hits = self.search(query, options) hits = transform_hits(pypi_hits) terminal_width = None if sys.stdout.isatty(): terminal_width = get_terminal_size()[0] print_results(hits, terminal_width=terminal_width) if pypi_hits: return SUCCESS return NO_MATCHES_FOUND def search(self, query, options): index_url = options.index with self._build_session(options) as session: transport = PipXmlrpcTransport(index_url, session) pypi = xmlrpc_client.ServerProxy(index_url, transport) hits = pypi.search({'name': query, 'summary': query}, 'or') return hits def transform_hits(hits): """ The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use. """ packages = OrderedDict() for hit in hits: name = hit['name'] summary = hit['summary'] version = hit['version'] if name not in packages.keys(): packages[name] = { 'name': name, 'summary': summary, 'versions': [version], } else: packages[name]['versions'].append(version) # if this is the highest version, replace summary and score if version == highest_version(packages[name]['versions']): packages[name]['summary'] = summary return list(packages.values()) def print_results(hits, name_column_width=None, terminal_width=None): if not hits: return if name_column_width is None: name_column_width = max([ len(hit['name']) + len(hit.get('versions', ['-'])[-1]) for hit in hits ]) + 4 installed_packages = [p.project_name for p in pkg_resources.working_set] for hit in hits: name = hit['name'] summary = hit['summary'] or '' version = hit.get('versions', ['-'])[-1] if terminal_width is not None: target_width = terminal_width - name_column_width - 5 if target_width > 10: # wrap and indent summary to fit terminal summary = textwrap.wrap(summary, target_width) summary = ('\n' + ' ' * (name_column_width + 3)).join(summary) line = '%-*s - %s' % (name_column_width, '%s (%s)' % (name, version), summary) try: logger.info(line) if name in installed_packages: dist = pkg_resources.get_distribution(name) with indent_log(): latest = highest_version(hit['versions']) if dist.version == latest: logger.info('INSTALLED: %s (latest)', dist.version) else: logger.info('INSTALLED: %s', dist.version) logger.info('LATEST: %s', latest) except UnicodeEncodeError: pass def highest_version(versions): return max(versions, key=parse_version)
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 984, 199, 646, 13390, 199, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 12, 28364, 199, 504, 7305, 14, 5819, 492, 8773, 199, 504, 7305, 14, 4249, 492, 510, 711, 8672, 4354, 7836, 199, 504, 7305, 14, 992, 492, 24330, 199, 504, 7305, 14, 1208, 492, 664, 63, 12010, 63, 890, 199, 504, 7305, 14, 1208, 14, 4806, 492, 4363, 63, 793, 199, 504, 7305, 14, 3924, 492, 14393, 199, 504, 7305, 14, 1205, 63, 6021, 492, 4825, 63, 14747, 654, 63, 13945, 199, 504, 7305, 423, 9884, 14, 27796, 14, 1023, 492, 2198, 465, 2198, 63, 1023, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 15432, 63, 1258, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 8730, 3110, 8, 3110, 304, 272, 408, 5278, 367, 24330, 6117, 7447, 536, 503, 6212, 3509, 665, 1131, 30, 1041, 272, 536, 275, 283, 1733, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 1131, 11193, 272, 6212, 275, 283, 5278, 24330, 367, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 5278, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 73, 297, 2850, 1080, 297, 288, 2053, 534, 1080, 297, 288, 8214, 534, 2632, 297, 288, 849, 29, 2713, 2252, 14, 17343, 63, 633, 12, 288, 1720, 534, 1563, 2851, 402, 2018, 15665, 5499, 334, 885, 450, 885, 5942, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 291, 14, 1760, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 267, 340, 440, 1249, 26, 288, 746, 14393, 360, 7718, 1415, 1423, 334, 1733, 1827, 28583, 267, 1827, 275, 1249, 267, 1134, 1038, 63, 16595, 275, 291, 14, 1733, 8, 1131, 12, 1511, 9, 267, 19745, 275, 5793, 63, 16595, 8, 17343, 63, 16595, 9, 398, 11167, 63, 2063, 275, 488, 267, 340, 984, 14, 2703, 14, 21122, 837, 288, 11167, 63, 2063, 275, 664, 63, 12010, 63, 890, 3430, 16, 61, 398, 870, 63, 2604, 8, 16595, 12, 11167, 63, 2063, 29, 12010, 63, 2063, 9, 267, 340, 1134, 1038, 63, 16595, 26, 288, 372, 28364, 267, 372, 4825, 63, 14747, 654, 63, 13945, 339, 347, 2754, 8, 277, 12, 1827, 12, 1511, 304, 267, 1478, 63, 633, 275, 1511, 14, 1080, 267, 543, 291, 423, 1506, 63, 1730, 8, 1419, 9, 465, 2351, 26, 288, 7773, 275, 510, 711, 8672, 4354, 7836, 8, 1080, 63, 633, 12, 2351, 9, 288, 1134, 1038, 275, 15432, 63, 1258, 14, 3120, 4936, 8, 1080, 63, 633, 12, 7773, 9, 288, 19745, 275, 1134, 1038, 14, 1733, 3252, 354, 356, 1827, 12, 283, 4705, 356, 1827, 1386, 283, 269, 358, 288, 372, 19745, 421, 199, 318, 5793, 63, 16595, 8, 16595, 304, 272, 408, 272, 710, 769, 687, 1134, 1038, 365, 7710, 282, 769, 402, 5459, 14, 2136, 2934, 282, 769, 402, 272, 6117, 543, 314, 769, 402, 5459, 5489, 8308, 14, 961, 15373, 314, 272, 769, 687, 1134, 1038, 1901, 1373, 781, 883, 675, 14, 272, 408, 272, 6117, 275, 8773, 342, 272, 367, 9793, 315, 19745, 26, 267, 536, 275, 9793, 459, 354, 418, 267, 6212, 275, 9793, 459, 4705, 418, 267, 1015, 275, 9793, 459, 1023, 418, 398, 340, 536, 440, 315, 6117, 14, 1612, 837, 288, 6117, 59, 354, 61, 275, 469, 355, 283, 354, 356, 536, 12, 355, 283, 4705, 356, 6212, 12, 355, 283, 6234, 356, 359, 1023, 467, 288, 789, 267, 587, 26, 288, 6117, 59, 354, 2733, 6234, 2278, 740, 8, 1023, 9, 953, 327, 340, 642, 365, 314, 15356, 1015, 12, 3350, 6212, 436, 5396, 288, 340, 1015, 508, 15356, 63, 1023, 8, 5154, 59, 354, 2733, 6234, 9090, 355, 6117, 59, 354, 2733, 4705, 418, 275, 6212, 339, 372, 769, 8, 5154, 14, 1459, 1012, 421, 199, 318, 870, 63, 2604, 8, 16595, 12, 536, 63, 2301, 63, 2063, 29, 403, 12, 11167, 63, 2063, 29, 403, 304, 272, 340, 440, 19745, 26, 267, 372, 272, 340, 536, 63, 2301, 63, 2063, 365, 488, 26, 267, 536, 63, 2301, 63, 2063, 275, 1390, 779, 288, 822, 8, 12948, 459, 354, 1105, 435, 822, 8, 12948, 14, 362, 360, 6234, 297, 11573, 1105, 1988, 17, 566, 288, 367, 9793, 315, 19745, 267, 4794, 435, 841, 339, 4903, 63, 5154, 275, 359, 80, 14, 1715, 63, 354, 367, 299, 315, 5496, 63, 4435, 14, 9818, 63, 409, 61, 272, 367, 9793, 315, 19745, 26, 267, 536, 275, 9793, 459, 354, 418, 267, 6212, 275, 9793, 459, 4705, 418, 503, 2125, 267, 1015, 275, 9793, 14, 362, 360, 6234, 297, 11573, 1105, 1988, 17, 61, 267, 340, 11167, 63, 2063, 365, 440, 488, 26, 288, 1347, 63, 2063, 275, 11167, 63, 2063, 446, 536, 63, 2301, 63, 2063, 446, 959, 288, 340, 1347, 63, 2063, 690, 1616, 26, 355, 327, 4816, 436, 4363, 6212, 370, 5542, 11167, 355, 6212, 275, 13390, 14, 3823, 8, 4705, 12, 1347, 63, 2063, 9, 355, 6212, 275, 17485, 78, 7, 435, 283, 283, 627, 334, 354, 63, 2301, 63, 2063, 435, 650, 4992, 904, 8, 4705, 9, 398, 1004, 275, 1543, 13, 10, 83, 446, 450, 83, 7, 450, 334, 354, 63, 2301, 63, 2063, 12, 2892, 1543, 83, 4366, 83, 3171, 450, 334, 354, 12, 1015, 395, 6212, 9, 267, 862, 26, 288, 2512, 14, 815, 8, 604, 9, 288, 340, 536, 315, 4903, 63, 5154, 26, 355, 2917, 275, 5496, 63, 4435, 14, 362, 63, 4972, 8, 354, 9, 355, 543, 4363, 63, 793, 837, 490, 8839, 275, 15356, 63, 1023, 8, 12948, 459, 6234, 1105, 490, 340, 2917, 14, 1023, 508, 8839, 26, 717, 2512, 14, 815, 360, 15942, 26, 450, 83, 334, 7410, 3196, 2917, 14, 1023, 9, 490, 587, 26, 717, 2512, 14, 815, 360, 15942, 26, 450, 83, 297, 2917, 14, 1023, 9, 717, 2512, 14, 815, 360, 20307, 1719, 26, 259, 450 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 984, 199, 646, 13390, 199, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 12, 28364, 199, 504, 7305, 14, 5819, 492, 8773, 199, 504, 7305, 14, 4249, 492, 510, 711, 8672, 4354, 7836, 199, 504, 7305, 14, 992, 492, 24330, 199, 504, 7305, 14, 1208, 492, 664, 63, 12010, 63, 890, 199, 504, 7305, 14, 1208, 14, 4806, 492, 4363, 63, 793, 199, 504, 7305, 14, 3924, 492, 14393, 199, 504, 7305, 14, 1205, 63, 6021, 492, 4825, 63, 14747, 654, 63, 13945, 199, 504, 7305, 423, 9884, 14, 27796, 14, 1023, 492, 2198, 465, 2198, 63, 1023, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 15432, 63, 1258, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 8730, 3110, 8, 3110, 304, 272, 408, 5278, 367, 24330, 6117, 7447, 536, 503, 6212, 3509, 665, 1131, 30, 1041, 272, 536, 275, 283, 1733, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 1131, 11193, 272, 6212, 275, 283, 5278, 24330, 367, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 5278, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 73, 297, 2850, 1080, 297, 288, 2053, 534, 1080, 297, 288, 8214, 534, 2632, 297, 288, 849, 29, 2713, 2252, 14, 17343, 63, 633, 12, 288, 1720, 534, 1563, 2851, 402, 2018, 15665, 5499, 334, 885, 450, 885, 5942, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 291, 14, 1760, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 267, 340, 440, 1249, 26, 288, 746, 14393, 360, 7718, 1415, 1423, 334, 1733, 1827, 28583, 267, 1827, 275, 1249, 267, 1134, 1038, 63, 16595, 275, 291, 14, 1733, 8, 1131, 12, 1511, 9, 267, 19745, 275, 5793, 63, 16595, 8, 17343, 63, 16595, 9, 398, 11167, 63, 2063, 275, 488, 267, 340, 984, 14, 2703, 14, 21122, 837, 288, 11167, 63, 2063, 275, 664, 63, 12010, 63, 890, 3430, 16, 61, 398, 870, 63, 2604, 8, 16595, 12, 11167, 63, 2063, 29, 12010, 63, 2063, 9, 267, 340, 1134, 1038, 63, 16595, 26, 288, 372, 28364, 267, 372, 4825, 63, 14747, 654, 63, 13945, 339, 347, 2754, 8, 277, 12, 1827, 12, 1511, 304, 267, 1478, 63, 633, 275, 1511, 14, 1080, 267, 543, 291, 423, 1506, 63, 1730, 8, 1419, 9, 465, 2351, 26, 288, 7773, 275, 510, 711, 8672, 4354, 7836, 8, 1080, 63, 633, 12, 2351, 9, 288, 1134, 1038, 275, 15432, 63, 1258, 14, 3120, 4936, 8, 1080, 63, 633, 12, 7773, 9, 288, 19745, 275, 1134, 1038, 14, 1733, 3252, 354, 356, 1827, 12, 283, 4705, 356, 1827, 1386, 283, 269, 358, 288, 372, 19745, 421, 199, 318, 5793, 63, 16595, 8, 16595, 304, 272, 408, 272, 710, 769, 687, 1134, 1038, 365, 7710, 282, 769, 402, 5459, 14, 2136, 2934, 282, 769, 402, 272, 6117, 543, 314, 769, 402, 5459, 5489, 8308, 14, 961, 15373, 314, 272, 769, 687, 1134, 1038, 1901, 1373, 781, 883, 675, 14, 272, 408, 272, 6117, 275, 8773, 342, 272, 367, 9793, 315, 19745, 26, 267, 536, 275, 9793, 459, 354, 418, 267, 6212, 275, 9793, 459, 4705, 418, 267, 1015, 275, 9793, 459, 1023, 418, 398, 340, 536, 440, 315, 6117, 14, 1612, 837, 288, 6117, 59, 354, 61, 275, 469, 355, 283, 354, 356, 536, 12, 355, 283, 4705, 356, 6212, 12, 355, 283, 6234, 356, 359, 1023, 467, 288, 789, 267, 587, 26, 288, 6117, 59, 354, 2733, 6234, 2278, 740, 8, 1023, 9, 953, 327, 340, 642, 365, 314, 15356, 1015, 12, 3350, 6212, 436, 5396, 288, 340, 1015, 508, 15356, 63, 1023, 8, 5154, 59, 354, 2733, 6234, 9090, 355, 6117, 59, 354, 2733, 4705, 418, 275, 6212, 339, 372, 769, 8, 5154, 14, 1459, 1012, 421, 199, 318, 870, 63, 2604, 8, 16595, 12, 536, 63, 2301, 63, 2063, 29, 403, 12, 11167, 63, 2063, 29, 403, 304, 272, 340, 440, 19745, 26, 267, 372, 272, 340, 536, 63, 2301, 63, 2063, 365, 488, 26, 267, 536, 63, 2301, 63, 2063, 275, 1390, 779, 288, 822, 8, 12948, 459, 354, 1105, 435, 822, 8, 12948, 14, 362, 360, 6234, 297, 11573, 1105, 1988, 17, 566, 288, 367, 9793, 315, 19745, 267, 4794, 435, 841, 339, 4903, 63, 5154, 275, 359, 80, 14, 1715, 63, 354, 367, 299, 315, 5496, 63, 4435, 14, 9818, 63, 409, 61, 272, 367, 9793, 315, 19745, 26, 267, 536, 275, 9793, 459, 354, 418, 267, 6212, 275, 9793, 459, 4705, 418, 503, 2125, 267, 1015, 275, 9793, 14, 362, 360, 6234, 297, 11573, 1105, 1988, 17, 61, 267, 340, 11167, 63, 2063, 365, 440, 488, 26, 288, 1347, 63, 2063, 275, 11167, 63, 2063, 446, 536, 63, 2301, 63, 2063, 446, 959, 288, 340, 1347, 63, 2063, 690, 1616, 26, 355, 327, 4816, 436, 4363, 6212, 370, 5542, 11167, 355, 6212, 275, 13390, 14, 3823, 8, 4705, 12, 1347, 63, 2063, 9, 355, 6212, 275, 17485, 78, 7, 435, 283, 283, 627, 334, 354, 63, 2301, 63, 2063, 435, 650, 4992, 904, 8, 4705, 9, 398, 1004, 275, 1543, 13, 10, 83, 446, 450, 83, 7, 450, 334, 354, 63, 2301, 63, 2063, 12, 2892, 1543, 83, 4366, 83, 3171, 450, 334, 354, 12, 1015, 395, 6212, 9, 267, 862, 26, 288, 2512, 14, 815, 8, 604, 9, 288, 340, 536, 315, 4903, 63, 5154, 26, 355, 2917, 275, 5496, 63, 4435, 14, 362, 63, 4972, 8, 354, 9, 355, 543, 4363, 63, 793, 837, 490, 8839, 275, 15356, 63, 1023, 8, 12948, 459, 6234, 1105, 490, 340, 2917, 14, 1023, 508,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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 ]
jhawkesworth/ansible
lib/ansible/modules/cloud/huawei/hwc_network_vpc.py
3
12864
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2018 Huawei # GNU General Public License v3.0+ (see COPYING or # https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ############################################################################### # Documentation ############################################################################### ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: hwc_network_vpc description: - Represents an vpc resource. short_description: Creates a Huawei Cloud VPC version_added: '2.8' author: Huawei Inc. (@huaweicloud) requirements: - requests >= 2.18.4 - keystoneauth1 >= 3.6.0 options: state: description: - Whether the given object should exist in vpc. type: str choices: ['present', 'absent'] default: 'present' name: description: - the name of vpc. type: str required: true cidr: description: - the range of available subnets in the vpc. type: str required: true extends_documentation_fragment: hwc ''' EXAMPLES = ''' - name: create a vpc hwc_network_vpc: identity_endpoint: "{{ identity_endpoint }}" user: "{{ user }}" password: "{{ password }}" domain: "{{ domain }}" project: "{{ project }}" region: "{{ region }}" name: "vpc_1" cidr: "192.168.100.0/24" state: present ''' RETURN = ''' id: description: - the id of vpc. type: str returned: success name: description: - the name of vpc. type: str returned: success cidr: description: - the range of available subnets in the vpc. type: str returned: success status: description: - the status of vpc. type: str returned: success routes: description: - the route information. type: complex returned: success contains: destination: description: - the destination network segment of a route. type: str returned: success next_hop: description: - the next hop of a route. If the route type is peering, it will provide VPC peering connection ID. type: str returned: success enable_shared_snat: description: - show whether the shared snat is enabled. type: bool returned: success ''' ############################################################################### # Imports ############################################################################### from ansible.module_utils.hwc_utils import (Config, HwcModule, get_region, HwcClientException, navigate_hash, HwcClientException404, remove_nones_from_dict, build_path, remove_empty_from_dict, are_dicts_different) import re import time ############################################################################### # Main ############################################################################### def main(): """Main function""" module = HwcModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(required=True, type='str'), cidr=dict(required=True, type='str') ), supports_check_mode=True, ) config = Config(module, 'vpc') state = module.params['state'] if (not module.params.get("id")) and module.params.get("name"): module.params['id'] = get_id_by_name(config) fetch = None link = self_link(module) # the link will include Nones if required format parameters are missed if not re.search('/None/|/None$', link): client = config.client(get_region(module), "vpc", "project") fetch = fetch_resource(module, client, link) if fetch: fetch = fetch.get('vpc') changed = False if fetch: if state == 'present': expect = _get_editable_properties(module) current_state = response_to_hash(module, fetch) if are_dicts_different(expect, current_state): if not module.check_mode: fetch = update(config, self_link(module)) fetch = response_to_hash(module, fetch.get('vpc')) changed = True else: fetch = current_state else: if not module.check_mode: delete(config, self_link(module)) fetch = {} changed = True else: if state == 'present': if not module.check_mode: fetch = create(config, "vpcs") fetch = response_to_hash(module, fetch.get('vpc')) changed = True else: fetch = {} fetch.update({'changed': changed}) module.exit_json(**fetch) def create(config, link): module = config.module client = config.client(get_region(module), "vpc", "project") r = None try: r = client.post(link, resource_to_create(module)) except HwcClientException as ex: msg = ("module(hwc_network_vpc): error creating " "resource, error: %s" % str(ex)) module.fail_json(msg=msg) wait_done = wait_for_operation(config, 'create', r) v = navigate_hash(wait_done, ['vpc', 'id']) url = build_path(module, 'vpcs/{op_id}', {'op_id': v}) return fetch_resource(module, client, url) def update(config, link): module = config.module client = config.client(get_region(module), "vpc", "project") r = None try: r = client.put(link, resource_to_update(module)) except HwcClientException as ex: msg = ("module(hwc_network_vpc): error updating " "resource, error: %s" % str(ex)) module.fail_json(msg=msg) wait_for_operation(config, 'update', r) return fetch_resource(module, client, link) def delete(config, link): module = config.module client = config.client(get_region(module), "vpc", "project") try: client.delete(link) except HwcClientException as ex: msg = ("module(hwc_network_vpc): error deleting " "resource, error: %s" % str(ex)) module.fail_json(msg=msg) wait_for_delete(module, client, link) def fetch_resource(module, client, link): try: return client.get(link) except HwcClientException as ex: msg = ("module(hwc_network_vpc): error fetching " "resource, error: %s" % str(ex)) module.fail_json(msg=msg) def get_id_by_name(config): module = config.module client = config.client(get_region(module), "vpc", "project") name = module.params.get("name") link = "vpcs" query_link = "?marker={marker}&limit=10" link += query_link not_format_keys = re.findall("={marker}", link) none_values = re.findall("=None", link) if not (not_format_keys or none_values): r = None try: r = client.get(link) except Exception: pass if r is None: return None r = r.get('vpcs', []) ids = [ i.get('id') for i in r if i.get('name', '') == name ] if not ids: return None elif len(ids) == 1: return ids[0] else: module.fail_json(msg="Multiple resources with same name are found.") elif none_values: module.fail_json( msg="Can not find id by name because url includes None.") else: p = {'marker': ''} ids = set() while True: r = None try: r = client.get(link.format(**p)) except Exception: pass if r is None: break r = r.get('vpcs', []) if r == []: break for i in r: if i.get('name') == name: ids.add(i.get('id')) if len(ids) >= 2: module.fail_json( msg="Multiple resources with same name are found.") p['marker'] = r[-1].get('id') return ids.pop() if ids else None def self_link(module): return build_path(module, "vpcs/{id}") def resource_to_create(module): request = remove_empty_from_dict({ u'name': module.params.get('name'), u'cidr': module.params.get('cidr') }) return {'vpc': request} def resource_to_update(module): request = remove_nones_from_dict({ u'name': module.params.get('name'), u'cidr': module.params.get('cidr') }) return {'vpc': request} def _get_editable_properties(module): request = remove_nones_from_dict({ "name": module.params.get("name"), "cidr": module.params.get("cidr"), }) return request def response_to_hash(module, response): """ Remove unnecessary properties from the response. This is for doing comparisons with Ansible's current parameters. """ return { u'id': response.get(u'id'), u'name': response.get(u'name'), u'cidr': response.get(u'cidr'), u'status': response.get(u'status'), u'routes': VpcRoutesArray(response.get(u'routes', []), module).from_response(), u'enable_shared_snat': response.get(u'enable_shared_snat') } def wait_for_operation(config, op_type, op_result): module = config.module op_id = navigate_hash(op_result, ['vpc', 'id']) url = build_path(module, "vpcs/{op_id}", {'op_id': op_id}) timeout = 60 * int(module.params['timeouts'][op_type].rstrip('m')) states = { 'create': { 'allowed': ['CREATING', 'DONW', 'OK'], 'complete': ['OK'], }, 'update': { 'allowed': ['PENDING_UPDATE', 'DONW', 'OK'], 'complete': ['OK'], } } return wait_for_completion(url, timeout, states[op_type]['allowed'], states[op_type]['complete'], config) def wait_for_completion(op_uri, timeout, allowed_states, complete_states, config): module = config.module client = config.client(get_region(module), "vpc", "project") end = time.time() + timeout while time.time() <= end: try: op_result = fetch_resource(module, client, op_uri) except Exception: time.sleep(1.0) continue raise_if_errors(op_result, module) status = navigate_hash(op_result, ['vpc', 'status']) if status not in allowed_states: module.fail_json(msg="Invalid async operation status %s" % status) if status in complete_states: return op_result time.sleep(1.0) module.fail_json(msg="Timeout to wait completion.") def raise_if_errors(response, module): errors = navigate_hash(response, []) if errors: module.fail_json(msg=navigate_hash(response, [])) def wait_for_delete(module, client, link): end = time.time() + 60 * int( module.params['timeouts']['delete'].rstrip('m')) while time.time() <= end: try: client.get(link) except HwcClientException404: return except Exception: pass time.sleep(1.0) module.fail_json(msg="Timeout to wait for deletion to be complete.") class VpcRoutesArray(object): def __init__(self, request, module): self.module = module if request: self.request = request else: self.request = [] def to_request(self): items = [] for item in self.request: items.append(self._request_for_item(item)) return items def from_response(self): items = [] for item in self.request: items.append(self._response_from_item(item)) return items def _request_for_item(self, item): return { u'destination': item.get('destination'), u'nexthop': item.get('next_hop') } def _response_from_item(self, item): return { u'destination': item.get(u'destination'), u'next_hop': item.get(u'nexthop') } if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 869, 1458, 21431, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 11490, 199, 3, 15249, 199, 11490, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12073, 67, 63, 1200, 63, 11742, 199, 1802, 26, 272, 446, 21591, 376, 12830, 2073, 14, 199, 3612, 63, 1802, 26, 10560, 282, 869, 1458, 21431, 8142, 19209, 199, 1023, 63, 3270, 26, 283, 18, 14, 24, 7, 199, 2502, 26, 869, 1458, 21431, 3277, 14, 8593, 27002, 1129, 530, 320, 1181, 9, 199, 7538, 26, 272, 446, 4145, 2356, 499, 14, 1085, 14, 20, 272, 446, 19395, 1178, 17, 2356, 650, 14, 22, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 12830, 14, 267, 730, 26, 620, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 536, 26, 267, 1369, 26, 288, 446, 314, 536, 402, 12830, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 16770, 26, 267, 1369, 26, 288, 446, 314, 1425, 402, 2808, 18709, 315, 314, 12830, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 199, 11036, 63, 9970, 63, 7677, 26, 12073, 67, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 282, 12830, 523, 12073, 67, 63, 1200, 63, 11742, 26, 489, 8503, 63, 6520, 26, 7370, 8503, 63, 6520, 7820, 489, 922, 26, 7370, 922, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 2881, 26, 7370, 2881, 7820, 489, 2199, 26, 7370, 2199, 7820, 489, 4897, 26, 7370, 4897, 7820, 489, 536, 26, 298, 11742, 63, 17, 2, 489, 16770, 26, 298, 5756, 14, 6568, 14, 1960, 14, 16, 15, 1194, 2, 489, 1174, 26, 3451, 199, 2344, 199, 199, 9677, 275, 1449, 272, 1305, 26, 267, 1369, 26, 288, 446, 314, 1305, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 536, 26, 267, 1369, 26, 288, 446, 314, 536, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 16770, 26, 267, 1369, 26, 288, 446, 314, 1425, 402, 2808, 18709, 315, 314, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 2004, 26, 267, 1369, 26, 288, 446, 314, 2004, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 15777, 26, 267, 1369, 26, 288, 446, 314, 7475, 2556, 14, 267, 730, 26, 6114, 267, 2138, 26, 3182, 267, 3509, 26, 288, 5724, 26, 355, 1369, 26, 490, 446, 314, 5724, 2784, 8135, 402, 282, 7475, 14, 355, 730, 26, 620, 355, 2138, 26, 3182, 288, 2163, 63, 13376, 26, 355, 1369, 26, 490, 446, 314, 2163, 22377, 402, 282, 7475, 14, 982, 314, 7475, 730, 365, 9104, 316, 12, 1993, 652, 911, 5647, 19209, 9104, 316, 1950, 2870, 14, 355, 730, 26, 620, 355, 2138, 26, 3182, 272, 4756, 63, 5555, 63, 23774, 26, 267, 1369, 26, 288, 446, 2498, 3775, 314, 5709, 6895, 292, 365, 5223, 14, 267, 730, 26, 2155, 267, 2138, 26, 3182, 199, 2344, 199, 199, 11490, 199, 3, 24339, 199, 11490, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 8090, 67, 63, 1208, 492, 334, 2028, 12, 869, 13683, 2377, 12, 664, 63, 4551, 12, 4490, 869, 13683, 3041, 1726, 12, 20850, 63, 2227, 12, 4490, 869, 13683, 3041, 1726, 5188, 12, 4490, 2813, 63, 3592, 83, 63, 504, 63, 807, 12, 1900, 63, 515, 12, 4490, 2813, 63, 1667, 63, 504, 63, 807, 12, 4490, 787, 63, 7892, 63, 14020, 9, 199, 646, 295, 199, 646, 900, 199, 199, 11490, 199, 3, 11298, 199, 11490, 421, 199, 318, 2446, 837, 272, 408, 6756, 805, 624, 339, 859, 275, 869, 13683, 2377, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 995, 730, 534, 495, 659, 288, 536, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 288, 16770, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 358, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 272, 1101, 275, 4094, 8, 578, 12, 283, 11742, 358, 339, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 340, 334, 1397, 859, 14, 1162, 14, 362, 480, 344, 2237, 436, 859, 14, 1162, 14, 362, 480, 354, 2349, 267, 859, 14, 1162, 459, 344, 418, 275, 664, 63, 344, 63, 991, 63, 354, 8, 888, 9, 339, 5267, 275, 488, 272, 2142, 275, 291, 63, 1073, 8, 578, 9, 272, 327, 314, 2142, 911, 2387, 488, 83, 340, 1415, 1475, 2633, 787, 3201, 939, 272, 340, 440, 295, 14, 1733, 2336, 403, 15, 92, 15, 403, 4268, 2142, 304, 267, 1890, 275, 1101, 14, 1258, 8, 362, 63, 4551, 8, 578, 395, 298, 11742, 401, 298, 1715, 531, 267, 5267, 275, 5267, 63, 1927, 8, 578, 12, 1890, 12, 2142, 9, 267, 340, 5267, 26, 288, 5267, 275, 5267, 14, 362, 360, 11742, 358, 272, 2896, 275, 756, 339, 340, 5267, 26, 267, 340, 1174, 508, 283, 1881, 356, 288, 4282, 275, 485, 362, 63, 10820, 63, 3282, 8, 578, 9, 288, 1453, 63, 929, 275, 1177, 63, 475, 63, 2227, 8, 578, 12, 5267, 9, 288, 340, 787, 63, 7892, 63, 14020, 8, 4921, 12, 1453, 63, 929, 304, 355, 340, 440, 859, 14, 1074, 63, 632, 26, 490, 5267, 275, 1678, 8, 888, 12, 291, 63, 1073, 8, 578, 430, 490, 5267, 275, 1177, 63, 475, 63, 2227, 8, 578, 12, 5267, 14, 362, 360 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 869, 1458, 21431, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 11490, 199, 3, 15249, 199, 11490, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12073, 67, 63, 1200, 63, 11742, 199, 1802, 26, 272, 446, 21591, 376, 12830, 2073, 14, 199, 3612, 63, 1802, 26, 10560, 282, 869, 1458, 21431, 8142, 19209, 199, 1023, 63, 3270, 26, 283, 18, 14, 24, 7, 199, 2502, 26, 869, 1458, 21431, 3277, 14, 8593, 27002, 1129, 530, 320, 1181, 9, 199, 7538, 26, 272, 446, 4145, 2356, 499, 14, 1085, 14, 20, 272, 446, 19395, 1178, 17, 2356, 650, 14, 22, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 12830, 14, 267, 730, 26, 620, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 536, 26, 267, 1369, 26, 288, 446, 314, 536, 402, 12830, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 16770, 26, 267, 1369, 26, 288, 446, 314, 1425, 402, 2808, 18709, 315, 314, 12830, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 199, 11036, 63, 9970, 63, 7677, 26, 12073, 67, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 282, 12830, 523, 12073, 67, 63, 1200, 63, 11742, 26, 489, 8503, 63, 6520, 26, 7370, 8503, 63, 6520, 7820, 489, 922, 26, 7370, 922, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 2881, 26, 7370, 2881, 7820, 489, 2199, 26, 7370, 2199, 7820, 489, 4897, 26, 7370, 4897, 7820, 489, 536, 26, 298, 11742, 63, 17, 2, 489, 16770, 26, 298, 5756, 14, 6568, 14, 1960, 14, 16, 15, 1194, 2, 489, 1174, 26, 3451, 199, 2344, 199, 199, 9677, 275, 1449, 272, 1305, 26, 267, 1369, 26, 288, 446, 314, 1305, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 536, 26, 267, 1369, 26, 288, 446, 314, 536, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 16770, 26, 267, 1369, 26, 288, 446, 314, 1425, 402, 2808, 18709, 315, 314, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 2004, 26, 267, 1369, 26, 288, 446, 314, 2004, 402, 12830, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 15777, 26, 267, 1369, 26, 288, 446, 314, 7475, 2556, 14, 267, 730, 26, 6114, 267, 2138, 26, 3182, 267, 3509, 26, 288, 5724, 26, 355, 1369, 26, 490, 446, 314, 5724, 2784, 8135, 402, 282, 7475, 14, 355, 730, 26, 620, 355, 2138, 26, 3182, 288, 2163, 63, 13376, 26, 355, 1369, 26, 490, 446, 314, 2163, 22377, 402, 282, 7475, 14, 982, 314, 7475, 730, 365, 9104, 316, 12, 1993, 652, 911, 5647, 19209, 9104, 316, 1950, 2870, 14, 355, 730, 26, 620, 355, 2138, 26, 3182, 272, 4756, 63, 5555, 63, 23774, 26, 267, 1369, 26, 288, 446, 2498, 3775, 314, 5709, 6895, 292, 365, 5223, 14, 267, 730, 26, 2155, 267, 2138, 26, 3182, 199, 2344, 199, 199, 11490, 199, 3, 24339, 199, 11490, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 8090, 67, 63, 1208, 492, 334, 2028, 12, 869, 13683, 2377, 12, 664, 63, 4551, 12, 4490, 869, 13683, 3041, 1726, 12, 20850, 63, 2227, 12, 4490, 869, 13683, 3041, 1726, 5188, 12, 4490, 2813, 63, 3592, 83, 63, 504, 63, 807, 12, 1900, 63, 515, 12, 4490, 2813, 63, 1667, 63, 504, 63, 807, 12, 4490, 787, 63, 7892, 63, 14020, 9, 199, 646, 295, 199, 646, 900, 199, 199, 11490, 199, 3, 11298, 199, 11490, 421, 199, 318, 2446, 837, 272, 408, 6756, 805, 624, 339, 859, 275, 869, 13683, 2377, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 995, 730, 534, 495, 659, 288, 536, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 288, 16770, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 358, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 272, 1101, 275, 4094, 8, 578, 12, 283, 11742, 358, 339, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 340, 334, 1397, 859, 14, 1162, 14, 362, 480, 344, 2237, 436, 859, 14, 1162, 14, 362, 480, 354, 2349, 267, 859, 14, 1162, 459, 344, 418, 275, 664, 63, 344, 63, 991, 63, 354, 8, 888, 9, 339, 5267, 275, 488, 272, 2142, 275, 291, 63, 1073, 8, 578, 9, 272, 327, 314, 2142, 911, 2387, 488, 83, 340, 1415, 1475, 2633, 787, 3201, 939, 272, 340, 440, 295, 14, 1733, 2336, 403, 15, 92, 15, 403, 4268, 2142, 304, 267, 1890, 275, 1101, 14, 1258, 8, 362, 63, 4551, 8, 578, 395, 298, 11742, 401, 298, 1715, 531, 267, 5267, 275, 5267, 63, 1927, 8, 578, 12, 1890, 12, 2142, 9, 267, 340, 5267, 26, 288, 5267, 275, 5267, 14, 362, 360, 11742, 358, 272, 2896, 275, 756, 339, 340, 5267, 26, 267, 340, 1174, 508, 283, 1881, 356, 288, 4282, 275, 485, 362, 63, 10820, 63, 3282, 8, 578, 9, 288, 1453, 63, 929, 275, 1177, 63, 475, 63, 2227, 8, 578, 12, 5267, 9, 288, 340, 787, 63, 7892, 63, 14020, 8, 4921, 12, 1453, 63, 929, 304, 355, 340, 440, 859, 14, 1074, 63, 632, 26, 490, 5267, 275, 1678, 8, 888, 12, 291, 63, 1073, 8, 578, 430, 490, 5267, 275, 1177, 63, 475, 63, 2227, 8, 578, 12, 5267, 14, 362, 360, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eepalms/gem5-newcache
tests/configs/simple-atomic-mp.py
69
2376
# Copyright (c) 2013 ARM Limited # All rights reserved. # # The license below extends only to copyright in the software and shall # not be construed as granting a license to any other intellectual # property including but not limited to intellectual property relating # to a hardware implementation of the functionality of the software # licensed hereunder. You may use the software subject to the license # terms below provided that you ensure that this notice is replicated # unmodified and in its entirety in all distributions of the software, # modified or unmodified, in source code or in binary form. # # Copyright (c) 2006-2007 The Regents of The University of Michigan # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution; # neither the name of the copyright holders nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Authors: Andreas Hansson from m5.objects import * from base_config import * nb_cores = 4 root = BaseSESystem(mem_mode='atomic', cpu_class=AtomicSimpleCPU, num_cpus=nb_cores).create_root()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6171, 27155, 23954, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 6061, 264, 305, 869, 290, 385, 265, 199, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 1300, 63, 888, 492, 627, 199, 199, 4994, 63, 4630, 275, 841, 199, 1231, 275, 3523, 51, 654, 3045, 8, 5286, 63, 632, 534, 10910, 297, 5033, 63, 533, 29, 31931, 3184, 11011, 12, 490, 1967, 63, 8896, 29, 4994, 63, 4630, 680, 981, 63, 1231, 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 ]
[ 1898, 334, 67, 9, 6171, 27155, 23954, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 6061, 264, 305, 869, 290, 385, 265, 199, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 1300, 63, 888, 492, 627, 199, 199, 4994, 63, 4630, 275, 841, 199, 1231, 275, 3523, 51, 654, 3045, 8, 5286, 63, 632, 534, 10910, 297, 5033, 63, 533, 29, 31931, 3184, 11011, 12, 490, 1967, 63, 8896, 29, 4994, 63, 4630, 680, 981, 63, 1231, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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page used in acceptance tests. """ from collections import OrderedDict from django.test import TestCase from shoppingcart.processors.CyberSource2 import sign, verify_signatures from shoppingcart.processors.exceptions import CCProcessorSignatureException from shoppingcart.tests.payment_fake import PaymentFakeView class PaymentFakeViewTest(TestCase): """ Test that the fake payment view interacts correctly with the shopping cart. """ shard = 4 def setUp(self): super(PaymentFakeViewTest, self).setUp() # Reset the view state PaymentFakeView.PAYMENT_STATUS_RESPONSE = "success" self.client_post_params = OrderedDict([ ('amount', '25.00'), ('currency', 'usd'), ('transaction_type', 'sale'), ('orderNumber', '33'), ('access_key', '123456789'), ('merchantID', 'edx'), ('djch', '012345678912'), ('orderPage_version', 2), ('orderPage_serialNumber', '1234567890'), ('profile_id', "00000001"), ('reference_number', 10), ('locale', 'en'), ('signed_date_time', '2014-08-18T13:59:31Z'), ]) def test_accepts_client_signatures(self): # Generate shoppingcart signatures post_params = sign(self.client_post_params) # Simulate a POST request from the payment workflow # page to the fake payment page. resp = self.client.post( '/shoppingcart/payment_fake', dict(post_params) ) # Expect that the response was successful self.assertEqual(resp.status_code, 200) # Expect that we were served the payment page # (not the error page) self.assertIn("Payment Form", resp.content) def test_rejects_invalid_signature(self): # Generate shoppingcart signatures post_params = sign(self.client_post_params) # Tamper with the signature post_params['signature'] = "invalid" # Simulate a POST request from the payment workflow # page to the fake payment page. resp = self.client.post( '/shoppingcart/payment_fake', dict(post_params) ) # Expect that we got an error self.assertIn("Error", resp.content) def test_sends_valid_signature(self): # Generate shoppingcart signatures post_params = sign(self.client_post_params) # Get the POST params that the view would send back to us resp_params = PaymentFakeView.response_post_params(post_params) # Check that the client accepts these try: verify_signatures(resp_params) except CCProcessorSignatureException: self.fail("Client rejected signatures.") def test_set_payment_status(self): # Generate shoppingcart signatures post_params = sign(self.client_post_params) # Configure the view to declined payments resp = self.client.put( '/shoppingcart/payment_fake', data="decline", content_type='text/plain' ) self.assertEqual(resp.status_code, 200) # Check that the decision is "DECLINE" resp_params = PaymentFakeView.response_post_params(post_params) self.assertEqual(resp_params.get('decision'), 'DECLINE') # Configure the view to fail payments resp = self.client.put( '/shoppingcart/payment_fake', data="failure", content_type='text/plain' ) self.assertEqual(resp.status_code, 200) # Check that the decision is "REJECT" resp_params = PaymentFakeView.response_post_params(post_params) self.assertEqual(resp_params.get('decision'), 'REJECT') # Configure the view to accept payments resp = self.client.put( '/shoppingcart/payment_fake', data="success", content_type='text/plain' ) self.assertEqual(resp.status_code, 200) # Check that the decision is "ACCEPT" resp_params = PaymentFakeView.response_post_params(post_params) self.assertEqual(resp_params.get('decision'), 'ACCEPT')
agpl-3.0
[ 624, 199, 2925, 367, 314, 4026, 11628, 2034, 1202, 315, 4729, 554, 2295, 14, 199, 624, 199, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 25630, 4073, 8153, 14, 10547, 14, 9156, 605, 2980, 18, 492, 2070, 12, 4911, 63, 15132, 199, 504, 25630, 4073, 8153, 14, 10547, 14, 3924, 492, 17586, 10438, 10014, 1726, 199, 504, 25630, 4073, 8153, 14, 2219, 14, 7948, 63, 3183, 492, 25523, 8249, 2768, 421, 199, 533, 25523, 8249, 2768, 774, 8, 1746, 304, 272, 408, 272, 1379, 626, 314, 4026, 11628, 2455, 17232, 83, 272, 6657, 543, 314, 25630, 4073, 16942, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 22374, 8249, 2768, 774, 12, 291, 680, 5996, 342, 398, 327, 15510, 314, 2455, 1174, 267, 25523, 8249, 2768, 14, 17698, 4479, 63, 6305, 63, 12801, 275, 298, 3742, 2, 398, 291, 14, 1258, 63, 1932, 63, 1162, 275, 8773, 779, 288, 661, 4606, 297, 283, 821, 14, 383, 659, 288, 661, 4968, 297, 283, 31597, 659, 288, 661, 5945, 63, 466, 297, 283, 8515, 659, 288, 661, 1648, 3259, 297, 283, 1153, 659, 288, 661, 2732, 63, 498, 297, 283, 11272, 659, 288, 661, 2626, 26938, 998, 297, 283, 8268, 659, 288, 661, 18256, 335, 297, 283, 11371, 713, 659, 288, 661, 1648, 3276, 63, 1023, 297, 499, 395, 288, 661, 1648, 3276, 63, 2171, 3259, 297, 283, 21515, 659, 288, 661, 2913, 63, 344, 297, 298, 23848, 1288, 288, 661, 4443, 63, 1955, 297, 1616, 395, 288, 661, 5508, 297, 283, 287, 659, 288, 661, 1737, 63, 602, 63, 521, 297, 283, 7280, 13, 2036, 13, 1085, 52, 969, 26, 1427, 26, 2192, 58, 659, 267, 4794, 339, 347, 511, 63, 27692, 63, 1258, 63, 15132, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 10751, 5434, 282, 8761, 1056, 687, 314, 11628, 10431, 267, 327, 2034, 370, 314, 4026, 11628, 2034, 14, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 1211, 8, 1932, 63, 1162, 9, 267, 776, 398, 327, 15100, 626, 314, 1177, 1990, 9512, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 15100, 626, 781, 4898, 19733, 314, 11628, 2034, 267, 327, 334, 1397, 314, 1125, 2034, 9, 267, 291, 14, 4080, 480, 22374, 8204, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 16857, 83, 63, 3197, 63, 5233, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 377, 5282, 281, 543, 314, 4955, 267, 2963, 63, 1162, 459, 5233, 418, 275, 298, 3197, 2, 398, 327, 10751, 5434, 282, 8761, 1056, 687, 314, 11628, 10431, 267, 327, 2034, 370, 314, 4026, 11628, 2034, 14, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 1211, 8, 1932, 63, 1162, 9, 267, 776, 398, 327, 15100, 626, 781, 4788, 376, 1125, 267, 291, 14, 4080, 480, 547, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 2464, 795, 63, 1078, 63, 5233, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 2372, 314, 8761, 1862, 626, 314, 2455, 3955, 3222, 1771, 370, 2739, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 398, 327, 2670, 626, 314, 1890, 11479, 3520, 267, 862, 26, 288, 4911, 63, 15132, 8, 4518, 63, 1162, 9, 398, 871, 17586, 10438, 10014, 1726, 26, 288, 291, 14, 1633, 480, 3041, 18935, 17597, 2685, 339, 347, 511, 63, 409, 63, 7948, 63, 1205, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 15453, 314, 2455, 370, 15021, 1942, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 9427, 1132, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 27402, 3565, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 27402, 3565, 358, 398, 327, 15453, 314, 2455, 370, 2449, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 5328, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 907, 5550, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 907, 5550, 358, 398, 327, 15453, 314, 2455, 370, 4729, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 3742, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 13089, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 13089, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2925, 367, 314, 4026, 11628, 2034, 1202, 315, 4729, 554, 2295, 14, 199, 624, 199, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 25630, 4073, 8153, 14, 10547, 14, 9156, 605, 2980, 18, 492, 2070, 12, 4911, 63, 15132, 199, 504, 25630, 4073, 8153, 14, 10547, 14, 3924, 492, 17586, 10438, 10014, 1726, 199, 504, 25630, 4073, 8153, 14, 2219, 14, 7948, 63, 3183, 492, 25523, 8249, 2768, 421, 199, 533, 25523, 8249, 2768, 774, 8, 1746, 304, 272, 408, 272, 1379, 626, 314, 4026, 11628, 2455, 17232, 83, 272, 6657, 543, 314, 25630, 4073, 16942, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 22374, 8249, 2768, 774, 12, 291, 680, 5996, 342, 398, 327, 15510, 314, 2455, 1174, 267, 25523, 8249, 2768, 14, 17698, 4479, 63, 6305, 63, 12801, 275, 298, 3742, 2, 398, 291, 14, 1258, 63, 1932, 63, 1162, 275, 8773, 779, 288, 661, 4606, 297, 283, 821, 14, 383, 659, 288, 661, 4968, 297, 283, 31597, 659, 288, 661, 5945, 63, 466, 297, 283, 8515, 659, 288, 661, 1648, 3259, 297, 283, 1153, 659, 288, 661, 2732, 63, 498, 297, 283, 11272, 659, 288, 661, 2626, 26938, 998, 297, 283, 8268, 659, 288, 661, 18256, 335, 297, 283, 11371, 713, 659, 288, 661, 1648, 3276, 63, 1023, 297, 499, 395, 288, 661, 1648, 3276, 63, 2171, 3259, 297, 283, 21515, 659, 288, 661, 2913, 63, 344, 297, 298, 23848, 1288, 288, 661, 4443, 63, 1955, 297, 1616, 395, 288, 661, 5508, 297, 283, 287, 659, 288, 661, 1737, 63, 602, 63, 521, 297, 283, 7280, 13, 2036, 13, 1085, 52, 969, 26, 1427, 26, 2192, 58, 659, 267, 4794, 339, 347, 511, 63, 27692, 63, 1258, 63, 15132, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 10751, 5434, 282, 8761, 1056, 687, 314, 11628, 10431, 267, 327, 2034, 370, 314, 4026, 11628, 2034, 14, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 1211, 8, 1932, 63, 1162, 9, 267, 776, 398, 327, 15100, 626, 314, 1177, 1990, 9512, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 15100, 626, 781, 4898, 19733, 314, 11628, 2034, 267, 327, 334, 1397, 314, 1125, 2034, 9, 267, 291, 14, 4080, 480, 22374, 8204, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 16857, 83, 63, 3197, 63, 5233, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 377, 5282, 281, 543, 314, 4955, 267, 2963, 63, 1162, 459, 5233, 418, 275, 298, 3197, 2, 398, 327, 10751, 5434, 282, 8761, 1056, 687, 314, 11628, 10431, 267, 327, 2034, 370, 314, 4026, 11628, 2034, 14, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 1211, 8, 1932, 63, 1162, 9, 267, 776, 398, 327, 15100, 626, 781, 4788, 376, 1125, 267, 291, 14, 4080, 480, 547, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 2464, 795, 63, 1078, 63, 5233, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 2372, 314, 8761, 1862, 626, 314, 2455, 3955, 3222, 1771, 370, 2739, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 398, 327, 2670, 626, 314, 1890, 11479, 3520, 267, 862, 26, 288, 4911, 63, 15132, 8, 4518, 63, 1162, 9, 398, 871, 17586, 10438, 10014, 1726, 26, 288, 291, 14, 1633, 480, 3041, 18935, 17597, 2685, 339, 347, 511, 63, 409, 63, 7948, 63, 1205, 8, 277, 304, 398, 327, 7958, 25630, 4073, 8153, 17597, 267, 2963, 63, 1162, 275, 2070, 8, 277, 14, 1258, 63, 1932, 63, 1162, 9, 398, 327, 15453, 314, 2455, 370, 15021, 1942, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 9427, 1132, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 27402, 3565, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 27402, 3565, 358, 398, 327, 15453, 314, 2455, 370, 2449, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 5328, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 907, 5550, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 907, 5550, 358, 398, 327, 15453, 314, 2455, 370, 4729, 8633, 1470, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 1994, 17788, 15, 7948, 63, 3183, 297, 288, 666, 628, 3742, 401, 1564, 63, 466, 534, 505, 15, 6104, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 327, 2670, 626, 314, 14692, 365, 298, 13089, 2, 267, 3085, 63, 1162, 275, 25523, 8249, 2768, 14, 1310, 63, 1932, 63, 1162, 8, 1932, 63, 1162, 9, 267, 291, 14, 629, 8, 4518, 63, 1162, 14, 362, 360, 16622, 659, 283, 13089, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
saintdragon2/python-3-lecture-2015
civil-final/2nd_presentation/11조/pygame/tests/sysfont_test.py
21
1666
#################################### IMPORTS ################################### if __name__ == '__main__': import sys import os pkg_dir = os.path.split(os.path.abspath(__file__))[0] parent_dir, pkg_name = os.path.split(pkg_dir) is_pygame_pkg = (pkg_name == 'tests' and os.path.split(parent_dir)[1] == 'pygame') if not is_pygame_pkg: sys.path.insert(0, parent_dir) else: is_pygame_pkg = __name__.startswith('pygame.tests.') if is_pygame_pkg: from pygame.tests.test_utils import test_not_implemented, unittest else: from test.test_utils import test_not_implemented, unittest ################################################################################ class SysfontModuleTest(unittest.TestCase): def todo_test_create_aliases(self): # __doc__ (as of 2008-08-02) for pygame.sysfont.create_aliases: # self.fail() def todo_test_initsysfonts(self): # __doc__ (as of 2008-08-02) for pygame.sysfont.initsysfonts: # self.fail() def todo_test_initsysfonts_darwin(self): # __doc__ (as of 2008-08-02) for pygame.sysfont.initsysfonts_darwin: # self.fail() def todo_test_initsysfonts_unix(self): # __doc__ (as of 2008-08-02) for pygame.sysfont.initsysfonts_unix: # self.fail() def todo_test_initsysfonts_win32(self): # __doc__ (as of 2008-08-02) for pygame.sysfont.initsysfonts_win32: # self.fail() ################################################################################ if __name__ == '__main__': unittest.main()
mit
[ 1371, 381, 5025, 2596, 51, 10371, 5680, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 272, 492, 747, 272, 5496, 63, 694, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 59, 16, 61, 272, 1676, 63, 694, 12, 5496, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 4600, 63, 694, 9, 272, 365, 63, 22278, 63, 4600, 275, 334, 4600, 63, 354, 508, 283, 2219, 7, 436, 2151, 747, 14, 515, 14, 1294, 8, 1708, 63, 694, 2788, 17, 61, 508, 283, 22278, 358, 272, 340, 440, 365, 63, 22278, 63, 4600, 26, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 1676, 63, 694, 9, 199, 2836, 26, 272, 365, 63, 22278, 63, 4600, 275, 636, 354, 4343, 2460, 360, 22278, 14, 2219, 2659, 199, 199, 692, 365, 63, 22278, 63, 4600, 26, 272, 687, 9193, 14, 2219, 14, 396, 63, 1208, 492, 511, 63, 1397, 63, 13825, 12, 2882, 199, 2836, 26, 272, 687, 511, 14, 396, 63, 1208, 492, 511, 63, 1397, 63, 13825, 12, 2882, 199, 199, 13289, 199, 199, 533, 28766, 4246, 2377, 774, 8, 2796, 14, 1746, 304, 272, 347, 11386, 63, 396, 63, 981, 63, 8602, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 981, 63, 8602, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 13245, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 13245, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 11864, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 11864, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 2676, 708, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 2676, 708, 26, 8592, 327, 24807, 291, 14, 1633, 342, 199, 199, 13289, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 381, 5025, 2596, 51, 10371, 5680, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 272, 492, 747, 272, 5496, 63, 694, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 59, 16, 61, 272, 1676, 63, 694, 12, 5496, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 4600, 63, 694, 9, 272, 365, 63, 22278, 63, 4600, 275, 334, 4600, 63, 354, 508, 283, 2219, 7, 436, 2151, 747, 14, 515, 14, 1294, 8, 1708, 63, 694, 2788, 17, 61, 508, 283, 22278, 358, 272, 340, 440, 365, 63, 22278, 63, 4600, 26, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 1676, 63, 694, 9, 199, 2836, 26, 272, 365, 63, 22278, 63, 4600, 275, 636, 354, 4343, 2460, 360, 22278, 14, 2219, 2659, 199, 199, 692, 365, 63, 22278, 63, 4600, 26, 272, 687, 9193, 14, 2219, 14, 396, 63, 1208, 492, 511, 63, 1397, 63, 13825, 12, 2882, 199, 2836, 26, 272, 687, 511, 14, 396, 63, 1208, 492, 511, 63, 1397, 63, 13825, 12, 2882, 199, 199, 13289, 199, 199, 533, 28766, 4246, 2377, 774, 8, 2796, 14, 1746, 304, 272, 347, 11386, 63, 396, 63, 981, 63, 8602, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 981, 63, 8602, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 13245, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 13245, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 11864, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 11864, 26, 8592, 327, 24807, 291, 14, 1633, 342, 18407, 347, 11386, 63, 396, 63, 826, 1274, 19864, 63, 2676, 708, 8, 277, 304, 398, 327, 636, 1301, 363, 334, 305, 402, 9079, 13, 2036, 13, 996, 9, 367, 9193, 14, 1274, 4246, 14, 826, 1274, 19864, 63, 2676, 708, 26, 8592, 327, 24807, 291, 14, 1633, 342, 199, 199, 13289, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
abought/osf.io
scripts/tests/test_migrate_logs_fix.py
57
1339
from website.models import Node from tests.base import OsfTestCase from tests.factories import ProjectFactory, UserFactory, NodeFactory from scripts.migrate_logs_fix import ( do_migration, get_targets ) class TestMigrateLogs(OsfTestCase): def tearDown(self): OsfTestCase.tearDown(self) Node.remove() def test_get_targets(self): project1 = ProjectFactory() for log in project1.logs: log.should_hide = True log.save() project1.save() targets = get_targets() assert targets is not None assert len(targets) is 1 def test_do_migration(self): project = ProjectFactory() user = UserFactory() node = NodeFactory(parent=project) node.add_contributor(contributor=user) node.save() for log in node.logs: if log.action == 'contributor_added': log.should_hide = True log.save() project.logs.append(log) project.save() targets = get_targets() do_migration(targets) logs = [each for each in project.logs if each.action == 'contributor_added'] assert len(logs) is 0 logs2 = [each for each in node.logs if each.action == 'contributor_added'] assert logs2[0].should_hide is False
apache-2.0
[ 504, 10691, 14, 992, 492, 5013, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 2295, 14, 15406, 492, 32249, 12, 16047, 12, 5013, 2927, 199, 504, 10554, 14, 8462, 63, 7270, 63, 970, 492, 334, 272, 886, 63, 8998, 12, 664, 63, 4684, 199, 9, 421, 199, 533, 1379, 26641, 16333, 8, 47, 7646, 1746, 304, 339, 347, 6766, 8, 277, 304, 267, 593, 7646, 1746, 14, 12336, 8, 277, 9, 267, 5013, 14, 2168, 342, 339, 347, 511, 63, 362, 63, 4684, 8, 277, 304, 267, 2199, 17, 275, 32249, 342, 267, 367, 943, 315, 2199, 17, 14, 7270, 26, 288, 943, 14, 5626, 63, 8191, 275, 715, 288, 943, 14, 2117, 342, 267, 2199, 17, 14, 2117, 342, 398, 4545, 275, 664, 63, 4684, 342, 267, 702, 4545, 365, 440, 488, 267, 702, 822, 8, 4684, 9, 365, 413, 339, 347, 511, 63, 1117, 63, 8998, 8, 277, 304, 267, 2199, 275, 32249, 342, 267, 922, 275, 16047, 342, 267, 1031, 275, 5013, 2927, 8, 1708, 29, 1715, 9, 267, 1031, 14, 525, 63, 16833, 8, 16833, 29, 751, 9, 267, 1031, 14, 2117, 342, 267, 367, 943, 315, 1031, 14, 7270, 26, 288, 340, 943, 14, 1287, 508, 283, 16833, 63, 3270, 356, 355, 943, 14, 5626, 63, 8191, 275, 715, 355, 943, 14, 2117, 342, 355, 2199, 14, 7270, 14, 740, 8, 793, 9, 267, 2199, 14, 2117, 342, 398, 4545, 275, 664, 63, 4684, 342, 267, 886, 63, 8998, 8, 4684, 9, 398, 9610, 275, 359, 10885, 367, 1924, 315, 2199, 14, 7270, 340, 1924, 14, 1287, 508, 283, 16833, 63, 3270, 418, 267, 702, 822, 8, 7270, 9, 365, 378, 398, 9610, 18, 275, 359, 10885, 367, 1924, 315, 1031, 14, 7270, 340, 1924, 14, 1287, 508, 283, 16833, 63, 3270, 418, 267, 702, 9610, 18, 59, 16, 1055, 5626, 63, 8191, 365, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10691, 14, 992, 492, 5013, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 2295, 14, 15406, 492, 32249, 12, 16047, 12, 5013, 2927, 199, 504, 10554, 14, 8462, 63, 7270, 63, 970, 492, 334, 272, 886, 63, 8998, 12, 664, 63, 4684, 199, 9, 421, 199, 533, 1379, 26641, 16333, 8, 47, 7646, 1746, 304, 339, 347, 6766, 8, 277, 304, 267, 593, 7646, 1746, 14, 12336, 8, 277, 9, 267, 5013, 14, 2168, 342, 339, 347, 511, 63, 362, 63, 4684, 8, 277, 304, 267, 2199, 17, 275, 32249, 342, 267, 367, 943, 315, 2199, 17, 14, 7270, 26, 288, 943, 14, 5626, 63, 8191, 275, 715, 288, 943, 14, 2117, 342, 267, 2199, 17, 14, 2117, 342, 398, 4545, 275, 664, 63, 4684, 342, 267, 702, 4545, 365, 440, 488, 267, 702, 822, 8, 4684, 9, 365, 413, 339, 347, 511, 63, 1117, 63, 8998, 8, 277, 304, 267, 2199, 275, 32249, 342, 267, 922, 275, 16047, 342, 267, 1031, 275, 5013, 2927, 8, 1708, 29, 1715, 9, 267, 1031, 14, 525, 63, 16833, 8, 16833, 29, 751, 9, 267, 1031, 14, 2117, 342, 267, 367, 943, 315, 1031, 14, 7270, 26, 288, 340, 943, 14, 1287, 508, 283, 16833, 63, 3270, 356, 355, 943, 14, 5626, 63, 8191, 275, 715, 355, 943, 14, 2117, 342, 355, 2199, 14, 7270, 14, 740, 8, 793, 9, 267, 2199, 14, 2117, 342, 398, 4545, 275, 664, 63, 4684, 342, 267, 886, 63, 8998, 8, 4684, 9, 398, 9610, 275, 359, 10885, 367, 1924, 315, 2199, 14, 7270, 340, 1924, 14, 1287, 508, 283, 16833, 63, 3270, 418, 267, 702, 822, 8, 7270, 9, 365, 378, 398, 9610, 18, 275, 359, 10885, 367, 1924, 315, 1031, 14, 7270, 340, 1924, 14, 1287, 508, 283, 16833, 63, 3270, 418, 267, 702, 9610, 18, 59, 16, 1055, 5626, 63, 8191, 365, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
jtaghiyar/kronos
setup.py
1
1513
''' Created on Jul 10, 2014 @author: jtaghiyar ''' import codecs import os import re from setuptools import setup def read(*paths): here = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(here, *paths)) as f: return f.read() def get_version(): version_file = read("kronos", "kronos_version.py") version_match = re.search(r"^kronos_version = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError("Unable to find version string.") long_description = read('README.md') setup(name='kronos_pipeliner', version=get_version(), description='A workflow assembler for genome analytics and informatics', long_description=long_description, classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Scientific/Engineering :: Bio-Informatics", ], keywords='pipeline workflow bioinformatics kronos', author='M. Jafar Taghiyar', author_email='jafar.taghiyar@gmail.com', url='https://github.com/jtaghiyar/kronos', license='MIT', packages=['kronos', 'templates'], entry_points={'console_scripts':['kronos=kronos:main']}, install_requires = ['pyyaml>=3.11', 'ruffus==2.4.1'] )
mit
[ 2344, 199, 10502, 641, 1603, 348, 1616, 12, 6927, 199, 199, 32, 2502, 26, 1335, 1450, 5812, 89, 285, 199, 2344, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 295, 199, 504, 9116, 492, 3272, 199, 199, 318, 1586, 2031, 3771, 304, 272, 2348, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 1681, 12, 627, 3771, 430, 465, 289, 26, 267, 372, 289, 14, 739, 342, 199, 199, 318, 664, 63, 1023, 837, 272, 1015, 63, 493, 275, 1586, 480, 75, 2641, 736, 401, 298, 75, 2641, 736, 63, 1023, 14, 647, 531, 272, 1015, 63, 1431, 275, 295, 14, 1733, 8, 82, 16136, 75, 2641, 736, 63, 1023, 275, 788, 60, 937, 7059, 1154, 937, 10, 11820, 60, 937, 401, 2892, 1015, 63, 493, 12, 295, 14, 45, 9, 272, 340, 1015, 63, 1431, 26, 267, 372, 1015, 63, 1431, 14, 923, 8, 17, 9, 272, 746, 6064, 480, 6005, 370, 2342, 1015, 1059, 2685, 199, 199, 2809, 63, 1802, 275, 1586, 360, 18195, 14, 1064, 358, 199, 199, 2758, 8, 354, 534, 75, 2641, 736, 63, 4990, 31338, 297, 489, 1015, 29, 362, 63, 1023, 1062, 489, 1369, 534, 33, 10431, 22931, 82, 367, 29924, 30159, 436, 315, 509, 3889, 83, 297, 489, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 489, 19137, 1524, 267, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 267, 298, 23910, 23975, 3800, 27491, 15, 497, 1733, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 699, 2308, 13, 607, 509, 3889, 83, 401, 4960, 2156, 489, 7681, 534, 7379, 10431, 28897, 262, 509, 3889, 83, 1022, 2641, 736, 297, 489, 4132, 534, 45, 14, 1603, 2756, 285, 8053, 5812, 89, 285, 297, 489, 4132, 63, 2123, 534, 74, 2756, 285, 14, 1450, 5812, 89, 285, 32, 6799, 14, 957, 297, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 74, 1450, 5812, 89, 285, 15, 75, 2641, 736, 297, 489, 4190, 534, 13965, 297, 489, 6117, 2968, 75, 2641, 736, 297, 283, 5876, 995, 489, 2397, 63, 3438, 3713, 6614, 63, 6429, 21662, 75, 2641, 736, 29, 75, 2641, 736, 26, 973, 14949, 489, 3907, 63, 6537, 275, 788, 647, 5963, 8119, 19, 14, 845, 297, 283, 82, 3043, 527, 389, 18, 14, 20, 14, 17, 418, 1362, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 10502, 641, 1603, 348, 1616, 12, 6927, 199, 199, 32, 2502, 26, 1335, 1450, 5812, 89, 285, 199, 2344, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 295, 199, 504, 9116, 492, 3272, 199, 199, 318, 1586, 2031, 3771, 304, 272, 2348, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 1681, 12, 627, 3771, 430, 465, 289, 26, 267, 372, 289, 14, 739, 342, 199, 199, 318, 664, 63, 1023, 837, 272, 1015, 63, 493, 275, 1586, 480, 75, 2641, 736, 401, 298, 75, 2641, 736, 63, 1023, 14, 647, 531, 272, 1015, 63, 1431, 275, 295, 14, 1733, 8, 82, 16136, 75, 2641, 736, 63, 1023, 275, 788, 60, 937, 7059, 1154, 937, 10, 11820, 60, 937, 401, 2892, 1015, 63, 493, 12, 295, 14, 45, 9, 272, 340, 1015, 63, 1431, 26, 267, 372, 1015, 63, 1431, 14, 923, 8, 17, 9, 272, 746, 6064, 480, 6005, 370, 2342, 1015, 1059, 2685, 199, 199, 2809, 63, 1802, 275, 1586, 360, 18195, 14, 1064, 358, 199, 199, 2758, 8, 354, 534, 75, 2641, 736, 63, 4990, 31338, 297, 489, 1015, 29, 362, 63, 1023, 1062, 489, 1369, 534, 33, 10431, 22931, 82, 367, 29924, 30159, 436, 315, 509, 3889, 83, 297, 489, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 489, 19137, 1524, 267, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 267, 298, 23910, 23975, 3800, 27491, 15, 497, 1733, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 699, 2308, 13, 607, 509, 3889, 83, 401, 4960, 2156, 489, 7681, 534, 7379, 10431, 28897, 262, 509, 3889, 83, 1022, 2641, 736, 297, 489, 4132, 534, 45, 14, 1603, 2756, 285, 8053, 5812, 89, 285, 297, 489, 4132, 63, 2123, 534, 74, 2756, 285, 14, 1450, 5812, 89, 285, 32, 6799, 14, 957, 297, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 74, 1450, 5812, 89, 285, 15, 75, 2641, 736, 297, 489, 4190, 534, 13965, 297, 489, 6117, 2968, 75, 2641, 736, 297, 283, 5876, 995, 489, 2397, 63, 3438, 3713, 6614, 63, 6429, 21662, 75, 2641, 736, 29, 75, 2641, 736, 26, 973, 14949, 489, 3907, 63, 6537, 275, 788, 647, 5963, 8119, 19, 14, 845, 297, 283, 82, 3043, 527, 389, 18, 14, 20, 14, 17, 418, 1362, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
DecipherOne/Troglodyte
Trog Build Dependencies/Python26/Lib/logging/config.py
2
13417
# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name of Vinay Sajip # not be used in advertising or publicity pertaining to distribution # of the software without specific, written prior permission. # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL # VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER # IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ Configuration functions for the logging package for Python. The core package is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. Should work under Python versions >= 1.5.2, except that source line information is not available unless 'sys._getframe()' is. Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread import threading except ImportError: thread = None from SocketServer import ThreadingTCPServer, StreamRequestHandler DEFAULT_LOGGING_CONFIG_PORT = 9030 if sys.platform == "win32": RESET_ERROR = 10054 #WSAECONNRESET else: RESET_ERROR = 104 #ECONNRESET # # The following code implements a socket listener for on-the-fly # reconfiguration of logging. # # _listener holds the server object doing the listening _listener = None def fileConfig(fname, defaults=None, disable_existing_loggers=1): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). In versions of ConfigParser which have the readfp method [typically shipped in 2.x versions of Python], you can pass in a file-like object rather than a filename, in which case the file-like object will be read using readfp. """ import ConfigParser cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) else: cp.read(fname) formatters = _create_formatters(cp) # critical section logging._acquireLock() try: logging._handlers.clear() del logging._handlerList[:] # Handlers add themselves to logging._handlers handlers = _install_handlers(cp, formatters) _install_loggers(cp, handlers, disable_existing_loggers) finally: logging._releaseLock() def _resolve(name): """Resolve a dotted name to a global object.""" name = string.split(name, '.') used = name.pop(0) found = __import__(used) for n in name: used = used + '.' + n try: found = getattr(found, n) except AttributeError: __import__(used) found = getattr(found, n) return found def _strip_spaces(alist): return map(lambda x: string.strip(x), alist) def _encoded(s): return s if isinstance(s, str) else s.encode('utf-8') def _create_formatters(cp): """Create and return formatters""" flist = cp.get("formatters", "keys") if not len(flist): return {} flist = string.split(flist, ",") flist = _strip_spaces(flist) formatters = {} for form in flist: sectname = "formatter_%s" % form opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) else: fs = None if "datefmt" in opts: dfs = cp.get(sectname, "datefmt", 1) else: dfs = None c = logging.Formatter if "class" in opts: class_name = cp.get(sectname, "class") if class_name: c = _resolve(class_name) f = c(fs, dfs) formatters[form] = f return formatters def _install_handlers(cp, formatters): """Install and return handlers""" hlist = cp.get("handlers", "keys") if not len(hlist): return {} hlist = string.split(hlist, ",") hlist = _strip_spaces(hlist) handlers = {} fixups = [] #for inter-handler references for hand in hlist: sectname = "handler_%s" % hand klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: fmt = cp.get(sectname, "formatter") else: fmt = "" try: klass = eval(klass, vars(logging)) except (AttributeError, NameError): klass = _resolve(klass) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = klass(*args) if "level" in opts: level = cp.get(sectname, "level") h.setLevel(logging._levelNames[level]) if len(fmt): h.setFormatter(formatters[fmt]) if issubclass(klass, logging.handlers.MemoryHandler): if "target" in opts: target = cp.get(sectname,"target") else: target = "" if len(target): #the target handler may not be loaded yet, so keep for later... fixups.append((h, target)) handlers[hand] = h #now all handlers are loaded, fixup inter-handler references... for h, t in fixups: h.setTarget(handlers[t]) return handlers def _install_loggers(cp, handlers, disable_existing_loggers): """Create and install loggers""" # configure the root first llist = cp.get("loggers", "keys") llist = string.split(llist, ",") llist = map(lambda x: string.strip(x), llist) llist.remove("root") sectname = "logger_root" root = logging.root log = root opts = cp.options(sectname) if "level" in opts: level = cp.get(sectname, "level") log.setLevel(logging._levelNames[level]) for h in root.handlers[:]: root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") hlist = _strip_spaces(hlist) for hand in hlist: log.addHandler(handlers[hand]) #and now the others... #we don't want to lose the existing loggers, #since other threads may have pointers to them. #existing is set to contain all existing loggers, #and as we go through the new configuration we #remove any which are configured. At the end, #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. existing = root.manager.loggerDict.keys() #The list needs to be sorted so that we can #avoid disabling child loggers of explicitly #named loggers. With a sorted list it is easier #to find the child loggers. existing.sort(key=_encoded) #We'll keep the list of existing loggers #which are children of named loggers here... child_loggers = [] #now set up the new ones... for log in llist: sectname = "logger_%s" % log qn = cp.get(sectname, "qualname") opts = cp.options(sectname) if "propagate" in opts: propagate = cp.getint(sectname, "propagate") else: propagate = 1 logger = logging.getLogger(qn) if qn in existing: i = existing.index(qn) prefixed = qn + "." pflen = len(prefixed) num_existing = len(existing) i = i + 1 # look at the entry after qn while (i < num_existing) and (existing[i][:pflen] == prefixed): child_loggers.append(existing[i]) i = i + 1 existing.remove(qn) if "level" in opts: level = cp.get(sectname, "level") logger.setLevel(logging._levelNames[level]) for h in logger.handlers[:]: logger.removeHandler(h) logger.propagate = propagate logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") hlist = _strip_spaces(hlist) for hand in hlist: logger.addHandler(handlers[hand]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references #and by disabling them, you stop them doing any logging. #However, don't disable children of named loggers, as that's #probably not what was intended by the user. for log in existing: logger = root.manager.loggerDict[log] if log in child_loggers: logger.level = logging.NOTSET logger.handlers = [] logger.propagate = 1 elif disable_existing_loggers: logger.disabled = 1 def listen(port=DEFAULT_LOGGING_CONFIG_PORT): """ Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can join() when appropriate. To stop the server, call stopListening(). """ if not thread: raise NotImplementedError, "listen() needs threading to work" class ConfigStreamHandler(StreamRequestHandler): """ Handler for a logging configuration request. It expects a completely new logging configuration and uses fileConfig to install it. """ def handle(self): """ Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work. """ import tempfile try: conn = self.connection chunk = conn.recv(4) if len(chunk) == 4: slen = struct.unpack(">L", chunk)[0] chunk = self.connection.recv(slen) while len(chunk) < slen: chunk = chunk + conn.recv(slen - len(chunk)) #Apply new configuration. We'd like to be able to #create a StringIO and pass that in, but unfortunately #1.5.2 ConfigParser does not support reading file #objects, only actual files. So we create a temporary #file and remove it later. file = tempfile.mktemp(".ini") f = open(file, "w") f.write(chunk) f.close() try: fileConfig(file) except (KeyboardInterrupt, SystemExit): raise except: traceback.print_exc() os.remove(file) except socket.error, e: if type(e.args) != types.TupleType: raise else: errcode = e.args[0] if errcode != RESET_ERROR: raise class ConfigSocketReceiver(ThreadingTCPServer): """ A simple TCP socket-based logging config receiver. """ allow_reuse_address = 1 def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT, handler=None): ThreadingTCPServer.__init__(self, (host, port), handler) logging._acquireLock() self.abort = 0 logging._releaseLock() self.timeout = 1 def serve_until_stopped(self): import select abort = 0 while not abort: rd, wr, ex = select.select([self.socket.fileno()], [], [], self.timeout) if rd: self.handle_request() logging._acquireLock() abort = self.abort logging._releaseLock() def serve(rcvr, hdlr, port): server = rcvr(port=port, handler=hdlr) global _listener logging._acquireLock() _listener = server logging._releaseLock() server.serve_until_stopped() return threading.Thread(target=serve, args=(ConfigSocketReceiver, ConfigStreamHandler, port)) def stopListening(): """ Stop the listening server which was created with a call to listen(). """ global _listener if _listener: logging._acquireLock() _listener.abort = 1 _listener = None logging._releaseLock()
mit
[ 3, 1898, 12521, 13, 9488, 701, 28882, 1187, 428, 9091, 711, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 6866, 436, 626, 199, 3, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 199, 3, 21038, 3794, 12, 436, 626, 314, 536, 402, 28882, 1187, 428, 9091, 711, 199, 3, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 4084, 199, 3, 402, 314, 2032, 1928, 2488, 12, 5313, 6791, 4983, 14, 199, 3, 812, 568, 3448, 13950, 42, 1772, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 4141, 12, 6931, 199, 3, 11727, 5292, 2990, 1634, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 199, 3, 812, 568, 3448, 13950, 42, 1772, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 199, 3, 1821, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 199, 3, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 199, 5688, 3423, 367, 314, 2050, 2559, 367, 2018, 14, 710, 6170, 2559, 199, 374, 4079, 641, 13663, 499, 2564, 436, 6786, 2337, 475, 315, 1013, 14, 4159, 14, 1548, 12, 436, 315, 24585, 68, 199, 991, 3668, 1159, 943, 20, 74, 2656, 14, 199, 199, 11408, 1736, 1334, 2018, 5459, 2356, 413, 14, 21, 14, 18, 12, 871, 626, 1350, 1004, 199, 11697, 365, 440, 2808, 7444, 283, 1274, 423, 20912, 11716, 365, 14, 199, 199, 7384, 334, 35, 9, 12521, 13, 9300, 28882, 1187, 428, 9091, 711, 14, 2900, 5924, 5702, 14, 199, 199, 1378, 675, 12, 9329, 283, 646, 2050, 7, 436, 943, 13437, 1, 199, 624, 199, 199, 646, 984, 12, 2050, 12, 2050, 14, 5586, 12, 1059, 12, 2838, 12, 2702, 12, 747, 12, 5190, 12, 2943, 199, 199, 893, 26, 272, 492, 2462, 272, 492, 5796, 199, 2590, 3545, 26, 272, 2462, 275, 488, 199, 199, 504, 17766, 3120, 492, 11086, 316, 9735, 3120, 12, 8271, 11149, 421, 199, 3472, 63, 27896, 63, 5569, 63, 3657, 275, 9137, 1216, 199, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 272, 12565, 775, 63, 3170, 275, 2948, 1477, 257, 327, 55, 4251, 37, 17489, 18066, 199, 2836, 26, 272, 12565, 775, 63, 3170, 275, 21083, 258, 327, 37, 17489, 18066, 199, 199, 3, 199, 3, 257, 710, 2569, 1233, 9031, 282, 2838, 11647, 367, 641, 13, 1589, 13, 21600, 199, 3, 257, 295, 4758, 402, 2050, 14, 199, 3, 199, 3, 257, 485, 9799, 15164, 314, 1654, 909, 9689, 314, 22721, 199, 63, 9799, 275, 488, 199, 199, 318, 570, 2028, 8, 5252, 12, 4243, 29, 403, 12, 3507, 63, 5952, 63, 22771, 29, 17, 304, 272, 408, 272, 5574, 314, 2050, 2897, 687, 282, 14196, 13, 908, 570, 14, 339, 961, 883, 506, 2797, 9978, 5431, 687, 376, 4223, 12, 17266, 376, 1284, 922, 272, 314, 21255, 370, 3504, 687, 7750, 876, 13, 31126, 13422, 334, 692, 314, 272, 15030, 6571, 282, 14729, 370, 3451, 314, 3415, 436, 2248, 314, 12414, 272, 2897, 680, 272, 1010, 5459, 402, 14196, 1314, 1172, 314, 1586, 3997, 1083, 359, 32251, 272, 15924, 1915, 315, 499, 14, 88, 5459, 402, 2018, 467, 1265, 883, 986, 315, 282, 570, 13, 2930, 909, 272, 7830, 2419, 282, 1788, 12, 315, 1314, 1930, 314, 570, 13, 2930, 909, 911, 506, 1586, 272, 1808, 1586, 3997, 14, 272, 408, 272, 492, 14196, 339, 7667, 275, 14196, 14, 15218, 8, 4322, 9, 272, 340, 2688, 8, 1850, 12, 283, 739, 3997, 358, 436, 2688, 8, 5252, 12, 283, 6407, 735, 267, 7667, 14, 739, 3997, 8, 5252, 9, 272, 587, 26, 267, 7667, 14, 739, 8, 5252, 9, 339, 30514, 275, 485, 981, 63, 24270, 8, 1850, 9, 339, 327, 19698, 3420, 272, 2050, 423, 8174, 6432, 342, 272, 862, 26, 267, 2050, 423, 5586, 14, 3584, 342, 267, 2150, 2050, 423, 2232, 1296, 5873, 267, 327, 18599, 83, 1050, 17279, 370, 2050, 423, 5586, 267, 8297, 275, 485, 3174, 63, 5586, 8, 1850, 12, 30514, 9, 267, 485, 3174, 63, 22771, 8, 1850, 12, 8297, 12, 3507, 63, 5952, 63, 22771, 9, 272, 3753, 26, 267, 2050, 423, 3221, 6432, 342, 421, 199, 318, 485, 6983, 8, 354, 304, 272, 408, 27459, 282, 18947, 536, 370, 282, 2288, 909, 1041, 272, 536, 275, 1059, 14, 1294, 8, 354, 12, 20093, 272, 1202, 275, 536, 14, 1935, 8, 16, 9, 272, 1911, 275, 636, 646, 721, 2972, 9, 272, 367, 302, 315, 536, 26, 267, 1202, 275, 1202, 435, 7815, 435, 302, 267, 862, 26, 288, 1911, 275, 2519, 8, 4214, 12, 302, 9, 267, 871, 4281, 26, 288, 636, 646, 721, 2972, 9, 288, 1911, 275, 2519, 8, 4214, 12, 302, 9, 272, 372, 1911, 199, 199, 318, 485, 1913, 63, 10749, 8, 26279, 304, 272, 372, 2341, 8, 2734, 671, 26, 1059, 14, 1913, 8, 88, 395, 741, 631, 9, 199, 199, 318, 485, 8167, 8, 83, 304, 272, 372, 308, 340, 1228, 8, 83, 12, 620, 9, 587, 308, 14, 2143, 360, 1624, 13, 24, 358, 199, 199, 318, 485, 981, 63, 24270, 8, 1850, 304, 272, 408, 2499, 436, 372, 30514, 624, 272, 28579, 275, 7667, 14, 362, 480, 24270, 401, 298, 1612, 531, 272, 340, 440, 822, 8, 70, 513, 304, 267, 372, 1052, 272, 28579, 275, 1059, 14, 1294, 8, 70, 513, 12, 3872, 531, 272, 28579, 275, 485, 1913, 63, 10749, 8, 70, 513, 9, 272, 30514, 275, 1052, 272, 367, 1824, 315, 28579, 26, 267, 21750, 354, 275, 298, 8911, 4970, 83, 2, 450, 1824, 267, 3999, 275, 7667, 14, 1419, 8, 8519, 354, 9, 267, 340, 298, 908, 2, 315, 3999, 26, 288, 7449, 275, 7667, 14, 362, 8, 8519, 354, 12, 298, 908, 401, 413, 9, 267, 587, 26, 288, 7449, 275, 488 ]
[ 1898, 12521, 13, 9488, 701, 28882, 1187, 428, 9091, 711, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 6866, 436, 626, 199, 3, 3865, 626, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 199, 3, 21038, 3794, 12, 436, 626, 314, 536, 402, 28882, 1187, 428, 9091, 711, 199, 3, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 4084, 199, 3, 402, 314, 2032, 1928, 2488, 12, 5313, 6791, 4983, 14, 199, 3, 812, 568, 3448, 13950, 42, 1772, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 4141, 12, 6931, 199, 3, 11727, 5292, 2990, 1634, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 199, 3, 812, 568, 3448, 13950, 42, 1772, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 199, 3, 1821, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 199, 3, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 199, 5688, 3423, 367, 314, 2050, 2559, 367, 2018, 14, 710, 6170, 2559, 199, 374, 4079, 641, 13663, 499, 2564, 436, 6786, 2337, 475, 315, 1013, 14, 4159, 14, 1548, 12, 436, 315, 24585, 68, 199, 991, 3668, 1159, 943, 20, 74, 2656, 14, 199, 199, 11408, 1736, 1334, 2018, 5459, 2356, 413, 14, 21, 14, 18, 12, 871, 626, 1350, 1004, 199, 11697, 365, 440, 2808, 7444, 283, 1274, 423, 20912, 11716, 365, 14, 199, 199, 7384, 334, 35, 9, 12521, 13, 9300, 28882, 1187, 428, 9091, 711, 14, 2900, 5924, 5702, 14, 199, 199, 1378, 675, 12, 9329, 283, 646, 2050, 7, 436, 943, 13437, 1, 199, 624, 199, 199, 646, 984, 12, 2050, 12, 2050, 14, 5586, 12, 1059, 12, 2838, 12, 2702, 12, 747, 12, 5190, 12, 2943, 199, 199, 893, 26, 272, 492, 2462, 272, 492, 5796, 199, 2590, 3545, 26, 272, 2462, 275, 488, 199, 199, 504, 17766, 3120, 492, 11086, 316, 9735, 3120, 12, 8271, 11149, 421, 199, 3472, 63, 27896, 63, 5569, 63, 3657, 275, 9137, 1216, 199, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 272, 12565, 775, 63, 3170, 275, 2948, 1477, 257, 327, 55, 4251, 37, 17489, 18066, 199, 2836, 26, 272, 12565, 775, 63, 3170, 275, 21083, 258, 327, 37, 17489, 18066, 199, 199, 3, 199, 3, 257, 710, 2569, 1233, 9031, 282, 2838, 11647, 367, 641, 13, 1589, 13, 21600, 199, 3, 257, 295, 4758, 402, 2050, 14, 199, 3, 199, 3, 257, 485, 9799, 15164, 314, 1654, 909, 9689, 314, 22721, 199, 63, 9799, 275, 488, 199, 199, 318, 570, 2028, 8, 5252, 12, 4243, 29, 403, 12, 3507, 63, 5952, 63, 22771, 29, 17, 304, 272, 408, 272, 5574, 314, 2050, 2897, 687, 282, 14196, 13, 908, 570, 14, 339, 961, 883, 506, 2797, 9978, 5431, 687, 376, 4223, 12, 17266, 376, 1284, 922, 272, 314, 21255, 370, 3504, 687, 7750, 876, 13, 31126, 13422, 334, 692, 314, 272, 15030, 6571, 282, 14729, 370, 3451, 314, 3415, 436, 2248, 314, 12414, 272, 2897, 680, 272, 1010, 5459, 402, 14196, 1314, 1172, 314, 1586, 3997, 1083, 359, 32251, 272, 15924, 1915, 315, 499, 14, 88, 5459, 402, 2018, 467, 1265, 883, 986, 315, 282, 570, 13, 2930, 909, 272, 7830, 2419, 282, 1788, 12, 315, 1314, 1930, 314, 570, 13, 2930, 909, 911, 506, 1586, 272, 1808, 1586, 3997, 14, 272, 408, 272, 492, 14196, 339, 7667, 275, 14196, 14, 15218, 8, 4322, 9, 272, 340, 2688, 8, 1850, 12, 283, 739, 3997, 358, 436, 2688, 8, 5252, 12, 283, 6407, 735, 267, 7667, 14, 739, 3997, 8, 5252, 9, 272, 587, 26, 267, 7667, 14, 739, 8, 5252, 9, 339, 30514, 275, 485, 981, 63, 24270, 8, 1850, 9, 339, 327, 19698, 3420, 272, 2050, 423, 8174, 6432, 342, 272, 862, 26, 267, 2050, 423, 5586, 14, 3584, 342, 267, 2150, 2050, 423, 2232, 1296, 5873, 267, 327, 18599, 83, 1050, 17279, 370, 2050, 423, 5586, 267, 8297, 275, 485, 3174, 63, 5586, 8, 1850, 12, 30514, 9, 267, 485, 3174, 63, 22771, 8, 1850, 12, 8297, 12, 3507, 63, 5952, 63, 22771, 9, 272, 3753, 26, 267, 2050, 423, 3221, 6432, 342, 421, 199, 318, 485, 6983, 8, 354, 304, 272, 408, 27459, 282, 18947, 536, 370, 282, 2288, 909, 1041, 272, 536, 275, 1059, 14, 1294, 8, 354, 12, 20093, 272, 1202, 275, 536, 14, 1935, 8, 16, 9, 272, 1911, 275, 636, 646, 721, 2972, 9, 272, 367, 302, 315, 536, 26, 267, 1202, 275, 1202, 435, 7815, 435, 302, 267, 862, 26, 288, 1911, 275, 2519, 8, 4214, 12, 302, 9, 267, 871, 4281, 26, 288, 636, 646, 721, 2972, 9, 288, 1911, 275, 2519, 8, 4214, 12, 302, 9, 272, 372, 1911, 199, 199, 318, 485, 1913, 63, 10749, 8, 26279, 304, 272, 372, 2341, 8, 2734, 671, 26, 1059, 14, 1913, 8, 88, 395, 741, 631, 9, 199, 199, 318, 485, 8167, 8, 83, 304, 272, 372, 308, 340, 1228, 8, 83, 12, 620, 9, 587, 308, 14, 2143, 360, 1624, 13, 24, 358, 199, 199, 318, 485, 981, 63, 24270, 8, 1850, 304, 272, 408, 2499, 436, 372, 30514, 624, 272, 28579, 275, 7667, 14, 362, 480, 24270, 401, 298, 1612, 531, 272, 340, 440, 822, 8, 70, 513, 304, 267, 372, 1052, 272, 28579, 275, 1059, 14, 1294, 8, 70, 513, 12, 3872, 531, 272, 28579, 275, 485, 1913, 63, 10749, 8, 70, 513, 9, 272, 30514, 275, 1052, 272, 367, 1824, 315, 28579, 26, 267, 21750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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 ]
sasukeh/acos-client
acos_client/v21/slb/member.py
4
1790
# Copyright 2014, Doug Wiegley, A10 Networks. # # 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 acos_client.v21.base as base class Member(base.BaseV21): def _write(self, action, service_group_name, server_name, server_port, status=None, **kwargs): params = { "name": service_group_name, "member": self.minimal_dict({ "server": server_name, "port": int(server_port), "status": status }) } self._post(action, params, **kwargs) def create(self, service_group_name, server_name, server_port, status=1, **kwargs): self._write("slb.service_group.member.create", service_group_name, server_name, server_port, status, **kwargs) def update(self, service_group_name, server_name, server_port, status=1, **kwargs): self._write("slb.service_group.member.update", service_group_name, server_name, server_port, status, **kwargs) def delete(self, service_group_name, server_name, server_port, **kwargs): self._write("slb.service_group.member.delete", service_group_name, server_name, int(server_port), **kwargs)
apache-2.0
[ 3, 1898, 6927, 12, 221, 577, 810, 71, 644, 1873, 3845, 89, 12, 221, 437, 709, 17138, 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, 282, 5197, 63, 1258, 14, 86, 2025, 14, 1095, 465, 1300, 421, 199, 533, 14409, 8, 1095, 14, 1563, 54, 2025, 304, 339, 347, 485, 952, 8, 277, 12, 1595, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2049, 2004, 29, 403, 12, 1011, 958, 304, 267, 1862, 275, 469, 288, 298, 354, 582, 2435, 63, 923, 63, 354, 12, 288, 298, 1114, 582, 291, 14, 21508, 63, 807, 2561, 355, 298, 1000, 582, 1654, 63, 354, 12, 355, 298, 719, 582, 1109, 8, 1000, 63, 719, 395, 355, 298, 1205, 582, 2004, 288, 3828, 267, 789, 267, 291, 423, 1932, 8, 1287, 12, 1862, 12, 1011, 958, 9, 339, 347, 1218, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 29, 17, 12, 2049, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 981, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 12, 1011, 958, 9, 339, 347, 1678, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 29, 17, 12, 2049, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 873, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 12, 1011, 958, 9, 339, 347, 3145, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 1807, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1109, 8, 1000, 63, 719, 395, 1011, 958, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 12, 221, 577, 810, 71, 644, 1873, 3845, 89, 12, 221, 437, 709, 17138, 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, 282, 5197, 63, 1258, 14, 86, 2025, 14, 1095, 465, 1300, 421, 199, 533, 14409, 8, 1095, 14, 1563, 54, 2025, 304, 339, 347, 485, 952, 8, 277, 12, 1595, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2049, 2004, 29, 403, 12, 1011, 958, 304, 267, 1862, 275, 469, 288, 298, 354, 582, 2435, 63, 923, 63, 354, 12, 288, 298, 1114, 582, 291, 14, 21508, 63, 807, 2561, 355, 298, 1000, 582, 1654, 63, 354, 12, 355, 298, 719, 582, 1109, 8, 1000, 63, 719, 395, 355, 298, 1205, 582, 2004, 288, 3828, 267, 789, 267, 291, 423, 1932, 8, 1287, 12, 1862, 12, 1011, 958, 9, 339, 347, 1218, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 29, 17, 12, 2049, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 981, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 12, 1011, 958, 9, 339, 347, 1678, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 29, 17, 12, 2049, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 873, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1654, 63, 719, 12, 2004, 12, 1011, 958, 9, 339, 347, 3145, 8, 277, 12, 2435, 63, 923, 63, 354, 12, 1654, 63, 354, 12, 1654, 63, 719, 12, 1011, 958, 304, 267, 291, 423, 952, 480, 2482, 66, 14, 1364, 63, 923, 14, 1114, 14, 1807, 401, 2435, 63, 923, 63, 354, 12, 490, 1654, 63, 354, 12, 1109, 8, 1000, 63, 719, 395, 1011, 958, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
ATIX-AG/ansible
lib/ansible/modules/network/f5/bigip_hostname.py
28
6234
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (c) 2017 F5 Networks Inc. # GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: bigip_hostname short_description: Manage the hostname of a BIG-IP description: - Manage the hostname of a BIG-IP. version_added: "2.3" options: hostname: description: - Hostname of the BIG-IP host. required: True extends_documentation_fragment: f5 author: - Tim Rupp (@caphrim007) - Matthew Lam (@mryanlam) ''' EXAMPLES = r''' - name: Set the hostname of the BIG-IP bigip_hostname: hostname: bigip.localhost.localdomain password: secret server: lb.mydomain.com user: admin delegate_to: localhost ''' RETURN = r''' hostname: description: The new hostname of the device returned: changed type: string sample: big-ip01.internal ''' from ansible.module_utils.basic import AnsibleModule HAS_DEVEL_IMPORTS = False try: # Sideband repository used for dev from library.module_utils.network.f5.bigip import HAS_F5SDK from library.module_utils.network.f5.bigip import F5Client from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import fqdn_name from library.module_utils.network.f5.common import f5_argument_spec try: from library.module_utils.network.f5.common import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False HAS_DEVEL_IMPORTS = True except ImportError: # Upstream Ansible from ansible.module_utils.network.f5.bigip import HAS_F5SDK from ansible.module_utils.network.f5.bigip import F5Client from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import fqdn_name from ansible.module_utils.network.f5.common import f5_argument_spec try: from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False class Parameters(AnsibleF5Parameters): api_attributes = ['hostname'] updatables = ['hostname'] returnables = ['hostname'] def to_return(self): result = {} for returnable in self.returnables: result[returnable] = getattr(self, returnable) result = self._filter_params(result) return result @property def hostname(self): if self._values['hostname'] is None: return None return str(self._values['hostname']) class ModuleManager(object): def __init__(self, *args, **kwargs): self.module = kwargs.get('module', None) self.client = kwargs.get('client', None) self.have = None self.want = Parameters(params=self.module.params) self.changes = Parameters() def _set_changed_options(self): changed = {} for key in Parameters.returnables: if getattr(self.want, key) is not None: changed[key] = getattr(self.want, key) if changed: self.changes = Parameters(params=changed) def _update_changed_options(self): changed = {} for key in Parameters.updatables: if getattr(self.want, key) is not None: attr1 = getattr(self.want, key) attr2 = getattr(self.have, key) if attr1 != attr2: changed[key] = attr1 self.changes = Parameters(params=changed) if changed: return True return False def exec_module(self): result = dict() try: changed = self.update() except iControlUnexpectedHTTPError as e: raise F5ModuleError(str(e)) changes = self.changes.to_return() result.update(**changes) result.update(dict(changed=changed)) return result def read_current_from_device(self): resource = self.client.api.tm.sys.global_settings.load() result = resource.attrs return Parameters(params=result) def update(self): self.have = self.read_current_from_device() if not self.should_update(): return False if self.module.check_mode: return True self.update_on_device() return True def should_update(self): result = self._update_changed_options() if result: return True return False def update_on_device(self): params = self.want.api_params() resource = self.client.api.tm.sys.global_settings.load() resource.modify(**params) self.client.api.tm.cm.devices.exec_cmd( 'mv', name=self.have.hostname, target=self.want.hostname ) class ArgumentSpec(object): def __init__(self): self.supports_check_mode = True argument_spec = dict( hostname=dict( required=True ) ) self.argument_spec = {} self.argument_spec.update(f5_argument_spec) self.argument_spec.update(argument_spec) def main(): spec = ArgumentSpec() module = AnsibleModule( argument_spec=spec.argument_spec, supports_check_mode=spec.supports_check_mode ) if not HAS_F5SDK: module.fail_json(msg="The python f5-sdk module is required") try: client = F5Client(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) module.exit_json(**results) except F5ModuleError as e: cleanup_tokens(client) module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 27281, 63, 4269, 199, 3612, 63, 1802, 26, 14944, 314, 6246, 402, 282, 16524, 13, 1772, 199, 1802, 26, 523, 446, 14944, 314, 6246, 402, 282, 16524, 13, 1772, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 1419, 26, 523, 6246, 26, 272, 1369, 26, 489, 446, 10891, 354, 402, 314, 16524, 13, 1772, 1591, 14, 272, 1415, 26, 715, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 523, 446, 18619, 29640, 491, 455, 8593, 77, 651, 290, 17984, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 314, 6246, 402, 314, 16524, 13, 1772, 523, 27281, 63, 4269, 26, 272, 6246, 26, 27281, 14, 5967, 14, 1832, 2261, 272, 2505, 26, 7565, 272, 1654, 26, 11104, 14, 30945, 14, 957, 272, 922, 26, 4628, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 4269, 26, 523, 1369, 26, 710, 892, 6246, 402, 314, 2243, 523, 2138, 26, 2896, 523, 730, 26, 1059, 523, 2690, 26, 7282, 13, 711, 614, 14, 4672, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 13533, 63, 1093, 10429, 63, 17576, 51, 275, 756, 199, 199, 893, 26, 272, 327, 428, 2655, 7877, 7611, 1202, 367, 4866, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 7509, 63, 38, 21, 14939, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 481, 21, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 9058, 63, 4504, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 31039, 63, 354, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 272, 862, 26, 267, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 871, 3545, 26, 267, 7509, 63, 38, 21, 14939, 275, 756, 272, 7509, 63, 1093, 10429, 63, 17576, 51, 275, 715, 199, 2590, 3545, 26, 272, 327, 4949, 1745, 2622, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 7509, 63, 38, 21, 14939, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 481, 21, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 9058, 63, 4504, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 31039, 63, 354, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 272, 862, 26, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 871, 3545, 26, 267, 7509, 63, 38, 21, 14939, 275, 756, 421, 199, 533, 3897, 8, 10047, 38, 21, 5976, 304, 272, 2986, 63, 2987, 275, 788, 4269, 418, 272, 1536, 4616, 5921, 275, 788, 4269, 418, 272, 372, 5921, 275, 788, 4269, 418, 339, 347, 370, 63, 1107, 8, 277, 304, 267, 754, 275, 1052, 267, 367, 372, 461, 315, 291, 14, 1107, 5921, 26, 288, 754, 59, 1107, 461, 61, 275, 2519, 8, 277, 12, 372, 461, 9, 267, 754, 275, 291, 423, 1541, 63, 1162, 8, 1099, 9, 267, 372, 754, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 340, 291, 423, 1459, 459, 4269, 418, 365, 488, 26, 288, 372, 488, 267, 372, 620, 8, 277, 423, 1459, 459, 4269, 1105, 421, 199, 533, 24118, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 578, 275, 2074, 14, 362, 360, 578, 297, 488, 9, 267, 291, 14, 1258, 275, 2074, 14, 362, 360, 1258, 297, 488, 9, 267, 291, 14, 7804, 275, 488, 267, 291, 14, 7051, 275, 3897, 8, 1162, 29, 277, 14, 578, 14, 1162, 9, 267, 291, 14, 6627, 275, 3897, 342, 339, 347, 485, 409, 63, 2489, 63, 1419, 8, 277, 304, 267, 2896, 275, 1052, 267, 367, 790, 315, 3897, 14, 1107, 5921, 26, 288, 340, 2519, 8, 277, 14, 7051, 12, 790, 9, 365, 440, 488, 26, 355, 2896, 59, 498, 61, 275, 2519, 8, 277, 14, 7051, 12, 790, 9, 267, 340, 2896, 26, 288, 291, 14, 6627, 275, 3897, 8, 1162, 29, 2489, 9, 339, 347, 485, 873, 63, 2489, 63, 1419, 8, 277, 304, 267, 2896, 275, 1052, 267, 367, 790, 315, 3897, 14, 384, 4616, 5921, 26, 288, 340, 2519, 8, 277, 14, 7051, 12, 790, 9, 365, 440, 488, 26, 355, 1921, 17, 275, 2519, 8, 277, 14, 7051, 12, 790, 9, 355, 1921, 18, 275, 2519, 8, 277, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 27281, 63, 4269, 199, 3612, 63, 1802, 26, 14944, 314, 6246, 402, 282, 16524, 13, 1772, 199, 1802, 26, 523, 446, 14944, 314, 6246, 402, 282, 16524, 13, 1772, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 1419, 26, 523, 6246, 26, 272, 1369, 26, 489, 446, 10891, 354, 402, 314, 16524, 13, 1772, 1591, 14, 272, 1415, 26, 715, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 523, 446, 18619, 29640, 491, 455, 8593, 77, 651, 290, 17984, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 314, 6246, 402, 314, 16524, 13, 1772, 523, 27281, 63, 4269, 26, 272, 6246, 26, 27281, 14, 5967, 14, 1832, 2261, 272, 2505, 26, 7565, 272, 1654, 26, 11104, 14, 30945, 14, 957, 272, 922, 26, 4628, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 4269, 26, 523, 1369, 26, 710, 892, 6246, 402, 314, 2243, 523, 2138, 26, 2896, 523, 730, 26, 1059, 523, 2690, 26, 7282, 13, 711, 614, 14, 4672, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 13533, 63, 1093, 10429, 63, 17576, 51, 275, 756, 199, 199, 893, 26, 272, 327, 428, 2655, 7877, 7611, 1202, 367, 4866, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 7509, 63, 38, 21, 14939, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 481, 21, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 9058, 63, 4504, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 31039, 63, 354, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 272, 862, 26, 267, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 871, 3545, 26, 267, 7509, 63, 38, 21, 14939, 275, 756, 272, 7509, 63, 1093, 10429, 63, 17576, 51, 275, 715, 199, 2590, 3545, 26, 272, 327, 4949, 1745, 2622, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 7509, 63, 38, 21, 14939, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 17833, 492, 481, 21, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 9058, 63, 4504, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 31039, 63, 354, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 272, 862, 26, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 871, 3545, 26, 267, 7509, 63, 38, 21, 14939, 275, 756, 421, 199, 533, 3897, 8, 10047, 38, 21, 5976, 304, 272, 2986, 63, 2987, 275, 788, 4269, 418, 272, 1536, 4616, 5921, 275, 788, 4269, 418, 272, 372, 5921, 275, 788, 4269, 418, 339, 347, 370, 63, 1107, 8, 277, 304, 267, 754, 275, 1052, 267, 367, 372, 461, 315, 291, 14, 1107, 5921, 26, 288, 754, 59, 1107, 461, 61, 275, 2519, 8, 277, 12, 372, 461, 9, 267, 754, 275, 291, 423, 1541, 63, 1162, 8, 1099, 9, 267, 372, 754, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 340, 291, 423, 1459, 459, 4269, 418, 365, 488, 26, 288, 372, 488, 267, 372, 620, 8, 277, 423, 1459, 459, 4269, 1105, 421, 199, 533, 24118, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 578, 275, 2074, 14, 362, 360, 578, 297, 488, 9, 267, 291, 14, 1258, 275, 2074, 14, 362, 360, 1258, 297, 488, 9, 267, 291, 14, 7804, 275, 488, 267, 291, 14, 7051, 275, 3897, 8, 1162, 29, 277, 14, 578, 14, 1162, 9, 267, 291, 14, 6627, 275, 3897, 342, 339, 347, 485, 409, 63, 2489, 63, 1419, 8, 277, 304, 267, 2896, 275, 1052, 267, 367, 790, 315, 3897, 14, 1107, 5921, 26, 288, 340, 2519, 8, 277, 14, 7051, 12, 790, 9, 365, 440, 488, 26, 355, 2896, 59, 498, 61, 275, 2519, 8, 277, 14, 7051, 12, 790, 9, 267, 340, 2896, 26, 288, 291, 14, 6627, 275, 3897, 8, 1162, 29, 2489, 9, 339, 347, 485, 873, 63, 2489, 63, 1419, 8, 277, 304, 267, 2896, 275, 1052, 267, 367, 790, 315, 3897, 14, 384, 4616, 5921, 26, 288, 340, 2519, 8, 277, 14, 7051, 12, 790, 9, 365, 440, 488, 26, 355, 1921, 17, 275, 2519, 8, 277, 14, 7051, 12, 790, 9, 355, 1921, 18, 275, 2519, 8, 277, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
fernandezcuesta/ansible
lib/ansible/modules/database/misc/redis.py
8
10672
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: redis short_description: Various redis commands, slave and flush description: - Unified utility to interact with redis instances. 'slave' sets a redis instance in slave or master mode. 'flush' flushes all the instance or a specified db. 'config' (new in 1.6), ensures a configuration setting on an instance. version_added: "1.3" options: command: description: - The selected redis command required: true default: null choices: [ "slave", "flush", "config" ] login_password: description: - The password used to authenticate with (usually not used) required: false default: null login_host: description: - The host running the database required: false default: localhost login_port: description: - The port to connect to required: false default: 6379 master_host: description: - The host of the master instance [slave command] required: false default: null master_port: description: - The port of the master instance [slave command] required: false default: null slave_mode: description: - the mode of the redis instance [slave command] required: false default: slave choices: [ "master", "slave" ] db: description: - The database to flush (used in db mode) [flush command] required: false default: null flush_mode: description: - Type of flush (all the dbs in a redis instance or a specific one) [flush command] required: false default: all choices: [ "all", "db" ] name: version_added: 1.6 description: - A redis config key. required: false default: null value: version_added: 1.6 description: - A redis config value. required: false default: null notes: - Requires the redis-py Python package on the remote host. You can install it with pip (pip install redis) or with a package manager. https://github.com/andymccurdy/redis-py - If the redis master instance we are making slave of is password protected this needs to be in the redis.conf in the masterauth variable requirements: [ redis ] author: "Xabier Larrakoetxea (@slok)" ''' EXAMPLES = ''' # Set local redis instance to be slave of melee.island on port 6377 - redis: command: slave master_host: melee.island master_port: 6377 # Deactivate slave mode - redis: command: slave slave_mode: master # Flush all the redis db - redis: command: flush flush_mode: all # Flush only one db in a redis instance - redis: command: flush db: 1 flush_mode: db # Configure local redis to have 10000 max clients - redis: command: config name: maxclients value: 10000 # Configure local redis to have lua time limit of 100 ms - redis: command: config name: lua-time-limit value: 100 ''' import traceback try: import redis except ImportError: redis_found = False else: redis_found = True from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native # =========================================== # Redis module specific support methods. # def set_slave_mode(client, master_host, master_port): try: return client.slaveof(master_host, master_port) except Exception: return False def set_master_mode(client): try: return client.slaveof() except Exception: return False def flush(client, db=None): try: if not isinstance(db, int): return client.flushall() else: # The passed client has been connected to the database already return client.flushdb() except Exception: return False # =========================================== # Module execution. # def main(): module = AnsibleModule( argument_spec = dict( command=dict(default=None, choices=['slave', 'flush', 'config']), login_password=dict(default=None, no_log=True), login_host=dict(default='localhost'), login_port=dict(default=6379, type='int'), master_host=dict(default=None), master_port=dict(default=None, type='int'), slave_mode=dict(default='slave', choices=['master', 'slave']), db=dict(default=None, type='int'), flush_mode=dict(default='all', choices=['all', 'db']), name=dict(default=None), value=dict(default=None) ), supports_check_mode = True ) if not redis_found: module.fail_json(msg="python redis module is required") login_password = module.params['login_password'] login_host = module.params['login_host'] login_port = module.params['login_port'] command = module.params['command'] # Slave Command section ----------- if command == "slave": master_host = module.params['master_host'] master_port = module.params['master_port'] mode = module.params['slave_mode'] #Check if we have all the data if mode == "slave": # Only need data if we want to be slave if not master_host: module.fail_json( msg='In slave mode master host must be provided') if not master_port: module.fail_json( msg='In slave mode master port must be provided') #Connect and check r = redis.StrictRedis(host=login_host, port=login_port, password=login_password) try: r.ping() except Exception as e: module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc()) #Check if we are already in the mode that we want info = r.info() if mode == "master" and info["role"] == "master": module.exit_json(changed=False, mode=mode) elif mode == "slave" and\ info["role"] == "slave" and\ info["master_host"] == master_host and\ info["master_port"] == master_port: status = { 'status': mode, 'master_host': master_host, 'master_port': master_port, } module.exit_json(changed=False, mode=status) else: # Do the stuff # (Check Check_mode before commands so the commands aren't evaluated # if not necessary) if mode == "slave": if module.check_mode or\ set_slave_mode(r, master_host, master_port): info = r.info() status = { 'status': mode, 'master_host': master_host, 'master_port': master_port, } module.exit_json(changed=True, mode=status) else: module.fail_json(msg='Unable to set slave mode') else: if module.check_mode or set_master_mode(r): module.exit_json(changed=True, mode=mode) else: module.fail_json(msg='Unable to set master mode') # flush Command section ----------- elif command == "flush": db = module.params['db'] mode = module.params['flush_mode'] #Check if we have all the data if mode == "db": if db is None: module.fail_json( msg="In db mode the db number must be provided") #Connect and check r = redis.StrictRedis(host=login_host, port=login_port, password=login_password, db=db) try: r.ping() except Exception as e: module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc()) # Do the stuff # (Check Check_mode before commands so the commands aren't evaluated # if not necessary) if mode == "all": if module.check_mode or flush(r): module.exit_json(changed=True, flushed=True) else: # Flush never fails :) module.fail_json(msg="Unable to flush all databases") else: if module.check_mode or flush(r, db): module.exit_json(changed=True, flushed=True, db=db) else: # Flush never fails :) module.fail_json(msg="Unable to flush '%d' database" % db) elif command == 'config': name = module.params['name'] value = module.params['value'] r = redis.StrictRedis(host=login_host, port=login_port, password=login_password) try: r.ping() except Exception as e: module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc()) try: old_value = r.config_get(name)[name] except Exception as e: module.fail_json(msg="unable to read config: %s" % to_native(e), exception=traceback.format_exc()) changed = old_value != value if module.check_mode or not changed: module.exit_json(changed=changed, name=name, value=value) else: try: r.config_set(name, value) except Exception as e: module.fail_json(msg="unable to write config: %s" % to_native(e), exception=traceback.format_exc()) module.exit_json(changed=changed, name=name, value=value) else: module.fail_json(msg='A valid command must be provided') if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 16967, 199, 3612, 63, 1802, 26, 21107, 1785, 16967, 3718, 12, 15494, 436, 8976, 199, 1802, 26, 2043, 446, 1910, 4541, 11420, 370, 17232, 543, 16967, 4454, 14, 1362, 283, 12384, 7, 5951, 282, 16967, 1256, 315, 15494, 503, 5288, 818, 14, 1362, 283, 4939, 7, 8976, 397, 1006, 314, 1256, 503, 282, 2013, 1592, 14, 1362, 283, 888, 7, 334, 1222, 315, 413, 14, 22, 395, 15620, 282, 2897, 4260, 641, 376, 1256, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 1419, 26, 272, 1414, 26, 267, 1369, 26, 288, 446, 710, 4895, 16967, 1414, 267, 1415, 26, 2549, 267, 849, 26, 2973, 267, 3415, 26, 359, 298, 12384, 401, 298, 4939, 401, 298, 888, 2, 1622, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 2505, 1202, 370, 12895, 543, 334, 25118, 440, 1202, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 3879, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 11667, 272, 4676, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 370, 4907, 370, 267, 1415, 26, 3055, 267, 849, 26, 1227, 12015, 272, 5288, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 402, 314, 5288, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 5288, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 402, 314, 5288, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 15494, 63, 632, 26, 267, 1369, 26, 288, 446, 314, 818, 402, 314, 16967, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 15494, 267, 3415, 26, 359, 298, 4133, 401, 298, 12384, 2, 1622, 272, 1592, 26, 267, 1369, 26, 288, 446, 710, 3050, 370, 8976, 334, 2972, 315, 1592, 818, 9, 359, 4939, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 8976, 63, 632, 26, 267, 1369, 26, 288, 446, 2434, 402, 8976, 334, 452, 314, 366, 1533, 315, 282, 16967, 1256, 503, 282, 2488, 1373, 9, 1598, 359, 4939, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 1006, 267, 3415, 26, 359, 298, 452, 401, 298, 697, 2, 1622, 272, 536, 26, 267, 1015, 63, 3270, 26, 413, 14, 22, 267, 1369, 26, 288, 446, 437, 16967, 1101, 790, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 574, 26, 267, 1015, 63, 3270, 26, 413, 14, 22, 267, 1369, 26, 288, 446, 437, 16967, 1101, 574, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 421, 199, 5983, 26, 2043, 446, 15127, 314, 16967, 13, 647, 2018, 2559, 641, 314, 3982, 1591, 14, 2047, 883, 1362, 3907, 652, 543, 7305, 334, 9983, 3907, 16967, 9, 503, 543, 282, 2559, 5256, 14, 1362, 4178, 921, 5031, 14, 957, 15, 460, 89, 5466, 895, 8161, 15, 15369, 13, 647, 2043, 446, 982, 314, 16967, 5288, 1256, 781, 787, 10663, 15494, 402, 365, 2505, 17819, 1362, 642, 4839, 370, 506, 315, 314, 16967, 14, 2190, 315, 314, 28065, 2967, 762, 1750, 199, 199, 7538, 26, 359, 16967, 1622, 199, 2502, 26, 298, 56, 371, 4446, 491, 285, 345, 7697, 386, 10656, 8593, 83, 320, 75, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2494, 2257, 16967, 1256, 370, 506, 15494, 402, 562, 18387, 14, 374, 9688, 641, 1844, 1227, 7332, 199, 13, 16967, 26, 272, 1414, 26, 15494, 272, 5288, 63, 1102, 26, 562, 18387, 14, 374, 9688, 272, 5288, 63, 719, 26, 1227, 7332, 199, 199, 3, 1487, 8222, 15494, 818, 199, 13, 16967, 26, 272, 1414, 26, 15494, 272, 15494, 63, 632, 26, 5288, 199, 199, 3, 11040, 2084, 1006, 314, 16967, 1592, 199, 13, 16967, 26, 272, 1414, 26, 8976, 272, 8976, 63, 632, 26, 1006, 199, 199, 3, 11040, 2084, 1454, 1373, 1592, 315, 282, 16967, 1256, 199, 13, 16967, 26, 272, 1414, 26, 8976, 272, 1592, 26, 413, 272, 8976, 63, 632, 26, 1592, 199, 199, 3, 15453, 2257, 16967, 370, 1172, 11630, 1390, 13431, 199, 13, 16967, 26, 272, 1414, 26, 1101, 272, 536, 26, 1390, 14555, 272, 574, 26, 11630, 199, 199, 3, 15453, 2257, 16967, 370, 1172, 634, 1458, 900, 2304, 402, 2948, 6605, 199, 13, 16967, 26, 272, 1414, 26, 1101, 272, 536, 26, 634, 1458, 13, 521, 13, 3097, 272, 574, 26, 2948, 199, 2344, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 16967, 199, 2590, 3545, 26, 272, 16967, 63, 4214, 275, 756, 199, 2836, 26, 272, 16967, 63, 4214, 275, 715, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 3, 19469, 17575, 199, 3, 25496, 859, 2488, 2291, 3102, 14, 199, 3, 199, 199, 318, 663, 63, 12384, 63, 632, 8, 1258, 12, 5288, 63, 1102, 12, 5288, 63, 719, 304, 272, 862, 26, 267, 372, 1890, 14, 12384, 1618, 8, 4133, 63, 1102, 12, 5288, 63, 719, 9, 272, 871, 2186, 26, 267, 372, 756, 421, 199, 318, 663, 63, 4133, 63, 632, 8, 1258, 304, 272, 862, 26, 267, 372, 1890, 14, 12384, 1618, 342, 272, 871, 2186, 26, 267, 372, 756, 421, 199, 318, 8976, 8, 1258, 12, 1592, 29, 403, 304, 272, 862, 26, 267, 340, 440, 1228, 8, 697, 12, 1109, 304, 288, 372, 1890, 14, 4939, 452, 342, 267, 587 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 16967, 199, 3612, 63, 1802, 26, 21107, 1785, 16967, 3718, 12, 15494, 436, 8976, 199, 1802, 26, 2043, 446, 1910, 4541, 11420, 370, 17232, 543, 16967, 4454, 14, 1362, 283, 12384, 7, 5951, 282, 16967, 1256, 315, 15494, 503, 5288, 818, 14, 1362, 283, 4939, 7, 8976, 397, 1006, 314, 1256, 503, 282, 2013, 1592, 14, 1362, 283, 888, 7, 334, 1222, 315, 413, 14, 22, 395, 15620, 282, 2897, 4260, 641, 376, 1256, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 1419, 26, 272, 1414, 26, 267, 1369, 26, 288, 446, 710, 4895, 16967, 1414, 267, 1415, 26, 2549, 267, 849, 26, 2973, 267, 3415, 26, 359, 298, 12384, 401, 298, 4939, 401, 298, 888, 2, 1622, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 2505, 1202, 370, 12895, 543, 334, 25118, 440, 1202, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 3879, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 11667, 272, 4676, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 370, 4907, 370, 267, 1415, 26, 3055, 267, 849, 26, 1227, 12015, 272, 5288, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 402, 314, 5288, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 5288, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 402, 314, 5288, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 15494, 63, 632, 26, 267, 1369, 26, 288, 446, 314, 818, 402, 314, 16967, 1256, 359, 12384, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 15494, 267, 3415, 26, 359, 298, 4133, 401, 298, 12384, 2, 1622, 272, 1592, 26, 267, 1369, 26, 288, 446, 710, 3050, 370, 8976, 334, 2972, 315, 1592, 818, 9, 359, 4939, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 8976, 63, 632, 26, 267, 1369, 26, 288, 446, 2434, 402, 8976, 334, 452, 314, 366, 1533, 315, 282, 16967, 1256, 503, 282, 2488, 1373, 9, 1598, 359, 4939, 1414, 61, 267, 1415, 26, 3055, 267, 849, 26, 1006, 267, 3415, 26, 359, 298, 452, 401, 298, 697, 2, 1622, 272, 536, 26, 267, 1015, 63, 3270, 26, 413, 14, 22, 267, 1369, 26, 288, 446, 437, 16967, 1101, 790, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 574, 26, 267, 1015, 63, 3270, 26, 413, 14, 22, 267, 1369, 26, 288, 446, 437, 16967, 1101, 574, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 421, 199, 5983, 26, 2043, 446, 15127, 314, 16967, 13, 647, 2018, 2559, 641, 314, 3982, 1591, 14, 2047, 883, 1362, 3907, 652, 543, 7305, 334, 9983, 3907, 16967, 9, 503, 543, 282, 2559, 5256, 14, 1362, 4178, 921, 5031, 14, 957, 15, 460, 89, 5466, 895, 8161, 15, 15369, 13, 647, 2043, 446, 982, 314, 16967, 5288, 1256, 781, 787, 10663, 15494, 402, 365, 2505, 17819, 1362, 642, 4839, 370, 506, 315, 314, 16967, 14, 2190, 315, 314, 28065, 2967, 762, 1750, 199, 199, 7538, 26, 359, 16967, 1622, 199, 2502, 26, 298, 56, 371, 4446, 491, 285, 345, 7697, 386, 10656, 8593, 83, 320, 75, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2494, 2257, 16967, 1256, 370, 506, 15494, 402, 562, 18387, 14, 374, 9688, 641, 1844, 1227, 7332, 199, 13, 16967, 26, 272, 1414, 26, 15494, 272, 5288, 63, 1102, 26, 562, 18387, 14, 374, 9688, 272, 5288, 63, 719, 26, 1227, 7332, 199, 199, 3, 1487, 8222, 15494, 818, 199, 13, 16967, 26, 272, 1414, 26, 15494, 272, 15494, 63, 632, 26, 5288, 199, 199, 3, 11040, 2084, 1006, 314, 16967, 1592, 199, 13, 16967, 26, 272, 1414, 26, 8976, 272, 8976, 63, 632, 26, 1006, 199, 199, 3, 11040, 2084, 1454, 1373, 1592, 315, 282, 16967, 1256, 199, 13, 16967, 26, 272, 1414, 26, 8976, 272, 1592, 26, 413, 272, 8976, 63, 632, 26, 1592, 199, 199, 3, 15453, 2257, 16967, 370, 1172, 11630, 1390, 13431, 199, 13, 16967, 26, 272, 1414, 26, 1101, 272, 536, 26, 1390, 14555, 272, 574, 26, 11630, 199, 199, 3, 15453, 2257, 16967, 370, 1172, 634, 1458, 900, 2304, 402, 2948, 6605, 199, 13, 16967, 26, 272, 1414, 26, 1101, 272, 536, 26, 634, 1458, 13, 521, 13, 3097, 272, 574, 26, 2948, 199, 2344, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 16967, 199, 2590, 3545, 26, 272, 16967, 63, 4214, 275, 756, 199, 2836, 26, 272, 16967, 63, 4214, 275, 715, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 3, 19469, 17575, 199, 3, 25496, 859, 2488, 2291, 3102, 14, 199, 3, 199, 199, 318, 663, 63, 12384, 63, 632, 8, 1258, 12, 5288, 63, 1102, 12, 5288, 63, 719, 304, 272, 862, 26, 267, 372, 1890, 14, 12384, 1618, 8, 4133, 63, 1102, 12, 5288, 63, 719, 9, 272, 871, 2186, 26, 267, 372, 756, 421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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 ]
wdv4758h/ZipPy
edu.uci.python.benchmark/src/micro/boolean-logic.py
1
1621
# zwei 04/24/2014 # micro benchmark: method call polymorphic inspired by richards import time iteration = 50000 class Task(object): def __init__(self, p, w, h): self.packet_pending = p self.task_waiting = w self.task_holding = h self.link = None def isTaskHoldingOrWaiting(self): return self.task_holding or (not self.packet_pending and self.task_waiting) def isTaskHoldingOrWaiting(task_holding, packet_pending, task_waiting): return task_holding or (not packet_pending and task_waiting) TASK_LIST = [Task(False, False, True), Task(False, True, False), Task(True, True, False), Task(True, False, True)] def setupTaskQueue(): prev = None for t in TASK_LIST: t.link = prev prev = t return t TASK_QUEUE = setupTaskQueue() def dostuff(): total = 0 for i in range(iteration): t = TASK_QUEUE while t is not None: if (t.isTaskHoldingOrWaiting()): total += 1 t = t.link return total def noObjectDoStuff(): p = True w = False h = True total = 0 for i in range(iteration): h = isTaskHoldingOrWaiting(h, p, w) if (isTaskHoldingOrWaiting(h, p, w)): total += 1 return total def measure(num): print("Start timing...") start = time.time() for i in range(num): # 50000 result = dostuff() print(result) duration = "%.3f\n" % (time.time() - start) print("boolean-logic: " + duration) # warm up for i in range(500): dostuff() measure(1000)
bsd-3-clause
[ 3, 1315, 21431, 28527, 15, 1194, 15, 7280, 199, 3, 9967, 12338, 26, 1083, 1240, 27905, 315, 8721, 581, 701, 8012, 1560, 795, 199, 646, 900, 199, 199, 12575, 275, 959, 993, 199, 199, 533, 8495, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 299, 12, 336, 12, 394, 304, 267, 291, 14, 6253, 63, 6455, 275, 299, 267, 291, 14, 1765, 63, 14093, 275, 336, 267, 291, 14, 1765, 63, 72, 13122, 275, 394, 267, 291, 14, 1073, 275, 488, 339, 347, 365, 4476, 40, 13122, 2844, 19189, 8, 277, 304, 267, 372, 291, 14, 1765, 63, 72, 13122, 503, 334, 1397, 291, 14, 6253, 63, 6455, 436, 291, 14, 1765, 63, 14093, 9, 199, 199, 318, 365, 4476, 40, 13122, 2844, 19189, 8, 1765, 63, 72, 13122, 12, 3644, 63, 6455, 12, 2120, 63, 14093, 304, 272, 372, 2120, 63, 72, 13122, 503, 334, 1397, 3644, 63, 6455, 436, 2120, 63, 14093, 9, 258, 199, 199, 17179, 63, 4924, 275, 359, 4476, 8, 797, 12, 756, 12, 715, 395, 221, 1467, 8495, 8, 797, 12, 715, 12, 756, 395, 221, 1467, 8495, 8, 549, 12, 715, 12, 756, 395, 221, 1467, 8495, 8, 549, 12, 756, 12, 715, 1874, 199, 199, 318, 3272, 4476, 3737, 837, 272, 5071, 275, 488, 272, 367, 307, 315, 377, 7946, 63, 4924, 26, 267, 307, 14, 1073, 275, 5071, 267, 5071, 275, 307, 272, 372, 307, 199, 199, 17179, 63, 15125, 275, 3272, 4476, 3737, 342, 199, 199, 318, 886, 14573, 837, 272, 3141, 275, 378, 272, 367, 284, 315, 1425, 8, 12575, 304, 267, 307, 275, 377, 7946, 63, 15125, 267, 1830, 307, 365, 440, 488, 26, 288, 340, 334, 84, 14, 374, 4476, 40, 13122, 2844, 19189, 5109, 355, 3141, 847, 413, 288, 307, 275, 307, 14, 1073, 339, 372, 3141, 199, 199, 318, 949, 1692, 2585, 933, 3043, 837, 272, 299, 275, 715, 272, 336, 275, 756, 272, 394, 275, 715, 272, 3141, 275, 378, 272, 367, 284, 315, 1425, 8, 12575, 304, 267, 394, 275, 365, 4476, 40, 13122, 2844, 19189, 8, 72, 12, 299, 12, 336, 9, 267, 340, 334, 374, 4476, 40, 13122, 2844, 19189, 8, 72, 12, 299, 12, 336, 2298, 288, 3141, 847, 413, 339, 372, 3141, 258, 199, 199, 318, 9775, 8, 1507, 304, 272, 870, 480, 3162, 20542, 12594, 272, 1343, 275, 900, 14, 521, 342, 339, 367, 284, 315, 1425, 8, 1507, 304, 327, 959, 993, 489, 754, 275, 886, 14573, 342, 339, 870, 8, 1099, 9, 272, 7373, 275, 31681, 19, 70, 60, 78, 2, 450, 334, 521, 14, 521, 342, 446, 1343, 9, 272, 870, 480, 4871, 13, 15370, 26, 298, 435, 7373, 9, 199, 199, 3, 20060, 1536, 199, 509, 284, 315, 1425, 8, 5783, 304, 272, 886, 14573, 342, 199, 199, 9580, 8, 5279, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1315, 21431, 28527, 15, 1194, 15, 7280, 199, 3, 9967, 12338, 26, 1083, 1240, 27905, 315, 8721, 581, 701, 8012, 1560, 795, 199, 646, 900, 199, 199, 12575, 275, 959, 993, 199, 199, 533, 8495, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 299, 12, 336, 12, 394, 304, 267, 291, 14, 6253, 63, 6455, 275, 299, 267, 291, 14, 1765, 63, 14093, 275, 336, 267, 291, 14, 1765, 63, 72, 13122, 275, 394, 267, 291, 14, 1073, 275, 488, 339, 347, 365, 4476, 40, 13122, 2844, 19189, 8, 277, 304, 267, 372, 291, 14, 1765, 63, 72, 13122, 503, 334, 1397, 291, 14, 6253, 63, 6455, 436, 291, 14, 1765, 63, 14093, 9, 199, 199, 318, 365, 4476, 40, 13122, 2844, 19189, 8, 1765, 63, 72, 13122, 12, 3644, 63, 6455, 12, 2120, 63, 14093, 304, 272, 372, 2120, 63, 72, 13122, 503, 334, 1397, 3644, 63, 6455, 436, 2120, 63, 14093, 9, 258, 199, 199, 17179, 63, 4924, 275, 359, 4476, 8, 797, 12, 756, 12, 715, 395, 221, 1467, 8495, 8, 797, 12, 715, 12, 756, 395, 221, 1467, 8495, 8, 549, 12, 715, 12, 756, 395, 221, 1467, 8495, 8, 549, 12, 756, 12, 715, 1874, 199, 199, 318, 3272, 4476, 3737, 837, 272, 5071, 275, 488, 272, 367, 307, 315, 377, 7946, 63, 4924, 26, 267, 307, 14, 1073, 275, 5071, 267, 5071, 275, 307, 272, 372, 307, 199, 199, 17179, 63, 15125, 275, 3272, 4476, 3737, 342, 199, 199, 318, 886, 14573, 837, 272, 3141, 275, 378, 272, 367, 284, 315, 1425, 8, 12575, 304, 267, 307, 275, 377, 7946, 63, 15125, 267, 1830, 307, 365, 440, 488, 26, 288, 340, 334, 84, 14, 374, 4476, 40, 13122, 2844, 19189, 5109, 355, 3141, 847, 413, 288, 307, 275, 307, 14, 1073, 339, 372, 3141, 199, 199, 318, 949, 1692, 2585, 933, 3043, 837, 272, 299, 275, 715, 272, 336, 275, 756, 272, 394, 275, 715, 272, 3141, 275, 378, 272, 367, 284, 315, 1425, 8, 12575, 304, 267, 394, 275, 365, 4476, 40, 13122, 2844, 19189, 8, 72, 12, 299, 12, 336, 9, 267, 340, 334, 374, 4476, 40, 13122, 2844, 19189, 8, 72, 12, 299, 12, 336, 2298, 288, 3141, 847, 413, 339, 372, 3141, 258, 199, 199, 318, 9775, 8, 1507, 304, 272, 870, 480, 3162, 20542, 12594, 272, 1343, 275, 900, 14, 521, 342, 339, 367, 284, 315, 1425, 8, 1507, 304, 327, 959, 993, 489, 754, 275, 886, 14573, 342, 339, 870, 8, 1099, 9, 272, 7373, 275, 31681, 19, 70, 60, 78, 2, 450, 334, 521, 14, 521, 342, 446, 1343, 9, 272, 870, 480, 4871, 13, 15370, 26, 298, 435, 7373, 9, 199, 199, 3, 20060, 1536, 199, 509, 284, 315, 1425, 8, 5783, 304, 272, 886, 14573, 342, 199, 199, 9580, 8, 5279, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pelson/conda-build
tests/test_misc.py
4
2003
import json from os.path import join import pytest from conda_build.utils import on_win import conda_build._link as _link from conda_build.conda_interface import PathType, EntityEncoder, CrossPlatformStLink def test_pyc_f_2(): assert _link.pyc_f('sp/utils.py', (2, 7, 9)) == 'sp/utils.pyc' def test_pyc_f_3(): for f, r in [ ('sp/utils.py', 'sp/__pycache__/utils.cpython-34.pyc'), ('sp/foo/utils.py', 'sp/foo/__pycache__/utils.cpython-34.pyc'), ]: assert _link.pyc_f(f, (3, 4, 2)) == r def test_pathtype(): hardlink = PathType("hardlink") assert str(hardlink) == "hardlink" assert hardlink.__json__() == 'hardlink' softlink = PathType("softlink") assert str(softlink) == "softlink" assert softlink.__json__() == "softlink" def test_entity_encoder(tmpdir): test_file = join(str(tmpdir), "test-file") test_json = {"a": PathType("hardlink"), "b": 1} with open(test_file, "w") as f: json.dump(test_json, f, cls=EntityEncoder) with open(test_file, "r") as f: json_file = json.load(f) assert json_file == {"a": "hardlink", "b": 1} @pytest.mark.skipif(on_win, reason="link not available on win/py2.7") def test_crossplatform_st_link(tmpdir): from os import link test_file = join(str(tmpdir), "test-file") test_file_linked = join(str(tmpdir), "test-file-linked") test_file_link = join(str(tmpdir), "test-file-link") open(test_file, "a").close() open(test_file_link, "a").close() link(test_file_link, test_file_linked) assert 1 == CrossPlatformStLink.st_nlink(test_file) assert 2 == CrossPlatformStLink.st_nlink(test_file_link) assert 2 == CrossPlatformStLink.st_nlink(test_file_linked) @pytest.mark.skipif(not on_win, reason="already tested") def test_crossplatform_st_link_on_win(tmpdir): test_file = join(str(tmpdir), "test-file") open(test_file, "a").close() assert 1 == CrossPlatformStLink.st_nlink(test_file)
bsd-3-clause
[ 646, 2022, 199, 504, 747, 14, 515, 492, 4263, 199, 199, 646, 4613, 199, 504, 406, 983, 63, 1506, 14, 1208, 492, 641, 63, 2676, 199, 646, 406, 983, 63, 1506, 423, 1073, 465, 485, 1073, 199, 504, 406, 983, 63, 1506, 14, 23463, 63, 3266, 492, 6912, 804, 12, 17680, 6679, 12, 28965, 10397, 933, 3834, 421, 199, 318, 511, 63, 11357, 63, 70, 63, 18, 837, 272, 702, 485, 1073, 14, 11357, 63, 70, 360, 681, 15, 1208, 14, 647, 297, 334, 18, 12, 1520, 12, 1749, 430, 508, 283, 681, 15, 1208, 14, 11357, 7, 199, 199, 318, 511, 63, 11357, 63, 70, 63, 19, 837, 272, 367, 289, 12, 519, 315, 359, 288, 661, 681, 15, 1208, 14, 647, 297, 1467, 283, 681, 22128, 647, 1637, 363, 15, 1208, 14, 67, 1548, 13, 1082, 14, 11357, 659, 288, 661, 681, 15, 1421, 15, 1208, 14, 647, 297, 1467, 283, 681, 15, 1421, 22128, 647, 1637, 363, 15, 1208, 14, 67, 1548, 13, 1082, 14, 11357, 659, 272, 16246, 267, 702, 485, 1073, 14, 11357, 63, 70, 8, 70, 12, 334, 19, 12, 841, 12, 499, 430, 508, 519, 421, 199, 318, 511, 63, 515, 466, 837, 272, 7508, 1073, 275, 6912, 804, 480, 8726, 1073, 531, 272, 702, 620, 8, 8726, 1073, 9, 508, 298, 8726, 1073, 2, 272, 702, 7508, 1073, 855, 1001, 4533, 508, 283, 8726, 1073, 7, 339, 11620, 1073, 275, 6912, 804, 480, 4617, 1073, 531, 272, 702, 620, 8, 4617, 1073, 9, 508, 298, 4617, 1073, 2, 272, 702, 11620, 1073, 855, 1001, 4533, 508, 298, 4617, 1073, 2, 421, 199, 318, 511, 63, 4502, 63, 9347, 8, 8616, 304, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 511, 63, 1001, 275, 2420, 65, 582, 6912, 804, 480, 8726, 1073, 1288, 298, 66, 582, 413, 93, 272, 543, 1551, 8, 396, 63, 493, 12, 298, 87, 531, 465, 289, 26, 267, 2022, 14, 2724, 8, 396, 63, 1001, 12, 289, 12, 843, 29, 7302, 6679, 9, 339, 543, 1551, 8, 396, 63, 493, 12, 298, 82, 531, 465, 289, 26, 267, 2022, 63, 493, 275, 2022, 14, 912, 8, 70, 9, 272, 702, 2022, 63, 493, 508, 2420, 65, 582, 298, 8726, 1073, 401, 298, 66, 582, 413, 93, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 265, 63, 2676, 12, 4499, 628, 1073, 440, 2808, 641, 4747, 15, 647, 18, 14, 23, 531, 199, 318, 511, 63, 7925, 3246, 63, 270, 63, 1073, 8, 8616, 304, 272, 687, 747, 492, 2142, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 511, 63, 493, 63, 12751, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 13, 12751, 531, 272, 511, 63, 493, 63, 1073, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 13, 1073, 531, 339, 1551, 8, 396, 63, 493, 12, 298, 65, 3471, 1600, 342, 272, 1551, 8, 396, 63, 493, 63, 1073, 12, 298, 65, 3471, 1600, 342, 272, 2142, 8, 396, 63, 493, 63, 1073, 12, 511, 63, 493, 63, 12751, 9, 272, 702, 413, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 9, 272, 702, 499, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 63, 1073, 9, 272, 702, 499, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 63, 12751, 9, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 641, 63, 2676, 12, 4499, 628, 14039, 12470, 531, 199, 318, 511, 63, 7925, 3246, 63, 270, 63, 1073, 63, 265, 63, 2676, 8, 8616, 304, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 1551, 8, 396, 63, 493, 12, 298, 65, 3471, 1600, 342, 272, 702, 413, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2022, 199, 504, 747, 14, 515, 492, 4263, 199, 199, 646, 4613, 199, 504, 406, 983, 63, 1506, 14, 1208, 492, 641, 63, 2676, 199, 646, 406, 983, 63, 1506, 423, 1073, 465, 485, 1073, 199, 504, 406, 983, 63, 1506, 14, 23463, 63, 3266, 492, 6912, 804, 12, 17680, 6679, 12, 28965, 10397, 933, 3834, 421, 199, 318, 511, 63, 11357, 63, 70, 63, 18, 837, 272, 702, 485, 1073, 14, 11357, 63, 70, 360, 681, 15, 1208, 14, 647, 297, 334, 18, 12, 1520, 12, 1749, 430, 508, 283, 681, 15, 1208, 14, 11357, 7, 199, 199, 318, 511, 63, 11357, 63, 70, 63, 19, 837, 272, 367, 289, 12, 519, 315, 359, 288, 661, 681, 15, 1208, 14, 647, 297, 1467, 283, 681, 22128, 647, 1637, 363, 15, 1208, 14, 67, 1548, 13, 1082, 14, 11357, 659, 288, 661, 681, 15, 1421, 15, 1208, 14, 647, 297, 1467, 283, 681, 15, 1421, 22128, 647, 1637, 363, 15, 1208, 14, 67, 1548, 13, 1082, 14, 11357, 659, 272, 16246, 267, 702, 485, 1073, 14, 11357, 63, 70, 8, 70, 12, 334, 19, 12, 841, 12, 499, 430, 508, 519, 421, 199, 318, 511, 63, 515, 466, 837, 272, 7508, 1073, 275, 6912, 804, 480, 8726, 1073, 531, 272, 702, 620, 8, 8726, 1073, 9, 508, 298, 8726, 1073, 2, 272, 702, 7508, 1073, 855, 1001, 4533, 508, 283, 8726, 1073, 7, 339, 11620, 1073, 275, 6912, 804, 480, 4617, 1073, 531, 272, 702, 620, 8, 4617, 1073, 9, 508, 298, 4617, 1073, 2, 272, 702, 11620, 1073, 855, 1001, 4533, 508, 298, 4617, 1073, 2, 421, 199, 318, 511, 63, 4502, 63, 9347, 8, 8616, 304, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 511, 63, 1001, 275, 2420, 65, 582, 6912, 804, 480, 8726, 1073, 1288, 298, 66, 582, 413, 93, 272, 543, 1551, 8, 396, 63, 493, 12, 298, 87, 531, 465, 289, 26, 267, 2022, 14, 2724, 8, 396, 63, 1001, 12, 289, 12, 843, 29, 7302, 6679, 9, 339, 543, 1551, 8, 396, 63, 493, 12, 298, 82, 531, 465, 289, 26, 267, 2022, 63, 493, 275, 2022, 14, 912, 8, 70, 9, 272, 702, 2022, 63, 493, 508, 2420, 65, 582, 298, 8726, 1073, 401, 298, 66, 582, 413, 93, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 265, 63, 2676, 12, 4499, 628, 1073, 440, 2808, 641, 4747, 15, 647, 18, 14, 23, 531, 199, 318, 511, 63, 7925, 3246, 63, 270, 63, 1073, 8, 8616, 304, 272, 687, 747, 492, 2142, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 511, 63, 493, 63, 12751, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 13, 12751, 531, 272, 511, 63, 493, 63, 1073, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 13, 1073, 531, 339, 1551, 8, 396, 63, 493, 12, 298, 65, 3471, 1600, 342, 272, 1551, 8, 396, 63, 493, 63, 1073, 12, 298, 65, 3471, 1600, 342, 272, 2142, 8, 396, 63, 493, 63, 1073, 12, 511, 63, 493, 63, 12751, 9, 272, 702, 413, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 9, 272, 702, 499, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 63, 1073, 9, 272, 702, 499, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 63, 12751, 9, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 641, 63, 2676, 12, 4499, 628, 14039, 12470, 531, 199, 318, 511, 63, 7925, 3246, 63, 270, 63, 1073, 63, 265, 63, 2676, 8, 8616, 304, 272, 511, 63, 493, 275, 4263, 8, 495, 8, 8616, 395, 298, 396, 13, 493, 531, 272, 1551, 8, 396, 63, 493, 12, 298, 65, 3471, 1600, 342, 272, 702, 413, 508, 28965, 10397, 933, 3834, 14, 270, 63, 78, 1073, 8, 396, 63, 493, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0, 0, 0, 0, 0 ]
abought/osf.io
website/addons/box/tests/test_models.py
15
1908
# -*- coding: utf-8 -*- import mock from nose.tools import * # noqa (PEP8 asserts) from tests.base import OsfTestCase from tests.factories import UserFactory from website.addons.box.tests.factories import ( BoxUserSettingsFactory, BoxNodeSettingsFactory, BoxAccountFactory ) from website.addons.box.model import BoxNodeSettings from website.addons.base.testing import models class TestNodeSettings(models.OAuthAddonNodeSettingsTestSuiteMixin, OsfTestCase): short_name = 'box' full_name = 'Box' ExternalAccountFactory = BoxAccountFactory NodeSettingsFactory = BoxNodeSettingsFactory NodeSettingsClass = BoxNodeSettings UserSettingsFactory = BoxUserSettingsFactory def setUp(self): self.mock_update_data = mock.patch.object( BoxNodeSettings, '_update_folder_data' ) self.mock_update_data.start() super(TestNodeSettings, self).setUp() def tearDown(self): self.mock_update_data.stop() super(TestNodeSettings, self).tearDown() def test_folder_defaults_to_none(self): node_settings = BoxNodeSettings(user_settings=self.user_settings) node_settings.save() assert_is_none(node_settings.folder_id) @mock.patch("website.addons.box.model.Box.refresh_oauth_key") def test_serialize_credentials(self, mock_refresh): mock_refresh.return_value = True super(TestNodeSettings, self).test_serialize_credentials() @mock.patch( 'website.addons.box.model.BoxUserSettings.revoke_remote_oauth_access', mock.PropertyMock() ) def test_complete_has_auth_not_verified(self): super(TestNodeSettings, self).test_complete_has_auth_not_verified() class TestUserSettings(models.OAuthAddonUserSettingTestSuiteMixin, OsfTestCase): short_name = 'box' full_name = 'Box' ExternalAccountFactory = BoxAccountFactory
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 1683, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 8151, 334, 25633, 24, 702, 83, 9, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 2295, 14, 15406, 492, 16047, 199, 199, 504, 10691, 14, 10788, 14, 1977, 14, 2219, 14, 15406, 492, 334, 272, 20783, 1899, 5268, 2927, 12, 272, 20783, 1716, 5268, 2927, 12, 272, 20783, 6009, 2927, 199, 9, 199, 504, 10691, 14, 10788, 14, 1977, 14, 1238, 492, 20783, 1716, 5268, 199, 199, 504, 10691, 14, 10788, 14, 1095, 14, 4776, 492, 1709, 421, 199, 533, 1379, 1716, 5268, 8, 992, 14, 12906, 19654, 1716, 5268, 10591, 4256, 12, 593, 7646, 1746, 304, 339, 3974, 63, 354, 275, 283, 1977, 7, 272, 2615, 63, 354, 275, 283, 3532, 7, 272, 18802, 6009, 2927, 275, 20783, 6009, 2927, 339, 5013, 5268, 2927, 275, 20783, 1716, 5268, 2927, 272, 5013, 5268, 2543, 275, 20783, 1716, 5268, 272, 2876, 5268, 2927, 275, 20783, 1899, 5268, 2927, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 63, 873, 63, 576, 275, 1683, 14, 2068, 14, 785, 8, 288, 20783, 1716, 5268, 12, 288, 2513, 873, 63, 3741, 63, 576, 7, 267, 776, 267, 291, 14, 1805, 63, 873, 63, 576, 14, 928, 342, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 5996, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 63, 873, 63, 576, 14, 2379, 342, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 3741, 63, 4322, 63, 475, 63, 3592, 8, 277, 304, 267, 1031, 63, 1751, 275, 20783, 1716, 5268, 8, 751, 63, 1751, 29, 277, 14, 751, 63, 1751, 9, 267, 1031, 63, 1751, 14, 2117, 342, 267, 702, 63, 374, 63, 3592, 8, 932, 63, 1751, 14, 3741, 63, 344, 9, 339, 768, 1805, 14, 2068, 480, 7360, 14, 10788, 14, 1977, 14, 1238, 14, 3532, 14, 6635, 63, 6126, 63, 498, 531, 272, 347, 511, 63, 3549, 63, 6942, 8, 277, 12, 1683, 63, 6635, 304, 267, 1683, 63, 6635, 14, 1107, 63, 585, 275, 715, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 396, 63, 3549, 63, 6942, 342, 339, 768, 1805, 14, 2068, 8, 267, 283, 7360, 14, 10788, 14, 1977, 14, 1238, 14, 3532, 1899, 5268, 14, 24445, 63, 3846, 63, 6126, 63, 2732, 297, 267, 1683, 14, 3697, 3346, 342, 272, 776, 272, 347, 511, 63, 4883, 63, 1989, 63, 1178, 63, 1397, 63, 12949, 8, 277, 304, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 396, 63, 4883, 63, 1989, 63, 1178, 63, 1397, 63, 12949, 342, 199, 199, 533, 1379, 1899, 5268, 8, 992, 14, 12906, 19654, 1899, 7776, 10591, 4256, 12, 593, 7646, 1746, 304, 339, 3974, 63, 354, 275, 283, 1977, 7, 272, 2615, 63, 354, 275, 283, 3532, 7, 272, 18802, 6009, 2927, 275, 20783, 6009, 2927, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1683, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 8151, 334, 25633, 24, 702, 83, 9, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 2295, 14, 15406, 492, 16047, 199, 199, 504, 10691, 14, 10788, 14, 1977, 14, 2219, 14, 15406, 492, 334, 272, 20783, 1899, 5268, 2927, 12, 272, 20783, 1716, 5268, 2927, 12, 272, 20783, 6009, 2927, 199, 9, 199, 504, 10691, 14, 10788, 14, 1977, 14, 1238, 492, 20783, 1716, 5268, 199, 199, 504, 10691, 14, 10788, 14, 1095, 14, 4776, 492, 1709, 421, 199, 533, 1379, 1716, 5268, 8, 992, 14, 12906, 19654, 1716, 5268, 10591, 4256, 12, 593, 7646, 1746, 304, 339, 3974, 63, 354, 275, 283, 1977, 7, 272, 2615, 63, 354, 275, 283, 3532, 7, 272, 18802, 6009, 2927, 275, 20783, 6009, 2927, 339, 5013, 5268, 2927, 275, 20783, 1716, 5268, 2927, 272, 5013, 5268, 2543, 275, 20783, 1716, 5268, 272, 2876, 5268, 2927, 275, 20783, 1899, 5268, 2927, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 63, 873, 63, 576, 275, 1683, 14, 2068, 14, 785, 8, 288, 20783, 1716, 5268, 12, 288, 2513, 873, 63, 3741, 63, 576, 7, 267, 776, 267, 291, 14, 1805, 63, 873, 63, 576, 14, 928, 342, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 5996, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 63, 873, 63, 576, 14, 2379, 342, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 3741, 63, 4322, 63, 475, 63, 3592, 8, 277, 304, 267, 1031, 63, 1751, 275, 20783, 1716, 5268, 8, 751, 63, 1751, 29, 277, 14, 751, 63, 1751, 9, 267, 1031, 63, 1751, 14, 2117, 342, 267, 702, 63, 374, 63, 3592, 8, 932, 63, 1751, 14, 3741, 63, 344, 9, 339, 768, 1805, 14, 2068, 480, 7360, 14, 10788, 14, 1977, 14, 1238, 14, 3532, 14, 6635, 63, 6126, 63, 498, 531, 272, 347, 511, 63, 3549, 63, 6942, 8, 277, 12, 1683, 63, 6635, 304, 267, 1683, 63, 6635, 14, 1107, 63, 585, 275, 715, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 396, 63, 3549, 63, 6942, 342, 339, 768, 1805, 14, 2068, 8, 267, 283, 7360, 14, 10788, 14, 1977, 14, 1238, 14, 3532, 1899, 5268, 14, 24445, 63, 3846, 63, 6126, 63, 2732, 297, 267, 1683, 14, 3697, 3346, 342, 272, 776, 272, 347, 511, 63, 4883, 63, 1989, 63, 1178, 63, 1397, 63, 12949, 8, 277, 304, 267, 1613, 8, 774, 1716, 5268, 12, 291, 680, 396, 63, 4883, 63, 1989, 63, 1178, 63, 1397, 63, 12949, 342, 199, 199, 533, 1379, 1899, 5268, 8, 992, 14, 12906, 19654, 1899, 7776, 10591, 4256, 12, 593, 7646, 1746, 304, 339, 3974, 63, 354, 275, 283, 1977, 7, 272, 2615, 63, 354, 275, 283, 3532, 7, 272, 18802, 6009, 2927, 275, 20783, 6009, 2927, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sergey-dryabzhinsky/denyhosts_sync
tests/test_models.py
2
6478
# denyhosts sync server # Copyright (C) 2015 Jan-Pascal van Best <janpascal@vanbest.org> # 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 time from denyhosts_server import models from denyhosts_server import controllers from denyhosts_server.models import Cracker, Report from twisted.internet.defer import inlineCallbacks, returnValue import base class ModelsTest(base.TestBase): @inlineCallbacks def test_add_cracker(self): cracker_ip = "127.0.0.1" now = time.time() cracker = Cracker(ip_address=cracker_ip, first_time=now, latest_time=now, total_reports=0, current_reports=0, resiliency=0) cracker = yield cracker.save() c2 = yield controllers.get_cracker(cracker_ip) yield self.assertIsNotNone(c2) self.assertEqual(c2.ip_address, cracker.ip_address, "Save and re-fetch cracker from database") self.assertEqual(c2.id, cracker.id, "Save and re-fetch cracker from database") self.assertEqual(c2.first_time, cracker.first_time, "Save and re-fetch cracker from database") self.assertEqual(c2.latest_time, cracker.latest_time, "Save and re-fetch cracker from database") self.assertEqual(c2.total_reports, cracker.total_reports, "Save and re-fetch cracker from database") self.assertEqual(c2.current_reports, cracker.current_reports, "Save and re-fetch cracker from database") self.assertEqual(c2.id, cracker.id, "Save and re-fetch cracker from database") @inlineCallbacks def test_add_report(self): now = time.time() yield Cracker(ip_address="192.168.1.1", first_time=now, latest_time=now, total_reports=0, current_reports=0).save() c = yield controllers.get_cracker("192.168.1.1") yield self.assertIsNotNone(c) yield controllers.add_report_to_cracker(c, "127.0.0.1") r = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"], limit=1) returnValue(self.assertIsNotNone(r, "Added report is in database")) @inlineCallbacks def test_add_multiple_reports(self): now = time.time() yield Cracker(ip_address="192.168.1.1", first_time=now, latest_time=now, total_reports=0, current_reports=0).save() c = yield controllers.get_cracker("192.168.1.1") yield self.assertIsNotNone(c) yield controllers.add_report_to_cracker(c, "127.0.0.1", now) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 1, "First added report is in database") # Add second report shortly after first yield controllers.add_report_to_cracker(c, "127.0.0.1", now+1) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 1, "Second added report should be ignored") # Add second report after 24 hours yield controllers.add_report_to_cracker(c, "127.0.0.1", now+24*3600+1) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 2, "Second report should be added after 24 hours ") # Add third report shortly after second, should be ignored yield controllers.add_report_to_cracker(c, "127.0.0.1", now+24*3600+10) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 2, "Third report shortly after second should be ignored") # Add third report after again 24 hours yield controllers.add_report_to_cracker(c, "127.0.0.1", now+2*24*3600+20) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 3, "Third report after again 24 hours, should be added") # Add fourth report time_added = now + 2*24*3600 + 30 yield controllers.add_report_to_cracker(c, "127.0.0.1", time_added) reports = yield Report.find( where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"], orderby='latest_report_time asc') self.assertEqual(len(reports), 3, "Fourth report, should be merged") self.assertEqual(reports[-1].latest_report_time, time_added, "Latest report time should be updated") self.assertEquals(c.current_reports, 1, "Only one unique reporter should be counted") self.assertEquals(c.total_reports, 6, "Cracker reported six timed in total") # Perform maintenance, expire original report yield controllers.perform_maintenance(limit = now+1) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 2, "Maintenance should remove oldest report") yield c.refresh() self.assertEqual(c.current_reports, 1, "Maintenance should still leave one unique reporter") # Perform maintenance, expire second report yield controllers.perform_maintenance(limit = now+24*3600+11) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 1, "Maintenance should remove one more report") yield c.refresh() self.assertEqual(c.current_reports, 1, "Maintenance should still leave one unique reporter") # Perform maintenance again, expire last report and cracker yield controllers.perform_maintenance(limit = now+2*24*3600+31) reports = yield Report.find(where=["cracker_id=? and ip_address=?",c.id,"127.0.0.1"]) self.assertEqual(len(reports), 0, "Maintenance should remove last report") cracker = yield controllers.get_cracker("192.168.1.1") self.assertIsNone(cracker, "Maintenance should remove cracker") # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
agpl-3.0
[ 3, 5376, 89, 5146, 7604, 1654, 199, 3, 1898, 334, 35, 9, 6900, 17474, 13, 48, 305, 915, 20744, 699, 597, 665, 24418, 15534, 915, 32, 20662, 7010, 14, 1308, 30, 199, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 701, 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, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 900, 199, 199, 504, 5376, 89, 5146, 63, 1000, 492, 1709, 199, 504, 5376, 89, 5146, 63, 1000, 492, 27325, 221, 199, 504, 5376, 89, 5146, 63, 1000, 14, 992, 492, 445, 8085, 281, 12, 11774, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 12, 372, 1110, 199, 199, 646, 1300, 199, 199, 533, 29941, 774, 8, 1095, 14, 14440, 304, 339, 768, 24813, 272, 347, 511, 63, 525, 63, 67, 8085, 281, 8, 277, 304, 267, 286, 8085, 281, 63, 711, 275, 298, 4195, 14, 16, 14, 16, 14, 17, 2, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 8085, 281, 275, 445, 8085, 281, 8, 711, 63, 1562, 29, 67, 8085, 281, 63, 711, 12, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 12, 28633, 317, 9501, 29, 16, 9, 267, 286, 8085, 281, 275, 1995, 286, 8085, 281, 14, 2117, 342, 398, 286, 18, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 8, 67, 8085, 281, 63, 711, 9, 267, 1995, 291, 14, 10389, 8, 67, 18, 9, 267, 291, 14, 629, 8, 67, 18, 14, 711, 63, 1562, 12, 286, 8085, 281, 14, 711, 63, 1562, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 344, 12, 286, 8085, 281, 14, 344, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 2246, 63, 521, 12, 286, 8085, 281, 14, 2246, 63, 521, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 7410, 63, 521, 12, 286, 8085, 281, 14, 7410, 63, 521, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 2923, 63, 15629, 12, 286, 8085, 281, 14, 2923, 63, 15629, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 1818, 63, 15629, 12, 286, 8085, 281, 14, 1818, 63, 15629, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 344, 12, 286, 8085, 281, 14, 344, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 339, 768, 24813, 272, 347, 511, 63, 525, 63, 3070, 8, 277, 304, 267, 3063, 275, 900, 14, 521, 342, 267, 1995, 445, 8085, 281, 8, 711, 63, 1562, 628, 5756, 14, 6568, 14, 17, 14, 17, 401, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 680, 2117, 342, 267, 286, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 480, 5756, 14, 6568, 14, 17, 14, 17, 531, 267, 1995, 291, 14, 10389, 8, 67, 9, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8, 67, 12, 298, 4195, 14, 16, 14, 16, 14, 17, 531, 398, 519, 275, 1995, 11774, 14, 1623, 8, 4509, 6270, 67, 8085, 281, 63, 344, 18048, 436, 3384, 63, 1562, 29, 15583, 67, 14, 344, 4589, 4195, 14, 16, 14, 16, 14, 17, 2255, 2304, 29, 17, 9, 267, 372, 1110, 8, 277, 14, 10389, 8, 82, 12, 298, 20201, 3622, 365, 315, 3050, 2237, 5493, 768, 24813, 272, 347, 511, 63, 525, 63, 6048, 63, 15629, 8, 277, 304, 267, 3063, 275, 900, 14, 521, 342, 398, 1995, 445, 8085, 281, 8, 711, 63, 1562, 628, 5756, 14, 6568, 14, 17, 14, 17, 401, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 680, 2117, 342, 267, 286, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 480, 5756, 14, 6568, 14, 17, 14, 17, 531, 267, 1995, 291, 14, 10389, 8, 67, 9, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8, 67, 12, 298, 4195, 14, 16, 14, 16, 14, 17, 401, 3063, 9, 398, 13924, 275, 1995, 11774, 14, 1623, 8, 4509, 6270, 67, 8085, 281, 63, 344, 18048, 436, 3384, 63, 1562, 29, 15583, 67, 14, 344, 4589, 4195, 14, 16, 14, 16, 14, 17, 3135, 267, 291, 14, 629, 8, 552, 8, 15629, 395, 413, 12, 298, 7147, 3483, 3622, 365, 315, 3050, 531, 398, 327, 2654, 3499, 3622, 3974, 590, 2410, 1642, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8, 67, 12, 298, 4195, 14, 16, 14, 16, 14, 17, 401, 3063, 11, 17, 9, 267, 13924, 275, 1995, 11774, 14, 1623, 8, 4509, 6270, 67, 8085, 281, 63, 344, 18048, 436, 3384, 63, 1562, 29, 15583, 67, 14, 344, 4589, 4195, 14, 16, 14, 16, 14, 17, 3135, 267, 291, 14, 629, 8, 552, 8, 15629, 395, 413, 12, 298, 11906, 3483 ]
[ 5376, 89, 5146, 7604, 1654, 199, 3, 1898, 334, 35, 9, 6900, 17474, 13, 48, 305, 915, 20744, 699, 597, 665, 24418, 15534, 915, 32, 20662, 7010, 14, 1308, 30, 199, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 701, 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, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 900, 199, 199, 504, 5376, 89, 5146, 63, 1000, 492, 1709, 199, 504, 5376, 89, 5146, 63, 1000, 492, 27325, 221, 199, 504, 5376, 89, 5146, 63, 1000, 14, 992, 492, 445, 8085, 281, 12, 11774, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 12, 372, 1110, 199, 199, 646, 1300, 199, 199, 533, 29941, 774, 8, 1095, 14, 14440, 304, 339, 768, 24813, 272, 347, 511, 63, 525, 63, 67, 8085, 281, 8, 277, 304, 267, 286, 8085, 281, 63, 711, 275, 298, 4195, 14, 16, 14, 16, 14, 17, 2, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 8085, 281, 275, 445, 8085, 281, 8, 711, 63, 1562, 29, 67, 8085, 281, 63, 711, 12, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 12, 28633, 317, 9501, 29, 16, 9, 267, 286, 8085, 281, 275, 1995, 286, 8085, 281, 14, 2117, 342, 398, 286, 18, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 8, 67, 8085, 281, 63, 711, 9, 267, 1995, 291, 14, 10389, 8, 67, 18, 9, 267, 291, 14, 629, 8, 67, 18, 14, 711, 63, 1562, 12, 286, 8085, 281, 14, 711, 63, 1562, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 344, 12, 286, 8085, 281, 14, 344, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 2246, 63, 521, 12, 286, 8085, 281, 14, 2246, 63, 521, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 7410, 63, 521, 12, 286, 8085, 281, 14, 7410, 63, 521, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 2923, 63, 15629, 12, 286, 8085, 281, 14, 2923, 63, 15629, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 1818, 63, 15629, 12, 286, 8085, 281, 14, 1818, 63, 15629, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 267, 291, 14, 629, 8, 67, 18, 14, 344, 12, 286, 8085, 281, 14, 344, 12, 298, 8229, 436, 295, 13, 3535, 286, 8085, 281, 687, 3050, 531, 339, 768, 24813, 272, 347, 511, 63, 525, 63, 3070, 8, 277, 304, 267, 3063, 275, 900, 14, 521, 342, 267, 1995, 445, 8085, 281, 8, 711, 63, 1562, 628, 5756, 14, 6568, 14, 17, 14, 17, 401, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 680, 2117, 342, 267, 286, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 480, 5756, 14, 6568, 14, 17, 14, 17, 531, 267, 1995, 291, 14, 10389, 8, 67, 9, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8, 67, 12, 298, 4195, 14, 16, 14, 16, 14, 17, 531, 398, 519, 275, 1995, 11774, 14, 1623, 8, 4509, 6270, 67, 8085, 281, 63, 344, 18048, 436, 3384, 63, 1562, 29, 15583, 67, 14, 344, 4589, 4195, 14, 16, 14, 16, 14, 17, 2255, 2304, 29, 17, 9, 267, 372, 1110, 8, 277, 14, 10389, 8, 82, 12, 298, 20201, 3622, 365, 315, 3050, 2237, 5493, 768, 24813, 272, 347, 511, 63, 525, 63, 6048, 63, 15629, 8, 277, 304, 267, 3063, 275, 900, 14, 521, 342, 398, 1995, 445, 8085, 281, 8, 711, 63, 1562, 628, 5756, 14, 6568, 14, 17, 14, 17, 401, 1642, 63, 521, 29, 2131, 12, 8839, 63, 521, 29, 2131, 12, 3141, 63, 15629, 29, 16, 12, 1453, 63, 15629, 29, 16, 680, 2117, 342, 267, 286, 275, 1995, 27325, 14, 362, 63, 67, 8085, 281, 480, 5756, 14, 6568, 14, 17, 14, 17, 531, 267, 1995, 291, 14, 10389, 8, 67, 9, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8, 67, 12, 298, 4195, 14, 16, 14, 16, 14, 17, 401, 3063, 9, 398, 13924, 275, 1995, 11774, 14, 1623, 8, 4509, 6270, 67, 8085, 281, 63, 344, 18048, 436, 3384, 63, 1562, 29, 15583, 67, 14, 344, 4589, 4195, 14, 16, 14, 16, 14, 17, 3135, 267, 291, 14, 629, 8, 552, 8, 15629, 395, 413, 12, 298, 7147, 3483, 3622, 365, 315, 3050, 531, 398, 327, 2654, 3499, 3622, 3974, 590, 2410, 1642, 267, 1995, 27325, 14, 525, 63, 3070, 63, 475, 63, 67, 8085, 281, 8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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ucrawler/cp-uc
libs/pyutil/scripts/memdump2dot.py
106
1589
#!/usr/bin/env python import bindann bindann.install_exception_handler() import sys inf = open(sys.argv[1], "r") outf = open(sys.argv[1]+".dot", "w") outf.write("digraph %s {\n" % sys.argv[1].replace(".","")) def parse_netstring(l, i): try: j = l.find(':', i) if j == -1: return (None, len(l),) lenval = int(l[i:j]) val = l[j+1:j+1+lenval] # skip the comma assert l[j+1+lenval] == "," return (val, j+1+lenval+1,) except Exception, le: le.args = tuple(le.args + (l, i,)) raise def parse_ref(l, i): (attrname, i,) = parse_netstring(l, i) j = l.find(",", i) assert j != -1 objid = l[i:j] return (objid, attrname, j+1,) def parse_memdump_line(l): result = [] i = l.find('-') objid = l[:i] (objdesc, i,) = parse_netstring(l, i+1) result.append((objid, objdesc,)) while i != -1 and i < len(l): (objid, attrname, i,) = parse_ref(l, i) result.append((objid, attrname,)) return result for l in inf: if l[-1] != "\n": raise "waht the HECK? %r" % l res = parse_memdump_line(l.strip()) # declare the node outf.write("\"%s\" [label=\"%s\"];\n" % (res[0][0], res[0][1],)) # declare all the edges for edge in res[1:]: if edge[1]: # a named edge outf.write("\"%s\" -> \"%s\" [style=bold, label=\"%s\"];\n" % (res[0][0], edge[0], edge[1],)) else: # an anonymous edge outf.write("\"%s\" -> \"%s\";\n" % (res[0][0], edge[0])) outf.write("}")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 5398, 1189, 199, 3409, 1189, 14, 3174, 63, 1971, 63, 2232, 342, 199, 199, 646, 984, 199, 199, 4904, 275, 1551, 8, 1274, 14, 3020, 59, 17, 467, 298, 82, 531, 199, 199, 548, 70, 275, 1551, 8, 1274, 14, 3020, 59, 17, 2807, 1674, 3287, 401, 298, 87, 531, 199, 548, 70, 14, 952, 480, 328, 2180, 450, 83, 9459, 78, 2, 450, 984, 14, 3020, 59, 17, 1055, 1814, 30381, 341, 430, 199, 199, 318, 2198, 63, 846, 875, 8, 76, 12, 284, 304, 272, 862, 26, 267, 1335, 275, 634, 14, 1623, 16451, 284, 9, 267, 340, 1335, 508, 446, 17, 26, 288, 372, 334, 403, 12, 822, 8, 76, 16945, 267, 822, 637, 275, 1109, 8, 76, 59, 73, 26, 74, 566, 267, 1139, 275, 634, 59, 74, 11, 17, 26, 74, 11, 17, 11, 552, 637, 61, 267, 327, 3372, 314, 10029, 267, 702, 634, 59, 74, 11, 17, 11, 552, 637, 61, 508, 21147, 267, 372, 334, 637, 12, 1335, 11, 17, 11, 552, 637, 11, 17, 4258, 272, 871, 2186, 12, 1026, 26, 267, 1026, 14, 589, 275, 2008, 8, 274, 14, 589, 435, 334, 76, 12, 284, 4641, 267, 746, 199, 199, 318, 2198, 63, 1121, 8, 76, 12, 284, 304, 272, 334, 962, 354, 12, 284, 4258, 275, 2198, 63, 846, 875, 8, 76, 12, 284, 9, 272, 1335, 275, 634, 14, 1623, 11854, 401, 284, 9, 272, 702, 1335, 1137, 446, 17, 272, 1559, 344, 275, 634, 59, 73, 26, 74, 61, 272, 372, 334, 1113, 344, 12, 26367, 12, 1335, 11, 17, 4258, 199, 199, 318, 2198, 63, 278, 1064, 1220, 63, 604, 8, 76, 304, 272, 754, 275, 942, 339, 284, 275, 634, 14, 1623, 21950, 272, 1559, 344, 275, 634, 1491, 73, 61, 272, 334, 1113, 3257, 12, 284, 4258, 275, 2198, 63, 846, 875, 8, 76, 12, 284, 11, 17, 9, 339, 754, 14, 740, 1332, 1113, 344, 12, 1559, 3257, 4641, 339, 1830, 284, 1137, 446, 17, 436, 284, 665, 822, 8, 76, 304, 267, 334, 1113, 344, 12, 26367, 12, 284, 4258, 275, 2198, 63, 1121, 8, 76, 12, 284, 9, 267, 754, 14, 740, 1332, 1113, 344, 12, 26367, 4641, 339, 372, 754, 199, 199, 509, 634, 315, 10739, 26, 272, 340, 634, 1988, 17, 61, 1137, 1867, 78, 582, 267, 746, 298, 758, 517, 314, 8378, 2504, 31, 450, 82, 2, 450, 634, 272, 522, 275, 2198, 63, 278, 1064, 1220, 63, 604, 8, 76, 14, 1913, 1012, 272, 327, 20771, 314, 1031, 272, 27552, 14, 952, 480, 4451, 5, 83, 4451, 359, 1302, 26766, 83, 60, 937, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 522, 59, 16, 1527, 17, 467, 430, 339, 327, 20771, 1006, 314, 8207, 272, 367, 6275, 315, 522, 59, 17, 10688, 267, 340, 6275, 59, 17, 2189, 288, 327, 282, 4310, 6275, 288, 27552, 14, 952, 480, 4451, 5, 83, 4451, 1035, 18321, 83, 4451, 359, 2487, 29, 9771, 12, 1768, 26766, 83, 60, 937, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 6275, 59, 16, 467, 6275, 59, 17, 467, 430, 267, 587, 26, 288, 327, 376, 16535, 6275, 288, 27552, 14, 952, 480, 4451, 5, 83, 4451, 1035, 18321, 83, 4451, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 6275, 59, 16, 2459, 199, 199, 548, 70, 14, 952, 480, 15412, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 5398, 1189, 199, 3409, 1189, 14, 3174, 63, 1971, 63, 2232, 342, 199, 199, 646, 984, 199, 199, 4904, 275, 1551, 8, 1274, 14, 3020, 59, 17, 467, 298, 82, 531, 199, 199, 548, 70, 275, 1551, 8, 1274, 14, 3020, 59, 17, 2807, 1674, 3287, 401, 298, 87, 531, 199, 548, 70, 14, 952, 480, 328, 2180, 450, 83, 9459, 78, 2, 450, 984, 14, 3020, 59, 17, 1055, 1814, 30381, 341, 430, 199, 199, 318, 2198, 63, 846, 875, 8, 76, 12, 284, 304, 272, 862, 26, 267, 1335, 275, 634, 14, 1623, 16451, 284, 9, 267, 340, 1335, 508, 446, 17, 26, 288, 372, 334, 403, 12, 822, 8, 76, 16945, 267, 822, 637, 275, 1109, 8, 76, 59, 73, 26, 74, 566, 267, 1139, 275, 634, 59, 74, 11, 17, 26, 74, 11, 17, 11, 552, 637, 61, 267, 327, 3372, 314, 10029, 267, 702, 634, 59, 74, 11, 17, 11, 552, 637, 61, 508, 21147, 267, 372, 334, 637, 12, 1335, 11, 17, 11, 552, 637, 11, 17, 4258, 272, 871, 2186, 12, 1026, 26, 267, 1026, 14, 589, 275, 2008, 8, 274, 14, 589, 435, 334, 76, 12, 284, 4641, 267, 746, 199, 199, 318, 2198, 63, 1121, 8, 76, 12, 284, 304, 272, 334, 962, 354, 12, 284, 4258, 275, 2198, 63, 846, 875, 8, 76, 12, 284, 9, 272, 1335, 275, 634, 14, 1623, 11854, 401, 284, 9, 272, 702, 1335, 1137, 446, 17, 272, 1559, 344, 275, 634, 59, 73, 26, 74, 61, 272, 372, 334, 1113, 344, 12, 26367, 12, 1335, 11, 17, 4258, 199, 199, 318, 2198, 63, 278, 1064, 1220, 63, 604, 8, 76, 304, 272, 754, 275, 942, 339, 284, 275, 634, 14, 1623, 21950, 272, 1559, 344, 275, 634, 1491, 73, 61, 272, 334, 1113, 3257, 12, 284, 4258, 275, 2198, 63, 846, 875, 8, 76, 12, 284, 11, 17, 9, 339, 754, 14, 740, 1332, 1113, 344, 12, 1559, 3257, 4641, 339, 1830, 284, 1137, 446, 17, 436, 284, 665, 822, 8, 76, 304, 267, 334, 1113, 344, 12, 26367, 12, 284, 4258, 275, 2198, 63, 1121, 8, 76, 12, 284, 9, 267, 754, 14, 740, 1332, 1113, 344, 12, 26367, 4641, 339, 372, 754, 199, 199, 509, 634, 315, 10739, 26, 272, 340, 634, 1988, 17, 61, 1137, 1867, 78, 582, 267, 746, 298, 758, 517, 314, 8378, 2504, 31, 450, 82, 2, 450, 634, 272, 522, 275, 2198, 63, 278, 1064, 1220, 63, 604, 8, 76, 14, 1913, 1012, 272, 327, 20771, 314, 1031, 272, 27552, 14, 952, 480, 4451, 5, 83, 4451, 359, 1302, 26766, 83, 60, 937, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 522, 59, 16, 1527, 17, 467, 430, 339, 327, 20771, 1006, 314, 8207, 272, 367, 6275, 315, 522, 59, 17, 10688, 267, 340, 6275, 59, 17, 2189, 288, 327, 282, 4310, 6275, 288, 27552, 14, 952, 480, 4451, 5, 83, 4451, 1035, 18321, 83, 4451, 359, 2487, 29, 9771, 12, 1768, 26766, 83, 60, 937, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 6275, 59, 16, 467, 6275, 59, 17, 467, 430, 267, 587, 26, 288, 327, 376, 16535, 6275, 288, 27552, 14, 952, 480, 4451, 5, 83, 4451, 1035, 18321, 83, 4451, 3779, 78, 2, 450, 334, 470, 59, 16, 1527, 16, 467, 6275, 59, 16, 2459, 199, 199, 548, 70, 14, 952, 480, 15412, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
BiznetGIO/horizon
openstack_dashboard/api/base.py
1
12067
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from collections import Sequence import functools from django.conf import settings import semantic_version import six from horizon import exceptions __all__ = ('APIResourceWrapper', 'APIDictWrapper', 'get_service_from_catalog', 'url_for',) @functools.total_ordering class Version(object): def __init__(self, version): self.version = semantic_version.Version(str(version), partial=True) def __eq__(self, other): return self.version == Version(other).version def __lt__(self, other): return self.version < Version(other).version def __repr__(self): return "Version('%s')" % self.version def __str__(self): return str(self.version) def __hash__(self): return hash(str(self.version)) class APIVersionManager(object): """Object to store and manage API versioning data and utility methods.""" SETTINGS_KEY = "OPENSTACK_API_VERSIONS" def __init__(self, service_type, preferred_version=None): self.service_type = service_type self.preferred = preferred_version self._active = None self.supported = {} # As a convenience, we can drop in a placeholder for APIs that we # have not yet needed to version. This is useful, for example, when # panels such as the admin metadata_defs wants to check the active # version even though it's not explicitly defined. Previously # this caused a KeyError. if self.preferred: self.supported[self.preferred] = {"version": self.preferred} @property def active(self): if self._active is None: self.get_active_version() return self._active def load_supported_version(self, version, data): version = Version(version) self.supported[version] = data def get_active_version(self): if self._active is not None: return self.supported[self._active] key = getattr(settings, self.SETTINGS_KEY, {}).get(self.service_type) if key is None: # TODO(gabriel): support API version discovery here; we'll leave # the setting in as a way of overriding the latest available # version. key = self.preferred version = Version(key) # Provide a helpful error message if the specified version isn't in the # supported list. if version not in self.supported: choices = ", ".join(str(k) for k in six.iterkeys(self.supported)) msg = ('%s is not a supported API version for the %s service, ' ' choices are: %s' % (version, self.service_type, choices)) raise exceptions.ConfigurationError(msg) self._active = version return self.supported[self._active] def clear_active_cache(self): self._active = None class APIResourceWrapper(object): """Simple wrapper for api objects. Define _attrs on the child class and pass in the api object as the only argument to the constructor """ _attrs = [] _apiresource = None # Make sure _apiresource is there even in __init__. def __init__(self, apiresource): self._apiresource = apiresource def __getattribute__(self, attr): try: return object.__getattribute__(self, attr) except AttributeError: if attr not in self._attrs: raise # __getattr__ won't find properties return getattr(self._apiresource, attr) def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, dict((attr, getattr(self, attr)) for attr in self._attrs if hasattr(self, attr))) def to_dict(self): obj = {} for key in self._attrs: obj[key] = getattr(self._apiresource, key, None) return obj class APIDictWrapper(object): """Simple wrapper for api dictionaries Some api calls return dictionaries. This class provides identical behavior as APIResourceWrapper, except that it will also behave as a dictionary, in addition to attribute accesses. Attribute access is the preferred method of access, to be consistent with api resource objects from novaclient. """ _apidict = {} # Make sure _apidict is there even in __init__. def __init__(self, apidict): self._apidict = apidict def __getattribute__(self, attr): try: return object.__getattribute__(self, attr) except AttributeError: if attr not in self._apidict: raise return self._apidict[attr] def __getitem__(self, item): try: return getattr(self, item) except (AttributeError, TypeError) as e: # caller is expecting a KeyError raise KeyError(e) def __contains__(self, item): try: return hasattr(self, item) except TypeError: return False def get(self, item, default=None): try: return getattr(self, item) except (AttributeError, TypeError): return default def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, self._apidict) def to_dict(self): return self._apidict class Quota(object): """Wrapper for individual limits in a quota.""" def __init__(self, name, limit): self.name = name self.limit = limit def __repr__(self): return "<Quota: (%s, %s)>" % (self.name, self.limit) class QuotaSet(Sequence): """Wrapper for client QuotaSet objects. This turns the individual quotas into Quota objects for easier handling/iteration. `QuotaSet` objects support a mix of `list` and `dict` methods; you can use the bracket notation (`qs["my_quota"] = 0`) to add new quota values, and use the `get` method to retrieve a specific quota, but otherwise it behaves much like a list or tuple, particularly in supporting iteration. """ def __init__(self, apiresource=None): self.items = [] if apiresource: if hasattr(apiresource, '_info'): items = apiresource._info.items() else: items = apiresource.items() for k, v in items: if k == 'id': continue self[k] = v def __setitem__(self, k, v): v = int(v) if v is not None else v q = Quota(k, v) self.items.append(q) def __getitem__(self, index): return self.items[index] def __add__(self, other): """Merge another QuotaSet into this one. Existing quotas are not overridden. """ if not isinstance(other, QuotaSet): msg = "Can only add QuotaSet to QuotaSet, " \ "but received %s instead" % type(other) raise ValueError(msg) for item in other: if self.get(item.name).limit is None: self.items.append(item) return self def __len__(self): return len(self.items) def __repr__(self): return repr(self.items) def get(self, key, default=None): match = [quota for quota in self.items if quota.name == key] return match.pop() if len(match) else Quota(key, default) def add(self, other): return self.__add__(other) def get_service_from_catalog(catalog, service_type): if catalog: for service in catalog: if 'type' not in service: continue if service['type'] == service_type: return service return None def get_version_from_service(service): if service and service.get('endpoints'): endpoint = service['endpoints'][0] if 'interface' in endpoint: return 3 else: return 2.0 return 2.0 # Mapping of V2 Catalog Endpoint_type to V3 Catalog Interfaces ENDPOINT_TYPE_TO_INTERFACE = { 'publicURL': 'public', 'internalURL': 'internal', 'adminURL': 'admin', } def get_url_for_service(service, region, endpoint_type): if 'type' not in service: return None identity_version = get_version_from_service(service) service_endpoints = service.get('endpoints', []) available_endpoints = [endpoint for endpoint in service_endpoints if region == _get_endpoint_region(endpoint)] """if we are dealing with the identity service and there is no endpoint in the current region, it is okay to use the first endpoint for any identity service endpoints and we can assume that it is global """ if service['type'] == 'identity' and not available_endpoints: available_endpoints = [endpoint for endpoint in service_endpoints] for endpoint in available_endpoints: try: if identity_version < 3: return endpoint.get(endpoint_type) else: interface = \ ENDPOINT_TYPE_TO_INTERFACE.get(endpoint_type, '') if endpoint.get('interface') == interface: return endpoint.get('url') except (IndexError, KeyError): """it could be that the current endpoint just doesn't match the type, continue trying the next one """ pass return None def url_for(request, service_type, endpoint_type=None, region=None): endpoint_type = endpoint_type or getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'publicURL') fallback_endpoint_type = getattr(settings, 'SECONDARY_ENDPOINT_TYPE', None) catalog = request.user.service_catalog service = get_service_from_catalog(catalog, service_type) if service: if not region: region = request.user.services_region url = get_url_for_service(service, region, endpoint_type) if not url and fallback_endpoint_type: url = get_url_for_service(service, region, fallback_endpoint_type) if url: return url raise exceptions.ServiceCatalogException(service_type) def is_service_enabled(request, service_type): service = get_service_from_catalog(request.user.service_catalog, service_type) if service: region = request.user.services_region for endpoint in service.get('endpoints', []): if 'type' not in service: continue # ignore region for identity if service['type'] == 'identity' or \ _get_endpoint_region(endpoint) == region: return True return False def _get_endpoint_region(endpoint): """Common function for getting the region from endpoint. In Keystone V3, region has been deprecated in favor of region_id. This method provides a way to get region that works for both Keystone V2 and V3. """ return endpoint.get('region_id') or endpoint.get('region')
apache-2.0
[ 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 5055, 492, 10975, 199, 646, 9143, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 646, 32451, 63, 1023, 199, 646, 3816, 199, 199, 504, 21726, 492, 4967, 421, 199, 363, 452, 363, 275, 661, 3735, 4031, 4590, 297, 283, 1282, 998, 73, 319, 4590, 297, 1779, 283, 362, 63, 1364, 63, 504, 63, 7959, 297, 283, 633, 63, 509, 9538, 421, 199, 32, 17869, 14, 2923, 63, 7128, 199, 533, 3394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1015, 304, 267, 291, 14, 1023, 275, 32451, 63, 1023, 14, 3353, 8, 495, 8, 1023, 395, 7417, 29, 549, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 1023, 508, 3394, 8, 1848, 680, 1023, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 1023, 665, 3394, 8, 1848, 680, 1023, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 3353, 3508, 83, 19124, 450, 291, 14, 1023, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1023, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 495, 8, 277, 14, 1023, 430, 421, 199, 533, 3261, 3353, 2988, 8, 785, 304, 272, 408, 1692, 370, 3877, 436, 9635, 3261, 1015, 316, 666, 436, 11420, 3102, 1041, 339, 11543, 52, 3881, 63, 3078, 275, 298, 9935, 17014, 63, 3735, 63, 26358, 2, 339, 347, 636, 826, 721, 277, 12, 2435, 63, 466, 12, 14388, 63, 1023, 29, 403, 304, 267, 291, 14, 1364, 63, 466, 275, 2435, 63, 466, 267, 291, 14, 17477, 275, 14388, 63, 1023, 267, 291, 423, 2682, 275, 488, 267, 291, 14, 4946, 275, 1052, 267, 327, 3709, 282, 16777, 12, 781, 883, 5978, 315, 282, 10069, 367, 15913, 626, 781, 267, 327, 1172, 440, 5966, 4346, 370, 1015, 14, 961, 365, 2997, 12, 367, 2893, 12, 1380, 267, 327, 12748, 83, 4066, 465, 314, 4628, 3341, 63, 8710, 15061, 370, 1104, 314, 4702, 267, 327, 1015, 2755, 10617, 652, 1159, 440, 7662, 3247, 14, 26902, 590, 267, 327, 642, 18104, 282, 4067, 14, 267, 340, 291, 14, 17477, 26, 288, 291, 14, 4946, 59, 277, 14, 17477, 61, 275, 2420, 1023, 582, 291, 14, 17477, 93, 339, 768, 1829, 272, 347, 4702, 8, 277, 304, 267, 340, 291, 423, 2682, 365, 488, 26, 288, 291, 14, 362, 63, 2682, 63, 1023, 342, 267, 372, 291, 423, 2682, 339, 347, 2248, 63, 4946, 63, 1023, 8, 277, 12, 1015, 12, 666, 304, 267, 1015, 275, 3394, 8, 1023, 9, 267, 291, 14, 4946, 59, 1023, 61, 275, 666, 339, 347, 664, 63, 2682, 63, 1023, 8, 277, 304, 267, 340, 291, 423, 2682, 365, 440, 488, 26, 288, 372, 291, 14, 4946, 59, 277, 423, 2682, 61, 267, 790, 275, 2519, 8, 1751, 12, 291, 14, 13931, 63, 3078, 12, 13056, 362, 8, 277, 14, 1364, 63, 466, 9, 267, 340, 790, 365, 488, 26, 288, 327, 3254, 8, 71, 371, 322, 352, 304, 2291, 3261, 1015, 13172, 2348, 27, 781, 7171, 10137, 288, 327, 314, 4260, 315, 465, 282, 4340, 402, 18972, 314, 8839, 2808, 288, 327, 1015, 14, 288, 790, 275, 291, 14, 17477, 267, 1015, 275, 3394, 8, 498, 9, 267, 327, 22896, 282, 24606, 1125, 1245, 340, 314, 2013, 1015, 5712, 1133, 315, 314, 267, 327, 3748, 769, 14, 267, 340, 1015, 440, 315, 291, 14, 4946, 26, 288, 3415, 275, 3872, 3680, 904, 8, 495, 8, 75, 9, 367, 1022, 315, 3816, 14, 16007, 8, 277, 14, 4946, 430, 288, 1499, 275, 16651, 83, 365, 440, 282, 3748, 3261, 1015, 367, 314, 450, 83, 2435, 12, 283, 673, 283, 3415, 787, 26, 450, 83, 7, 450, 334, 1023, 12, 291, 14, 1364, 63, 466, 12, 3415, 430, 288, 746, 4967, 14, 5688, 547, 8, 1328, 9, 267, 291, 423, 2682, 275, 1015, 267, 372, 291, 14, 4946, 59, 277, 423, 2682, 61, 339, 347, 5436, 63, 2682, 63, 1637, 8, 277, 304, 267, 291, 423, 2682, 275, 488, 421, 199, 533, 3261, 4031, 4590, 8, 785, 304, 272, 408, 3184, 4975, 367, 2986, 2251, 14, 339, 13930, 485, 3288, 641, 314, 1982, 1021, 436, 986, 315, 314, 272, 2986, 909, 465, 314, 1454, 1423, 370, 314, 3787, 272, 408, 272, 485, 3288, 275, 942, 272, 485, 1246, 1927, 275, 488, 221, 327, 4155, 3238, 485, 1246, 1927, 365, 2337, 2755, 315, 636, 826, 4343, 339, 347, 636, 826, 721, 277, 12, 2986, 1927, 304, 267, 291, 423, 1246, 1927, 275, 2986, 1927, 339, 347, 636, 18480, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 1921, 9, 267, 871, 4281, 26, 288, 340, 1921, 440, 315, 291, 423, 3288, 26, 355, 746, 288, 327, 636, 5675, 363, 7859, 1133, 2342, 4382, 288, 372, 2519, 8, 277, 423, 1246, 1927, 12, 1921, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 26, 450, 83, 4335, 450, 334, 277, 855, 533, 4914, 354, 3108, 2490, 1211, 1332, 962, 12 ]
[ 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 5055, 492, 10975, 199, 646, 9143, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 646, 32451, 63, 1023, 199, 646, 3816, 199, 199, 504, 21726, 492, 4967, 421, 199, 363, 452, 363, 275, 661, 3735, 4031, 4590, 297, 283, 1282, 998, 73, 319, 4590, 297, 1779, 283, 362, 63, 1364, 63, 504, 63, 7959, 297, 283, 633, 63, 509, 9538, 421, 199, 32, 17869, 14, 2923, 63, 7128, 199, 533, 3394, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1015, 304, 267, 291, 14, 1023, 275, 32451, 63, 1023, 14, 3353, 8, 495, 8, 1023, 395, 7417, 29, 549, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 1023, 508, 3394, 8, 1848, 680, 1023, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 1023, 665, 3394, 8, 1848, 680, 1023, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 3353, 3508, 83, 19124, 450, 291, 14, 1023, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1023, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 495, 8, 277, 14, 1023, 430, 421, 199, 533, 3261, 3353, 2988, 8, 785, 304, 272, 408, 1692, 370, 3877, 436, 9635, 3261, 1015, 316, 666, 436, 11420, 3102, 1041, 339, 11543, 52, 3881, 63, 3078, 275, 298, 9935, 17014, 63, 3735, 63, 26358, 2, 339, 347, 636, 826, 721, 277, 12, 2435, 63, 466, 12, 14388, 63, 1023, 29, 403, 304, 267, 291, 14, 1364, 63, 466, 275, 2435, 63, 466, 267, 291, 14, 17477, 275, 14388, 63, 1023, 267, 291, 423, 2682, 275, 488, 267, 291, 14, 4946, 275, 1052, 267, 327, 3709, 282, 16777, 12, 781, 883, 5978, 315, 282, 10069, 367, 15913, 626, 781, 267, 327, 1172, 440, 5966, 4346, 370, 1015, 14, 961, 365, 2997, 12, 367, 2893, 12, 1380, 267, 327, 12748, 83, 4066, 465, 314, 4628, 3341, 63, 8710, 15061, 370, 1104, 314, 4702, 267, 327, 1015, 2755, 10617, 652, 1159, 440, 7662, 3247, 14, 26902, 590, 267, 327, 642, 18104, 282, 4067, 14, 267, 340, 291, 14, 17477, 26, 288, 291, 14, 4946, 59, 277, 14, 17477, 61, 275, 2420, 1023, 582, 291, 14, 17477, 93, 339, 768, 1829, 272, 347, 4702, 8, 277, 304, 267, 340, 291, 423, 2682, 365, 488, 26, 288, 291, 14, 362, 63, 2682, 63, 1023, 342, 267, 372, 291, 423, 2682, 339, 347, 2248, 63, 4946, 63, 1023, 8, 277, 12, 1015, 12, 666, 304, 267, 1015, 275, 3394, 8, 1023, 9, 267, 291, 14, 4946, 59, 1023, 61, 275, 666, 339, 347, 664, 63, 2682, 63, 1023, 8, 277, 304, 267, 340, 291, 423, 2682, 365, 440, 488, 26, 288, 372, 291, 14, 4946, 59, 277, 423, 2682, 61, 267, 790, 275, 2519, 8, 1751, 12, 291, 14, 13931, 63, 3078, 12, 13056, 362, 8, 277, 14, 1364, 63, 466, 9, 267, 340, 790, 365, 488, 26, 288, 327, 3254, 8, 71, 371, 322, 352, 304, 2291, 3261, 1015, 13172, 2348, 27, 781, 7171, 10137, 288, 327, 314, 4260, 315, 465, 282, 4340, 402, 18972, 314, 8839, 2808, 288, 327, 1015, 14, 288, 790, 275, 291, 14, 17477, 267, 1015, 275, 3394, 8, 498, 9, 267, 327, 22896, 282, 24606, 1125, 1245, 340, 314, 2013, 1015, 5712, 1133, 315, 314, 267, 327, 3748, 769, 14, 267, 340, 1015, 440, 315, 291, 14, 4946, 26, 288, 3415, 275, 3872, 3680, 904, 8, 495, 8, 75, 9, 367, 1022, 315, 3816, 14, 16007, 8, 277, 14, 4946, 430, 288, 1499, 275, 16651, 83, 365, 440, 282, 3748, 3261, 1015, 367, 314, 450, 83, 2435, 12, 283, 673, 283, 3415, 787, 26, 450, 83, 7, 450, 334, 1023, 12, 291, 14, 1364, 63, 466, 12, 3415, 430, 288, 746, 4967, 14, 5688, 547, 8, 1328, 9, 267, 291, 423, 2682, 275, 1015, 267, 372, 291, 14, 4946, 59, 277, 423, 2682, 61, 339, 347, 5436, 63, 2682, 63, 1637, 8, 277, 304, 267, 291, 423, 2682, 275, 488, 421, 199, 533, 3261, 4031, 4590, 8, 785, 304, 272, 408, 3184, 4975, 367, 2986, 2251, 14, 339, 13930, 485, 3288, 641, 314, 1982, 1021, 436, 986, 315, 314, 272, 2986, 909, 465, 314, 1454, 1423, 370, 314, 3787, 272, 408, 272, 485, 3288, 275, 942, 272, 485, 1246, 1927, 275, 488, 221, 327, 4155, 3238, 485, 1246, 1927, 365, 2337, 2755, 315, 636, 826, 4343, 339, 347, 636, 826, 721, 277, 12, 2986, 1927, 304, 267, 291, 423, 1246, 1927, 275, 2986, 1927, 339, 347, 636, 18480, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 1921, 9, 267, 871, 4281, 26, 288, 340, 1921, 440, 315, 291, 423, 3288, 26, 355, 746, 288, 327, 636, 5675, 363, 7859, 1133, 2342, 4382, 288, 372, 2519, 8, 277, 423, 1246, 1927, 12, 1921, 9, 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, 1 ]
robinro/ansible
lib/ansible/modules/cloud/webfaction/webfaction_site.py
63
7118
#!/usr/bin/python # # Create Webfaction website using Ansible and the Webfaction API # # ------------------------------------------ # # (c) Quentin Stafford-Fraser 2015 # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: webfaction_site short_description: Add or remove a website on a Webfaction host description: - Add or remove a website on a Webfaction host. Further documentation at http://github.com/quentinsf/ansible-webfaction. author: Quentin Stafford-Fraser (@quentinsf) version_added: "2.0" notes: - Sadly, you I(do) need to know your webfaction hostname for the C(host) parameter. But at least, unlike the API, you don't need to know the IP address. You can use a DNS name. - If a site of the same name exists in the account but on a different host, the operation will exit. - > You can run playbooks that use this on a local machine, or on a Webfaction host, or elsewhere, since the scripts use the remote webfaction API. The location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API <http://docs.webfaction.com/xmlrpc-api/>`_ for more info. options: name: description: - The name of the website required: true state: description: - Whether the website should exist required: false choices: ['present', 'absent'] default: "present" host: description: - The webfaction host on which the site should be created. required: true https: description: - Whether or not to use HTTPS required: false choices: - true - false default: 'false' site_apps: description: - A mapping of URLs to apps required: false subdomains: description: - A list of subdomains associated with this site. required: false default: null login_name: description: - The webfaction account to use required: true login_password: description: - The webfaction password to use required: true ''' EXAMPLES = ''' - name: create website webfaction_site: name: testsite1 state: present host: myhost.webfaction.com subdomains: - 'testsite1.my_domain.org' site_apps: - ['testapp1', '/'] https: no login_name: "{{webfaction_user}}" login_password: "{{webfaction_passwd}}" ''' import socket import xmlrpclib webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') def main(): module = AnsibleModule( argument_spec = dict( name = dict(required=True), state = dict(required=False, choices=['present', 'absent'], default='present'), # You can specify an IP address or hostname. host = dict(required=True), https = dict(required=False, type='bool', default=False), subdomains = dict(required=False, type='list', default=[]), site_apps = dict(required=False, type='list', default=[]), login_name = dict(required=True), login_password = dict(required=True, no_log=True), ), supports_check_mode=True ) site_name = module.params['name'] site_state = module.params['state'] site_host = module.params['host'] site_ip = socket.gethostbyname(site_host) session_id, account = webfaction.login( module.params['login_name'], module.params['login_password'] ) site_list = webfaction.list_websites(session_id) site_map = dict([(i['name'], i) for i in site_list]) existing_site = site_map.get(site_name) result = {} # Here's where the real stuff happens if site_state == 'present': # Does a site with this name already exist? if existing_site: # If yes, but it's on a different IP address, then fail. # If we wanted to allow relocation, we could add a 'relocate=true' option # which would get the existing IP address, delete the site there, and create it # at the new address. A bit dangerous, perhaps, so for now we'll require manual # deletion if it's on another host. if existing_site['ip'] != site_ip: module.fail_json(msg="Website already exists with a different IP address. Please fix by hand.") # If it's on this host and the key parameters are the same, nothing needs to be done. if (existing_site['https'] == module.boolean(module.params['https'])) and \ (set(existing_site['subdomains']) == set(module.params['subdomains'])) and \ (dict(existing_site['website_apps']) == dict(module.params['site_apps'])): module.exit_json( changed = False ) positional_args = [ session_id, site_name, site_ip, module.boolean(module.params['https']), module.params['subdomains'], ] for a in module.params['site_apps']: positional_args.append( (a[0], a[1]) ) if not module.check_mode: # If this isn't a dry run, create or modify the site result.update( webfaction.create_website( *positional_args ) if not existing_site else webfaction.update_website ( *positional_args ) ) elif site_state == 'absent': # If the site's already not there, nothing changed. if not existing_site: module.exit_json( changed = False, ) if not module.check_mode: # If this isn't a dry run, delete the site result.update( webfaction.delete_website(session_id, site_name, site_ip) ) else: module.fail_json(msg="Unknown state specified: {}".format(site_state)) module.exit_json( changed = True, result = result ) from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 2790, 6001, 17287, 10691, 1808, 2622, 436, 314, 6001, 17287, 3261, 199, 3, 199, 3, 11016, 9460, 199, 3, 199, 3, 334, 67, 9, 5843, 484, 262, 7083, 70, 18090, 13, 38, 345, 332, 6900, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 3330, 17287, 63, 2124, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 282, 10691, 641, 282, 6001, 17287, 1591, 199, 1802, 26, 272, 446, 2654, 503, 2813, 282, 10691, 641, 282, 6001, 17287, 1591, 14, 221, 28876, 3794, 737, 1455, 921, 5031, 14, 957, 15, 9333, 3617, 70, 15, 4853, 13, 2520, 17287, 14, 199, 2502, 26, 5843, 484, 262, 7083, 70, 18090, 13, 38, 345, 332, 8593, 9333, 3617, 70, 9, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 5983, 26, 272, 446, 428, 350, 590, 12, 1265, 473, 8, 1117, 9, 1929, 370, 5715, 2195, 3330, 17287, 6246, 367, 314, 445, 8, 1102, 9, 2725, 14, 221, 11017, 737, 5210, 12, 29750, 314, 3261, 12, 1265, 2793, 1133, 1929, 370, 5715, 314, 3531, 489, 2287, 14, 2047, 883, 675, 282, 10237, 536, 14, 272, 446, 982, 282, 4770, 402, 314, 2011, 536, 3495, 315, 314, 2933, 1325, 641, 282, 3365, 1591, 12, 314, 3439, 911, 4458, 14, 272, 446, 690, 489, 2047, 883, 1255, 5232, 8858, 626, 675, 642, 641, 282, 2257, 6844, 12, 503, 641, 282, 6001, 17287, 1591, 12, 503, 25320, 12, 3967, 314, 10554, 675, 314, 3982, 3330, 17287, 3261, 14, 489, 710, 2909, 365, 440, 11012, 14, 9738, 12, 3879, 3062, 641, 3663, 7057, 473, 8, 5206, 24657, 590, 9, 365, 5526, 2289, 16142, 770, 14, 982, 1265, 2793, 1133, 4165, 473, 8, 5967, 9, 465, 489, 2195, 1591, 12, 1265, 1443, 2934, 370, 1050, 445, 8, 2171, 26, 413, 9, 370, 314, 299, 9316, 14, 272, 446, 1666, 658, 1589, 3330, 17287, 3261, 665, 1014, 921, 4757, 14, 2520, 17287, 14, 957, 15, 17596, 13, 1246, 3133, 18417, 367, 1655, 2256, 14, 199, 199, 1419, 26, 339, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 10691, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 10691, 1077, 2187, 267, 1415, 26, 3055, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 298, 1881, 2, 339, 1591, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 1591, 641, 1314, 314, 4770, 1077, 506, 2737, 14, 267, 1415, 26, 2549, 339, 4178, 26, 267, 1369, 26, 288, 446, 7480, 503, 440, 370, 675, 14147, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 2549, 288, 446, 3055, 267, 849, 26, 283, 3910, 7, 339, 4770, 63, 5181, 26, 267, 1369, 26, 288, 446, 437, 4412, 402, 10867, 370, 8686, 267, 1415, 26, 3055, 339, 1007, 9756, 26, 267, 1369, 26, 288, 446, 437, 769, 402, 1007, 9756, 4568, 543, 642, 4770, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 339, 4676, 63, 354, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 2933, 370, 675, 267, 1415, 26, 2549, 339, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 2505, 370, 675, 267, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 523, 446, 536, 26, 1218, 10691, 272, 3330, 17287, 63, 2124, 26, 489, 536, 26, 511, 2124, 17, 489, 1174, 26, 3451, 489, 1591, 26, 3002, 1102, 14, 2520, 17287, 14, 957, 489, 1007, 9756, 26, 267, 446, 283, 396, 2124, 17, 14, 1662, 63, 2261, 14, 1308, 7, 489, 4770, 63, 5181, 26, 267, 446, 788, 19700, 17, 297, 1994, 418, 489, 4178, 26, 949, 489, 4676, 63, 354, 26, 7370, 2520, 17287, 63, 751, 30618, 489, 4676, 63, 2060, 26, 7370, 2520, 17287, 63, 12671, 30618, 199, 2344, 199, 199, 646, 2838, 199, 646, 19122, 199, 199, 2520, 17287, 275, 19122, 14, 3120, 4936, 360, 2859, 921, 1246, 14, 2520, 17287, 14, 957, 6217, 199, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 275, 1211, 8, 2427, 29, 549, 395, 288, 1174, 275, 1211, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 288, 327, 2047, 883, 4165, 376, 3531, 2287, 503, 6246, 14, 288, 1591, 275, 1211, 8, 2427, 29, 549, 395, 288, 4178, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 2245, 297, 849, 29, 797, 395, 288, 1007, 9756, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 513, 297, 849, 1524, 2522, 288, 4770, 63, 5181, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 513, 297, 849, 1524, 2522, 288, 4676, 63, 354, 275, 1211, 8, 2427, 29, 549, 395, 288, 4676, 63, 2060, 275, 1211, 8, 2427, 29, 549, 12, 949, 63, 793, 29, 549, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 272, 4770, 63, 354, 221, 275, 859, 14, 1162, 459, 354, 418, 272, 4770, 63, 929, 275 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 2790, 6001, 17287, 10691, 1808, 2622, 436, 314, 6001, 17287, 3261, 199, 3, 199, 3, 11016, 9460, 199, 3, 199, 3, 334, 67, 9, 5843, 484, 262, 7083, 70, 18090, 13, 38, 345, 332, 6900, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 3330, 17287, 63, 2124, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 282, 10691, 641, 282, 6001, 17287, 1591, 199, 1802, 26, 272, 446, 2654, 503, 2813, 282, 10691, 641, 282, 6001, 17287, 1591, 14, 221, 28876, 3794, 737, 1455, 921, 5031, 14, 957, 15, 9333, 3617, 70, 15, 4853, 13, 2520, 17287, 14, 199, 2502, 26, 5843, 484, 262, 7083, 70, 18090, 13, 38, 345, 332, 8593, 9333, 3617, 70, 9, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 5983, 26, 272, 446, 428, 350, 590, 12, 1265, 473, 8, 1117, 9, 1929, 370, 5715, 2195, 3330, 17287, 6246, 367, 314, 445, 8, 1102, 9, 2725, 14, 221, 11017, 737, 5210, 12, 29750, 314, 3261, 12, 1265, 2793, 1133, 1929, 370, 5715, 314, 3531, 489, 2287, 14, 2047, 883, 675, 282, 10237, 536, 14, 272, 446, 982, 282, 4770, 402, 314, 2011, 536, 3495, 315, 314, 2933, 1325, 641, 282, 3365, 1591, 12, 314, 3439, 911, 4458, 14, 272, 446, 690, 489, 2047, 883, 1255, 5232, 8858, 626, 675, 642, 641, 282, 2257, 6844, 12, 503, 641, 282, 6001, 17287, 1591, 12, 503, 25320, 12, 3967, 314, 10554, 675, 314, 3982, 3330, 17287, 3261, 14, 489, 710, 2909, 365, 440, 11012, 14, 9738, 12, 3879, 3062, 641, 3663, 7057, 473, 8, 5206, 24657, 590, 9, 365, 5526, 2289, 16142, 770, 14, 982, 1265, 2793, 1133, 4165, 473, 8, 5967, 9, 465, 489, 2195, 1591, 12, 1265, 1443, 2934, 370, 1050, 445, 8, 2171, 26, 413, 9, 370, 314, 299, 9316, 14, 272, 446, 1666, 658, 1589, 3330, 17287, 3261, 665, 1014, 921, 4757, 14, 2520, 17287, 14, 957, 15, 17596, 13, 1246, 3133, 18417, 367, 1655, 2256, 14, 199, 199, 1419, 26, 339, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 10691, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 10691, 1077, 2187, 267, 1415, 26, 3055, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 298, 1881, 2, 339, 1591, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 1591, 641, 1314, 314, 4770, 1077, 506, 2737, 14, 267, 1415, 26, 2549, 339, 4178, 26, 267, 1369, 26, 288, 446, 7480, 503, 440, 370, 675, 14147, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 2549, 288, 446, 3055, 267, 849, 26, 283, 3910, 7, 339, 4770, 63, 5181, 26, 267, 1369, 26, 288, 446, 437, 4412, 402, 10867, 370, 8686, 267, 1415, 26, 3055, 339, 1007, 9756, 26, 267, 1369, 26, 288, 446, 437, 769, 402, 1007, 9756, 4568, 543, 642, 4770, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 339, 4676, 63, 354, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 2933, 370, 675, 267, 1415, 26, 2549, 339, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 3330, 17287, 2505, 370, 675, 267, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 523, 446, 536, 26, 1218, 10691, 272, 3330, 17287, 63, 2124, 26, 489, 536, 26, 511, 2124, 17, 489, 1174, 26, 3451, 489, 1591, 26, 3002, 1102, 14, 2520, 17287, 14, 957, 489, 1007, 9756, 26, 267, 446, 283, 396, 2124, 17, 14, 1662, 63, 2261, 14, 1308, 7, 489, 4770, 63, 5181, 26, 267, 446, 788, 19700, 17, 297, 1994, 418, 489, 4178, 26, 949, 489, 4676, 63, 354, 26, 7370, 2520, 17287, 63, 751, 30618, 489, 4676, 63, 2060, 26, 7370, 2520, 17287, 63, 12671, 30618, 199, 2344, 199, 199, 646, 2838, 199, 646, 19122, 199, 199, 2520, 17287, 275, 19122, 14, 3120, 4936, 360, 2859, 921, 1246, 14, 2520, 17287, 14, 957, 6217, 199, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 275, 1211, 8, 2427, 29, 549, 395, 288, 1174, 275, 1211, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 288, 327, 2047, 883, 4165, 376, 3531, 2287, 503, 6246, 14, 288, 1591, 275, 1211, 8, 2427, 29, 549, 395, 288, 4178, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 2245, 297, 849, 29, 797, 395, 288, 1007, 9756, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 513, 297, 849, 1524, 2522, 288, 4770, 63, 5181, 275, 1211, 8, 2427, 29, 797, 12, 730, 534, 513, 297, 849, 1524, 2522, 288, 4676, 63, 354, 275, 1211, 8, 2427, 29, 549, 395, 288, 4676, 63, 2060, 275, 1211, 8, 2427, 29, 549, 12, 949, 63, 793, 29, 549, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 272, 4770, 63, 354, 221, 275, 859, 14, 1162, 459, 354, 418, 272, 4770, 63, 929, 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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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 ]
Ernesto99/odoo
addons/website/models/ir_http.py
162
13407
# -*- coding: utf-8 -*- import logging import os import re import traceback import werkzeug import werkzeug.routing import werkzeug.utils import openerp from openerp.addons.base import ir from openerp.addons.base.ir import ir_qweb from openerp.addons.website.models.website import slug, url_for, _UNSLUG_RE from openerp.http import request from openerp.tools import config from openerp.osv import orm from openerp.tools.safe_eval import safe_eval as eval logger = logging.getLogger(__name__) class RequestUID(object): def __init__(self, **kw): self.__dict__.update(kw) class ir_http(orm.AbstractModel): _inherit = 'ir.http' rerouting_limit = 10 geo_ip_resolver = None def _get_converters(self): return dict( super(ir_http, self)._get_converters(), model=ModelConverter, page=PageConverter, ) def _auth_method_public(self): # TODO: select user_id from matching website if not request.session.uid: request.uid = self.pool['ir.model.data'].xmlid_to_res_id(request.cr, openerp.SUPERUSER_ID, 'base.public_user') else: request.uid = request.session.uid bots = "bot|crawl|slurp|spider|curl|wget|facebookexternalhit".split("|") def is_a_bot(self): # We don't use regexp and ustr voluntarily # timeit has been done to check the optimum method ua = request.httprequest.environ.get('HTTP_USER_AGENT', '').lower() try: return any(bot in ua for bot in self.bots) except UnicodeDecodeError: return any(bot in ua.encode('ascii', 'ignore') for bot in self.bots) def get_nearest_lang(self, lang): # Try to find a similar lang. Eg: fr_BE and fr_FR if lang in request.website.get_languages(): return lang short = lang.split('_')[0] for code, name in request.website.get_languages(): if code.startswith(short): return code return False def _dispatch(self): first_pass = not hasattr(request, 'website') request.website = None func = None try: func, arguments = self._find_handler() request.website_enabled = func.routing.get('website', False) except werkzeug.exceptions.NotFound: # either we have a language prefixed route, either a real 404 # in all cases, website processes them request.website_enabled = True request.website_multilang = ( request.website_enabled and func and func.routing.get('multilang', func.routing['type'] == 'http') ) if 'geoip' not in request.session: record = {} if self.geo_ip_resolver is None: try: import GeoIP # updated database can be downloaded on MaxMind website # http://dev.maxmind.com/geoip/legacy/install/city/ geofile = config.get('geoip_database') if os.path.exists(geofile): self.geo_ip_resolver = GeoIP.open(geofile, GeoIP.GEOIP_STANDARD) else: self.geo_ip_resolver = False logger.warning('GeoIP database file %r does not exists', geofile) except ImportError: self.geo_ip_resolver = False if self.geo_ip_resolver and request.httprequest.remote_addr: record = self.geo_ip_resolver.record_by_addr(request.httprequest.remote_addr) or {} request.session['geoip'] = record cook_lang = request.httprequest.cookies.get('website_lang') if request.website_enabled: try: if func: self._authenticate(func.routing['auth']) else: self._auth_method_public() except Exception as e: return self._handle_exception(e) request.redirect = lambda url, code=302: werkzeug.utils.redirect(url_for(url), code) request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context) langs = [lg[0] for lg in request.website.get_languages()] path = request.httprequest.path.split('/') if first_pass: nearest_lang = not func and self.get_nearest_lang(path[1]) url_lang = nearest_lang and path[1] preferred_lang = ((cook_lang if cook_lang in langs else False) or self.get_nearest_lang(request.lang) or request.website.default_lang_code) is_a_bot = self.is_a_bot() request.lang = request.context['lang'] = nearest_lang or preferred_lang # if lang in url but not the displayed or default language --> change or remove # or no lang in url, and lang to dispay not the default language --> add lang # and not a POST request # and not a bot or bot but default lang in url if ((url_lang and (url_lang != request.lang or url_lang == request.website.default_lang_code)) or (not url_lang and request.website_multilang and request.lang != request.website.default_lang_code) and request.httprequest.method != 'POST') \ and (not is_a_bot or (url_lang and url_lang == request.website.default_lang_code)): if url_lang: path.pop(1) if request.lang != request.website.default_lang_code: path.insert(1, request.lang) path = '/'.join(path) or '/' redirect = request.redirect(path + '?' + request.httprequest.query_string) redirect.set_cookie('website_lang', request.lang) return redirect elif url_lang: path.pop(1) return self.reroute('/'.join(path) or '/') # bind modified context request.website = request.website.with_context(request.context) resp = super(ir_http, self)._dispatch() if request.website_enabled and cook_lang != request.lang and hasattr(resp, 'set_cookie'): resp.set_cookie('website_lang', request.lang) return resp def reroute(self, path): if not hasattr(request, 'rerouting'): request.rerouting = [request.httprequest.path] if path in request.rerouting: raise Exception("Rerouting loop is forbidden") request.rerouting.append(path) if len(request.rerouting) > self.rerouting_limit: raise Exception("Rerouting limit exceeded") request.httprequest.environ['PATH_INFO'] = path # void werkzeug cached_property. TODO: find a proper way to do this for key in ('path', 'full_path', 'url', 'base_url'): request.httprequest.__dict__.pop(key, None) return self._dispatch() def _postprocess_args(self, arguments, rule): super(ir_http, self)._postprocess_args(arguments, rule) for key, val in arguments.items(): # Replace uid placeholder by the current request.uid if isinstance(val, orm.BaseModel) and isinstance(val._uid, RequestUID): arguments[key] = val.sudo(request.uid) try: _, path = rule.build(arguments) assert path is not None except Exception, e: return self._handle_exception(e, code=404) if getattr(request, 'website_multilang', False) and request.httprequest.method in ('GET', 'HEAD'): generated_path = werkzeug.url_unquote_plus(path) current_path = werkzeug.url_unquote_plus(request.httprequest.path) if generated_path != current_path: if request.lang != request.website.default_lang_code: path = '/' + request.lang + path if request.httprequest.query_string: path += '?' + request.httprequest.query_string return werkzeug.utils.redirect(path, code=301) def _handle_exception(self, exception, code=500): is_website_request = bool(getattr(request, 'website_enabled', False) and request.website) if not is_website_request: # Don't touch non website requests exception handling return super(ir_http, self)._handle_exception(exception) else: try: response = super(ir_http, self)._handle_exception(exception) if isinstance(response, Exception): exception = response else: # if parent excplicitely returns a plain response, then we don't touch it return response except Exception, e: exception = e values = dict( exception=exception, traceback=traceback.format_exc(exception), ) code = getattr(exception, 'code', code) if isinstance(exception, openerp.exceptions.AccessError): code = 403 if isinstance(exception, ir_qweb.QWebException): values.update(qweb_exception=exception) if isinstance(exception.qweb.get('cause'), openerp.exceptions.AccessError): code = 403 if isinstance(exception, werkzeug.exceptions.HTTPException) and code is None: # Hand-crafted HTTPException likely coming from abort(), # usually for a redirect response -> return it directly return exception if code == 500: logger.error("500 Internal Server Error:\n\n%s", values['traceback']) if 'qweb_exception' in values: view = request.registry.get("ir.ui.view") views = view._views_get(request.cr, request.uid, exception.qweb['template'], request.context) to_reset = [v for v in views if v.model_data_id.noupdate is True and not v.page] values['views'] = to_reset elif code == 403: logger.warn("403 Forbidden:\n\n%s", values['traceback']) values.update( status_message=werkzeug.http.HTTP_STATUS_CODES[code], status_code=code, ) if not request.uid: self._auth_method_public() try: html = request.website._render('website.%s' % code, values) except Exception: html = request.website._render('website.http_error', values) return werkzeug.wrappers.Response(html, status=code, content_type='text/html;charset=utf-8') class ModelConverter(ir.ir_http.ModelConverter): def __init__(self, url_map, model=False, domain='[]'): super(ModelConverter, self).__init__(url_map, model) self.domain = domain self.regex = _UNSLUG_RE.pattern def to_url(self, value): return slug(value) def to_python(self, value): m = re.match(self.regex, value) _uid = RequestUID(value=value, match=m, converter=self) record_id = int(m.group(2)) if record_id < 0: # limited support for negative IDs due to our slug pattern, assume abs() if not found if not request.registry[self.model].exists(request.cr, _uid, [record_id]): record_id = abs(record_id) return request.registry[self.model].browse( request.cr, _uid, record_id, context=request.context) def generate(self, cr, uid, query=None, args=None, context=None): obj = request.registry[self.model] domain = eval( self.domain, (args or {}).copy()) if query: domain.append((obj._rec_name, 'ilike', '%'+query+'%')) for record in obj.search_read(cr, uid, domain=domain, fields=['write_date',obj._rec_name], context=context): if record.get(obj._rec_name, False): yield {'loc': (record['id'], record[obj._rec_name])} class PageConverter(werkzeug.routing.PathConverter): """ Only point of this converter is to bundle pages enumeration logic """ def generate(self, cr, uid, query=None, args={}, context=None): View = request.registry['ir.ui.view'] views = View.search_read(cr, uid, [['page', '=', True]], fields=['xml_id','priority','write_date'], order='name', context=context) for view in views: xid = view['xml_id'].startswith('website.') and view['xml_id'][8:] or view['xml_id'] # the 'page/homepage' url is indexed as '/', avoid aving the same page referenced twice # when we will have an url mapping mechanism, replace this by a rule: page/homepage --> / if xid=='homepage': continue if query and query.lower() not in xid.lower(): continue record = {'loc': xid} if view['priority'] <> 16: record['__priority'] = min(round(view['priority'] / 32.0,1), 1) if view['write_date']: record['__lastmod'] = view['write_date'][:10] yield record
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 5190, 199, 199, 646, 10380, 199, 646, 10380, 14, 9492, 199, 646, 10380, 14, 1208, 199, 199, 646, 5166, 199, 504, 5166, 14, 10788, 14, 1095, 492, 8190, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 492, 8190, 63, 22600, 199, 504, 5166, 14, 10788, 14, 7360, 14, 992, 14, 7360, 492, 8889, 12, 1166, 63, 509, 12, 485, 1734, 4929, 10134, 63, 907, 199, 504, 5166, 14, 1014, 492, 1056, 199, 504, 5166, 14, 2537, 492, 1101, 199, 504, 5166, 14, 4795, 492, 9813, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 4784, 6685, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 855, 807, 4343, 873, 8, 829, 9, 199, 199, 533, 8190, 63, 1014, 8, 1025, 14, 8458, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1014, 7, 339, 295, 9492, 63, 3097, 275, 1616, 272, 8509, 63, 711, 63, 7717, 275, 488, 339, 347, 485, 362, 63, 17911, 8, 277, 304, 267, 372, 1211, 8, 288, 1613, 8, 723, 63, 1014, 12, 291, 10445, 362, 63, 17911, 1062, 288, 1402, 29, 1685, 11907, 12, 288, 2034, 29, 3276, 11907, 12, 267, 776, 339, 347, 485, 1178, 63, 765, 63, 3455, 8, 277, 304, 267, 327, 3254, 26, 3504, 922, 63, 344, 687, 4877, 10691, 267, 340, 440, 1056, 14, 1730, 14, 1535, 26, 288, 1056, 14, 1535, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 10198, 7401, 63, 475, 63, 470, 63, 344, 8, 1069, 14, 1556, 12, 5166, 14, 20710, 63, 998, 12, 283, 1095, 14, 3455, 63, 751, 358, 267, 587, 26, 288, 1056, 14, 1535, 275, 1056, 14, 1730, 14, 1535, 339, 31726, 275, 298, 3018, 92, 67, 22910, 92, 2482, 300, 80, 92, 12856, 92, 17096, 92, 87, 362, 92, 1409, 15056, 415, 88, 2147, 12948, 1674, 1294, 25795, 531, 272, 347, 365, 63, 65, 63, 3018, 8, 277, 304, 267, 327, 2136, 2793, 1133, 675, 13156, 436, 399, 495, 5236, 638, 11406, 267, 327, 900, 390, 965, 2757, 4224, 370, 1104, 314, 5323, 453, 1083, 267, 18500, 275, 1056, 14, 16916, 26762, 14, 2314, 14, 362, 360, 2856, 63, 3791, 63, 14565, 297, 12548, 2325, 342, 267, 862, 26, 288, 372, 1263, 8, 3018, 315, 18500, 367, 5888, 315, 291, 14, 28143, 9, 267, 871, 18965, 26, 288, 372, 1263, 8, 3018, 315, 18500, 14, 2143, 360, 4371, 297, 283, 4247, 358, 367, 5888, 315, 291, 14, 28143, 9, 339, 347, 664, 63, 16615, 63, 4159, 8, 277, 12, 6339, 304, 267, 327, 7649, 370, 2342, 282, 8545, 6339, 14, 662, 71, 26, 9513, 63, 6773, 436, 9513, 63, 5372, 267, 340, 6339, 315, 1056, 14, 7360, 14, 362, 63, 13209, 837, 288, 372, 6339, 398, 3974, 275, 6339, 14, 1294, 6412, 5832, 16, 61, 267, 367, 1233, 12, 536, 315, 1056, 14, 7360, 14, 362, 63, 13209, 837, 288, 340, 1233, 14, 2460, 8, 3612, 304, 355, 372, 1233, 267, 372, 756, 339, 347, 485, 6052, 8, 277, 304, 267, 1642, 63, 1529, 275, 440, 2688, 8, 1069, 12, 283, 7360, 358, 267, 1056, 14, 7360, 275, 488, 267, 2562, 275, 488, 267, 862, 26, 288, 2562, 12, 2368, 275, 291, 423, 1623, 63, 2232, 342, 288, 1056, 14, 7360, 63, 3827, 275, 2562, 14, 9492, 14, 362, 360, 7360, 297, 756, 9, 267, 871, 10380, 14, 3924, 14, 4667, 26, 288, 327, 1902, 781, 1172, 282, 2637, 18239, 7475, 12, 1902, 282, 3363, 7901, 288, 327, 315, 1006, 5560, 12, 10691, 10358, 3062, 288, 1056, 14, 7360, 63, 3827, 275, 715, 398, 1056, 14, 7360, 63, 3029, 4159, 275, 334, 288, 1056, 14, 7360, 63, 3827, 436, 288, 2562, 436, 2562, 14, 9492, 14, 362, 360, 3029, 4159, 297, 2562, 14, 9492, 459, 466, 418, 508, 283, 1014, 358, 267, 776, 398, 340, 283, 28799, 7, 440, 315, 1056, 14, 1730, 26, 288, 2777, 275, 1052, 288, 340, 291, 14, 6721, 63, 711, 63, 7717, 365, 488, 26, 355, 862, 26, 490, 492, 18378, 490, 327, 4588, 3050, 883, 506, 13557, 641, 8228, 45, 688, 10691, 490, 327, 1455, 921, 2374, 14, 988, 77, 688, 14, 957, 15, 28799, 15, 10000, 15, 3174, 15, 3690, 15, 490, 8509, 493, 275, 1101, 14, 362, 360, 28799, 63, 4659, 358, 490, 340, 747, 14, 515, 14, 2444, 8, 6721, 493, 304, 717, 291, 14, 6721, 63, 711, 63, 7717, 275, 18378, 14, 1490, 8, 6721, 493, 12, 18378, 14, 18120, 1772, 63, 19547, 9, 490, 587, 26, 717, 291, 14, 6721, 63, 711, 63, 7717, 275, 756, 717, 2512, 14, 3764, 360, 28848, 3050, 570, 450, 82, 1630, 440, 3495, 297, 8509, 493, 9, 355, 871, 3545, 26, 490, 291, 14, 6721, 63, 711, 63, 7717, 275, 756, 288, 340, 291, 14, 6721, 63, 711, 63, 7717, 436, 1056, 14, 16916, 26762, 14, 3846, 63, 2697, 26, 355, 2777, 275, 291, 14, 6721, 63, 711, 63, 7717, 14, 3059, 63, 991, 63, 2697, 8, 1069, 14, 16916, 26762, 14, 3846, 63, 2697, 9, 503, 1052, 288, 1056, 14, 1730, 459, 28799, 418, 275, 2777, 398, 512, 745, 63, 4159, 275, 1056, 14, 16916, 26762, 14, 7792, 14, 362, 360, 7360, 63, 4159, 358, 267, 340, 1056, 14, 7360, 63, 3827, 26, 288, 862, 26, 355, 340, 2562, 26, 490, 291, 423, 13975, 8, 1532, 14, 9492, 459, 1178, 1105, 355, 587, 26, 490, 291, 423, 1178, 63, 765, 63, 3455, 342, 288, 871, 2186, 465, 325, 26, 355, 372, 291, 423, 2479, 63, 1971, 8, 69, 9, 953, 1056, 14, 4876, 275, 2400, 1166, 12, 1233, 29, 8551, 26, 10380, 14, 1208, 14, 4876, 8, 633, 63, 509, 8, 633, 395, 1233, 9, 288, 1056, 14, 7360, 275, 1056, 14, 5189, 459, 7360, 2278, 362, 63, 1818, 63, 7360, 8, 1069, 14, 1556, 12, 1056, 14, 1535, 12, 1067, 29, 1069, 14, 1100, 9, 288, 31769, 275, 359, 9783, 59, 16, 61, 367, 634, 71 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 5190, 199, 199, 646, 10380, 199, 646, 10380, 14, 9492, 199, 646, 10380, 14, 1208, 199, 199, 646, 5166, 199, 504, 5166, 14, 10788, 14, 1095, 492, 8190, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 492, 8190, 63, 22600, 199, 504, 5166, 14, 10788, 14, 7360, 14, 992, 14, 7360, 492, 8889, 12, 1166, 63, 509, 12, 485, 1734, 4929, 10134, 63, 907, 199, 504, 5166, 14, 1014, 492, 1056, 199, 504, 5166, 14, 2537, 492, 1101, 199, 504, 5166, 14, 4795, 492, 9813, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 4784, 6685, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 855, 807, 4343, 873, 8, 829, 9, 199, 199, 533, 8190, 63, 1014, 8, 1025, 14, 8458, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1014, 7, 339, 295, 9492, 63, 3097, 275, 1616, 272, 8509, 63, 711, 63, 7717, 275, 488, 339, 347, 485, 362, 63, 17911, 8, 277, 304, 267, 372, 1211, 8, 288, 1613, 8, 723, 63, 1014, 12, 291, 10445, 362, 63, 17911, 1062, 288, 1402, 29, 1685, 11907, 12, 288, 2034, 29, 3276, 11907, 12, 267, 776, 339, 347, 485, 1178, 63, 765, 63, 3455, 8, 277, 304, 267, 327, 3254, 26, 3504, 922, 63, 344, 687, 4877, 10691, 267, 340, 440, 1056, 14, 1730, 14, 1535, 26, 288, 1056, 14, 1535, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 10198, 7401, 63, 475, 63, 470, 63, 344, 8, 1069, 14, 1556, 12, 5166, 14, 20710, 63, 998, 12, 283, 1095, 14, 3455, 63, 751, 358, 267, 587, 26, 288, 1056, 14, 1535, 275, 1056, 14, 1730, 14, 1535, 339, 31726, 275, 298, 3018, 92, 67, 22910, 92, 2482, 300, 80, 92, 12856, 92, 17096, 92, 87, 362, 92, 1409, 15056, 415, 88, 2147, 12948, 1674, 1294, 25795, 531, 272, 347, 365, 63, 65, 63, 3018, 8, 277, 304, 267, 327, 2136, 2793, 1133, 675, 13156, 436, 399, 495, 5236, 638, 11406, 267, 327, 900, 390, 965, 2757, 4224, 370, 1104, 314, 5323, 453, 1083, 267, 18500, 275, 1056, 14, 16916, 26762, 14, 2314, 14, 362, 360, 2856, 63, 3791, 63, 14565, 297, 12548, 2325, 342, 267, 862, 26, 288, 372, 1263, 8, 3018, 315, 18500, 367, 5888, 315, 291, 14, 28143, 9, 267, 871, 18965, 26, 288, 372, 1263, 8, 3018, 315, 18500, 14, 2143, 360, 4371, 297, 283, 4247, 358, 367, 5888, 315, 291, 14, 28143, 9, 339, 347, 664, 63, 16615, 63, 4159, 8, 277, 12, 6339, 304, 267, 327, 7649, 370, 2342, 282, 8545, 6339, 14, 662, 71, 26, 9513, 63, 6773, 436, 9513, 63, 5372, 267, 340, 6339, 315, 1056, 14, 7360, 14, 362, 63, 13209, 837, 288, 372, 6339, 398, 3974, 275, 6339, 14, 1294, 6412, 5832, 16, 61, 267, 367, 1233, 12, 536, 315, 1056, 14, 7360, 14, 362, 63, 13209, 837, 288, 340, 1233, 14, 2460, 8, 3612, 304, 355, 372, 1233, 267, 372, 756, 339, 347, 485, 6052, 8, 277, 304, 267, 1642, 63, 1529, 275, 440, 2688, 8, 1069, 12, 283, 7360, 358, 267, 1056, 14, 7360, 275, 488, 267, 2562, 275, 488, 267, 862, 26, 288, 2562, 12, 2368, 275, 291, 423, 1623, 63, 2232, 342, 288, 1056, 14, 7360, 63, 3827, 275, 2562, 14, 9492, 14, 362, 360, 7360, 297, 756, 9, 267, 871, 10380, 14, 3924, 14, 4667, 26, 288, 327, 1902, 781, 1172, 282, 2637, 18239, 7475, 12, 1902, 282, 3363, 7901, 288, 327, 315, 1006, 5560, 12, 10691, 10358, 3062, 288, 1056, 14, 7360, 63, 3827, 275, 715, 398, 1056, 14, 7360, 63, 3029, 4159, 275, 334, 288, 1056, 14, 7360, 63, 3827, 436, 288, 2562, 436, 2562, 14, 9492, 14, 362, 360, 3029, 4159, 297, 2562, 14, 9492, 459, 466, 418, 508, 283, 1014, 358, 267, 776, 398, 340, 283, 28799, 7, 440, 315, 1056, 14, 1730, 26, 288, 2777, 275, 1052, 288, 340, 291, 14, 6721, 63, 711, 63, 7717, 365, 488, 26, 355, 862, 26, 490, 492, 18378, 490, 327, 4588, 3050, 883, 506, 13557, 641, 8228, 45, 688, 10691, 490, 327, 1455, 921, 2374, 14, 988, 77, 688, 14, 957, 15, 28799, 15, 10000, 15, 3174, 15, 3690, 15, 490, 8509, 493, 275, 1101, 14, 362, 360, 28799, 63, 4659, 358, 490, 340, 747, 14, 515, 14, 2444, 8, 6721, 493, 304, 717, 291, 14, 6721, 63, 711, 63, 7717, 275, 18378, 14, 1490, 8, 6721, 493, 12, 18378, 14, 18120, 1772, 63, 19547, 9, 490, 587, 26, 717, 291, 14, 6721, 63, 711, 63, 7717, 275, 756, 717, 2512, 14, 3764, 360, 28848, 3050, 570, 450, 82, 1630, 440, 3495, 297, 8509, 493, 9, 355, 871, 3545, 26, 490, 291, 14, 6721, 63, 711, 63, 7717, 275, 756, 288, 340, 291, 14, 6721, 63, 711, 63, 7717, 436, 1056, 14, 16916, 26762, 14, 3846, 63, 2697, 26, 355, 2777, 275, 291, 14, 6721, 63, 711, 63, 7717, 14, 3059, 63, 991, 63, 2697, 8, 1069, 14, 16916, 26762, 14, 3846, 63, 2697, 9, 503, 1052, 288, 1056, 14, 1730, 459, 28799, 418, 275, 2777, 398, 512, 745, 63, 4159, 275, 1056, 14, 16916, 26762, 14, 7792, 14, 362, 360, 7360, 63, 4159, 358, 267, 340, 1056, 14, 7360, 63, 3827, 26, 288, 862, 26, 355, 340, 2562, 26, 490, 291, 423, 13975, 8, 1532, 14, 9492, 459, 1178, 1105, 355, 587, 26, 490, 291, 423, 1178, 63, 765, 63, 3455, 342, 288, 871, 2186, 465, 325, 26, 355, 372, 291, 423, 2479, 63, 1971, 8, 69, 9, 953, 1056, 14, 4876, 275, 2400, 1166, 12, 1233, 29, 8551, 26, 10380, 14, 1208, 14, 4876, 8, 633, 63, 509, 8, 633, 395, 1233, 9, 288, 1056, 14, 7360, 275, 1056, 14, 5189, 459, 7360, 2278, 362, 63, 1818, 63, 7360, 8, 1069, 14, 1556, 12, 1056, 14, 1535, 12, 1067, 29, 1069, 14, 1100, 9, 288, 31769, 275, 359, 9783, 59, 16, 61, 367, 634, 71, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
CLVsol/oehealth_gs
oehealth_gs_medicament/__openerp__.py
1
2003
# -*- encoding: utf-8 -*- ################################################################################ # # # Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU Affero General Public License for more details. # # # # You should have received a copy of the GNU Affero General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ { 'name': 'OpenERP Health: Medicament - GaranteSul', 'version': '1.0.0', 'author': 'Carlos Eduardo Vercelino - CLVsol', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', 'website': 'http://oehealth.org', 'description': ''' ''', 'images': [], 'depends': ['oehealth_medicament', 'oehealth_gs_base', ], 'data': [], 'demo': [], 'test': [], 'init_xml': ['oehealth_medicament_view.xml', ], 'test': [], 'update_xml': [], 'installable': True, 'active': False, 'css': [], }
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 13289, 199, 3, 26209, 327, 199, 3, 1898, 334, 35, 9, 6171, 13, 31982, 221, 14243, 11560, 662, 2033, 1005, 79, 5444, 301, 472, 79, 446, 13354, 54, 7873, 8295, 327, 199, 3, 26209, 327, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 260, 327, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 221, 327, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 3322, 327, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 2476, 3515, 327, 199, 3, 26209, 327, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 4519, 327, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 5185, 327, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 4483, 327, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 14516, 327, 199, 3, 26209, 327, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 258, 327, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 263, 327, 199, 13289, 199, 199, 91, 272, 283, 354, 356, 283, 25347, 5311, 6130, 26, 3194, 5000, 14040, 446, 598, 10475, 51, 348, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 14, 16, 297, 272, 283, 2502, 356, 283, 16034, 11560, 662, 2033, 1005, 79, 5444, 301, 472, 79, 446, 13354, 54, 7873, 297, 272, 283, 3710, 356, 283, 9417, 18167, 15, 8632, 83, 297, 272, 283, 1682, 356, 283, 1254, 2749, 13, 19, 297, 272, 283, 7360, 356, 283, 1014, 921, 13361, 9665, 14, 1308, 297, 272, 283, 1802, 356, 1449, 272, 21281, 272, 283, 4782, 356, 990, 272, 283, 8912, 356, 788, 13361, 9665, 63, 3700, 67, 14040, 297, 355, 283, 13361, 9665, 63, 458, 63, 1095, 297, 355, 2156, 272, 283, 576, 356, 990, 272, 283, 8768, 356, 990, 272, 283, 396, 356, 990, 272, 283, 826, 63, 1652, 356, 788, 13361, 9665, 63, 3700, 67, 14040, 63, 1345, 14, 1652, 297, 326, 2156, 272, 283, 396, 356, 990, 272, 283, 873, 63, 1652, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2682, 356, 756, 12, 272, 283, 3919, 356, 990, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 13289, 199, 3, 26209, 327, 199, 3, 1898, 334, 35, 9, 6171, 13, 31982, 221, 14243, 11560, 662, 2033, 1005, 79, 5444, 301, 472, 79, 446, 13354, 54, 7873, 8295, 327, 199, 3, 26209, 327, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 260, 327, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 221, 327, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 3322, 327, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 2476, 3515, 327, 199, 3, 26209, 327, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 4519, 327, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 5185, 327, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 4483, 327, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 14516, 327, 199, 3, 26209, 327, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 258, 327, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 263, 327, 199, 13289, 199, 199, 91, 272, 283, 354, 356, 283, 25347, 5311, 6130, 26, 3194, 5000, 14040, 446, 598, 10475, 51, 348, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 14, 16, 297, 272, 283, 2502, 356, 283, 16034, 11560, 662, 2033, 1005, 79, 5444, 301, 472, 79, 446, 13354, 54, 7873, 297, 272, 283, 3710, 356, 283, 9417, 18167, 15, 8632, 83, 297, 272, 283, 1682, 356, 283, 1254, 2749, 13, 19, 297, 272, 283, 7360, 356, 283, 1014, 921, 13361, 9665, 14, 1308, 297, 272, 283, 1802, 356, 1449, 272, 21281, 272, 283, 4782, 356, 990, 272, 283, 8912, 356, 788, 13361, 9665, 63, 3700, 67, 14040, 297, 355, 283, 13361, 9665, 63, 458, 63, 1095, 297, 355, 2156, 272, 283, 576, 356, 990, 272, 283, 8768, 356, 990, 272, 283, 396, 356, 990, 272, 283, 826, 63, 1652, 356, 788, 13361, 9665, 63, 3700, 67, 14040, 63, 1345, 14, 1652, 297, 326, 2156, 272, 283, 396, 356, 990, 272, 283, 873, 63, 1652, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2682, 356, 756, 12, 272, 283, 3919, 356, 990, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
bop/bauhaus
lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/introspection.py
109
4592
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection from django.contrib.gis.gdal import OGRGeomType class GeoIntrospectionError(Exception): pass class PostGISIntrospection(DatabaseIntrospection): # Reverse dictionary for PostGIS geometry types not populated until # introspection is actually performed. postgis_types_reverse = {} ignored_tables = DatabaseIntrospection.ignored_tables + [ 'geography_columns', 'geometry_columns', 'raster_columns', 'spatial_ref_sys', 'raster_overviews', ] def get_postgis_types(self): """ Returns a dictionary with keys that are the PostgreSQL object identification integers for the PostGIS geometry and/or geography types (if supported). """ cursor = self.connection.cursor() # The OID integers associated with the geometry type may # be different across versions; hence, this is why we have # to query the PostgreSQL pg_type table corresponding to the # PostGIS custom data types. oid_sql = 'SELECT "oid" FROM "pg_type" WHERE "typname" = %s' try: cursor.execute(oid_sql, ('geometry',)) GEOM_TYPE = cursor.fetchone()[0] postgis_types = { GEOM_TYPE : 'GeometryField' } if self.connection.ops.geography: cursor.execute(oid_sql, ('geography',)) GEOG_TYPE = cursor.fetchone()[0] # The value for the geography type is actually a tuple # to pass in the `geography=True` keyword to the field # definition. postgis_types[GEOG_TYPE] = ('GeometryField', {'geography' : True}) finally: cursor.close() return postgis_types def get_field_type(self, data_type, description): if not self.postgis_types_reverse: # If the PostGIS types reverse dictionary is not populated, do so # now. In order to prevent unnecessary requests upon connection # intialization, the `data_types_reverse` dictionary is not updated # with the PostGIS custom types until introspection is actually # performed -- in other words, when this function is called. self.postgis_types_reverse = self.get_postgis_types() self.data_types_reverse.update(self.postgis_types_reverse) return super(PostGISIntrospection, self).get_field_type(data_type, description) def get_geometry_type(self, table_name, geo_col): """ The geometry type OID used by PostGIS does not indicate the particular type of field that a geometry column is (e.g., whether it's a PointField or a PolygonField). Thus, this routine queries the PostGIS metadata tables to determine the geometry type, """ cursor = self.connection.cursor() try: try: # First seeing if this geometry column is in the `geometry_columns` cursor.execute('SELECT "coord_dimension", "srid", "type" ' 'FROM "geometry_columns" ' 'WHERE "f_table_name"=%s AND "f_geometry_column"=%s', (table_name, geo_col)) row = cursor.fetchone() if not row: raise GeoIntrospectionError except GeoIntrospectionError: if self.connection.ops.geography: cursor.execute('SELECT "coord_dimension", "srid", "type" ' 'FROM "geography_columns" ' 'WHERE "f_table_name"=%s AND "f_geography_column"=%s', (table_name, geo_col)) row = cursor.fetchone() if not row: raise Exception('Could not find a geometry or geography column for "%s"."%s"' % (table_name, geo_col)) # OGRGeomType does not require GDAL and makes it easy to convert # from OGC geom type name to Django field. field_type = OGRGeomType(row[2]).django # Getting any GeometryField keyword arguments that are not the default. dim = row[0] srid = row[1] field_params = {} if srid != 4326: field_params['srid'] = srid if dim != 2: field_params['dim'] = dim finally: cursor.close() return field_type, field_params
mit
[ 504, 1639, 14, 697, 14, 7765, 14, 15437, 63, 20270, 18, 14, 21627, 492, 8692, 30516, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 25756, 199, 199, 533, 8875, 30516, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 20929, 30516, 8, 7243, 30516, 304, 272, 327, 22734, 2600, 367, 20929, 3400, 2943, 440, 16460, 5133, 272, 327, 1109, 14254, 365, 5965, 10585, 14, 272, 2963, 5668, 63, 1313, 63, 4471, 275, 1052, 339, 5525, 63, 5987, 275, 8692, 30516, 14, 11996, 63, 5987, 435, 359, 267, 283, 6721, 9773, 63, 3406, 297, 267, 283, 7660, 63, 3406, 297, 267, 283, 20876, 63, 3406, 297, 267, 283, 11679, 63, 1121, 63, 1274, 297, 267, 283, 20876, 63, 1883, 4196, 297, 272, 1622, 339, 347, 664, 63, 1932, 5668, 63, 1313, 8, 277, 304, 267, 408, 267, 1803, 282, 2600, 543, 2883, 626, 787, 314, 20175, 909, 267, 29193, 9446, 367, 314, 20929, 3400, 436, 15, 269, 267, 8509, 9773, 2943, 334, 692, 3748, 680, 267, 408, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 327, 710, 593, 998, 9446, 4568, 543, 314, 3400, 730, 1443, 267, 327, 506, 3365, 9371, 5459, 27, 19407, 12, 642, 365, 10842, 781, 1172, 267, 327, 370, 1827, 314, 20175, 10275, 63, 466, 1817, 5226, 370, 314, 267, 327, 20929, 3537, 666, 2943, 14, 267, 20109, 63, 3009, 275, 283, 4859, 298, 1170, 2, 4442, 298, 4198, 63, 466, 2, 6038, 298, 9749, 354, 2, 275, 450, 83, 7, 267, 862, 26, 288, 3920, 14, 2526, 8, 1170, 63, 3009, 12, 661, 7660, 16829, 288, 8991, 7474, 63, 2711, 275, 3920, 14, 11591, 3430, 16, 61, 288, 2963, 5668, 63, 1313, 275, 469, 8991, 7474, 63, 2711, 520, 283, 6831, 792, 7, 789, 288, 340, 291, 14, 2105, 14, 1483, 14, 6721, 9773, 26, 355, 3920, 14, 2526, 8, 1170, 63, 3009, 12, 661, 6721, 9773, 16829, 355, 8991, 14008, 63, 2711, 275, 3920, 14, 11591, 3430, 16, 61, 355, 327, 710, 574, 367, 314, 8509, 9773, 730, 365, 5965, 282, 2008, 355, 327, 370, 986, 315, 314, 658, 6721, 9773, 29, 549, 64, 4252, 370, 314, 901, 355, 327, 5492, 14, 355, 2963, 5668, 63, 1313, 59, 4962, 14008, 63, 2711, 61, 275, 661, 6831, 792, 297, 791, 6721, 9773, 7, 520, 715, 1552, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 2963, 5668, 63, 1313, 339, 347, 664, 63, 698, 63, 466, 8, 277, 12, 666, 63, 466, 12, 1369, 304, 267, 340, 440, 291, 14, 1932, 5668, 63, 1313, 63, 4471, 26, 288, 327, 982, 314, 20929, 2943, 3837, 2600, 365, 440, 16460, 12, 886, 880, 288, 327, 3063, 14, 221, 1010, 1865, 370, 7981, 23361, 4145, 12188, 1950, 288, 327, 315, 1009, 2072, 12, 314, 658, 576, 63, 1313, 63, 4471, 64, 2600, 365, 440, 4588, 288, 327, 543, 314, 20929, 3537, 2943, 5133, 1109, 14254, 365, 5965, 288, 327, 10585, 1553, 315, 1163, 5932, 12, 1380, 642, 805, 365, 2797, 14, 288, 291, 14, 1932, 5668, 63, 1313, 63, 4471, 275, 291, 14, 362, 63, 1932, 5668, 63, 1313, 342, 288, 291, 14, 576, 63, 1313, 63, 4471, 14, 873, 8, 277, 14, 1932, 5668, 63, 1313, 63, 4471, 9, 267, 372, 1613, 8, 6564, 11092, 30516, 12, 291, 680, 362, 63, 698, 63, 466, 8, 576, 63, 466, 12, 1369, 9, 339, 347, 664, 63, 7660, 63, 466, 8, 277, 12, 1817, 63, 354, 12, 8509, 63, 761, 304, 267, 408, 267, 710, 3400, 730, 593, 998, 1202, 701, 20929, 1630, 440, 6623, 314, 6770, 267, 730, 402, 901, 626, 282, 3400, 2763, 365, 334, 69, 14, 71, 2020, 3775, 652, 1159, 282, 267, 7584, 792, 503, 282, 17560, 792, 680, 221, 20227, 12, 642, 12981, 9212, 314, 20929, 267, 3341, 6716, 370, 6705, 314, 3400, 730, 12, 267, 408, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 862, 26, 288, 862, 26, 355, 327, 7758, 1937, 316, 340, 642, 3400, 2763, 365, 315, 314, 658, 7660, 63, 3406, 64, 355, 3920, 14, 2526, 360, 4859, 298, 7988, 63, 7430, 401, 298, 10498, 401, 298, 466, 2, 283, 3044, 283, 12491, 298, 7660, 63, 3406, 2, 283, 3044, 283, 17688, 298, 70, 63, 1224, 63, 354, 2, 2458, 83, 2401, 298, 70, 63, 7660, 63, 2301, 2, 2458, 83, 297, 3044, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 355, 1962, 275, 3920, 14, 11591, 342, 355, 340, 440, 1962, 26, 746, 8875, 30516, 547, 288, 871, 8875, 30516, 547, 26, 355, 340, 291, 14, 2105, 14, 1483, 14, 6721, 9773, 26, 490, 3920, 14, 2526, 360, 4859, 298, 7988, 63, 7430, 401, 298, 10498, 401, 298, 466, 2, 283, 3521, 283, 12491, 298, 6721, 9773, 63, 3406, 2, 283, 3521, 283, 17688, 298, 70, 63, 1224, 63, 354, 2, 2458, 83, 2401, 298, 70, 63, 6721, 9773, 63, 2301, 2, 2458, 83, 297, 3521, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 490, 1962, 275, 3920, 14, 11591, 342, 953, 340, 440, 1962, 26, 355, 746, 2186, 360, 6531, 440, 2342, 282, 3400, 503, 8509, 9773, 2763, 367, 2071, 83, 1674, 6808, 83, 4507, 450, 1816, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 953, 327, 25756, 1630, 440, 4409, 15801, 436, 7704, 652, 8837, 370, 3957, 288, 327, 687, 593, 7484, 9671, 730, 536, 370, 5634, 901, 14, 288, 901, 63, 466, 275, 25756, 8, 1143, 59, 18, 6575, 1176, 953, 327, 20703, 1263, 30490, 4252, 2368, 626, 787, 440, 314, 849, 14, 288, 8134, 275, 1962, 59, 16, 61, 288, 15627, 275, 1962, 59, 17, 61, 288, 901, 63, 1162, 275, 1052, 288, 340, 15627, 1137, 26719, 26, 355, 901, 63, 1162, 459, 10498, 418, 275, 15627, 288, 340, 8134, 1137, 499, 26, 355, 901, 63, 1162, 459, 3572, 418, 275, 8134, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 901, 63, 466, 12, 901, 63, 1162, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 697, 14, 7765, 14, 15437, 63, 20270, 18, 14, 21627, 492, 8692, 30516, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 25756, 199, 199, 533, 8875, 30516, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 20929, 30516, 8, 7243, 30516, 304, 272, 327, 22734, 2600, 367, 20929, 3400, 2943, 440, 16460, 5133, 272, 327, 1109, 14254, 365, 5965, 10585, 14, 272, 2963, 5668, 63, 1313, 63, 4471, 275, 1052, 339, 5525, 63, 5987, 275, 8692, 30516, 14, 11996, 63, 5987, 435, 359, 267, 283, 6721, 9773, 63, 3406, 297, 267, 283, 7660, 63, 3406, 297, 267, 283, 20876, 63, 3406, 297, 267, 283, 11679, 63, 1121, 63, 1274, 297, 267, 283, 20876, 63, 1883, 4196, 297, 272, 1622, 339, 347, 664, 63, 1932, 5668, 63, 1313, 8, 277, 304, 267, 408, 267, 1803, 282, 2600, 543, 2883, 626, 787, 314, 20175, 909, 267, 29193, 9446, 367, 314, 20929, 3400, 436, 15, 269, 267, 8509, 9773, 2943, 334, 692, 3748, 680, 267, 408, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 327, 710, 593, 998, 9446, 4568, 543, 314, 3400, 730, 1443, 267, 327, 506, 3365, 9371, 5459, 27, 19407, 12, 642, 365, 10842, 781, 1172, 267, 327, 370, 1827, 314, 20175, 10275, 63, 466, 1817, 5226, 370, 314, 267, 327, 20929, 3537, 666, 2943, 14, 267, 20109, 63, 3009, 275, 283, 4859, 298, 1170, 2, 4442, 298, 4198, 63, 466, 2, 6038, 298, 9749, 354, 2, 275, 450, 83, 7, 267, 862, 26, 288, 3920, 14, 2526, 8, 1170, 63, 3009, 12, 661, 7660, 16829, 288, 8991, 7474, 63, 2711, 275, 3920, 14, 11591, 3430, 16, 61, 288, 2963, 5668, 63, 1313, 275, 469, 8991, 7474, 63, 2711, 520, 283, 6831, 792, 7, 789, 288, 340, 291, 14, 2105, 14, 1483, 14, 6721, 9773, 26, 355, 3920, 14, 2526, 8, 1170, 63, 3009, 12, 661, 6721, 9773, 16829, 355, 8991, 14008, 63, 2711, 275, 3920, 14, 11591, 3430, 16, 61, 355, 327, 710, 574, 367, 314, 8509, 9773, 730, 365, 5965, 282, 2008, 355, 327, 370, 986, 315, 314, 658, 6721, 9773, 29, 549, 64, 4252, 370, 314, 901, 355, 327, 5492, 14, 355, 2963, 5668, 63, 1313, 59, 4962, 14008, 63, 2711, 61, 275, 661, 6831, 792, 297, 791, 6721, 9773, 7, 520, 715, 1552, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 2963, 5668, 63, 1313, 339, 347, 664, 63, 698, 63, 466, 8, 277, 12, 666, 63, 466, 12, 1369, 304, 267, 340, 440, 291, 14, 1932, 5668, 63, 1313, 63, 4471, 26, 288, 327, 982, 314, 20929, 2943, 3837, 2600, 365, 440, 16460, 12, 886, 880, 288, 327, 3063, 14, 221, 1010, 1865, 370, 7981, 23361, 4145, 12188, 1950, 288, 327, 315, 1009, 2072, 12, 314, 658, 576, 63, 1313, 63, 4471, 64, 2600, 365, 440, 4588, 288, 327, 543, 314, 20929, 3537, 2943, 5133, 1109, 14254, 365, 5965, 288, 327, 10585, 1553, 315, 1163, 5932, 12, 1380, 642, 805, 365, 2797, 14, 288, 291, 14, 1932, 5668, 63, 1313, 63, 4471, 275, 291, 14, 362, 63, 1932, 5668, 63, 1313, 342, 288, 291, 14, 576, 63, 1313, 63, 4471, 14, 873, 8, 277, 14, 1932, 5668, 63, 1313, 63, 4471, 9, 267, 372, 1613, 8, 6564, 11092, 30516, 12, 291, 680, 362, 63, 698, 63, 466, 8, 576, 63, 466, 12, 1369, 9, 339, 347, 664, 63, 7660, 63, 466, 8, 277, 12, 1817, 63, 354, 12, 8509, 63, 761, 304, 267, 408, 267, 710, 3400, 730, 593, 998, 1202, 701, 20929, 1630, 440, 6623, 314, 6770, 267, 730, 402, 901, 626, 282, 3400, 2763, 365, 334, 69, 14, 71, 2020, 3775, 652, 1159, 282, 267, 7584, 792, 503, 282, 17560, 792, 680, 221, 20227, 12, 642, 12981, 9212, 314, 20929, 267, 3341, 6716, 370, 6705, 314, 3400, 730, 12, 267, 408, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 862, 26, 288, 862, 26, 355, 327, 7758, 1937, 316, 340, 642, 3400, 2763, 365, 315, 314, 658, 7660, 63, 3406, 64, 355, 3920, 14, 2526, 360, 4859, 298, 7988, 63, 7430, 401, 298, 10498, 401, 298, 466, 2, 283, 3044, 283, 12491, 298, 7660, 63, 3406, 2, 283, 3044, 283, 17688, 298, 70, 63, 1224, 63, 354, 2, 2458, 83, 2401, 298, 70, 63, 7660, 63, 2301, 2, 2458, 83, 297, 3044, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 355, 1962, 275, 3920, 14, 11591, 342, 355, 340, 440, 1962, 26, 746, 8875, 30516, 547, 288, 871, 8875, 30516, 547, 26, 355, 340, 291, 14, 2105, 14, 1483, 14, 6721, 9773, 26, 490, 3920, 14, 2526, 360, 4859, 298, 7988, 63, 7430, 401, 298, 10498, 401, 298, 466, 2, 283, 3521, 283, 12491, 298, 6721, 9773, 63, 3406, 2, 283, 3521, 283, 17688, 298, 70, 63, 1224, 63, 354, 2, 2458, 83, 2401, 298, 70, 63, 6721, 9773, 63, 2301, 2, 2458, 83, 297, 3521, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 490, 1962, 275, 3920, 14, 11591, 342, 953, 340, 440, 1962, 26, 355, 746, 2186, 360, 6531, 440, 2342, 282, 3400, 503, 8509, 9773, 2763, 367, 2071, 83, 1674, 6808, 83, 4507, 450, 1816, 334, 1224, 63, 354, 12, 8509, 63, 761, 430, 953, 327, 25756, 1630, 440, 4409, 15801, 436, 7704, 652, 8837, 370, 3957, 288, 327, 687, 593, 7484, 9671, 730, 536, 370, 5634, 901, 14, 288, 901, 63, 466, 275, 25756, 8, 1143, 59, 18, 6575, 1176, 953, 327, 20703, 1263, 30490, 4252, 2368, 626, 787, 440, 314, 849, 14, 288, 8134, 275, 1962, 59, 16, 61, 288, 15627, 275, 1962, 59, 17, 61, 288, 901, 63, 1162, 275, 1052, 288, 340, 15627, 1137, 26719, 26, 355, 901, 63, 1162, 459, 10498, 418, 275, 15627, 288, 340, 8134, 1137, 499, 26, 355, 901, 63, 1162, 459, 3572, 418, 275, 8134, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 901, 63, 466, 12, 901, 63, 1162, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GbalsaC/bitnamiP
venv/lib/python2.7/site-packages/django/contrib/gis/tests/layermap/models.py
239
2241
from django.contrib.gis.db import models class State(models.Model): name = models.CharField(max_length=20) objects = models.GeoManager() class County(models.Model): name = models.CharField(max_length=25) state = models.ForeignKey(State) mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83 objects = models.GeoManager() class CountyFeat(models.Model): name = models.CharField(max_length=25) poly = models.PolygonField(srid=4269) objects = models.GeoManager() class City(models.Model): name = models.CharField(max_length=25) population = models.IntegerField() density = models.DecimalField(max_digits=7, decimal_places=1) dt = models.DateField() point = models.PointField() objects = models.GeoManager() class Interstate(models.Model): name = models.CharField(max_length=20) length = models.DecimalField(max_digits=6, decimal_places=2) path = models.LineStringField() objects = models.GeoManager() # Same as `City` above, but for testing model inheritance. class CityBase(models.Model): name = models.CharField(max_length=25) population = models.IntegerField() density = models.DecimalField(max_digits=7, decimal_places=1) point = models.PointField() objects = models.GeoManager() class ICity1(CityBase): dt = models.DateField() class ICity2(ICity1): dt_time = models.DateTimeField(auto_now=True) class Invalid(models.Model): point = models.PointField() # Mapping dictionaries for the models above. co_mapping = {'name' : 'Name', 'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case). 'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS. } cofeat_mapping = {'name' : 'Name', 'poly' : 'POLYGON', } city_mapping = {'name' : 'Name', 'population' : 'Population', 'density' : 'Density', 'dt' : 'Created', 'point' : 'POINT', } inter_mapping = {'name' : 'Name', 'length' : 'Length', 'path' : 'LINESTRING', }
agpl-3.0
[ 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 199, 199, 533, 8511, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 1849, 324, 369, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 1174, 275, 1709, 14, 3190, 8, 2223, 9, 272, 6118, 16242, 275, 1709, 14, 3947, 12367, 792, 8, 10498, 29, 20, 12442, 9, 327, 603, 2092, 393, 6585, 315, 653, 1554, 2658, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 1849, 324, 369, 24927, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 8446, 275, 1709, 14, 12367, 792, 8, 10498, 29, 20, 12442, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 14753, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 16423, 275, 1709, 14, 3901, 342, 272, 13650, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 23, 12, 6107, 63, 10696, 29, 17, 9, 272, 4487, 275, 1709, 14, 14071, 342, 272, 2376, 275, 1709, 14, 3428, 792, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 6551, 929, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 2582, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 22, 12, 6107, 63, 10696, 29, 18, 9, 272, 931, 275, 1709, 14, 3049, 14912, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 3, 14766, 465, 658, 17024, 64, 3432, 12, 1325, 367, 5343, 1402, 15433, 14, 199, 533, 14753, 1563, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 16423, 275, 1709, 14, 3901, 342, 272, 13650, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 23, 12, 6107, 63, 10696, 29, 17, 9, 272, 2376, 275, 1709, 14, 3428, 792, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 473, 17024, 17, 8, 17024, 1563, 304, 272, 4487, 275, 1709, 14, 14071, 342, 1362, 199, 533, 473, 17024, 18, 8, 948, 1209, 17, 304, 272, 4487, 63, 521, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 9, 199, 199, 533, 6378, 8, 992, 14, 1685, 304, 272, 2376, 275, 1709, 14, 3428, 792, 342, 199, 199, 3, 12340, 11196, 367, 314, 1709, 3432, 14, 199, 331, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 1598, 283, 929, 7, 520, 791, 354, 7, 520, 283, 2223, 2267, 327, 12718, 1159, 675, 4573, 4412, 2600, 367, 314, 485, 2407, 63, 5822, 334, 2223, 315, 642, 1930, 680, 1598, 283, 28432, 7, 520, 283, 21389, 23602, 297, 327, 12823, 3957, 25480, 57, 22340, 4534, 1901, 24895, 41, 23602, 51, 14, 1598, 789, 199, 199, 331, 11873, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 2116, 283, 6023, 7, 520, 283, 23602, 297, 2116, 789, 199, 199, 3690, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 355, 283, 16003, 7, 520, 283, 31824, 297, 355, 283, 15669, 7, 520, 283, 26211, 297, 355, 283, 3583, 7, 520, 283, 10502, 297, 355, 283, 1403, 7, 520, 283, 7217, 297, 355, 789, 199, 199, 1058, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 326, 283, 1267, 7, 520, 283, 4625, 297, 326, 283, 515, 7, 520, 283, 6143, 29780, 297, 326, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 199, 199, 533, 8511, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 1849, 324, 369, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 1174, 275, 1709, 14, 3190, 8, 2223, 9, 272, 6118, 16242, 275, 1709, 14, 3947, 12367, 792, 8, 10498, 29, 20, 12442, 9, 327, 603, 2092, 393, 6585, 315, 653, 1554, 2658, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 1849, 324, 369, 24927, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 8446, 275, 1709, 14, 12367, 792, 8, 10498, 29, 20, 12442, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 14753, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 16423, 275, 1709, 14, 3901, 342, 272, 13650, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 23, 12, 6107, 63, 10696, 29, 17, 9, 272, 4487, 275, 1709, 14, 14071, 342, 272, 2376, 275, 1709, 14, 3428, 792, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 6551, 929, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 2582, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 22, 12, 6107, 63, 10696, 29, 18, 9, 272, 931, 275, 1709, 14, 3049, 14912, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 3, 14766, 465, 658, 17024, 64, 3432, 12, 1325, 367, 5343, 1402, 15433, 14, 199, 533, 14753, 1563, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 821, 9, 272, 16423, 275, 1709, 14, 3901, 342, 272, 13650, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 23, 12, 6107, 63, 10696, 29, 17, 9, 272, 2376, 275, 1709, 14, 3428, 792, 342, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 199, 199, 533, 473, 17024, 17, 8, 17024, 1563, 304, 272, 4487, 275, 1709, 14, 14071, 342, 1362, 199, 533, 473, 17024, 18, 8, 948, 1209, 17, 304, 272, 4487, 63, 521, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 9, 199, 199, 533, 6378, 8, 992, 14, 1685, 304, 272, 2376, 275, 1709, 14, 3428, 792, 342, 199, 199, 3, 12340, 11196, 367, 314, 1709, 3432, 14, 199, 331, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 1598, 283, 929, 7, 520, 791, 354, 7, 520, 283, 2223, 2267, 327, 12718, 1159, 675, 4573, 4412, 2600, 367, 314, 485, 2407, 63, 5822, 334, 2223, 315, 642, 1930, 680, 1598, 283, 28432, 7, 520, 283, 21389, 23602, 297, 327, 12823, 3957, 25480, 57, 22340, 4534, 1901, 24895, 41, 23602, 51, 14, 1598, 789, 199, 199, 331, 11873, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 2116, 283, 6023, 7, 520, 283, 23602, 297, 2116, 789, 199, 199, 3690, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 355, 283, 16003, 7, 520, 283, 31824, 297, 355, 283, 15669, 7, 520, 283, 26211, 297, 355, 283, 3583, 7, 520, 283, 10502, 297, 355, 283, 1403, 7, 520, 283, 7217, 297, 355, 789, 199, 199, 1058, 63, 4745, 275, 791, 354, 7, 520, 283, 985, 297, 326, 283, 1267, 7, 520, 283, 4625, 297, 326, 283, 515, 7, 520, 283, 6143, 29780, 297, 326, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
migonzalvar/youtube-dl
youtube_dl/extractor/vidme.py
49
3430
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, float_or_none, str_to_int, ) class VidmeIE(InfoExtractor): _VALID_URL = r'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]+)' _TESTS = [{ 'url': 'https://vid.me/QNB', 'md5': 'f42d05e7149aeaec5c037b17e5d3dc82', 'info_dict': { 'id': 'QNB', 'ext': 'mp4', 'title': 'Fishing for piranha - the easy way', 'description': 'source: https://www.facebook.com/photo.php?v=312276045600871', 'duration': 119.92, 'timestamp': 1406313244, 'upload_date': '20140725', 'thumbnail': 're:^https?://.*\.jpg', 'view_count': int, 'like_count': int, }, }, { # tests uploader field 'url': 'https://vid.me/4Iib', 'info_dict': { 'id': '4Iib', 'ext': 'mp4', 'title': 'The Carver', 'description': 'md5:e9c24870018ae8113be936645b93ba3c', 'duration': 97.859999999999999, 'timestamp': 1433203629, 'upload_date': '20150602', 'uploader': 'Thomas', 'thumbnail': 're:^https?://.*\.jpg', 'view_count': int, 'like_count': int, }, 'params': { 'skip_download': True, }, }, { # From http://naked-yogi.tumblr.com/post/118312946248/naked-smoking-stretching 'url': 'https://vid.me/e/Wmur', 'only_matching': True, }] def _real_extract(self, url): url = url.replace('vid.me/e/', 'vid.me/') video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_url = self._html_search_regex( r'<source src="([^"]+)"', webpage, 'video URL') title = self._og_search_title(webpage) description = self._og_search_description(webpage, default='') thumbnail = self._og_search_thumbnail(webpage) timestamp = int_or_none(self._og_search_property( 'updated_time', webpage, fatal=False)) width = int_or_none(self._og_search_property( 'video:width', webpage, fatal=False)) height = int_or_none(self._og_search_property( 'video:height', webpage, fatal=False)) duration = float_or_none(self._html_search_regex( r'data-duration="([^"]+)"', webpage, 'duration', fatal=False)) view_count = str_to_int(self._html_search_regex( r'<(?:li|span) class="video_views">\s*([\d,\.]+)\s*plays?', webpage, 'view count', fatal=False)) like_count = str_to_int(self._html_search_regex( r'class="score js-video-vote-score"[^>]+data-score="([\d,\.\s]+)">', webpage, 'like count', fatal=False)) uploader = self._html_search_regex( 'class="video_author_username"[^>]*>([^<]+)', webpage, 'uploader', default=None) return { 'id': video_id, 'url': video_url, 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'width': width, 'height': height, 'duration': duration, 'view_count': view_count, 'like_count': like_count, 'uploader': uploader, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 620, 63, 475, 63, 442, 12, 199, 9, 421, 199, 533, 812, 344, 278, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 5017, 4537, 278, 32576, 69, 15, 5547, 2229, 48, 28, 344, 24693, 983, 13, 6353, 13, 58, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 49, 16170, 297, 267, 283, 1064, 21, 356, 283, 70, 2260, 68, 1717, 69, 23, 10721, 31881, 825, 21, 67, 18325, 66, 1196, 69, 21, 68, 19, 3833, 2564, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 49, 16170, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 38, 2453, 316, 367, 299, 723, 290, 2411, 446, 314, 8837, 4340, 297, 288, 283, 1802, 356, 283, 1365, 26, 4178, 921, 1544, 14, 16652, 14, 957, 15, 13834, 14, 8624, 31, 86, 29, 16683, 13319, 966, 1367, 383, 17369, 297, 288, 283, 5553, 356, 26497, 14, 2942, 12, 288, 283, 3954, 356, 4329, 1690, 2192, 708, 1602, 12, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 821, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 2930, 63, 835, 356, 1109, 12, 267, 1660, 272, 1660, 469, 267, 327, 2295, 25257, 901, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 20, 41, 1892, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 20, 41, 1892, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1918, 14243, 422, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 69, 25, 67, 1194, 1555, 23148, 3624, 24, 9225, 1235, 29959, 13067, 66, 3129, 2470, 19, 67, 297, 288, 283, 5553, 356, 15997, 14, 2426, 13453, 27055, 12, 288, 283, 3954, 356, 29235, 12122, 1344, 1398, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13725, 996, 297, 288, 283, 13671, 356, 283, 52, 526, 5892, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 2930, 63, 835, 356, 1109, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 11606, 1455, 921, 78, 16702, 13, 89, 31114, 14, 84, 453, 3345, 82, 14, 957, 15, 1932, 15, 845, 2658, 7263, 2466, 11242, 15, 78, 16702, 13, 83, 573, 17443, 13, 31593, 316, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 69, 15, 55, 77, 300, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 1166, 275, 1166, 14, 1814, 360, 5017, 14, 278, 15, 69, 3678, 283, 5017, 14, 278, 6217, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1365, 2928, 32391, 297, 9248, 12, 283, 3722, 2851, 358, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 13275, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 4913, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 5334, 63, 521, 297, 9248, 12, 14294, 29, 797, 430, 267, 3462, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 2063, 297, 9248, 12, 14294, 29, 797, 430, 267, 4569, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 3333, 297, 9248, 12, 14294, 29, 797, 430, 267, 7373, 275, 2069, 63, 269, 63, 3592, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 5121, 419, 13, 5553, 32391, 297, 9248, 12, 283, 5553, 297, 14294, 29, 797, 430, 267, 2455, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 5169, 317, 92, 3751, 9, 1021, 628, 3722, 63, 4196, 14559, 83, 10, 16510, 68, 4202, 14, 18096, 83, 10, 20591, 7044, 288, 9248, 12, 283, 1345, 2338, 297, 14294, 29, 797, 430, 267, 2839, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7, 533, 628, 3397, 8586, 13, 3722, 13, 14317, 13, 3397, 2, 25524, 576, 13, 3397, 628, 16510, 68, 4202, 3134, 83, 11896, 1743, 297, 288, 9248, 12, 283, 2930, 2338, 297, 14294, 29, 797, 430, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 283, 533, 628, 3722, 63, 2502, 63, 2473, 2, 28959, 30, 31204, 28798, 288, 9248, 12, 283, 13671, 297, 849, 29, 403, 9, 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, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 2063, 356, 3462, 12, 288, 283, 3333, 356, 4569, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 2930, 63, 835, 356, 2839, 63, 835, 12, 288, 283, 13671, 356, 25257, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 620, 63, 475, 63, 442, 12, 199, 9, 421, 199, 533, 812, 344, 278, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 5017, 4537, 278, 32576, 69, 15, 5547, 2229, 48, 28, 344, 24693, 983, 13, 6353, 13, 58, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 49, 16170, 297, 267, 283, 1064, 21, 356, 283, 70, 2260, 68, 1717, 69, 23, 10721, 31881, 825, 21, 67, 18325, 66, 1196, 69, 21, 68, 19, 3833, 2564, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 49, 16170, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 38, 2453, 316, 367, 299, 723, 290, 2411, 446, 314, 8837, 4340, 297, 288, 283, 1802, 356, 283, 1365, 26, 4178, 921, 1544, 14, 16652, 14, 957, 15, 13834, 14, 8624, 31, 86, 29, 16683, 13319, 966, 1367, 383, 17369, 297, 288, 283, 5553, 356, 26497, 14, 2942, 12, 288, 283, 3954, 356, 4329, 1690, 2192, 708, 1602, 12, 288, 283, 5064, 63, 602, 356, 283, 7280, 1780, 821, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 2930, 63, 835, 356, 1109, 12, 267, 1660, 272, 1660, 469, 267, 327, 2295, 25257, 901, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 20, 41, 1892, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 20, 41, 1892, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1918, 14243, 422, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 69, 25, 67, 1194, 1555, 23148, 3624, 24, 9225, 1235, 29959, 13067, 66, 3129, 2470, 19, 67, 297, 288, 283, 5553, 356, 15997, 14, 2426, 13453, 27055, 12, 288, 283, 3954, 356, 29235, 12122, 1344, 1398, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13725, 996, 297, 288, 283, 13671, 356, 283, 52, 526, 5892, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 2930, 63, 835, 356, 1109, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 11606, 1455, 921, 78, 16702, 13, 89, 31114, 14, 84, 453, 3345, 82, 14, 957, 15, 1932, 15, 845, 2658, 7263, 2466, 11242, 15, 78, 16702, 13, 83, 573, 17443, 13, 31593, 316, 267, 283, 633, 356, 283, 2859, 921, 5017, 14, 278, 15, 69, 15, 55, 77, 300, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 1166, 275, 1166, 14, 1814, 360, 5017, 14, 278, 15, 69, 3678, 283, 5017, 14, 278, 6217, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1365, 2928, 32391, 297, 9248, 12, 283, 3722, 2851, 358, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 13275, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 4913, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 5334, 63, 521, 297, 9248, 12, 14294, 29, 797, 430, 267, 3462, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 2063, 297, 9248, 12, 14294, 29, 797, 430, 267, 4569, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 3333, 297, 9248, 12, 14294, 29, 797, 430, 267, 7373, 275, 2069, 63, 269, 63, 3592, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 5121, 419, 13, 5553, 32391, 297, 9248, 12, 283, 5553, 297, 14294, 29, 797, 430, 267, 2455, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 5169, 317, 92, 3751, 9, 1021, 628, 3722, 63, 4196, 14559, 83, 10, 16510, 68, 4202, 14, 18096, 83, 10, 20591, 7044, 288, 9248, 12, 283, 1345, 2338, 297, 14294, 29, 797, 430, 267, 2839, 63, 835, 275, 620, 63, 475, 63, 442, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7, 533, 628, 3397, 8586, 13, 3722, 13, 14317, 13, 3397, 2, 25524, 576, 13, 3397, 628, 16510, 68, 4202, 3134, 83, 11896, 1743, 297, 288, 9248, 12, 283, 2930, 2338, 297, 14294, 29, 797, 430, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 283, 533, 628, 3722, 63, 2502, 63, 2473, 2, 28959, 30, 31204, 28798, 288, 9248, 12, 283, 13671, 297, 849, 29, 403, 9, 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, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 2063, 356, 3462, 12, 288, 283, 3333, 356, 4569, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 2930, 63, 835, 356, 2839, 63, 835, 12, 288, 283, 13671, 356, 25257, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Big-B702/python-for-android
python-build/python-libs/gdata/src/gdata/health/__init__.py
263
7090
#!/usr/bin/python # # Copyright 2009 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains extensions to Atom objects used with Google Health.""" __author__ = 'api.eric@google.com (Eric Bidelman)' import atom import gdata CCR_NAMESPACE = 'urn:astm-org:CCR' METADATA_NAMESPACE = 'http://schemas.google.com/health/metadata' class Ccr(atom.AtomBase): """Represents a Google Health <ContinuityOfCareRecord>.""" _tag = 'ContinuityOfCareRecord' _namespace = CCR_NAMESPACE _children = atom.AtomBase._children.copy() def __init__(self, extension_elements=None, extension_attributes=None, text=None): atom.AtomBase.__init__(self, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text) def GetAlerts(self): """Helper for extracting Alert/Allergy data from the CCR. Returns: A list of ExtensionElements (one for each allergy found) or None if no allergies where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Alerts')[0].FindChildren('Alert') except: return None def GetAllergies(self): """Alias for GetAlerts().""" return self.GetAlerts() def GetProblems(self): """Helper for extracting Problem/Condition data from the CCR. Returns: A list of ExtensionElements (one for each problem found) or None if no problems where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Problems')[0].FindChildren('Problem') except: return None def GetConditions(self): """Alias for GetProblems().""" return self.GetProblems() def GetProcedures(self): """Helper for extracting Procedure data from the CCR. Returns: A list of ExtensionElements (one for each procedure found) or None if no procedures where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Procedures')[0].FindChildren('Procedure') except: return None def GetImmunizations(self): """Helper for extracting Immunization data from the CCR. Returns: A list of ExtensionElements (one for each immunization found) or None if no immunizations where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Immunizations')[0].FindChildren('Immunization') except: return None def GetMedications(self): """Helper for extracting Medication data from the CCR. Returns: A list of ExtensionElements (one for each medication found) or None if no medications where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Medications')[0].FindChildren('Medication') except: return None def GetResults(self): """Helper for extracting Results/Labresults data from the CCR. Returns: A list of ExtensionElements (one for each result found) or None if no results where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Results')[0].FindChildren('Result') except: return None class ProfileEntry(gdata.GDataEntry): """The Google Health version of an Atom Entry.""" _tag = gdata.GDataEntry._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() _children['{%s}ContinuityOfCareRecord' % CCR_NAMESPACE] = ('ccr', Ccr) def __init__(self, ccr=None, author=None, category=None, content=None, atom_id=None, link=None, published=None, title=None, updated=None, text=None, extension_elements=None, extension_attributes=None): self.ccr = ccr gdata.GDataEntry.__init__( self, author=author, category=category, content=content, atom_id=atom_id, link=link, published=published, title=title, updated=updated, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text) class ProfileFeed(gdata.GDataFeed): """A feed containing a list of Google Health profile entries.""" _tag = gdata.GDataFeed._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [ProfileEntry]) class ProfileListEntry(gdata.GDataEntry): """The Atom Entry in the Google Health profile list feed.""" _tag = gdata.GDataEntry._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() def GetProfileId(self): return self.content.text def GetProfileName(self): return self.title.text class ProfileListFeed(gdata.GDataFeed): """A feed containing a list of Google Health profile list entries.""" _tag = gdata.GDataFeed._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [ProfileListEntry]) def ProfileEntryFromString(xml_string): """Converts an XML string into a ProfileEntry object. Args: xml_string: string The XML describing a Health profile feed entry. Returns: A ProfileEntry object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileEntry, xml_string) def ProfileListEntryFromString(xml_string): """Converts an XML string into a ProfileListEntry object. Args: xml_string: string The XML describing a Health profile list feed entry. Returns: A ProfileListEntry object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileListEntry, xml_string) def ProfileFeedFromString(xml_string): """Converts an XML string into a ProfileFeed object. Args: xml_string: string The XML describing a ProfileFeed feed. Returns: A ProfileFeed object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileFeed, xml_string) def ProfileListFeedFromString(xml_string): """Converts an XML string into a ProfileListFeed object. Args: xml_string: string The XML describing a ProfileListFeed feed. Returns: A ProfileListFeed object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileListFeed, xml_string)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 5478, 370, 18840, 2251, 1202, 543, 4475, 5311, 6130, 1041, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 281, 530, 32, 3098, 14, 957, 334, 37, 1567, 31012, 2264, 1237, 3171, 199, 199, 646, 6222, 199, 646, 11006, 421, 199, 2571, 50, 63, 13001, 275, 283, 349, 26, 1810, 77, 13, 1308, 26, 2571, 50, 7, 199, 8314, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 9665, 15, 2343, 7, 421, 199, 533, 445, 1556, 8, 4188, 14, 12097, 1563, 304, 523, 408, 18089, 282, 4475, 5311, 6130, 665, 24593, 24180, 3466, 35, 1530, 5433, 30, 1041, 819, 485, 1450, 275, 283, 24593, 24180, 3466, 35, 1530, 5433, 7, 523, 485, 3251, 275, 445, 2944, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 6222, 14, 12097, 1563, 855, 826, 721, 277, 12, 3329, 63, 5527, 29, 3435, 63, 5527, 12, 2574, 3329, 63, 2987, 29, 3435, 63, 2987, 12, 1318, 29, 505, 9, 819, 347, 2372, 33, 16676, 8, 277, 304, 272, 408, 4433, 367, 30137, 25762, 15, 2439, 1435, 4312, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 741, 1435, 4312, 1911, 9, 503, 488, 340, 489, 949, 741, 1435, 28152, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 33, 16676, 5832, 16, 1055, 6591, 7139, 360, 18758, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 2439, 1435, 28152, 8, 277, 304, 272, 408, 14149, 367, 2372, 33, 16676, 20693, 272, 372, 291, 14, 1002, 33, 16676, 342, 819, 347, 2372, 919, 7561, 8, 277, 304, 272, 408, 4433, 367, 30137, 20980, 15, 9558, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 5160, 1911, 9, 503, 488, 340, 489, 949, 8826, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 7561, 5832, 16, 1055, 6591, 7139, 360, 16467, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 23107, 8, 277, 304, 272, 408, 14149, 367, 2372, 919, 7561, 20693, 272, 372, 291, 14, 1002, 919, 7561, 342, 819, 347, 2372, 919, 6867, 1482, 8, 277, 304, 272, 408, 4433, 367, 30137, 2165, 12194, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 17782, 1911, 9, 503, 488, 340, 489, 949, 557, 6867, 1482, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 6867, 1482, 5832, 16, 1055, 6591, 7139, 360, 919, 12194, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 27564, 324, 12270, 8, 277, 304, 272, 408, 4433, 367, 30137, 473, 596, 324, 2072, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 25531, 324, 2072, 1911, 9, 503, 488, 340, 489, 949, 25531, 324, 12270, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 27564, 324, 12270, 5832, 16, 1055, 6591, 7139, 360, 27564, 324, 2072, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 1352, 21171, 83, 8, 277, 304, 272, 408, 4433, 367, 30137, 3194, 21171, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 562, 21171, 1911, 9, 503, 488, 340, 489, 949, 562, 21171, 83, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 1352, 21171, 83, 5832, 16, 1055, 6591, 7139, 360, 1352, 21171, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 6579, 8, 277, 304, 272, 408, 4433, 367, 30137, 24288, 15, 22511, 2604, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 754, 1911, 9, 503, 488, 340, 489, 949, 2058, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 6579, 5832, 16, 1055, 6591, 7139, 360, 2889, 358, 272, 871, 26, 489, 372, 488, 421, 199, 533, 14386, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 1918, 4475, 5311, 6130, 1015, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 11006, 14, 27413, 3900, 423, 1450, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 11006, 14, 27413, 3900 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 5478, 370, 18840, 2251, 1202, 543, 4475, 5311, 6130, 1041, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 281, 530, 32, 3098, 14, 957, 334, 37, 1567, 31012, 2264, 1237, 3171, 199, 199, 646, 6222, 199, 646, 11006, 421, 199, 2571, 50, 63, 13001, 275, 283, 349, 26, 1810, 77, 13, 1308, 26, 2571, 50, 7, 199, 8314, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 9665, 15, 2343, 7, 421, 199, 533, 445, 1556, 8, 4188, 14, 12097, 1563, 304, 523, 408, 18089, 282, 4475, 5311, 6130, 665, 24593, 24180, 3466, 35, 1530, 5433, 30, 1041, 819, 485, 1450, 275, 283, 24593, 24180, 3466, 35, 1530, 5433, 7, 523, 485, 3251, 275, 445, 2944, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 6222, 14, 12097, 1563, 855, 826, 721, 277, 12, 3329, 63, 5527, 29, 3435, 63, 5527, 12, 2574, 3329, 63, 2987, 29, 3435, 63, 2987, 12, 1318, 29, 505, 9, 819, 347, 2372, 33, 16676, 8, 277, 304, 272, 408, 4433, 367, 30137, 25762, 15, 2439, 1435, 4312, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 741, 1435, 4312, 1911, 9, 503, 488, 340, 489, 949, 741, 1435, 28152, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 33, 16676, 5832, 16, 1055, 6591, 7139, 360, 18758, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 2439, 1435, 28152, 8, 277, 304, 272, 408, 14149, 367, 2372, 33, 16676, 20693, 272, 372, 291, 14, 1002, 33, 16676, 342, 819, 347, 2372, 919, 7561, 8, 277, 304, 272, 408, 4433, 367, 30137, 20980, 15, 9558, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 5160, 1911, 9, 503, 488, 340, 489, 949, 8826, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 7561, 5832, 16, 1055, 6591, 7139, 360, 16467, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 23107, 8, 277, 304, 272, 408, 14149, 367, 2372, 919, 7561, 20693, 272, 372, 291, 14, 1002, 919, 7561, 342, 819, 347, 2372, 919, 6867, 1482, 8, 277, 304, 272, 408, 4433, 367, 30137, 2165, 12194, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 17782, 1911, 9, 503, 488, 340, 489, 949, 557, 6867, 1482, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 6867, 1482, 5832, 16, 1055, 6591, 7139, 360, 919, 12194, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 27564, 324, 12270, 8, 277, 304, 272, 408, 4433, 367, 30137, 473, 596, 324, 2072, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 25531, 324, 2072, 1911, 9, 503, 488, 340, 489, 949, 25531, 324, 12270, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 27564, 324, 12270, 5832, 16, 1055, 6591, 7139, 360, 27564, 324, 2072, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 1352, 21171, 83, 8, 277, 304, 272, 408, 4433, 367, 30137, 3194, 21171, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 562, 21171, 1911, 9, 503, 488, 340, 489, 949, 562, 21171, 83, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 1352, 21171, 83, 5832, 16, 1055, 6591, 7139, 360, 1352, 21171, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 6579, 8, 277, 304, 272, 408, 4433, 367, 30137, 24288, 15, 22511, 2604, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 754, 1911, 9, 503, 488, 340, 489, 949, 2058, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 6579, 5832, 16, 1055, 6591, 7139, 360, 2889, 358, 272, 871, 26, 489, 372, 488, 421, 199, 533, 14386, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 1918, 4475, 5311, 6130, 1015, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 11006, 14, 27413, 3900, 423, 1450, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
espressomd/espresso
testsuite/python/elc.py
2
2980
# Copyright (C) 2010-2019 The ESPResSo project # # This file is part of ESPResSo. # # ESPResSo 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. # # ESPResSo 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 unittest as ut import unittest_decorators as utx import espressomd.electrostatics import numpy as np GAP = np.array([0, 0, 3.]) BOX_L = np.array(3 * [10]) + GAP TIME_STEP = 1e-100 POTENTIAL_DIFFERENCE = -3. @utx.skipIfMissingFeatures(["P3M"]) class ElcTest(ut.TestCase): system = espressomd.System(box_l=BOX_L, time_step=TIME_STEP) system.cell_system.skin = 0.0 def test_finite_potential_drop(self): system = self.system p1 = system.part.add(pos=[0, 0, 1], q=+1) p2 = system.part.add(pos=[0, 0, 9], q=-1) p3m = espressomd.electrostatics.P3M( # zero is not allowed prefactor=1e-100, mesh=32, cao=5, accuracy=1e-3, ) elc = espressomd.electrostatics.ELC( p3m_actor=p3m, gap_size=GAP[2], maxPWerror=1e-3, delta_mid_top=-1, delta_mid_bot=-1, const_pot=1, pot_diff=POTENTIAL_DIFFERENCE, ) system.actors.add(elc) # Calculated energy U_elc = system.analysis.energy()['coulomb'] # Expected E-Field is voltage drop over the box E_expected = POTENTIAL_DIFFERENCE / (BOX_L[2] - GAP[2]) # Expected potential is -E_expected * z, so U_expected = -E_expected * (p1.pos[2] * p1.q + p2.pos[2] * p2.q) self.assertAlmostEqual(U_elc, U_expected) system.integrator.run(0) self.assertAlmostEqual(E_expected, p1.f[2] / p1.q) self.assertAlmostEqual(E_expected, p2.f[2] / p2.q) # Check if error is thrown when particles enter the ELC gap # positive direction p1.pos = [BOX_L[0] / 2, BOX_L[1] / 2, BOX_L[2] - GAP[2] / 2] with self.assertRaises(Exception): self.system.analysis.energy() with self.assertRaisesRegex(Exception, 'entered ELC gap region'): self.system.integrator.run(2) # negative direction p1.pos = [BOX_L[0] / 2, BOX_L[1] / 2, -GAP[2] / 2] with self.assertRaises(Exception): self.system.analysis.energy() with self.assertRaisesRegex(Exception, 'entered ELC gap region'): self.system.integrator.run(2) if __name__ == "__main__": ut.main()
gpl-3.0
[ 3, 1898, 334, 35, 9, 7129, 13, 14982, 710, 31334, 1322, 5158, 2199, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 31334, 1322, 5158, 14, 199, 3, 199, 3, 31334, 1322, 5158, 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, 31334, 1322, 5158, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 2882, 465, 11430, 199, 646, 2882, 63, 11582, 465, 11430, 88, 199, 646, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 199, 199, 646, 2680, 465, 980, 199, 199, 39, 1282, 275, 980, 14, 1144, 779, 16, 12, 378, 12, 650, 14444, 199, 15694, 63, 44, 275, 980, 14, 1144, 8, 19, 627, 359, 709, 566, 435, 598, 1282, 199, 4961, 63, 17988, 275, 413, 69, 13, 1960, 199, 48, 1387, 8246, 63, 10596, 540, 6013, 275, 446, 19, 14, 421, 199, 32, 337, 88, 14, 15118, 7718, 10807, 5234, 48, 19, 45, 3135, 199, 533, 662, 10181, 774, 8, 337, 14, 1746, 304, 272, 2656, 275, 9455, 2915, 676, 68, 14, 3989, 8, 1977, 63, 76, 29, 15694, 63, 44, 12, 900, 63, 2926, 29, 4961, 63, 17988, 9, 272, 2656, 14, 3890, 63, 2253, 14, 16409, 275, 378, 14, 16, 339, 347, 511, 63, 8005, 63, 24668, 63, 4824, 8, 277, 304, 267, 2656, 275, 291, 14, 2253, 398, 299, 17, 275, 2656, 14, 2064, 14, 525, 8, 1712, 1524, 16, 12, 378, 12, 413, 467, 1894, 29744, 17, 9, 267, 299, 18, 275, 2656, 14, 2064, 14, 525, 8, 1712, 1524, 16, 12, 378, 12, 1749, 467, 1894, 4022, 17, 9, 398, 299, 19, 77, 275, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 14, 48, 19, 45, 8, 288, 327, 4697, 365, 440, 4370, 288, 876, 4778, 29, 17, 69, 13, 1960, 12, 288, 9364, 29, 708, 12, 288, 1704, 79, 29, 21, 12, 288, 12862, 29, 17, 69, 13, 19, 12, 267, 776, 267, 579, 67, 275, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 14, 2901, 35, 8, 288, 299, 19, 77, 63, 5021, 29, 80, 19, 77, 12, 288, 16301, 63, 890, 29, 39, 1282, 59, 18, 467, 288, 1390, 10780, 705, 29, 17, 69, 13, 19, 12, 288, 5762, 63, 8523, 63, 2119, 4022, 17, 12, 288, 5762, 63, 8523, 63, 3018, 4022, 17, 12, 288, 950, 63, 14173, 29, 17, 12, 288, 27701, 63, 3028, 29, 48, 1387, 8246, 63, 10596, 540, 6013, 12, 267, 776, 267, 2656, 14, 32546, 14, 525, 8, 352, 67, 9, 398, 327, 19821, 972, 12304, 267, 738, 63, 352, 67, 275, 2656, 14, 10466, 14, 8443, 12047, 331, 13957, 887, 418, 398, 327, 13796, 662, 13, 792, 365, 29943, 5978, 1806, 314, 5689, 267, 662, 63, 2062, 275, 510, 1387, 8246, 63, 10596, 540, 6013, 1182, 334, 15694, 63, 44, 59, 18, 61, 446, 598, 1282, 59, 18, 566, 267, 327, 13796, 12330, 365, 446, 37, 63, 2062, 627, 1315, 12, 880, 267, 738, 63, 2062, 275, 446, 37, 63, 2062, 627, 334, 80, 17, 14, 1712, 59, 18, 61, 627, 299, 17, 14, 81, 435, 299, 18, 14, 1712, 59, 18, 61, 627, 299, 18, 14, 81, 9, 398, 291, 14, 7904, 8, 53, 63, 352, 67, 12, 738, 63, 2062, 9, 398, 2656, 14, 25323, 707, 14, 1065, 8, 16, 9, 267, 291, 14, 7904, 8, 37, 63, 2062, 12, 299, 17, 14, 70, 59, 18, 61, 1182, 299, 17, 14, 81, 9, 267, 291, 14, 7904, 8, 37, 63, 2062, 12, 299, 18, 14, 70, 59, 18, 61, 1182, 299, 18, 14, 81, 9, 398, 327, 2670, 340, 1125, 365, 14031, 1380, 26115, 9509, 314, 662, 7027, 16301, 267, 327, 7317, 7581, 267, 299, 17, 14, 1712, 275, 359, 15694, 63, 44, 59, 16, 61, 1182, 499, 12, 5240, 63, 44, 59, 17, 61, 1182, 499, 12, 5240, 63, 44, 59, 18, 61, 446, 598, 1282, 59, 18, 61, 1182, 499, 61, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 291, 14, 2253, 14, 10466, 14, 8443, 342, 267, 543, 291, 14, 16499, 8, 1726, 12, 283, 287, 3014, 662, 7027, 16301, 4897, 735, 288, 291, 14, 2253, 14, 25323, 707, 14, 1065, 8, 18, 9, 267, 327, 6946, 7581, 267, 299, 17, 14, 1712, 275, 359, 15694, 63, 44, 59, 16, 61, 1182, 499, 12, 5240, 63, 44, 59, 17, 61, 1182, 499, 12, 446, 39, 1282, 59, 18, 61, 1182, 499, 61, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 291, 14, 2253, 14, 10466, 14, 8443, 342, 267, 543, 291, 14, 16499, 8, 1726, 12, 283, 287, 3014, 662, 7027, 16301, 4897, 735, 288, 291, 14, 2253, 14, 25323, 707, 14, 1065, 8, 18, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11430, 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 ]
[ 1898, 334, 35, 9, 7129, 13, 14982, 710, 31334, 1322, 5158, 2199, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 31334, 1322, 5158, 14, 199, 3, 199, 3, 31334, 1322, 5158, 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, 31334, 1322, 5158, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 2882, 465, 11430, 199, 646, 2882, 63, 11582, 465, 11430, 88, 199, 646, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 199, 199, 646, 2680, 465, 980, 199, 199, 39, 1282, 275, 980, 14, 1144, 779, 16, 12, 378, 12, 650, 14444, 199, 15694, 63, 44, 275, 980, 14, 1144, 8, 19, 627, 359, 709, 566, 435, 598, 1282, 199, 4961, 63, 17988, 275, 413, 69, 13, 1960, 199, 48, 1387, 8246, 63, 10596, 540, 6013, 275, 446, 19, 14, 421, 199, 32, 337, 88, 14, 15118, 7718, 10807, 5234, 48, 19, 45, 3135, 199, 533, 662, 10181, 774, 8, 337, 14, 1746, 304, 272, 2656, 275, 9455, 2915, 676, 68, 14, 3989, 8, 1977, 63, 76, 29, 15694, 63, 44, 12, 900, 63, 2926, 29, 4961, 63, 17988, 9, 272, 2656, 14, 3890, 63, 2253, 14, 16409, 275, 378, 14, 16, 339, 347, 511, 63, 8005, 63, 24668, 63, 4824, 8, 277, 304, 267, 2656, 275, 291, 14, 2253, 398, 299, 17, 275, 2656, 14, 2064, 14, 525, 8, 1712, 1524, 16, 12, 378, 12, 413, 467, 1894, 29744, 17, 9, 267, 299, 18, 275, 2656, 14, 2064, 14, 525, 8, 1712, 1524, 16, 12, 378, 12, 1749, 467, 1894, 4022, 17, 9, 398, 299, 19, 77, 275, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 14, 48, 19, 45, 8, 288, 327, 4697, 365, 440, 4370, 288, 876, 4778, 29, 17, 69, 13, 1960, 12, 288, 9364, 29, 708, 12, 288, 1704, 79, 29, 21, 12, 288, 12862, 29, 17, 69, 13, 19, 12, 267, 776, 267, 579, 67, 275, 9455, 2915, 676, 68, 14, 26334, 293, 1986, 83, 14, 2901, 35, 8, 288, 299, 19, 77, 63, 5021, 29, 80, 19, 77, 12, 288, 16301, 63, 890, 29, 39, 1282, 59, 18, 467, 288, 1390, 10780, 705, 29, 17, 69, 13, 19, 12, 288, 5762, 63, 8523, 63, 2119, 4022, 17, 12, 288, 5762, 63, 8523, 63, 3018, 4022, 17, 12, 288, 950, 63, 14173, 29, 17, 12, 288, 27701, 63, 3028, 29, 48, 1387, 8246, 63, 10596, 540, 6013, 12, 267, 776, 267, 2656, 14, 32546, 14, 525, 8, 352, 67, 9, 398, 327, 19821, 972, 12304, 267, 738, 63, 352, 67, 275, 2656, 14, 10466, 14, 8443, 12047, 331, 13957, 887, 418, 398, 327, 13796, 662, 13, 792, 365, 29943, 5978, 1806, 314, 5689, 267, 662, 63, 2062, 275, 510, 1387, 8246, 63, 10596, 540, 6013, 1182, 334, 15694, 63, 44, 59, 18, 61, 446, 598, 1282, 59, 18, 566, 267, 327, 13796, 12330, 365, 446, 37, 63, 2062, 627, 1315, 12, 880, 267, 738, 63, 2062, 275, 446, 37, 63, 2062, 627, 334, 80, 17, 14, 1712, 59, 18, 61, 627, 299, 17, 14, 81, 435, 299, 18, 14, 1712, 59, 18, 61, 627, 299, 18, 14, 81, 9, 398, 291, 14, 7904, 8, 53, 63, 352, 67, 12, 738, 63, 2062, 9, 398, 2656, 14, 25323, 707, 14, 1065, 8, 16, 9, 267, 291, 14, 7904, 8, 37, 63, 2062, 12, 299, 17, 14, 70, 59, 18, 61, 1182, 299, 17, 14, 81, 9, 267, 291, 14, 7904, 8, 37, 63, 2062, 12, 299, 18, 14, 70, 59, 18, 61, 1182, 299, 18, 14, 81, 9, 398, 327, 2670, 340, 1125, 365, 14031, 1380, 26115, 9509, 314, 662, 7027, 16301, 267, 327, 7317, 7581, 267, 299, 17, 14, 1712, 275, 359, 15694, 63, 44, 59, 16, 61, 1182, 499, 12, 5240, 63, 44, 59, 17, 61, 1182, 499, 12, 5240, 63, 44, 59, 18, 61, 446, 598, 1282, 59, 18, 61, 1182, 499, 61, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 291, 14, 2253, 14, 10466, 14, 8443, 342, 267, 543, 291, 14, 16499, 8, 1726, 12, 283, 287, 3014, 662, 7027, 16301, 4897, 735, 288, 291, 14, 2253, 14, 25323, 707, 14, 1065, 8, 18, 9, 267, 327, 6946, 7581, 267, 299, 17, 14, 1712, 275, 359, 15694, 63, 44, 59, 16, 61, 1182, 499, 12, 5240, 63, 44, 59, 17, 61, 1182, 499, 12, 446, 39, 1282, 59, 18, 61, 1182, 499, 61, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 291, 14, 2253, 14, 10466, 14, 8443, 342, 267, 543, 291, 14, 16499, 8, 1726, 12, 283, 287, 3014, 662, 7027, 16301, 4897, 735, 288, 291, 14, 2253, 14, 25323, 707, 14, 1065, 8, 18, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11430, 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, 0 ]
[ 1, 1,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/eventql
deps/3rdparty/spidermonkey/mozjs/python/virtualenv/docs/conf.py
30
4590
# -*- coding: utf-8 -*- # # Paste documentation build configuration file, created by # sphinx-quickstart on Tue Apr 22 22:08:49 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import os import sys on_rtd = os.environ.get('READTHEDOCS', None) == 'True' # If your extensions are in another directory, add it here. sys.path.insert(0, os.path.abspath(os.pardir)) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. ## FIXME: disabled for now because I haven't figured out how to use this: #templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = 'virtualenv' copyright = '2007-2014, Ian Bicking, The Open Planning Project, PyPA' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. try: from virtualenv import __version__ # The short X.Y version. version = '.'.join(__version__.split('.')[:2]) # The full version, including alpha/beta/rc tags. release = __version__ except ImportError: version = release = 'dev' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. unused_docs = [] # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. #html_style = 'default.css' html_theme = 'default' if not on_rtd: try: import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] except ImportError: pass # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Content template for the index page. #html_index = '' # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If true, the reST sources are included in the HTML build as _sources/<name>. #html_copy_source = True # Output file base name for HTML help builder. htmlhelp_basename = 'Pastedoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). #latex_documents = [] # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 510, 9209, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 437, 2700, 6928, 6928, 26, 2036, 26, 1887, 9079, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18731, 12, 880, 2793, 1133, 5324, 1338, 315, 314, 3231, 199, 3, 626, 10621, 1133, 5927, 461, 334, 578, 8925, 787, 5849, 12, 2985, 3984, 4829, 5847, 680, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 574, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 574, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 265, 63, 29048, 275, 747, 14, 2314, 14, 362, 360, 5670, 2080, 1149, 47, 3298, 297, 488, 9, 508, 283, 549, 7, 199, 199, 3, 982, 2195, 5478, 787, 315, 4573, 2082, 12, 1050, 652, 2348, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 21386, 430, 199, 199, 3, 1696, 2897, 199, 3, 10652, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 309, 7600, 26, 6980, 367, 3063, 2952, 473, 19051, 1133, 6085, 3297, 734, 4212, 370, 675, 642, 26, 199, 3, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 20873, 14, 199, 1715, 275, 283, 21611, 7, 199, 7307, 275, 283, 9488, 13, 7280, 12, 473, 290, 699, 2000, 316, 12, 710, 3232, 7497, 11495, 7290, 12, 1611, 8470, 7, 199, 199, 3, 710, 849, 22372, 367, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 199, 3, 1163, 9825, 23088, 314, 6137, 8247, 14, 199, 893, 26, 272, 687, 19128, 492, 636, 1023, 363, 272, 327, 710, 3974, 1323, 14, 57, 1015, 14, 272, 1015, 275, 15671, 904, 3460, 1023, 4343, 1294, 7563, 1491, 18, 566, 272, 327, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 272, 4683, 275, 636, 1023, 363, 199, 2590, 3545, 26, 272, 1015, 275, 4683, 275, 283, 2374, 7, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 8618, 63, 4757, 275, 942, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 421, 199, 3, 8394, 367, 4163, 1072, 199, 3, 10652, 12797, 199, 199, 3, 710, 3449, 12083, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 437, 570, 402, 626, 536, 199, 3, 1471, 2187, 1902, 315, 10229, 7, 2955, 15, 931, 12, 503, 315, 1373, 402, 314, 3537, 3792, 199, 3, 1627, 315, 3517, 63, 1986, 63, 515, 14, 199, 3, 1360, 63, 2487, 275, 283, 885, 14, 3919, 7, 199, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 692, 440, 641, 63, 29048, 26, 272, 862, 26, 267, 492, 15882, 63, 29048, 63, 7915, 267, 3517, 63, 7915, 275, 283, 8008, 63, 29048, 63, 7915, 7, 267, 3517, 63, 7915, 63, 515, 275, 359, 8008, 63, 29048, 63, 7915, 14, 362, 63, 1360, 63, 7915, 63, 515, 5106, 272, 871, 3545, 26, 267, 986, 421, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 298, 885, 14, 3919, 2, 911, 8970, 314, 6762, 298, 885, 14, 3919, 1674, 199, 3, 3517, 63, 1986, 63, 515, 275, 4044, 1986, 418, 199, 199, 3, 982, 440, 3260, 282, 283, 6090, 4588, 641, 4881, 4913, 365, 11788, 737, 4036, 2034, 9048, 12, 199, 3, 1808, 314, 1627, 14053, 1475, 14, 199, 1360, 63, 2019, 63, 5334, 63, 5045, 275, 1543, 66, 450, 68, 12, 450, 57, 7, 199, 199, 3, 982, 2549, 12, 30255, 911, 506, 1202, 370, 3957, 9344, 436, 21106, 370, 199, 3, 24013, 25537, 3211, 9045, 14, 199, 3, 1360, 63, 1180, 63, 30781, 275, 715, 199, 199, 3, 6646, 1978, 367, 314, 1478, 2034, 14, 199, 3, 1360, 63, 1080, 275, 2125, 199, 199, 3, 8388, 18437, 7009, 12, 9033, 2213, 1561, 370, 1978, 1561, 14, 199, 3, 1360, 63, 29627, 275, 1052, 199, 199, 3, 10961, 7009, 626, 1077, 506, 8018, 370, 6497, 12, 9033, 2034, 1561, 370, 199, 3, 1978, 1561, 14, 199, 3, 1360, 63, 8460, 63, 5856, 275, 1052, 199, 199, 3, 982, 3055, 12, 949, 859, 1478, 365, 4046, 14, 199, 3, 1360, 63, 1180, 63, 27555, 275, 715, 199 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 510, 9209, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 437, 2700, 6928, 6928, 26, 2036, 26, 1887, 9079, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18731, 12, 880, 2793, 1133, 5324, 1338, 315, 314, 3231, 199, 3, 626, 10621, 1133, 5927, 461, 334, 578, 8925, 787, 5849, 12, 2985, 3984, 4829, 5847, 680, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 574, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 574, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 265, 63, 29048, 275, 747, 14, 2314, 14, 362, 360, 5670, 2080, 1149, 47, 3298, 297, 488, 9, 508, 283, 549, 7, 199, 199, 3, 982, 2195, 5478, 787, 315, 4573, 2082, 12, 1050, 652, 2348, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 21386, 430, 199, 199, 3, 1696, 2897, 199, 3, 10652, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 309, 7600, 26, 6980, 367, 3063, 2952, 473, 19051, 1133, 6085, 3297, 734, 4212, 370, 675, 642, 26, 199, 3, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 20873, 14, 199, 1715, 275, 283, 21611, 7, 199, 7307, 275, 283, 9488, 13, 7280, 12, 473, 290, 699, 2000, 316, 12, 710, 3232, 7497, 11495, 7290, 12, 1611, 8470, 7, 199, 199, 3, 710, 849, 22372, 367, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 199, 3, 1163, 9825, 23088, 314, 6137, 8247, 14, 199, 893, 26, 272, 687, 19128, 492, 636, 1023, 363, 272, 327, 710, 3974, 1323, 14, 57, 1015, 14, 272, 1015, 275, 15671, 904, 3460, 1023, 4343, 1294, 7563, 1491, 18, 566, 272, 327, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 272, 4683, 275, 636, 1023, 363, 199, 2590, 3545, 26, 272, 1015, 275, 4683, 275, 283, 2374, 7, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 8618, 63, 4757, 275, 942, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 421, 199, 3, 8394, 367, 4163, 1072, 199, 3, 10652, 12797, 199, 199, 3, 710, 3449, 12083, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 437, 570, 402, 626, 536, 199, 3, 1471, 2187, 1902, 315, 10229, 7, 2955, 15, 931, 12, 503, 315, 1373, 402, 314, 3537, 3792, 199, 3, 1627, 315, 3517, 63, 1986, 63, 515, 14, 199, 3, 1360, 63, 2487, 275, 283, 885, 14, 3919, 7, 199, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 692, 440, 641, 63, 29048, 26, 272, 862, 26, 267, 492, 15882, 63, 29048, 63, 7915, 267, 3517, 63, 7915, 275, 283, 8008, 63, 29048, 63, 7915, 7, 267, 3517, 63, 7915, 63, 515, 275, 359, 8008, 63, 29048, 63, 7915, 14, 362, 63, 1360, 63, 7915, 63, 515, 5106, 272, 871, 3545, 26, 267, 986, 421, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 298, 885, 14, 3919, 2, 911, 8970, 314, 6762, 298, 885, 14, 3919, 1674, 199, 3, 3517, 63, 1986, 63, 515, 275, 4044, 1986, 418, 199, 199, 3, 982, 440, 3260, 282, 283, 6090, 4588, 641, 4881, 4913, 365, 11788, 737, 4036, 2034, 9048, 12, 199, 3, 1808, 314, 1627, 14053, 1475, 14, 199, 1360, 63, 2019, 63, 5334, 63, 5045, 275, 1543, 66, 450, 68, 12, 450, 57, 7, 199, 199, 3, 982, 2549, 12, 30255, 911, 506, 1202, 370, 3957, 9344, 436, 21106, 370, 199, 3, 24013, 25537, 3211, 9045, 14, 199, 3, 1360, 63, 1180, 63, 30781, 275, 715, 199, 199, 3, 6646, 1978, 367, 314, 1478, 2034, 14, 199, 3, 1360, 63, 1080, 275, 2125, 199, 199, 3, 8388, 18437, 7009, 12, 9033, 2213, 1561, 370, 1978, 1561, 14, 199, 3, 1360, 63, 29627, 275, 1052, 199, 199, 3, 10961, 7009, 626, 1077, 506, 8018, 370, 6497, 12, 9033, 2034, 1561, 370, 199, 3, 1978, 1561, 14, 199, 3, 1360, 63, 8460, 63, 5856, 275, 1052, 199, 199, 3, 982, 3055, 12, 949, 859, 1478, 365, 4046, 14, 199, 3, 1360, 63, 1180, 63, 27555, 275, 715, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ozmartian/tvlinker
tvlinker/threads.py
1
11150
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import sys import time from datetime import datetime, timedelta from tzlocal import get_localzone import pytz import requests from PyQt5.QtCore import QObject, QSettings, QThread, pyqtSignal, pyqtSlot from PyQt5.QtWidgets import QMessageBox, qApp from bs4 import BeautifulSoup from requests.exceptions import HTTPError import cloudscraper from tvlinker.filesize import alternative, size try: # noinspection PyPackageRequirements import simplejson as json except ImportError: import json class ShadowSocks: config = { 'ssocks': { 'procs': ['ss-qt5', 'sslocal'], 'proxies': { 'http': 'socks5://127.0.0.1:1080', 'https': 'socks5://127.0.0.1:1080' }, }, 'v2ray': { 'procs': ['v2ray'], 'proxies': { 'http': 'socks5://127.0.0.1:10808', 'https': 'socks5://127.0.0.1:10808' } } } @staticmethod def detect() -> str: if sys.platform.startswith('linux'): ptypes = ShadowSocks.config.keys() ps = os.popen('ps -Af').read() for ptype in ptypes: procs = ShadowSocks.config[ptype]['procs'] for p in procs: if ps.count(p): return ptype return None @staticmethod def proxies() -> dict: proxy_type = ShadowSocks.detect() return ShadowSocks.config[proxy_type]['proxies'] if proxy_type is not None else {} class ScrapeWorker(QObject): addRow = pyqtSignal(list) workFinished = pyqtSignal() def __init__(self, source_url: str, useragent: str, maxpages: int): super(ScrapeWorker, self).__init__() self.maxpages = maxpages self.source_url = source_url self.user_agent = useragent self.scraper = cloudscraper.create_scraper() self.scraper.proxies = ShadowSocks.proxies() self.tz_format = '%b %d %Y %H:%M' self.tz_local = get_localzone() self.complete = False def scrape(self, pagenum: int) -> None: try: url = self.source_url.format(pagenum + 1) req = self.scraper.get(url) bs = BeautifulSoup(req.text, 'lxml') posts = bs('div', class_='post') for post in posts: dt_utc = datetime.strptime(post.find('div', class_='p-c p-c-time').get_text().strip(), self.tz_format) # TODO: fix hardcoded DST adjustment dt_local = dt_utc.replace(tzinfo=pytz.utc).astimezone(self.tz_local) - timedelta(hours=2) dlsize = post.find('h2').get_text().strip() table_row = [ dt_local.strftime(self.tz_format), post.find('a', class_='p-title').get('href').strip(), post.find('a', class_='p-title').get_text().strip(), dlsize[dlsize.rfind('(') + 1:len(dlsize) - 1] ] self.addRow.emit(table_row) except HTTPError: sys.stderr.write(sys.exc_info()[0]) # noinspection PyTypeChecker QMessageBox.critical(None, 'ERROR NOTIFICATION', sys.exc_info()[0]) # self.exit() @pyqtSlot() def begin(self): for page in range(self.maxpages): if QThread.currentThread().isInterruptionRequested(): return self.scrape(page) self.complete = True self.workFinished.emit() class HostersThread(QThread): setHosters = pyqtSignal(list) noLinks = pyqtSignal() def __init__(self, link_url: str, useragent: str): QThread.__init__(self) self.link_url = link_url self.user_agent = useragent self.scraper = cloudscraper.create_scraper() self.scraper.proxies = ShadowSocks.proxies() def __del__(self) -> None: self.wait() def get_hoster_links(self) -> None: try: req = self.scraper.get(self.link_url) bs = BeautifulSoup(req.text, 'lxml') links = bs.select('div.post h2[style="text-align: center;"]') self.setHosters.emit(links) except HTTPError: print(sys.exc_info()[0]) # noinspection PyTypeChecker QMessageBox.critical(None, 'ERROR NOTIFICATION', sys.exc_info()[0]) QThread.currentThread().quit() except IndexError: self.noLinks.emit() QThread.currentThread().quit() def run(self) -> None: self.get_hoster_links() class RealDebridThread(QThread): unrestrictedLink = pyqtSignal(str) supportedHosts = pyqtSignal(dict) hostStatus = pyqtSignal(dict) errorMsg = pyqtSignal(list) class RealDebridAction: UNRESTRICT_LINK = 0, SUPPORTED_HOSTS = 1, HOST_STATUS = 2 def __init__(self, settings: QSettings, api_url: str, link_url: str, action: RealDebridAction = RealDebridAction.UNRESTRICT_LINK, check_host: str = None): QThread.__init__(self) self.api_url = api_url self.api_token = settings.value('realdebrid_apitoken') self.api_proxy = settings.value('realdebrid_apiproxy', False, bool) self.link_url = link_url self.action = action self.check_host = check_host self.proxies = ShadowSocks.proxies() if self.api_proxy else {} def __del__(self): self.wait() def post(self, endpoint: str, payload: object = None) -> dict: try: res = requests.post('{0}{1}?auth_token={2}'.format(self.api_url, endpoint, self.api_token), data=payload, proxies=self.proxies) return res.json() except HTTPError: print(sys.exc_info()) self.errorMsg.emit([ 'ERROR NOTIFICATION', '<h3>Real-Debrid API Error</h3>' 'A problem occurred whilst communicating with Real-Debrid. Please check your ' 'Internet connection.<br/><br/>' '<b>ERROR LOG:</b><br/>(Error Code %s) %s<br/>%s' % (qApp.applicationName(), HTTPError.code, HTTPError.reason) ]) # self.exit() def unrestrict_link(self) -> None: jsonres = self.post(endpoint='/unrestrict/link', payload={'link': self.link_url}) if 'download' in jsonres.keys(): self.unrestrictedLink.emit(jsonres['download']) else: self.errorMsg.emit([ 'REALDEBRID ERROR', '<h3>Could not unrestrict link</h3>The hoster is most likely ' 'down, please try again later.<br/><br/>{}'.format(jsonres) ]) def supported_hosts(self) -> None: jsonres = self.post(endpoint='/hosts') self.supportedHosts.emit(jsonres) # def host_status(self, host: str) -> None: # jsonres = self.post(endpoint='/hosts/status') # self.hostStatus.emit(jsonres) def run(self) -> None: if self.action == RealDebridThread.RealDebridAction.UNRESTRICT_LINK: self.unrestrict_link() elif self.action == RealDebridThread.RealDebridAction.SUPPORTED_HOSTS: self.supported_hosts() # elif self.action == RealDebridThread.HOST_STATUS: # self.host_status(self.check_host) class Aria2Thread(QThread): aria2Confirmation = pyqtSignal(bool) def __init__(self, settings: QSettings, link_url: str): QThread.__init__(self) self.rpc_host = settings.value('aria2_rpc_host') self.rpc_port = settings.value('aria2_rpc_port') self.rpc_secret = settings.value('aria2_rpc_secret') self.rpc_username = settings.value('aria2_rpc_username') self.rpc_password = settings.value('aria2_rpc_password') self.link_url = link_url def __del__(self) -> None: self.wait() def add_uri(self) -> None: user, passwd = '', '' if len(self.rpc_username) > 0 and len(self.rpc_password) > 0: user = self.rpc_username passwd = self.rpc_password elif len(self.rpc_secret) > 0: user = 'token' passwd = self.rpc_secret aria2_endpoint = '%s:%s/jsonrpc' % (self.rpc_host, self.rpc_port) headers = {'Content-Type': 'application/json'} payload = json.dumps( { 'jsonrpc': '2.0', 'id': 1, 'method': 'aria2.addUri', 'params': ['%s:%s' % (user, passwd), [self.link_url]] }, sort_keys=False).encode('utf-8') try: from urllib.parse import urlencode from urllib.request import Request, urlopen req = Request(aria2_endpoint, headers=headers, data=payload) res = urlopen(req).read().decode('utf-8') jsonres = json.loads(res) # res = requests.post(aria2_endpoint, headers=headers, data=payload) # jsonres = res.json() self.aria2Confirmation.emit('result' in jsonres.keys()) except HTTPError: print(sys.exc_info()) # noinspection PyTypeChecker QMessageBox.critical(None, 'ERROR NOTIFICATION', sys.exc_info(), QMessageBox.Ok) self.aria2Confirmation.emit(False) # self.exit() def run(self) -> None: self.add_uri() class DownloadThread(QThread): dlComplete = pyqtSignal() dlProgress = pyqtSignal(int) dlProgressTxt = pyqtSignal(str) def __init__(self, link_url: str, dl_path: str): QThread.__init__(self) self.download_link = link_url self.download_path = dl_path self.cancel_download = False self.proxies = ShadowSocks.proxies() def __del__(self) -> None: self.wait() def download_file(self) -> None: req = requests.get(self.download_link, stream=True, proxies=self.proxies) filesize = int(req.headers['Content-Length']) filename = os.path.basename(self.download_path) downloadedChunk = 0 blockSize = 8192 start = time.clock() with open(self.download_path, 'wb') as f: for chunk in req.iter_content(chunk_size=blockSize): if self.cancel_download or not chunk: req.close() break f.write(chunk) downloadedChunk += len(chunk) progress = float(downloadedChunk) / filesize self.dlProgress.emit(progress * 100) dlspeed = downloadedChunk // (time.clock() - start) / 1000 progressTxt = '<b>Downloading {0}</b>:<br/>{1} of <b>{3}</b> [{2:.2%}] [{4} kbps]' \ .format(filename, downloadedChunk, progress, size(filesize, system=alternative), dlspeed) self.dlProgressTxt.emit(progressTxt) self.dlComplete.emit() def run(self) -> None: self.download_file()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 5823, 1832, 492, 664, 63, 1832, 2619, 199, 199, 646, 15444, 199, 646, 4145, 199, 199, 504, 14084, 21, 14, 10901, 492, 1413, 1692, 12, 1413, 5268, 12, 1413, 4436, 12, 27149, 11274, 12, 27149, 15183, 199, 504, 14084, 21, 14, 29081, 492, 25159, 12, 1894, 2640, 199, 504, 9922, 20, 492, 17132, 199, 504, 4145, 14, 3924, 492, 15050, 199, 199, 646, 8002, 12865, 529, 199, 199, 504, 13466, 20311, 14, 19233, 492, 13943, 12, 1568, 199, 199, 893, 26, 272, 327, 30870, 1611, 8599, 13902, 1470, 272, 492, 13804, 465, 2022, 199, 2590, 3545, 26, 272, 492, 2022, 421, 199, 533, 5244, 8369, 51, 27416, 26, 272, 1101, 275, 469, 267, 283, 385, 27416, 356, 469, 288, 283, 24463, 356, 788, 385, 13, 8440, 21, 297, 283, 385, 1832, 995, 288, 283, 17128, 356, 469, 355, 283, 1014, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 23514, 297, 355, 283, 2859, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 23514, 7, 288, 1660, 267, 1660, 267, 283, 86, 18, 803, 356, 469, 288, 283, 24463, 356, 788, 86, 18, 803, 995, 288, 283, 17128, 356, 469, 355, 283, 1014, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 709, 11292, 297, 355, 283, 2859, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 709, 11292, 7, 288, 789, 267, 789, 272, 789, 339, 768, 4639, 272, 347, 9696, 342, 1035, 620, 26, 267, 340, 984, 14, 3246, 14, 2460, 360, 5135, 735, 288, 299, 1313, 275, 5244, 8369, 51, 27416, 14, 888, 14, 1612, 342, 288, 7347, 275, 747, 14, 12207, 360, 1190, 446, 14799, 1959, 739, 342, 288, 367, 30990, 315, 299, 1313, 26, 355, 557, 1259, 275, 5244, 8369, 51, 27416, 14, 888, 59, 29707, 2733, 24463, 418, 355, 367, 299, 315, 557, 1259, 26, 490, 340, 7347, 14, 835, 8, 80, 304, 717, 372, 30990, 267, 372, 488, 339, 768, 4639, 272, 347, 14942, 342, 1035, 1211, 26, 267, 4566, 63, 466, 275, 5244, 8369, 51, 27416, 14, 13552, 342, 267, 372, 5244, 8369, 51, 27416, 14, 888, 59, 3280, 63, 466, 2733, 17128, 418, 340, 4566, 63, 466, 365, 440, 488, 587, 1052, 421, 199, 533, 13916, 345, 321, 12678, 8, 32260, 304, 272, 1050, 5810, 275, 27149, 11274, 8, 513, 9, 272, 1736, 13430, 275, 27149, 11274, 342, 339, 347, 636, 826, 721, 277, 12, 1350, 63, 633, 26, 620, 12, 922, 4054, 26, 620, 12, 1390, 5856, 26, 1109, 304, 267, 1613, 8, 7181, 345, 321, 12678, 12, 291, 2843, 826, 4533, 267, 291, 14, 988, 5856, 275, 1390, 5856, 267, 291, 14, 1365, 63, 633, 275, 1350, 63, 633, 267, 291, 14, 751, 63, 4054, 275, 922, 4054, 267, 291, 14, 12865, 529, 275, 8002, 12865, 529, 14, 981, 63, 12865, 529, 342, 267, 291, 14, 12865, 529, 14, 17128, 275, 5244, 8369, 51, 27416, 14, 17128, 342, 267, 291, 14, 3903, 63, 908, 275, 1543, 66, 450, 68, 450, 57, 450, 40, 2689, 45, 7, 267, 291, 14, 3903, 63, 1832, 275, 664, 63, 1832, 2619, 342, 267, 291, 14, 4883, 275, 756, 339, 347, 10328, 321, 8, 277, 12, 9881, 4869, 26, 1109, 9, 1035, 488, 26, 267, 862, 26, 288, 1166, 275, 291, 14, 1365, 63, 633, 14, 908, 8, 387, 2268, 453, 435, 413, 9, 288, 2648, 275, 291, 14, 12865, 529, 14, 362, 8, 633, 9, 288, 9922, 275, 17132, 8, 2103, 14, 505, 12, 283, 22899, 358, 288, 22238, 275, 9922, 360, 3015, 297, 1021, 7993, 1932, 358, 288, 367, 2963, 315, 22238, 26, 355, 4487, 63, 5834, 275, 2197, 14, 9866, 8, 1932, 14, 1623, 360, 3015, 297, 1021, 7993, 80, 13, 67, 299, 13, 67, 13, 521, 1959, 362, 63, 505, 1252, 1913, 1062, 291, 14, 3903, 63, 908, 9, 355, 327, 3254, 26, 5325, 7508, 15282, 22782, 27999, 355, 4487, 63, 1832, 275, 4487, 63, 5834, 14, 1814, 8, 9374, 29, 21948, 14, 5834, 680, 29648, 8, 277, 14, 3903, 63, 1832, 9, 446, 6871, 8, 8419, 29, 18, 9, 355, 15396, 890, 275, 2963, 14, 1623, 360, 72, 18, 1959, 362, 63, 505, 1252, 1913, 342, 355, 1817, 63, 1143, 275, 359, 490, 4487, 63, 1832, 14, 6205, 8, 277, 14, 3903, 63, 908, 395, 490, 2963, 14, 1623, 360, 65, 297, 1021, 7993, 80, 13, 1213, 1959, 362, 360, 6399, 1959, 1913, 1062, 490, 2963, 14, 1623, 360, 65, 297, 1021, 7993, 80, 13, 1213, 1959, 362, 63, 505, 1252, 1913, 1062, 490, 15396, 890, 59, 5030, 890, 14, 14542, 14097, 358, 435, 413, 26, 552, 8, 5030, 890, 9, 446, 413, 61, 355, 1622, 355, 291, 14, 525, 5810, 14, 8159, 8, 1224, 63, 1143, 9, 267, 871, 15050, 26, 288, 984, 14, 3083, 14, 952, 8, 1274, 14, 2804, 63, 815, 3430, 16, 566, 288, 327, 30870, 1611, 804, 3048, 288, 25159, 14, 13138, 8, 403, 12, 283, 3170, 2845, 14456, 2594, 297, 984, 14, 2804, 63, 815, 3430, 16, 566, 288, 327, 291, 14, 2224, 342, 339, 768, 24835, 15183, 342, 272, 347, 5386, 8, 277, 304, 267, 367, 2034, 315, 1425, 8, 277, 14, 988, 5856, 304, 288, 340, 1413, 4436, 14, 1818, 4436, 1252, 374, 2620, 5505, 296, 17935, 837, 355, 372, 288, 291, 14, 12865, 321, 8, 1606, 9, 267, 291, 14, 4883, 275, 715, 267, 291, 14, 800, 13430, 14, 8159, 342, 421, 199, 533, 869, 736, 878, 4436, 8, 49, 4436, 304, 272, 663, 40, 736, 878, 275, 27149, 11274, 8, 513, 9, 272, 949, 16974, 275, 27149, 11274, 342, 339, 347, 636, 826, 721, 277, 12, 2142, 63, 633, 26, 620, 12, 922, 4054, 26, 620, 304, 267, 1413, 4436, 855, 826, 721, 277, 9, 267, 291, 14, 1073, 63, 633, 275, 2142, 63, 633, 267, 291, 14, 751, 63, 4054, 275, 922, 4054, 267, 291, 14, 12865, 529, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 5823, 1832, 492, 664, 63, 1832, 2619, 199, 199, 646, 15444, 199, 646, 4145, 199, 199, 504, 14084, 21, 14, 10901, 492, 1413, 1692, 12, 1413, 5268, 12, 1413, 4436, 12, 27149, 11274, 12, 27149, 15183, 199, 504, 14084, 21, 14, 29081, 492, 25159, 12, 1894, 2640, 199, 504, 9922, 20, 492, 17132, 199, 504, 4145, 14, 3924, 492, 15050, 199, 199, 646, 8002, 12865, 529, 199, 199, 504, 13466, 20311, 14, 19233, 492, 13943, 12, 1568, 199, 199, 893, 26, 272, 327, 30870, 1611, 8599, 13902, 1470, 272, 492, 13804, 465, 2022, 199, 2590, 3545, 26, 272, 492, 2022, 421, 199, 533, 5244, 8369, 51, 27416, 26, 272, 1101, 275, 469, 267, 283, 385, 27416, 356, 469, 288, 283, 24463, 356, 788, 385, 13, 8440, 21, 297, 283, 385, 1832, 995, 288, 283, 17128, 356, 469, 355, 283, 1014, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 23514, 297, 355, 283, 2859, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 23514, 7, 288, 1660, 267, 1660, 267, 283, 86, 18, 803, 356, 469, 288, 283, 24463, 356, 788, 86, 18, 803, 995, 288, 283, 17128, 356, 469, 355, 283, 1014, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 709, 11292, 297, 355, 283, 2859, 356, 283, 21234, 21, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 709, 11292, 7, 288, 789, 267, 789, 272, 789, 339, 768, 4639, 272, 347, 9696, 342, 1035, 620, 26, 267, 340, 984, 14, 3246, 14, 2460, 360, 5135, 735, 288, 299, 1313, 275, 5244, 8369, 51, 27416, 14, 888, 14, 1612, 342, 288, 7347, 275, 747, 14, 12207, 360, 1190, 446, 14799, 1959, 739, 342, 288, 367, 30990, 315, 299, 1313, 26, 355, 557, 1259, 275, 5244, 8369, 51, 27416, 14, 888, 59, 29707, 2733, 24463, 418, 355, 367, 299, 315, 557, 1259, 26, 490, 340, 7347, 14, 835, 8, 80, 304, 717, 372, 30990, 267, 372, 488, 339, 768, 4639, 272, 347, 14942, 342, 1035, 1211, 26, 267, 4566, 63, 466, 275, 5244, 8369, 51, 27416, 14, 13552, 342, 267, 372, 5244, 8369, 51, 27416, 14, 888, 59, 3280, 63, 466, 2733, 17128, 418, 340, 4566, 63, 466, 365, 440, 488, 587, 1052, 421, 199, 533, 13916, 345, 321, 12678, 8, 32260, 304, 272, 1050, 5810, 275, 27149, 11274, 8, 513, 9, 272, 1736, 13430, 275, 27149, 11274, 342, 339, 347, 636, 826, 721, 277, 12, 1350, 63, 633, 26, 620, 12, 922, 4054, 26, 620, 12, 1390, 5856, 26, 1109, 304, 267, 1613, 8, 7181, 345, 321, 12678, 12, 291, 2843, 826, 4533, 267, 291, 14, 988, 5856, 275, 1390, 5856, 267, 291, 14, 1365, 63, 633, 275, 1350, 63, 633, 267, 291, 14, 751, 63, 4054, 275, 922, 4054, 267, 291, 14, 12865, 529, 275, 8002, 12865, 529, 14, 981, 63, 12865, 529, 342, 267, 291, 14, 12865, 529, 14, 17128, 275, 5244, 8369, 51, 27416, 14, 17128, 342, 267, 291, 14, 3903, 63, 908, 275, 1543, 66, 450, 68, 450, 57, 450, 40, 2689, 45, 7, 267, 291, 14, 3903, 63, 1832, 275, 664, 63, 1832, 2619, 342, 267, 291, 14, 4883, 275, 756, 339, 347, 10328, 321, 8, 277, 12, 9881, 4869, 26, 1109, 9, 1035, 488, 26, 267, 862, 26, 288, 1166, 275, 291, 14, 1365, 63, 633, 14, 908, 8, 387, 2268, 453, 435, 413, 9, 288, 2648, 275, 291, 14, 12865, 529, 14, 362, 8, 633, 9, 288, 9922, 275, 17132, 8, 2103, 14, 505, 12, 283, 22899, 358, 288, 22238, 275, 9922, 360, 3015, 297, 1021, 7993, 1932, 358, 288, 367, 2963, 315, 22238, 26, 355, 4487, 63, 5834, 275, 2197, 14, 9866, 8, 1932, 14, 1623, 360, 3015, 297, 1021, 7993, 80, 13, 67, 299, 13, 67, 13, 521, 1959, 362, 63, 505, 1252, 1913, 1062, 291, 14, 3903, 63, 908, 9, 355, 327, 3254, 26, 5325, 7508, 15282, 22782, 27999, 355, 4487, 63, 1832, 275, 4487, 63, 5834, 14, 1814, 8, 9374, 29, 21948, 14, 5834, 680, 29648, 8, 277, 14, 3903, 63, 1832, 9, 446, 6871, 8, 8419, 29, 18, 9, 355, 15396, 890, 275, 2963, 14, 1623, 360, 72, 18, 1959, 362, 63, 505, 1252, 1913, 342, 355, 1817, 63, 1143, 275, 359, 490, 4487, 63, 1832, 14, 6205, 8, 277, 14, 3903, 63, 908, 395, 490, 2963, 14, 1623, 360, 65, 297, 1021, 7993, 80, 13, 1213, 1959, 362, 360, 6399, 1959, 1913, 1062, 490, 2963, 14, 1623, 360, 65, 297, 1021, 7993, 80, 13, 1213, 1959, 362, 63, 505, 1252, 1913, 1062, 490, 15396, 890, 59, 5030, 890, 14, 14542, 14097, 358, 435, 413, 26, 552, 8, 5030, 890, 9, 446, 413, 61, 355, 1622, 355, 291, 14, 525, 5810, 14, 8159, 8, 1224, 63, 1143, 9, 267, 871, 15050, 26, 288, 984, 14, 3083, 14, 952, 8, 1274, 14, 2804, 63, 815, 3430, 16, 566, 288, 327, 30870, 1611, 804, 3048, 288, 25159, 14, 13138, 8, 403, 12, 283, 3170, 2845, 14456, 2594, 297, 984, 14, 2804, 63, 815, 3430, 16, 566, 288, 327, 291, 14, 2224, 342, 339, 768, 24835, 15183, 342, 272, 347, 5386, 8, 277, 304, 267, 367, 2034, 315, 1425, 8, 277, 14, 988, 5856, 304, 288, 340, 1413, 4436, 14, 1818, 4436, 1252, 374, 2620, 5505, 296, 17935, 837, 355, 372, 288, 291, 14, 12865, 321, 8, 1606, 9, 267, 291, 14, 4883, 275, 715, 267, 291, 14, 800, 13430, 14, 8159, 342, 421, 199, 533, 869, 736, 878, 4436, 8, 49, 4436, 304, 272, 663, 40, 736, 878, 275, 27149, 11274, 8, 513, 9, 272, 949, 16974, 275, 27149, 11274, 342, 339, 347, 636, 826, 721, 277, 12, 2142, 63, 633, 26, 620, 12, 922, 4054, 26, 620, 304, 267, 1413, 4436, 855, 826, 721, 277, 9, 267, 291, 14, 1073, 63, 633, 275, 2142, 63, 633, 267, 291, 14, 751, 63, 4054, 275, 922, 4054, 267, 291, 14, 12865, 529, 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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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 ]
jacky-young/crosswalk-test-suite
webapi/tct-download-tizen-tests/inst.xpk.py
357
6759
#!/usr/bin/env python import os import shutil import glob import time import sys import subprocess import string from optparse import OptionParser, make_option SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" SRC_DIR = "" PKG_SRC_DIR = "" def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it print "-->> \"%s\"" % cmd output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: output_line = cmd_proc.stdout.readline().strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break sys.stdout.write("%s\n" % output_line) sys.stdout.flush() output.append(output_line) return (cmd_return_code, output) def updateCMD(cmd=None): if "pkgcmd" in cmd: cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) return cmd def getUSERID(): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell id -u %s" % ( PARAMETERS.device, PARAMETERS.user) else: cmd = "ssh %s \"id -u %s\"" % ( PARAMETERS.device, PARAMETERS.user ) return doCMD(cmd) def getPKGID(pkg_name=None): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell %s" % ( PARAMETERS.device, updateCMD('pkgcmd -l')) else: cmd = "ssh %s \"%s\"" % ( PARAMETERS.device, updateCMD('pkgcmd -l')) (return_code, output) = doCMD(cmd) if return_code != 0: return None test_pkg_id = None for line in output: if line.find("[" + pkg_name + "]") != -1: pkgidIndex = line.split().index("pkgid") test_pkg_id = line.split()[pkgidIndex+1].strip("[]") break return test_pkg_id def doRemoteCMD(cmd=None): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) else: cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) return doCMD(cmd) def doRemoteCopy(src=None, dest=None): if PARAMETERS.mode == "SDB": cmd_prefix = "sdb -s %s push" % PARAMETERS.device cmd = "%s %s %s" % (cmd_prefix, src, dest) else: cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) (return_code, output) = doCMD(cmd) doRemoteCMD("sync") if return_code != 0: return True else: return False def uninstPKGs(): action_status = True for root, dirs, files in os.walk(SCRIPT_DIR): if root.endswith("mediasrc"): continue for file in files: if file.endswith(".xpk"): pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) if not pkg_id: action_status = False continue (return_code, output) = doRemoteCMD( "pkgcmd -u -t xpk -q -n %s" % pkg_id) for line in output: if "Failure" in line: action_status = False break (return_code, output) = doRemoteCMD( "rm -rf %s" % PKG_SRC_DIR) if return_code != 0: action_status = False return action_status def instPKGs(): action_status = True (return_code, output) = doRemoteCMD( "mkdir -p %s" % PKG_SRC_DIR) if return_code != 0: action_status = False for root, dirs, files in os.walk(SCRIPT_DIR): if root.endswith("mediasrc"): continue for file in files: if file.endswith(".xpk"): if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): action_status = False (return_code, output) = doRemoteCMD( "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) for line in output: if "Failure" in line: action_status = False break # Do some special copy/delete... steps ''' (return_code, output) = doRemoteCMD( "mkdir -p %s/tests" % PKG_SRC_DIR) if return_code != 0: action_status = False if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): action_status = False ''' return action_status def main(): try: usage = "usage: inst.py -i" opts_parser = OptionParser(usage=usage) opts_parser.add_option( "-m", dest="mode", action="store", help="Specify mode") opts_parser.add_option( "-s", dest="device", action="store", help="Specify device") opts_parser.add_option( "-i", dest="binstpkg", action="store_true", help="Install package") opts_parser.add_option( "-u", dest="buninstpkg", action="store_true", help="Uninstall package") opts_parser.add_option( "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() except Exception, e: print "Got wrong option: %s, exit ..." % e sys.exit(1) if not PARAMETERS.user: PARAMETERS.user = "app" global SRC_DIR, PKG_SRC_DIR SRC_DIR = "/home/%s/content" % PARAMETERS.user PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) if not PARAMETERS.mode: PARAMETERS.mode = "SDB" if PARAMETERS.mode == "SDB": if not PARAMETERS.device: (return_code, output) = doCMD("sdb devices") for line in output: if str.find(line, "\tdevice") != -1: PARAMETERS.device = line.split("\t")[0] break else: PARAMETERS.mode = "SSH" if not PARAMETERS.device: print "No device provided" sys.exit(1) user_info = getUSERID() re_code = user_info[0] if re_code == 0 : global XW_ENV userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: print "[Error] cmd commands error : %s"%str(user_info[1]) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: print "-i and -u are conflict" sys.exit(1) if PARAMETERS.buninstpkg: if not uninstPKGs(): sys.exit(1) else: if not instPKGs(): sys.exit(1) if __name__ == "__main__": main() sys.exit(0)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 5739, 199, 646, 900, 199, 646, 984, 199, 646, 3873, 199, 646, 1059, 199, 504, 8691, 492, 13491, 12, 1852, 63, 1422, 421, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 18150, 63, 2339, 275, 747, 14, 515, 14, 4846, 8, 10484, 63, 3022, 9, 199, 24014, 275, 488, 199, 3, 56, 55, 63, 9984, 275, 298, 3790, 6249, 1668, 63, 12763, 63, 24753, 63, 12368, 29, 11864, 26, 515, 13043, 1065, 15, 751, 15, 13128, 15, 17066, 15, 751, 63, 5610, 63, 3450, 2, 199, 12447, 63, 3022, 275, 3087, 199, 18150, 63, 12447, 63, 3022, 275, 3087, 421, 199, 318, 886, 9744, 8, 1760, 304, 272, 327, 4226, 440, 1929, 2429, 2653, 315, 642, 3974, 2884, 12, 4691, 4744, 886, 652, 272, 870, 4320, 1140, 18321, 83, 18781, 450, 2088, 272, 1072, 275, 942, 272, 2088, 63, 1107, 63, 600, 275, 413, 272, 2088, 63, 4687, 275, 3873, 14, 7942, 8, 267, 2088, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 13850, 12, 5218, 29, 549, 9, 339, 1830, 715, 26, 267, 1072, 63, 604, 275, 2088, 63, 4687, 14, 2703, 14, 6407, 1252, 1913, 4582, 82, 60, 78, 531, 267, 2088, 63, 1107, 63, 600, 275, 2088, 63, 4687, 14, 6843, 342, 267, 340, 1072, 63, 604, 508, 2125, 436, 2088, 63, 1107, 63, 600, 1137, 488, 26, 288, 2059, 267, 984, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1072, 63, 604, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 1072, 14, 740, 8, 1199, 63, 604, 9, 339, 372, 334, 1760, 63, 1107, 63, 600, 12, 1072, 9, 421, 199, 318, 1678, 9744, 8, 1760, 29, 403, 304, 272, 340, 298, 4600, 1760, 2, 315, 2088, 26, 267, 2088, 275, 298, 9648, 446, 450, 83, 446, 67, 1543, 83, 27, 5, 83, 4065, 450, 334, 24014, 14, 751, 12, 1323, 55, 63, 9984, 12, 2088, 9, 272, 372, 2088, 199, 318, 664, 3791, 998, 837, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 1305, 446, 85, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 8441, 344, 446, 85, 450, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 776, 272, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 664, 18150, 998, 8, 4600, 63, 354, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 488, 339, 511, 63, 4600, 63, 344, 275, 488, 272, 367, 1004, 315, 1072, 26, 267, 340, 1004, 14, 1623, 480, 905, 435, 5496, 63, 354, 435, 298, 12523, 1137, 446, 17, 26, 288, 5496, 344, 2681, 275, 1004, 14, 1294, 1252, 1080, 480, 4600, 344, 531, 288, 511, 63, 4600, 63, 344, 275, 1004, 14, 1294, 3430, 4600, 344, 2681, 11, 17, 1055, 1913, 480, 31346, 288, 2059, 272, 372, 511, 63, 4600, 63, 344, 421, 199, 318, 886, 6713, 9744, 8, 1760, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 339, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 886, 6713, 5116, 8, 2164, 29, 403, 12, 2053, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 63, 1861, 275, 298, 21624, 446, 83, 450, 83, 6675, 2, 450, 23710, 14, 1782, 267, 2088, 275, 2071, 83, 450, 83, 450, 83, 2, 450, 334, 1760, 63, 1861, 12, 2928, 12, 2053, 9, 272, 587, 26, 267, 2088, 275, 298, 17124, 446, 82, 450, 83, 450, 83, 26, 3149, 83, 2, 450, 334, 2164, 12, 23710, 14, 1782, 12, 2053, 9, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 886, 6713, 9744, 480, 5186, 531, 339, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 318, 625, 3615, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 340, 1738, 14, 4130, 480, 3700, 305, 1195, 2349, 288, 1980, 398, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 88, 2051, 2349, 355, 5496, 63, 344, 275, 664, 18150, 998, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 340, 440, 5496, 63, 344, 26, 490, 1595, 63, 1205, 275, 756, 490, 1980, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 490, 298, 4600, 1760, 446, 85, 446, 84, 671, 2051, 446, 81, 446, 78, 450, 83, 2, 450, 5496, 63, 344, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 267, 298, 5682, 446, 3941, 450, 83, 2, 450, 30281, 63, 12447, 63, 3022, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 1595, 63, 1205, 275, 756, 339, 372, 1595, 63, 1205, 421, 199, 318, 2727, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 5739, 199, 646, 900, 199, 646, 984, 199, 646, 3873, 199, 646, 1059, 199, 504, 8691, 492, 13491, 12, 1852, 63, 1422, 421, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 18150, 63, 2339, 275, 747, 14, 515, 14, 4846, 8, 10484, 63, 3022, 9, 199, 24014, 275, 488, 199, 3, 56, 55, 63, 9984, 275, 298, 3790, 6249, 1668, 63, 12763, 63, 24753, 63, 12368, 29, 11864, 26, 515, 13043, 1065, 15, 751, 15, 13128, 15, 17066, 15, 751, 63, 5610, 63, 3450, 2, 199, 12447, 63, 3022, 275, 3087, 199, 18150, 63, 12447, 63, 3022, 275, 3087, 421, 199, 318, 886, 9744, 8, 1760, 304, 272, 327, 4226, 440, 1929, 2429, 2653, 315, 642, 3974, 2884, 12, 4691, 4744, 886, 652, 272, 870, 4320, 1140, 18321, 83, 18781, 450, 2088, 272, 1072, 275, 942, 272, 2088, 63, 1107, 63, 600, 275, 413, 272, 2088, 63, 4687, 275, 3873, 14, 7942, 8, 267, 2088, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 13850, 12, 5218, 29, 549, 9, 339, 1830, 715, 26, 267, 1072, 63, 604, 275, 2088, 63, 4687, 14, 2703, 14, 6407, 1252, 1913, 4582, 82, 60, 78, 531, 267, 2088, 63, 1107, 63, 600, 275, 2088, 63, 4687, 14, 6843, 342, 267, 340, 1072, 63, 604, 508, 2125, 436, 2088, 63, 1107, 63, 600, 1137, 488, 26, 288, 2059, 267, 984, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1072, 63, 604, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 1072, 14, 740, 8, 1199, 63, 604, 9, 339, 372, 334, 1760, 63, 1107, 63, 600, 12, 1072, 9, 421, 199, 318, 1678, 9744, 8, 1760, 29, 403, 304, 272, 340, 298, 4600, 1760, 2, 315, 2088, 26, 267, 2088, 275, 298, 9648, 446, 450, 83, 446, 67, 1543, 83, 27, 5, 83, 4065, 450, 334, 24014, 14, 751, 12, 1323, 55, 63, 9984, 12, 2088, 9, 272, 372, 2088, 199, 318, 664, 3791, 998, 837, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 1305, 446, 85, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 8441, 344, 446, 85, 450, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 776, 272, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 664, 18150, 998, 8, 4600, 63, 354, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 488, 339, 511, 63, 4600, 63, 344, 275, 488, 272, 367, 1004, 315, 1072, 26, 267, 340, 1004, 14, 1623, 480, 905, 435, 5496, 63, 354, 435, 298, 12523, 1137, 446, 17, 26, 288, 5496, 344, 2681, 275, 1004, 14, 1294, 1252, 1080, 480, 4600, 344, 531, 288, 511, 63, 4600, 63, 344, 275, 1004, 14, 1294, 3430, 4600, 344, 2681, 11, 17, 1055, 1913, 480, 31346, 288, 2059, 272, 372, 511, 63, 4600, 63, 344, 421, 199, 318, 886, 6713, 9744, 8, 1760, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 339, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 886, 6713, 5116, 8, 2164, 29, 403, 12, 2053, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 63, 1861, 275, 298, 21624, 446, 83, 450, 83, 6675, 2, 450, 23710, 14, 1782, 267, 2088, 275, 2071, 83, 450, 83, 450, 83, 2, 450, 334, 1760, 63, 1861, 12, 2928, 12, 2053, 9, 272, 587, 26, 267, 2088, 275, 298, 17124, 446, 82, 450, 83, 450, 83, 26, 3149, 83, 2, 450, 334, 2164, 12, 23710, 14, 1782, 12, 2053, 9, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 886, 6713, 9744, 480, 5186, 531, 339, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 318, 625, 3615, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 340, 1738, 14, 4130, 480, 3700, 305, 1195, 2349, 288, 1980, 398, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 88, 2051, 2349, 355, 5496, 63, 344, 275, 664, 18150, 998, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 340, 440, 5496, 63, 344, 26, 490, 1595, 63, 1205, 275, 756, 490, 1980, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 490, 298, 4600, 1760, 446, 85, 446, 84, 671, 2051, 446, 81, 446, 78, 450, 83, 2, 450, 5496, 63, 344, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 267, 298, 5682, 446, 3941, 450, 83, 2, 450, 30281, 63, 12447, 63, 3022, 9, 272,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lianwutech/plugin_tcpclient_yykjir
plugin.py
2
3860
#!/usr/bin/env python # -*- coding:utf-8 -*- """ modbus网络的串口数据采集插件 1、device_id的组成方式为ip_port_slaveid 2、设备类型为0,协议类型为modbus 3、devices_info_dict需要持久化设备信息,启动时加载,变化时写入 4、device_cmd内容:json字符串 """ import time from setting import * from libs.daemon import Daemon from libs.plugin import * from libs.mqttclient import MQTTClient # 全局变量 devices_file_name = "devices.txt" config_file_name = "plugin.cfg" # 日志对象 logger = logging.getLogger('plugin') # 配置信息 config_info = load_config(config_file_name) # 主函数 class PluginDaemon(Daemon): def _run(self): # 切换工作目录 os.chdir(cur_file_dir()) if "channel_type" not in config_info \ or "protocol_type" not in config_info \ or "mqtt" not in config_info \ or "channel" not in config_info \ or "protocol" not in config_info: logger.fatal("配置文件配置项不全,启动失败。") return channel_type = config_info["channel_type"] protocol_type = config_info["protocol_type"] network_name = config_info["network_name"] # 获取channel类对象 channel_class = load_channel(channel_type) # 获取protocol类对象 protocol_class = load_protocol(protocol_type) # 参数检查 if channel_class.check_config(config_info["channel"]) \ and protocol_class.check_config(config_info["protocol"]) \ and MQTTClient.check_config(config_info["mqtt"]): logger.debug("参数检查通过。") else: logger.fatal("channel、protocol、mqtt参数配置项错误,请检查.") return # 此处需注意启动顺序,先创建mqtt对象,然后创建channel对象,mqtt对象设置channel属性,mqtt才能够链接服务器 # 1、初始化mqttclient对象 mqtt_client = MQTTClient(config_info["mqtt"], network_name) result = mqtt_client.connect() if not result: logger.fatal("mqtt connect fail.") return # 2、初始化protocol对象 protocol = protocol_class(config_info["protocol"]) # 3、初始化channel对象 channel = channel_class(config_info["channel"], devices_file_name, protocol, mqtt_client, network_name) # 4、设置通道对象 mqtt_client.set_channel(channel) while True: if not channel.isAlive(): logger.info("channel进程停止,重新启动。") channel.start() if not mqtt_client.isAlive(): logger.info("mqtt进程停止,重新启动。") mqtt_client.start() logger.debug("周期处理结束") time.sleep(2) # 主函数 def main(argv): pid_file_path = "/tmp/%s.pid" % plugin_name stdout_file_path = "/tmp/%s.stdout" % plugin_name stderr_file_path = "/tmp/%s.stderr" % plugin_name daemon = PluginDaemon(pid_file_path, stdout=stdout_file_path, stderr=stderr_file_path) if len(sys.argv) == 2: if 'start' == sys.argv[1]: daemon.start() elif 'stop' == sys.argv[1]: daemon.stop() elif 'restart' == sys.argv[1]: daemon.restart() else: logger.info("Unknown command") sys.exit(2) sys.exit(0) elif len(sys.argv) == 1: daemon.run() else: logger.info("usage: %s start|stop|restart" % sys.argv[0]) sys.exit(2) def entry_point(): """Zero-argument entry point for use with setuptools/distribute.""" raise SystemExit(main(sys.argv)) if __name__ == '__main__': entry_point()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 1624, 13, 24, 1882, 199, 624, 272, 3413, 5610, 20407, 240, 9360, 251, 8106, 4344, 111, 6075, 97, 22730, 10770, 230, 22982, 229, 22843, 241, 15054, 272, 413, 23709, 1782, 63, 344, 8106, 32061, 16888, 24302, 21041, 24971, 711, 63, 719, 63, 12384, 344, 272, 499, 23709, 14082, 123, 11546, 230, 10278, 24971, 16, 12356, 10450, 238, 14082, 107, 10278, 24971, 1494, 5610, 272, 650, 23709, 6410, 63, 815, 63, 807, 166, 251, 223, 22274, 32743, 17837, 228, 21018, 245, 14082, 123, 11546, 230, 27328, 12356, 8197, 108, 31001, 20494, 28990, 19182, 122, 12356, 6075, 247, 21018, 245, 20494, 17950, 248, 18236, 272, 841, 23709, 1782, 63, 1760, 17950, 228, 10270, 118, 25742, 1001, 26032, 25238, 100, 4344, 111, 199, 624, 199, 199, 646, 900, 199, 199, 504, 4260, 492, 627, 199, 504, 20314, 14, 10824, 492, 577, 8770, 199, 504, 20314, 14, 2718, 492, 627, 199, 504, 20314, 14, 19214, 1258, 492, 603, 49, 1481, 3041, 199, 199, 3, 7094, 228, 102, 27289, 223, 6075, 247, 22485, 199, 6410, 63, 493, 63, 354, 275, 298, 6410, 14, 2424, 2, 199, 888, 63, 493, 63, 354, 275, 298, 2718, 14, 4128, 2, 199, 199, 3, 8853, 246, 99, 25472, 26604, 165, 110, 95, 199, 2921, 275, 2050, 14, 5572, 360, 2718, 358, 199, 199, 3, 10469, 228, 236, 27029, 27328, 199, 888, 63, 815, 275, 2248, 63, 888, 8, 888, 63, 493, 63, 354, 9, 421, 199, 3, 221, 4344, 8698, 230, 122, 12211, 199, 533, 11349, 20555, 8, 20555, 304, 272, 347, 485, 1065, 8, 277, 304, 267, 327, 7094, 231, 230, 17109, 96, 18189, 99, 21927, 31869, 22918, 244, 267, 747, 14, 8563, 8, 895, 63, 493, 63, 694, 1012, 398, 340, 298, 2775, 63, 466, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 3922, 63, 466, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 19214, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 2775, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 3922, 2, 440, 315, 1101, 63, 815, 26, 288, 2512, 14, 16208, 480, 166, 228, 236, 27029, 29303, 166, 228, 236, 27029, 27513, 118, 19594, 8379, 102, 12356, 8197, 108, 31001, 11546, 110, 12979, 99, 20061, 531, 288, 372, 398, 3623, 63, 466, 275, 1101, 63, 815, 905, 2775, 63, 466, 937, 267, 4113, 63, 466, 275, 1101, 63, 815, 905, 3922, 63, 466, 937, 267, 2784, 63, 354, 275, 1101, 63, 815, 905, 1200, 63, 354, 937, 398, 327, 9065, 237, 116, 22924, 2775, 10100, 108, 118, 165, 110, 95, 267, 3623, 63, 533, 275, 2248, 63, 2775, 8, 2775, 63, 466, 9, 398, 327, 9065, 237, 116, 22924, 3922, 10100, 108, 118, 165, 110, 95, 267, 4113, 63, 533, 275, 2248, 63, 3922, 8, 3922, 63, 466, 9, 398, 327, 221, 32549, 12211, 163, 97, 223, 21788, 267, 340, 3623, 63, 533, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 2775, 3135, 971, 355, 436, 4113, 63, 533, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 3922, 3135, 971, 355, 436, 603, 49, 1481, 3041, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 19214, 21473, 288, 2512, 14, 1757, 480, 32549, 12211, 163, 97, 223, 21788, 14333, 249, 13201, 230, 20061, 531, 267, 587, 26, 288, 2512, 14, 16208, 480, 2775, 23709, 3922, 23709, 19214, 32549, 12211, 166, 228, 236, 27029, 27513, 118, 32064, 12356, 25977, 163, 97, 223, 21788, 2685, 288, 372, 398, 327, 8853, 256, 98, 11546, 227, 166, 251, 223, 20021, 102, 163, 227, 238, 8197, 108, 31001, 27513, 119, 15013, 238, 12356, 8379, 231, 9051, 250, 29427, 119, 19214, 26604, 165, 110, 95, 12356, 164, 227, 115, 30368, 9051, 250, 29427, 119, 2775, 26604, 165, 110, 95, 12356, 19214, 26604, 165, 110, 95, 14082, 123, 27029, 2775, 27289, 253, 17182, 101, 12356, 19214, 10862, 236, 28371, 11546, 254, 17747, 123, 24586, 6587, 236, 30521, 162, 248, 102, 267, 327, 413, 23709, 9051, 252, 25712, 234, 21018, 245, 19214, 1258, 26604, 165, 110, 95, 267, 22925, 63, 1258, 275, 603, 49, 1481, 3041, 8, 888, 63, 815, 905, 19214, 2255, 2784, 63, 354, 9, 267, 754, 275, 22925, 63, 1258, 14, 2242, 342, 267, 340, 440, 754, 26, 288, 2512, 14, 16208, 480, 19214, 4907, 2449, 2685, 288, 372, 398, 327, 499, 23709, 9051, 252, 25712, 234, 21018, 245, 3922, 26604, 165, 110, 95, 267, 4113, 275, 4113, 63, 533, 8, 888, 63, 815, 905, 3922, 3135, 398, 327, 650, 23709, 9051, 252, 25712, 234, 21018, 245, 2775, 26604, 165, 110, 95, 267, 3623, 275, 3623, 63, 533, 8, 888, 63, 815, 905, 2775, 2255, 7256, 63, 493, 63, 354, 12, 4113, 12, 22925, 63, 1258, 12, 2784, 63, 354, 9, 398, 327, 841, 23709, 14082, 123, 27029, 14333, 249, 24744, 242, 26604, 165, 110, 95, 267, 22925, 63, 1258, 14, 409, 63, 2775, 8, 2775, 9, 398, 1830, 715, 26, 288, 340, 440, 3623, 14, 374, 23692, 837, 355, 2512, 14, 815, 480, 2775, 13201, 250, 30664, 162, 224, 251, 17627, 96, 12356, 10770, 236, 22737, 8197, 108, 31001, 20061, 531, 355, 3623, 14, 928, 342, 953, 340, 440, 22925, 63, 1258, 14, 374, 23692, 837, 355, 2512, 14, 815, 480, 19214, 13201, 250, 30664, 162, 224, 251, 17627, 96, 12356, 10770, 236, 22737, 8197, 108, 31001, 20061, 531, 355, 22925, 63, 1258, 14, 928, 342, 288, 2512, 14, 1757, 480, 19580, 102, 14152, 11546, 227, 24946, 21872, 15771, 254, 531, 288, 900, 14, 4532, 8, 18, 9, 199, 199, 3, 221, 4344, 8698, 230, 122, 12211, 199, 318, 2446, 8, 3020, 304, 272, 4422, 63, 493, 63, 515, 275, 3286, 2791, 3149, 83, 14, 3150, 2, 450, 3589, 63, 354, 272, 3839, 63, 493, 63, 515, 275, 3286, 2791, 3149, 83, 14, 2703, 2, 450, 3589, 63, 354, 272, 4635, 63, 493, 63, 515, 275, 3286, 2791, 3149, 83, 14, 3083, 2, 450, 3589, 63, 354, 272, 11128, 275, 11349, 20555, 8, 3150, 63, 493, 63, 515, 12, 3839, 29, 2703, 63, 493, 63, 515, 12, 4635, 29, 3083, 63, 493, 63, 515, 9, 339, 340, 822, 8, 1274 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 1624, 13, 24, 1882, 199, 624, 272, 3413, 5610, 20407, 240, 9360, 251, 8106, 4344, 111, 6075, 97, 22730, 10770, 230, 22982, 229, 22843, 241, 15054, 272, 413, 23709, 1782, 63, 344, 8106, 32061, 16888, 24302, 21041, 24971, 711, 63, 719, 63, 12384, 344, 272, 499, 23709, 14082, 123, 11546, 230, 10278, 24971, 16, 12356, 10450, 238, 14082, 107, 10278, 24971, 1494, 5610, 272, 650, 23709, 6410, 63, 815, 63, 807, 166, 251, 223, 22274, 32743, 17837, 228, 21018, 245, 14082, 123, 11546, 230, 27328, 12356, 8197, 108, 31001, 20494, 28990, 19182, 122, 12356, 6075, 247, 21018, 245, 20494, 17950, 248, 18236, 272, 841, 23709, 1782, 63, 1760, 17950, 228, 10270, 118, 25742, 1001, 26032, 25238, 100, 4344, 111, 199, 624, 199, 199, 646, 900, 199, 199, 504, 4260, 492, 627, 199, 504, 20314, 14, 10824, 492, 577, 8770, 199, 504, 20314, 14, 2718, 492, 627, 199, 504, 20314, 14, 19214, 1258, 492, 603, 49, 1481, 3041, 199, 199, 3, 7094, 228, 102, 27289, 223, 6075, 247, 22485, 199, 6410, 63, 493, 63, 354, 275, 298, 6410, 14, 2424, 2, 199, 888, 63, 493, 63, 354, 275, 298, 2718, 14, 4128, 2, 199, 199, 3, 8853, 246, 99, 25472, 26604, 165, 110, 95, 199, 2921, 275, 2050, 14, 5572, 360, 2718, 358, 199, 199, 3, 10469, 228, 236, 27029, 27328, 199, 888, 63, 815, 275, 2248, 63, 888, 8, 888, 63, 493, 63, 354, 9, 421, 199, 3, 221, 4344, 8698, 230, 122, 12211, 199, 533, 11349, 20555, 8, 20555, 304, 272, 347, 485, 1065, 8, 277, 304, 267, 327, 7094, 231, 230, 17109, 96, 18189, 99, 21927, 31869, 22918, 244, 267, 747, 14, 8563, 8, 895, 63, 493, 63, 694, 1012, 398, 340, 298, 2775, 63, 466, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 3922, 63, 466, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 19214, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 2775, 2, 440, 315, 1101, 63, 815, 971, 355, 503, 298, 3922, 2, 440, 315, 1101, 63, 815, 26, 288, 2512, 14, 16208, 480, 166, 228, 236, 27029, 29303, 166, 228, 236, 27029, 27513, 118, 19594, 8379, 102, 12356, 8197, 108, 31001, 11546, 110, 12979, 99, 20061, 531, 288, 372, 398, 3623, 63, 466, 275, 1101, 63, 815, 905, 2775, 63, 466, 937, 267, 4113, 63, 466, 275, 1101, 63, 815, 905, 3922, 63, 466, 937, 267, 2784, 63, 354, 275, 1101, 63, 815, 905, 1200, 63, 354, 937, 398, 327, 9065, 237, 116, 22924, 2775, 10100, 108, 118, 165, 110, 95, 267, 3623, 63, 533, 275, 2248, 63, 2775, 8, 2775, 63, 466, 9, 398, 327, 9065, 237, 116, 22924, 3922, 10100, 108, 118, 165, 110, 95, 267, 4113, 63, 533, 275, 2248, 63, 3922, 8, 3922, 63, 466, 9, 398, 327, 221, 32549, 12211, 163, 97, 223, 21788, 267, 340, 3623, 63, 533, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 2775, 3135, 971, 355, 436, 4113, 63, 533, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 3922, 3135, 971, 355, 436, 603, 49, 1481, 3041, 14, 1074, 63, 888, 8, 888, 63, 815, 905, 19214, 21473, 288, 2512, 14, 1757, 480, 32549, 12211, 163, 97, 223, 21788, 14333, 249, 13201, 230, 20061, 531, 267, 587, 26, 288, 2512, 14, 16208, 480, 2775, 23709, 3922, 23709, 19214, 32549, 12211, 166, 228, 236, 27029, 27513, 118, 32064, 12356, 25977, 163, 97, 223, 21788, 2685, 288, 372, 398, 327, 8853, 256, 98, 11546, 227, 166, 251, 223, 20021, 102, 163, 227, 238, 8197, 108, 31001, 27513, 119, 15013, 238, 12356, 8379, 231, 9051, 250, 29427, 119, 19214, 26604, 165, 110, 95, 12356, 164, 227, 115, 30368, 9051, 250, 29427, 119, 2775, 26604, 165, 110, 95, 12356, 19214, 26604, 165, 110, 95, 14082, 123, 27029, 2775, 27289, 253, 17182, 101, 12356, 19214, 10862, 236, 28371, 11546, 254, 17747, 123, 24586, 6587, 236, 30521, 162, 248, 102, 267, 327, 413, 23709, 9051, 252, 25712, 234, 21018, 245, 19214, 1258, 26604, 165, 110, 95, 267, 22925, 63, 1258, 275, 603, 49, 1481, 3041, 8, 888, 63, 815, 905, 19214, 2255, 2784, 63, 354, 9, 267, 754, 275, 22925, 63, 1258, 14, 2242, 342, 267, 340, 440, 754, 26, 288, 2512, 14, 16208, 480, 19214, 4907, 2449, 2685, 288, 372, 398, 327, 499, 23709, 9051, 252, 25712, 234, 21018, 245, 3922, 26604, 165, 110, 95, 267, 4113, 275, 4113, 63, 533, 8, 888, 63, 815, 905, 3922, 3135, 398, 327, 650, 23709, 9051, 252, 25712, 234, 21018, 245, 2775, 26604, 165, 110, 95, 267, 3623, 275, 3623, 63, 533, 8, 888, 63, 815, 905, 2775, 2255, 7256, 63, 493, 63, 354, 12, 4113, 12, 22925, 63, 1258, 12, 2784, 63, 354, 9, 398, 327, 841, 23709, 14082, 123, 27029, 14333, 249, 24744, 242, 26604, 165, 110, 95, 267, 22925, 63, 1258, 14, 409, 63, 2775, 8, 2775, 9, 398, 1830, 715, 26, 288, 340, 440, 3623, 14, 374, 23692, 837, 355, 2512, 14, 815, 480, 2775, 13201, 250, 30664, 162, 224, 251, 17627, 96, 12356, 10770, 236, 22737, 8197, 108, 31001, 20061, 531, 355, 3623, 14, 928, 342, 953, 340, 440, 22925, 63, 1258, 14, 374, 23692, 837, 355, 2512, 14, 815, 480, 19214, 13201, 250, 30664, 162, 224, 251, 17627, 96, 12356, 10770, 236, 22737, 8197, 108, 31001, 20061, 531, 355, 22925, 63, 1258, 14, 928, 342, 288, 2512, 14, 1757, 480, 19580, 102, 14152, 11546, 227, 24946, 21872, 15771, 254, 531, 288, 900, 14, 4532, 8, 18, 9, 199, 199, 3, 221, 4344, 8698, 230, 122, 12211, 199, 318, 2446, 8, 3020, 304, 272, 4422, 63, 493, 63, 515, 275, 3286, 2791, 3149, 83, 14, 3150, 2, 450, 3589, 63, 354, 272, 3839, 63, 493, 63, 515, 275, 3286, 2791, 3149, 83, 14, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
DirkHoffmann/indico
indico/modules/events/posters.py
4
2466
# This file is part of Indico. # Copyright (C) 2002 - 2021 CERN # # Indico is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see the # LICENSE file for more details. from collections import namedtuple from reportlab.lib.units import cm from reportlab.lib.utils import ImageReader from indico.modules.designer import PageOrientation from indico.modules.designer.pdf import DesignerPDFBase from indico.util.placeholders import get_placeholders ConfigData = namedtuple('ConfigData', ['margin_horizontal', 'margin_vertical', 'page_size', 'page_orientation']) class PosterPDF(DesignerPDFBase): def __init__(self, template, config, event): super().__init__(template, config) self.event = event def _build_config(self, config_data): return ConfigData(page_orientation=PageOrientation.portrait, **config_data) def _build_pdf(self, canvas): config = self.config tpl_data = self.tpl_data if self.template.background_image: with self.template.background_image.open() as f: self._draw_background(canvas, ImageReader(self._remove_transparency(f)), tpl_data, config.margin_horizontal, config.margin_vertical, tpl_data.width_cm * cm, tpl_data.height_cm * cm) placeholders = get_placeholders('designer-fields') for item in tpl_data.items: placeholder = placeholders.get(item['type']) if placeholder: if placeholder.group == 'event': text = placeholder.render(self.event) else: continue elif item.get('text') is not None: text = item['text'] self._draw_item(canvas, item, tpl_data, text, config.margin_horizontal, config.margin_vertical) def _draw_poster(self, canvas, registration, pos_x, pos_y): """ Draw a badge for a given registration, at position pos_x, pos_y (top-left corner). """ config = self.config tpl_data = self.tpl_data badge_rect = (pos_x, self.height - pos_y - tpl_data.height_cm * cm, tpl_data.width_cm * cm, tpl_data.height_cm * cm) if config.dashed_border: canvas.saveState() canvas.setDash(1, 5) canvas.rect(*badge_rect) canvas.restoreState()
gpl-3.0
[ 3, 961, 570, 365, 1777, 402, 1010, 27347, 14, 199, 3, 1898, 334, 35, 9, 14790, 446, 499, 15385, 24354, 199, 3, 199, 3, 1010, 27347, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 10697, 844, 27, 1937, 314, 199, 3, 5113, 570, 367, 1655, 2436, 14, 199, 199, 504, 5055, 492, 12863, 199, 199, 504, 21773, 14, 773, 14, 5260, 492, 6904, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 504, 2539, 331, 14, 3112, 14, 14748, 281, 492, 10331, 27536, 199, 504, 2539, 331, 14, 3112, 14, 14748, 281, 14, 5607, 492, 1487, 25399, 7638, 1563, 199, 504, 2539, 331, 14, 1974, 14, 22100, 492, 664, 63, 22100, 421, 199, 2028, 1451, 275, 12863, 360, 2028, 1451, 297, 788, 9650, 63, 11392, 297, 283, 9650, 63, 7870, 297, 283, 1606, 63, 890, 297, 283, 1606, 63, 17001, 1105, 421, 199, 533, 25987, 351, 7638, 8, 20924, 281, 7638, 1563, 304, 339, 347, 636, 826, 721, 277, 12, 1978, 12, 1101, 12, 1566, 304, 267, 1613, 11027, 826, 721, 1160, 12, 1101, 9, 267, 291, 14, 1430, 275, 1566, 339, 347, 485, 1506, 63, 888, 8, 277, 12, 1101, 63, 576, 304, 267, 372, 4094, 1451, 8, 1606, 63, 17001, 29, 3276, 27536, 14, 719, 29179, 12, 1011, 888, 63, 576, 9, 339, 347, 485, 1506, 63, 5607, 8, 277, 12, 10218, 304, 267, 1101, 275, 291, 14, 888, 267, 20223, 63, 576, 275, 291, 14, 15436, 63, 576, 398, 340, 291, 14, 1160, 14, 7451, 63, 1569, 26, 288, 543, 291, 14, 1160, 14, 7451, 63, 1569, 14, 1490, 342, 465, 289, 26, 355, 291, 423, 5485, 63, 7451, 8, 7682, 12, 6047, 5929, 8, 277, 423, 2168, 63, 1515, 27292, 8, 70, 1826, 20223, 63, 576, 12, 4228, 1101, 14, 9650, 63, 11392, 12, 1101, 14, 9650, 63, 7870, 12, 4228, 20223, 63, 576, 14, 2063, 63, 4400, 627, 6904, 12, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 9, 398, 24987, 275, 664, 63, 22100, 360, 14748, 281, 13, 955, 358, 398, 367, 1242, 315, 20223, 63, 576, 14, 1744, 26, 288, 10069, 275, 24987, 14, 362, 8, 1053, 459, 466, 1105, 953, 340, 10069, 26, 355, 340, 10069, 14, 923, 508, 283, 1430, 356, 490, 1318, 275, 10069, 14, 3352, 8, 277, 14, 1430, 9, 355, 587, 26, 490, 1980, 288, 916, 1242, 14, 362, 360, 505, 358, 365, 440, 488, 26, 355, 1318, 275, 1242, 459, 505, 418, 953, 291, 423, 5485, 63, 1053, 8, 7682, 12, 1242, 12, 20223, 63, 576, 12, 1318, 12, 1101, 14, 9650, 63, 11392, 12, 1101, 14, 9650, 63, 7870, 9, 339, 347, 485, 5485, 63, 20801, 8, 277, 12, 10218, 12, 10991, 12, 2086, 63, 88, 12, 2086, 63, 89, 304, 267, 408, 267, 17813, 282, 23122, 367, 282, 1627, 10991, 12, 737, 3421, 2086, 63, 88, 12, 267, 2086, 63, 89, 334, 2119, 13, 3039, 17703, 680, 267, 408, 267, 1101, 275, 291, 14, 888, 267, 20223, 63, 576, 275, 291, 14, 15436, 63, 576, 398, 23122, 63, 1201, 275, 334, 1712, 63, 88, 12, 291, 14, 3333, 446, 2086, 63, 89, 446, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 12, 1993, 20223, 63, 576, 14, 2063, 63, 4400, 627, 6904, 12, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 9, 398, 340, 1101, 14, 6760, 379, 63, 8665, 26, 288, 10218, 14, 2117, 2223, 342, 288, 10218, 14, 409, 16659, 8, 17, 12, 959, 9, 288, 10218, 14, 1201, 2031, 18465, 63, 1201, 9, 288, 10218, 14, 8011, 2223, 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 ]
[ 961, 570, 365, 1777, 402, 1010, 27347, 14, 199, 3, 1898, 334, 35, 9, 14790, 446, 499, 15385, 24354, 199, 3, 199, 3, 1010, 27347, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 10697, 844, 27, 1937, 314, 199, 3, 5113, 570, 367, 1655, 2436, 14, 199, 199, 504, 5055, 492, 12863, 199, 199, 504, 21773, 14, 773, 14, 5260, 492, 6904, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 504, 2539, 331, 14, 3112, 14, 14748, 281, 492, 10331, 27536, 199, 504, 2539, 331, 14, 3112, 14, 14748, 281, 14, 5607, 492, 1487, 25399, 7638, 1563, 199, 504, 2539, 331, 14, 1974, 14, 22100, 492, 664, 63, 22100, 421, 199, 2028, 1451, 275, 12863, 360, 2028, 1451, 297, 788, 9650, 63, 11392, 297, 283, 9650, 63, 7870, 297, 283, 1606, 63, 890, 297, 283, 1606, 63, 17001, 1105, 421, 199, 533, 25987, 351, 7638, 8, 20924, 281, 7638, 1563, 304, 339, 347, 636, 826, 721, 277, 12, 1978, 12, 1101, 12, 1566, 304, 267, 1613, 11027, 826, 721, 1160, 12, 1101, 9, 267, 291, 14, 1430, 275, 1566, 339, 347, 485, 1506, 63, 888, 8, 277, 12, 1101, 63, 576, 304, 267, 372, 4094, 1451, 8, 1606, 63, 17001, 29, 3276, 27536, 14, 719, 29179, 12, 1011, 888, 63, 576, 9, 339, 347, 485, 1506, 63, 5607, 8, 277, 12, 10218, 304, 267, 1101, 275, 291, 14, 888, 267, 20223, 63, 576, 275, 291, 14, 15436, 63, 576, 398, 340, 291, 14, 1160, 14, 7451, 63, 1569, 26, 288, 543, 291, 14, 1160, 14, 7451, 63, 1569, 14, 1490, 342, 465, 289, 26, 355, 291, 423, 5485, 63, 7451, 8, 7682, 12, 6047, 5929, 8, 277, 423, 2168, 63, 1515, 27292, 8, 70, 1826, 20223, 63, 576, 12, 4228, 1101, 14, 9650, 63, 11392, 12, 1101, 14, 9650, 63, 7870, 12, 4228, 20223, 63, 576, 14, 2063, 63, 4400, 627, 6904, 12, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 9, 398, 24987, 275, 664, 63, 22100, 360, 14748, 281, 13, 955, 358, 398, 367, 1242, 315, 20223, 63, 576, 14, 1744, 26, 288, 10069, 275, 24987, 14, 362, 8, 1053, 459, 466, 1105, 953, 340, 10069, 26, 355, 340, 10069, 14, 923, 508, 283, 1430, 356, 490, 1318, 275, 10069, 14, 3352, 8, 277, 14, 1430, 9, 355, 587, 26, 490, 1980, 288, 916, 1242, 14, 362, 360, 505, 358, 365, 440, 488, 26, 355, 1318, 275, 1242, 459, 505, 418, 953, 291, 423, 5485, 63, 1053, 8, 7682, 12, 1242, 12, 20223, 63, 576, 12, 1318, 12, 1101, 14, 9650, 63, 11392, 12, 1101, 14, 9650, 63, 7870, 9, 339, 347, 485, 5485, 63, 20801, 8, 277, 12, 10218, 12, 10991, 12, 2086, 63, 88, 12, 2086, 63, 89, 304, 267, 408, 267, 17813, 282, 23122, 367, 282, 1627, 10991, 12, 737, 3421, 2086, 63, 88, 12, 267, 2086, 63, 89, 334, 2119, 13, 3039, 17703, 680, 267, 408, 267, 1101, 275, 291, 14, 888, 267, 20223, 63, 576, 275, 291, 14, 15436, 63, 576, 398, 23122, 63, 1201, 275, 334, 1712, 63, 88, 12, 291, 14, 3333, 446, 2086, 63, 89, 446, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 12, 1993, 20223, 63, 576, 14, 2063, 63, 4400, 627, 6904, 12, 20223, 63, 576, 14, 3333, 63, 4400, 627, 6904, 9, 398, 340, 1101, 14, 6760, 379, 63, 8665, 26, 288, 10218, 14, 2117, 2223, 342, 288, 10218, 14, 409, 16659, 8, 17, 12, 959, 9, 288, 10218, 14, 1201, 2031, 18465, 63, 1201, 9, 288, 10218, 14, 8011, 2223, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thnee/ansible
test/units/template/test_safe_eval.py
58
1820
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import sys from collections import defaultdict from units.compat import unittest from ansible.template.safe_eval import safe_eval class TestSafeEval(unittest.TestCase): def test_safe_eval_usage(self): # test safe eval calls with different possible types for the # locals dictionary, to ensure we don't run into problems like # ansible/ansible/issues/12206 again for locals_vars in (dict(), defaultdict(dict)): self.assertEqual(safe_eval('True', locals=locals_vars), True) self.assertEqual(safe_eval('False', locals=locals_vars), False) self.assertEqual(safe_eval('0', locals=locals_vars), 0) self.assertEqual(safe_eval('[]', locals=locals_vars), []) self.assertEqual(safe_eval('{}', locals=locals_vars), {}) @unittest.skipUnless(sys.version_info[:2] >= (2, 7), "Python 2.6 has no set literals") def test_set_literals(self): self.assertEqual(safe_eval('{0}'), set([0]))
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 504, 6204, 14, 5819, 492, 2882, 199, 504, 3242, 14, 1160, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 421, 199, 533, 1379, 11090, 10006, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 3489, 63, 2579, 63, 3807, 8, 277, 304, 267, 327, 511, 5048, 3468, 4882, 543, 3365, 3962, 2943, 367, 314, 267, 327, 9480, 2600, 12, 370, 4868, 781, 2793, 1133, 1255, 1901, 8826, 2839, 267, 327, 3242, 15, 4853, 15, 10115, 15, 713, 11089, 4020, 267, 367, 9480, 63, 2936, 315, 334, 807, 1062, 10018, 8, 807, 2298, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 549, 297, 9480, 29, 9350, 63, 2936, 395, 715, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 797, 297, 9480, 29, 9350, 63, 2936, 395, 756, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 16, 297, 9480, 29, 9350, 63, 2936, 395, 378, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 11894, 4300, 9480, 29, 9350, 63, 2936, 395, 3073, 288, 291, 14, 629, 8, 3489, 63, 2579, 17519, 297, 9480, 29, 9350, 63, 2936, 395, 5009, 339, 768, 2796, 14, 11278, 8, 1274, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 18, 12, 1520, 395, 298, 4718, 499, 14, 22, 965, 949, 663, 18041, 531, 272, 347, 511, 63, 409, 63, 5955, 8, 277, 304, 267, 291, 14, 629, 8, 3489, 63, 2579, 11117, 16, 93, 659, 663, 779, 16, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 504, 6204, 14, 5819, 492, 2882, 199, 504, 3242, 14, 1160, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 421, 199, 533, 1379, 11090, 10006, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 3489, 63, 2579, 63, 3807, 8, 277, 304, 267, 327, 511, 5048, 3468, 4882, 543, 3365, 3962, 2943, 367, 314, 267, 327, 9480, 2600, 12, 370, 4868, 781, 2793, 1133, 1255, 1901, 8826, 2839, 267, 327, 3242, 15, 4853, 15, 10115, 15, 713, 11089, 4020, 267, 367, 9480, 63, 2936, 315, 334, 807, 1062, 10018, 8, 807, 2298, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 549, 297, 9480, 29, 9350, 63, 2936, 395, 715, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 797, 297, 9480, 29, 9350, 63, 2936, 395, 756, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 360, 16, 297, 9480, 29, 9350, 63, 2936, 395, 378, 9, 288, 291, 14, 629, 8, 3489, 63, 2579, 11894, 4300, 9480, 29, 9350, 63, 2936, 395, 3073, 288, 291, 14, 629, 8, 3489, 63, 2579, 17519, 297, 9480, 29, 9350, 63, 2936, 395, 5009, 339, 768, 2796, 14, 11278, 8, 1274, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 18, 12, 1520, 395, 298, 4718, 499, 14, 22, 965, 949, 663, 18041, 531, 272, 347, 511, 63, 409, 63, 5955, 8, 277, 304, 267, 291, 14, 629, 8, 3489, 63, 2579, 11117, 16, 93, 659, 663, 779, 16, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
abferm/libqmi
build-aux/qmi-codegen/MessageList.py
6
9514
#!/usr/bin/env python # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation; 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright (C) 2012 Lanedo GmbH # import string from Message import Message import utils """ The MessageList class handles the generation of all messages for a given specific service """ class MessageList: """ Constructor """ def __init__(self, objects_dictionary, common_objects_dictionary): self.list = [] self.message_id_enum_name = None self.indication_id_enum_name = None self.service = None # Loop items in the list, creating Message objects for the messages # and looking for the special 'Message-ID-Enum' type for object_dictionary in objects_dictionary: if object_dictionary['type'] == 'Message' or \ object_dictionary['type'] == 'Indication': message = Message(object_dictionary, common_objects_dictionary) self.list.append(message) elif object_dictionary['type'] == 'Message-ID-Enum': self.message_id_enum_name = object_dictionary['name'] elif object_dictionary['type'] == 'Indication-ID-Enum': self.indication_id_enum_name = object_dictionary['name'] elif object_dictionary['type'] == 'Service': self.service = object_dictionary['name'] # We NEED the Message-ID-Enum field if self.message_id_enum_name is None: raise ValueError('Missing Message-ID-Enum field') # We NEED the Service field if self.service is None: raise ValueError('Missing Service field') """ Emit the enumeration of the messages found in the specific service """ def emit_message_ids_enum(self, f): translations = { 'enum_type' : utils.build_camelcase_name (self.message_id_enum_name) } template = ( '\n' 'typedef enum {\n') for message in self.list: if message.type == 'Message': translations['enum_name'] = message.id_enum_name translations['enum_value'] = message.id enum_template = ( ' ${enum_name} = ${enum_value},\n') template += string.Template(enum_template).substitute(translations) template += ( '} ${enum_type};\n' '\n') f.write(string.Template(template).substitute(translations)) """ Emit the enumeration of the indications found in the specific service """ def emit_indication_ids_enum(self, f): translations = { 'enum_type' : utils.build_camelcase_name (self.indication_id_enum_name) } template = ( '\n' 'typedef enum {\n') for message in self.list: if message.type == 'Indication': translations['enum_name'] = message.id_enum_name translations['enum_value'] = message.id enum_template = ( ' ${enum_name} = ${enum_value},\n') template += string.Template(enum_template).substitute(translations) template += ( '} ${enum_type};\n' '\n') f.write(string.Template(template).substitute(translations)) """ Emit the method responsible for getting a printable representation of all messages of a given service. """ def __emit_get_printable(self, hfile, cfile): translations = { 'service' : self.service.lower() } template = ( '\n' '#if defined (LIBQMI_GLIB_COMPILATION)\n' '\n' 'G_GNUC_INTERNAL\n' 'gchar *__qmi_message_${service}_get_printable (\n' ' QmiMessage *self,\n' ' const gchar *line_prefix);\n' '\n' '#endif\n' '\n') hfile.write(string.Template(template).substitute(translations)) template = ( '\n' 'gchar *\n' '__qmi_message_${service}_get_printable (\n' ' QmiMessage *self,\n' ' const gchar *line_prefix)\n' '{\n' ' if (qmi_message_is_indication (self)) {\n' ' switch (qmi_message_get_message_id (self)) {\n') for message in self.list: if message.type == 'Indication': translations['enum_name'] = message.id_enum_name translations['message_underscore'] = utils.build_underscore_name (message.name) translations['enum_value'] = message.id inner_template = ( ' case ${enum_name}:\n' ' return indication_${message_underscore}_get_printable (self, line_prefix);\n') template += string.Template(inner_template).substitute(translations) template += ( ' default:\n' ' return NULL;\n' ' }\n' ' } else {\n' ' switch (qmi_message_get_message_id (self)) {\n') for message in self.list: if message.type == 'Message': translations['enum_name'] = message.id_enum_name translations['message_underscore'] = utils.build_underscore_name (message.name) translations['enum_value'] = message.id inner_template = ( ' case ${enum_name}:\n' ' return message_${message_underscore}_get_printable (self, line_prefix);\n') template += string.Template(inner_template).substitute(translations) template += ( ' default:\n' ' return NULL;\n' ' }\n' ' }\n' '}\n') cfile.write(string.Template(template).substitute(translations)) """ Emit the method responsible for getting in which version the messages were introduced. """ def __emit_get_version_introduced(self, hfile, cfile): translations = { 'service' : self.service.lower() } template = ( '\n' '#if defined (LIBQMI_GLIB_COMPILATION)\n' '\n' 'G_GNUC_INTERNAL\n' 'gboolean __qmi_message_${service}_get_version_introduced (\n' ' QmiMessage *self,\n' ' guint *major,\n' ' guint *minor);\n' '\n' '#endif\n' '\n') hfile.write(string.Template(template).substitute(translations)) template = ( '\n' 'gboolean\n' '__qmi_message_${service}_get_version_introduced (\n' ' QmiMessage *self,\n' ' guint *major,\n' ' guint *minor)\n' '{\n' ' switch (qmi_message_get_message_id (self)) {\n') for message in self.list: if message.type == 'Message': # Only add if we know the version info if message.version_info != []: translations['enum_name'] = message.id_enum_name translations['message_major'] = message.version_info[0] translations['message_minor'] = message.version_info[1] inner_template = ( ' case ${enum_name}:\n' ' *major = ${message_major};\n' ' *minor = ${message_minor};\n' ' return TRUE;\n') template += string.Template(inner_template).substitute(translations) template += ( ' default:\n' ' return FALSE;\n' ' }\n' '}\n') cfile.write(string.Template(template).substitute(translations)) """ Emit the message list handling implementation """ def emit(self, hfile, cfile): # First, emit the message/indication IDs enum self.emit_message_ids_enum(cfile) if self.indication_id_enum_name is not None: self.emit_indication_ids_enum(cfile) # Then, emit all message handlers for message in self.list: message.emit(hfile, cfile) # First, emit common class code utils.add_separator(hfile, 'Service-specific printable', self.service); utils.add_separator(cfile, 'Service-specific printable', self.service); self.__emit_get_printable(hfile, cfile) self.__emit_get_version_introduced(hfile, cfile) """ Emit the sections """ def emit_sections(self, sfile): # Emit all message sections for message in self.list: message.emit_sections(sfile)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 32644, 27, 286, 13, 4316, 13, 2743, 26, 841, 1882, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 491, 290, 379, 79, 23428, 199, 3, 199, 199, 646, 1059, 199, 199, 504, 6430, 492, 6430, 199, 646, 3778, 199, 199, 624, 199, 1918, 6430, 1296, 1021, 10022, 314, 10152, 402, 1006, 3788, 367, 282, 1627, 199, 6100, 2435, 199, 624, 199, 533, 6430, 1296, 26, 339, 408, 272, 20297, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2251, 63, 9086, 12, 2863, 63, 1462, 63, 9086, 304, 267, 291, 14, 513, 275, 942, 267, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 275, 488, 267, 291, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 275, 488, 267, 291, 14, 1364, 275, 488, 398, 327, 18175, 2974, 315, 314, 769, 12, 6425, 6430, 2251, 367, 314, 3788, 267, 327, 436, 10023, 367, 314, 4539, 283, 2209, 13, 998, 13, 5081, 7, 730, 267, 367, 909, 63, 9086, 315, 2251, 63, 9086, 26, 288, 340, 909, 63, 9086, 459, 466, 418, 508, 283, 2209, 7, 503, 971, 2049, 909, 63, 9086, 459, 466, 418, 508, 283, 607, 21171, 356, 355, 1245, 275, 6430, 8, 785, 63, 9086, 12, 2863, 63, 1462, 63, 9086, 9, 355, 291, 14, 513, 14, 740, 8, 1188, 9, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 2209, 13, 998, 13, 5081, 356, 355, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 275, 909, 63, 9086, 459, 354, 418, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 607, 21171, 13, 998, 13, 5081, 356, 355, 291, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 275, 909, 63, 9086, 459, 354, 418, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 3167, 356, 355, 291, 14, 1364, 275, 909, 63, 9086, 459, 354, 418, 398, 327, 2136, 7110, 1149, 314, 6430, 13, 998, 13, 5081, 901, 267, 340, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 365, 488, 26, 288, 746, 1722, 360, 7718, 6430, 13, 998, 13, 5081, 901, 358, 398, 327, 2136, 7110, 1149, 314, 7591, 901, 267, 340, 291, 14, 1364, 365, 488, 26, 288, 746, 1722, 360, 7718, 7591, 901, 358, 2378, 408, 272, 662, 1147, 314, 28640, 402, 314, 3788, 1911, 315, 314, 2488, 2435, 272, 408, 272, 347, 8689, 63, 1188, 63, 1580, 63, 4869, 8, 277, 12, 289, 304, 267, 15547, 275, 469, 283, 4869, 63, 466, 7, 520, 3778, 14, 1506, 63, 22997, 2546, 63, 354, 334, 277, 14, 1188, 63, 344, 63, 4869, 63, 354, 9, 789, 267, 1978, 275, 334, 288, 1557, 78, 7, 288, 283, 9594, 4952, 9459, 78, 358, 267, 367, 1245, 315, 291, 14, 513, 26, 288, 340, 1245, 14, 466, 508, 283, 2209, 356, 355, 15547, 459, 4869, 63, 354, 418, 275, 1245, 14, 344, 63, 4869, 63, 354, 355, 15547, 459, 4869, 63, 585, 418, 275, 1245, 14, 344, 355, 4952, 63, 1160, 275, 334, 490, 283, 259, 10839, 4869, 63, 354, 93, 275, 10839, 4869, 63, 585, 1386, 60, 78, 358, 355, 1978, 847, 1059, 14, 4231, 8, 4869, 63, 1160, 680, 20374, 8, 13982, 9, 398, 1978, 847, 334, 288, 28544, 10839, 4869, 63, 466, 16055, 78, 7, 288, 1557, 78, 358, 267, 289, 14, 952, 8, 875, 14, 4231, 8, 1160, 680, 20374, 8, 13982, 430, 339, 408, 272, 662, 1147, 314, 28640, 402, 314, 2539, 1063, 83, 1911, 315, 314, 2488, 2435, 272, 408, 272, 347, 8689, 63, 3558, 1063, 63, 1580, 63, 4869, 8, 277, 12, 289, 304, 267, 15547, 275, 469, 283, 4869, 63, 466, 7, 520, 3778, 14, 1506, 63, 22997, 2546, 63, 354, 334, 277, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 9, 789, 267, 1978, 275, 334, 288, 1557, 78, 7, 288, 283, 9594, 4952, 9459, 78, 358, 267, 367, 1245, 315, 291, 14, 513, 26, 288, 340, 1245, 14, 466, 508, 283, 607, 21171, 356, 355, 15547, 459, 4869, 63, 354, 418, 275, 1245, 14, 344, 63, 4869, 63, 354, 355, 15547, 459, 4869, 63, 585, 418, 275, 1245, 14, 344, 355, 4952, 63, 1160, 275, 334, 490, 283, 259, 10839, 4869, 63, 354, 93, 275, 10839, 4869, 63, 585, 1386, 60, 78, 358, 355, 1978, 847, 1059, 14, 4231, 8, 4869, 63, 1160, 680, 20374, 8, 13982, 9, 398, 1978, 847, 334, 288, 28544, 10839, 4869, 63, 466, 16055, 78, 7, 288, 1557, 78, 358, 267, 289, 14, 952, 8, 875, 14, 4231, 8, 1160, 680, 20374, 8, 13982, 430, 2378, 408, 272, 662, 1147, 314, 1083, 17845, 367, 10232, 282, 21834, 6025, 402, 1006, 272, 3788, 402, 282, 1627, 2435, 14, 272, 408, 272, 347, 636, 8159, 63, 362, 63, 20557, 8, 277, 12, 394, 493, 12, 286, 493, 304, 267, 15547, 275, 469, 283, 1364, 7, 259, 520, 291, 14, 1364, 14, 2325, 342, 789, 398, 1978, 275, 334, 288, 1557, 78, 7, 288, 3943, 692, 3247, 334, 5617, 49, 10709, 63, 2226, 2100, 63, 6790, 1193, 2594 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 32644, 27, 286, 13, 4316, 13, 2743, 26, 841, 1882, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 491, 290, 379, 79, 23428, 199, 3, 199, 199, 646, 1059, 199, 199, 504, 6430, 492, 6430, 199, 646, 3778, 199, 199, 624, 199, 1918, 6430, 1296, 1021, 10022, 314, 10152, 402, 1006, 3788, 367, 282, 1627, 199, 6100, 2435, 199, 624, 199, 533, 6430, 1296, 26, 339, 408, 272, 20297, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2251, 63, 9086, 12, 2863, 63, 1462, 63, 9086, 304, 267, 291, 14, 513, 275, 942, 267, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 275, 488, 267, 291, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 275, 488, 267, 291, 14, 1364, 275, 488, 398, 327, 18175, 2974, 315, 314, 769, 12, 6425, 6430, 2251, 367, 314, 3788, 267, 327, 436, 10023, 367, 314, 4539, 283, 2209, 13, 998, 13, 5081, 7, 730, 267, 367, 909, 63, 9086, 315, 2251, 63, 9086, 26, 288, 340, 909, 63, 9086, 459, 466, 418, 508, 283, 2209, 7, 503, 971, 2049, 909, 63, 9086, 459, 466, 418, 508, 283, 607, 21171, 356, 355, 1245, 275, 6430, 8, 785, 63, 9086, 12, 2863, 63, 1462, 63, 9086, 9, 355, 291, 14, 513, 14, 740, 8, 1188, 9, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 2209, 13, 998, 13, 5081, 356, 355, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 275, 909, 63, 9086, 459, 354, 418, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 607, 21171, 13, 998, 13, 5081, 356, 355, 291, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 275, 909, 63, 9086, 459, 354, 418, 288, 916, 909, 63, 9086, 459, 466, 418, 508, 283, 3167, 356, 355, 291, 14, 1364, 275, 909, 63, 9086, 459, 354, 418, 398, 327, 2136, 7110, 1149, 314, 6430, 13, 998, 13, 5081, 901, 267, 340, 291, 14, 1188, 63, 344, 63, 4869, 63, 354, 365, 488, 26, 288, 746, 1722, 360, 7718, 6430, 13, 998, 13, 5081, 901, 358, 398, 327, 2136, 7110, 1149, 314, 7591, 901, 267, 340, 291, 14, 1364, 365, 488, 26, 288, 746, 1722, 360, 7718, 7591, 901, 358, 2378, 408, 272, 662, 1147, 314, 28640, 402, 314, 3788, 1911, 315, 314, 2488, 2435, 272, 408, 272, 347, 8689, 63, 1188, 63, 1580, 63, 4869, 8, 277, 12, 289, 304, 267, 15547, 275, 469, 283, 4869, 63, 466, 7, 520, 3778, 14, 1506, 63, 22997, 2546, 63, 354, 334, 277, 14, 1188, 63, 344, 63, 4869, 63, 354, 9, 789, 267, 1978, 275, 334, 288, 1557, 78, 7, 288, 283, 9594, 4952, 9459, 78, 358, 267, 367, 1245, 315, 291, 14, 513, 26, 288, 340, 1245, 14, 466, 508, 283, 2209, 356, 355, 15547, 459, 4869, 63, 354, 418, 275, 1245, 14, 344, 63, 4869, 63, 354, 355, 15547, 459, 4869, 63, 585, 418, 275, 1245, 14, 344, 355, 4952, 63, 1160, 275, 334, 490, 283, 259, 10839, 4869, 63, 354, 93, 275, 10839, 4869, 63, 585, 1386, 60, 78, 358, 355, 1978, 847, 1059, 14, 4231, 8, 4869, 63, 1160, 680, 20374, 8, 13982, 9, 398, 1978, 847, 334, 288, 28544, 10839, 4869, 63, 466, 16055, 78, 7, 288, 1557, 78, 358, 267, 289, 14, 952, 8, 875, 14, 4231, 8, 1160, 680, 20374, 8, 13982, 430, 339, 408, 272, 662, 1147, 314, 28640, 402, 314, 2539, 1063, 83, 1911, 315, 314, 2488, 2435, 272, 408, 272, 347, 8689, 63, 3558, 1063, 63, 1580, 63, 4869, 8, 277, 12, 289, 304, 267, 15547, 275, 469, 283, 4869, 63, 466, 7, 520, 3778, 14, 1506, 63, 22997, 2546, 63, 354, 334, 277, 14, 3558, 1063, 63, 344, 63, 4869, 63, 354, 9, 789, 267, 1978, 275, 334, 288, 1557, 78, 7, 288, 283, 9594, 4952, 9459, 78, 358, 267, 367, 1245, 315, 291, 14, 513, 26, 288, 340, 1245, 14, 466, 508, 283, 607, 21171, 356, 355, 15547, 459, 4869, 63, 354, 418, 275, 1245, 14, 344, 63, 4869, 63, 354, 355, 15547, 459, 4869, 63, 585, 418, 275, 1245, 14, 344, 355, 4952, 63, 1160, 275, 334, 490, 283, 259, 10839, 4869, 63, 354, 93, 275, 10839, 4869, 63, 585, 1386, 60, 78, 358, 355, 1978, 847, 1059, 14, 4231, 8, 4869, 63, 1160, 680, 20374, 8, 13982, 9, 398, 1978, 847, 334, 288, 28544, 10839, 4869, 63, 466, 16055, 78, 7, 288, 1557, 78, 358, 267, 289, 14, 952, 8, 875, 14, 4231, 8, 1160, 680, 20374, 8, 13982, 430, 2378, 408, 272, 662, 1147, 314, 1083, 17845, 367, 10232, 282, 21834, 6025, 402, 1006, 272, 3788, 402, 282, 1627, 2435, 14, 272, 408, 272, 347, 636, 8159, 63, 362, 63, 20557, 8, 277, 12, 394, 493, 12, 286, 493, 304, 267, 15547, 275, 469, 283, 1364, 7, 259, 520, 291, 14, 1364, 14, 2325, 342, 789, 398, 1978, 275, 334, 288, 1557, 78, 7, 288, 3943, 692, 3247, 334, 5617, 49, 10709, 63, 2226, 2100, 63, 6790, 1193, 2594, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
debugger87/spark
examples/src/main/python/sql/hive.py
24
3317
# # 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. # """ A simple example demonstrating Spark SQL Hive integration. Run with: ./bin/spark-submit examples/src/main/python/sql/hive.py """ from __future__ import print_function # $example on:spark_hive$ from os.path import expanduser, join, abspath from pyspark.sql import SparkSession from pyspark.sql import Row # $example off:spark_hive$ if __name__ == "__main__": # $example on:spark_hive$ # warehouse_location points to the default location for managed databases and tables warehouse_location = abspath('spark-warehouse') spark = SparkSession \ .builder \ .appName("Python Spark SQL Hive integration example") \ .config("spark.sql.warehouse.dir", warehouse_location) \ .enableHiveSupport() \ .getOrCreate() # spark is an existing SparkSession spark.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING) USING hive") spark.sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src") # Queries are expressed in HiveQL spark.sql("SELECT * FROM src").show() # +---+-------+ # |key| value| # +---+-------+ # |238|val_238| # | 86| val_86| # |311|val_311| # ... # Aggregation queries are also supported. spark.sql("SELECT COUNT(*) FROM src").show() # +--------+ # |count(1)| # +--------+ # | 500 | # +--------+ # The results of SQL queries are themselves DataFrames and support all normal functions. sqlDF = spark.sql("SELECT key, value FROM src WHERE key < 10 ORDER BY key") # The items in DataFrames are of type Row, which allows you to access each column by ordinal. stringsDS = sqlDF.rdd.map(lambda row: "Key: %d, Value: %s" % (row.key, row.value)) for record in stringsDS.collect(): print(record) # Key: 0, Value: val_0 # Key: 0, Value: val_0 # Key: 0, Value: val_0 # ... # You can also use DataFrames to create temporary views within a SparkSession. Record = Row("key", "value") recordsDF = spark.createDataFrame([Record(i, "val_" + str(i)) for i in range(1, 101)]) recordsDF.createOrReplaceTempView("records") # Queries can then join DataFrame data with data stored in Hive. spark.sql("SELECT * FROM records r JOIN src s ON r.key = s.key").show() # +---+------+---+------+ # |key| value|key| value| # +---+------+---+------+ # | 2| val_2| 2| val_2| # | 4| val_4| 4| val_4| # | 5| val_5| 5| val_5| # ... # $example off:spark_hive$ spark.stop()
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, 624, 199, 33, 3486, 2893, 23789, 495, 1958, 13932, 5385, 869, 1912, 13150, 14, 199, 2540, 543, 26, 523, 16605, 1393, 15, 9852, 13, 7275, 7251, 15, 2164, 15, 973, 15, 1548, 15, 3009, 15, 17230, 14, 647, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 2672, 2694, 641, 26, 9852, 63, 17230, 4, 199, 504, 747, 14, 515, 492, 6544, 751, 12, 4263, 12, 19529, 199, 199, 504, 15847, 14, 3009, 492, 13932, 4434, 199, 504, 15847, 14, 3009, 492, 15231, 199, 3, 2672, 2694, 2331, 26, 9852, 63, 17230, 4, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 2672, 2694, 641, 26, 9852, 63, 17230, 4, 272, 327, 13782, 63, 1985, 4501, 370, 314, 849, 2909, 367, 12883, 16219, 436, 6716, 272, 13782, 63, 1985, 275, 19529, 360, 9852, 13, 12806, 358, 339, 15442, 275, 13932, 4434, 971, 267, 1275, 5649, 971, 267, 1275, 571, 985, 480, 4718, 13932, 5385, 869, 1912, 13150, 2893, 531, 971, 267, 1275, 888, 480, 9852, 14, 3009, 14, 12806, 14, 694, 401, 13782, 63, 1985, 9, 971, 267, 1275, 4296, 30232, 11532, 342, 971, 267, 1275, 30457, 2499, 342, 339, 327, 15442, 365, 376, 3411, 13932, 4434, 272, 15442, 14, 3009, 480, 8366, 9934, 8036, 2845, 23875, 2928, 334, 498, 16429, 12, 574, 18661, 9, 32210, 29134, 531, 272, 15442, 14, 3009, 480, 7405, 7126, 20639, 1621, 3243, 283, 8589, 15, 2164, 15, 973, 15, 4435, 15, 11475, 17, 14, 2424, 7, 12872, 9934, 2928, 531, 339, 327, 5843, 5460, 787, 19147, 315, 869, 1912, 2940, 272, 15442, 14, 3009, 480, 4859, 627, 4442, 2928, 3471, 2384, 342, 272, 327, 435, 9018, 375, 9018, 272, 327, 1204, 498, 92, 221, 574, 92, 272, 327, 435, 9018, 375, 9018, 272, 327, 1204, 12332, 92, 637, 63, 12332, 92, 272, 327, 1204, 10300, 92, 1139, 63, 1184, 92, 272, 327, 1204, 17539, 92, 637, 63, 17539, 92, 272, 327, 2263, 339, 327, 21369, 425, 9212, 787, 2597, 3748, 14, 272, 15442, 14, 3009, 480, 4859, 24903, 21565, 4442, 2928, 3471, 2384, 342, 272, 327, 435, 518, 11, 272, 327, 1204, 835, 8, 17, 8636, 272, 327, 435, 518, 11, 272, 327, 1204, 259, 6891, 1204, 272, 327, 435, 518, 11, 339, 327, 710, 2058, 402, 5385, 9212, 787, 17279, 10071, 83, 436, 2291, 1006, 3293, 3423, 14, 272, 3875, 3888, 275, 15442, 14, 3009, 480, 4859, 790, 12, 574, 4442, 2928, 6038, 790, 665, 1616, 16044, 6515, 790, 531, 339, 327, 710, 2974, 315, 10071, 83, 787, 402, 730, 15231, 12, 1314, 6127, 1265, 370, 2879, 1924, 2763, 701, 24943, 14, 272, 3326, 3177, 275, 3875, 3888, 14, 20533, 14, 1130, 8, 2734, 1962, 26, 298, 1197, 26, 450, 68, 12, 1594, 26, 450, 83, 2, 450, 334, 1143, 14, 498, 12, 1962, 14, 585, 430, 272, 367, 2777, 315, 3326, 3177, 14, 7112, 837, 267, 870, 8, 3059, 9, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2263, 339, 327, 2047, 883, 2597, 675, 10071, 83, 370, 1218, 7937, 6858, 4453, 282, 13932, 4434, 14, 272, 12651, 275, 15231, 480, 498, 401, 298, 585, 531, 272, 5767, 3888, 275, 15442, 14, 25482, 779, 5433, 8, 73, 12, 298, 637, 12172, 435, 620, 8, 73, 430, 367, 284, 315, 1425, 8, 17, 12, 14313, 3948, 272, 5767, 3888, 14, 981, 2844, 11328, 6530, 2768, 480, 6502, 531, 339, 327, 5843, 5460, 883, 2066, 4263, 10071, 666, 543, 666, 5489, 315, 869, 1912, 14, 272, 15442, 14, 3009, 480, 4859, 627, 4442, 5767, 519, 10593, 2928, 308, 5258, 519, 14, 498, 275, 308, 14, 498, 3471, 2384, 342, 272, 327, 435, 9018, 28712, 9018, 28712, 272, 327, 1204, 498, 92, 574, 92, 498, 92, 574, 92, 272, 327, 435, 9018, 28712, 9018, 28712, 272, 327, 1204, 221, 499, 92, 1139, 63, 18, 92, 221, 499, 92, 1139, 63, 18, 92, 272, 327, 1204, 221, 841, 92, 1139, 63, 20, 92, 221, 841, 92, 1139, 63, 20, 92, 272, 327, 1204, 221, 959, 92, 1139, 63, 21, 92, 221, 959, 92, 1139, 63, 21, 92, 272, 327, 2263, 272, 327, 2672, 2694, 2331, 26, 9852, 63, 17230, 4, 339, 15442, 14, 2379, 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 ]
[ 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, 624, 199, 33, 3486, 2893, 23789, 495, 1958, 13932, 5385, 869, 1912, 13150, 14, 199, 2540, 543, 26, 523, 16605, 1393, 15, 9852, 13, 7275, 7251, 15, 2164, 15, 973, 15, 1548, 15, 3009, 15, 17230, 14, 647, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 2672, 2694, 641, 26, 9852, 63, 17230, 4, 199, 504, 747, 14, 515, 492, 6544, 751, 12, 4263, 12, 19529, 199, 199, 504, 15847, 14, 3009, 492, 13932, 4434, 199, 504, 15847, 14, 3009, 492, 15231, 199, 3, 2672, 2694, 2331, 26, 9852, 63, 17230, 4, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 2672, 2694, 641, 26, 9852, 63, 17230, 4, 272, 327, 13782, 63, 1985, 4501, 370, 314, 849, 2909, 367, 12883, 16219, 436, 6716, 272, 13782, 63, 1985, 275, 19529, 360, 9852, 13, 12806, 358, 339, 15442, 275, 13932, 4434, 971, 267, 1275, 5649, 971, 267, 1275, 571, 985, 480, 4718, 13932, 5385, 869, 1912, 13150, 2893, 531, 971, 267, 1275, 888, 480, 9852, 14, 3009, 14, 12806, 14, 694, 401, 13782, 63, 1985, 9, 971, 267, 1275, 4296, 30232, 11532, 342, 971, 267, 1275, 30457, 2499, 342, 339, 327, 15442, 365, 376, 3411, 13932, 4434, 272, 15442, 14, 3009, 480, 8366, 9934, 8036, 2845, 23875, 2928, 334, 498, 16429, 12, 574, 18661, 9, 32210, 29134, 531, 272, 15442, 14, 3009, 480, 7405, 7126, 20639, 1621, 3243, 283, 8589, 15, 2164, 15, 973, 15, 4435, 15, 11475, 17, 14, 2424, 7, 12872, 9934, 2928, 531, 339, 327, 5843, 5460, 787, 19147, 315, 869, 1912, 2940, 272, 15442, 14, 3009, 480, 4859, 627, 4442, 2928, 3471, 2384, 342, 272, 327, 435, 9018, 375, 9018, 272, 327, 1204, 498, 92, 221, 574, 92, 272, 327, 435, 9018, 375, 9018, 272, 327, 1204, 12332, 92, 637, 63, 12332, 92, 272, 327, 1204, 10300, 92, 1139, 63, 1184, 92, 272, 327, 1204, 17539, 92, 637, 63, 17539, 92, 272, 327, 2263, 339, 327, 21369, 425, 9212, 787, 2597, 3748, 14, 272, 15442, 14, 3009, 480, 4859, 24903, 21565, 4442, 2928, 3471, 2384, 342, 272, 327, 435, 518, 11, 272, 327, 1204, 835, 8, 17, 8636, 272, 327, 435, 518, 11, 272, 327, 1204, 259, 6891, 1204, 272, 327, 435, 518, 11, 339, 327, 710, 2058, 402, 5385, 9212, 787, 17279, 10071, 83, 436, 2291, 1006, 3293, 3423, 14, 272, 3875, 3888, 275, 15442, 14, 3009, 480, 4859, 790, 12, 574, 4442, 2928, 6038, 790, 665, 1616, 16044, 6515, 790, 531, 339, 327, 710, 2974, 315, 10071, 83, 787, 402, 730, 15231, 12, 1314, 6127, 1265, 370, 2879, 1924, 2763, 701, 24943, 14, 272, 3326, 3177, 275, 3875, 3888, 14, 20533, 14, 1130, 8, 2734, 1962, 26, 298, 1197, 26, 450, 68, 12, 1594, 26, 450, 83, 2, 450, 334, 1143, 14, 498, 12, 1962, 14, 585, 430, 272, 367, 2777, 315, 3326, 3177, 14, 7112, 837, 267, 870, 8, 3059, 9, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2606, 26, 378, 12, 1594, 26, 1139, 63, 16, 272, 327, 2263, 339, 327, 2047, 883, 2597, 675, 10071, 83, 370, 1218, 7937, 6858, 4453, 282, 13932, 4434, 14, 272, 12651, 275, 15231, 480, 498, 401, 298, 585, 531, 272, 5767, 3888, 275, 15442, 14, 25482, 779, 5433, 8, 73, 12, 298, 637, 12172, 435, 620, 8, 73, 430, 367, 284, 315, 1425, 8, 17, 12, 14313, 3948, 272, 5767, 3888, 14, 981, 2844, 11328, 6530, 2768, 480, 6502, 531, 339, 327, 5843, 5460, 883, 2066, 4263, 10071, 666, 543, 666, 5489, 315, 869, 1912, 14, 272, 15442, 14, 3009, 480, 4859, 627, 4442, 5767, 519, 10593, 2928, 308, 5258, 519, 14, 498, 275, 308, 14, 498, 3471, 2384, 342, 272, 327, 435, 9018, 28712, 9018, 28712, 272, 327, 1204, 498, 92, 574, 92, 498, 92, 574, 92, 272, 327, 435, 9018, 28712, 9018, 28712, 272, 327, 1204, 221, 499, 92, 1139, 63, 18, 92, 221, 499, 92, 1139, 63, 18, 92, 272, 327, 1204, 221, 841, 92, 1139, 63, 20, 92, 221, 841, 92, 1139, 63, 20, 92, 272, 327, 1204, 221, 959, 92, 1139, 63, 21, 92, 221, 959, 92, 1139, 63, 21, 92, 272, 327, 2263, 272, 327, 2672, 2694, 2331, 26, 9852, 63, 17230, 4, 339, 15442, 14, 2379, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1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x/Simulation.py
1
2680
# -*- coding: utf-8 -*- def sim_normal(nums, mean = 600, sd = 30): import numpy as np import numpy.random as nr for n in nums: dist = nr.normal(loc = mean, scale = sd, size = n) titl = 'Normal distribution with ' + str(n) + ' values' print('Summary for ' + str(n) + ' samples') print(dist_summary(dist, titl)) print('Emperical 95% CIs') print(np.percentile(dist, [2.5, 97.5])) print(' ') return('Done!') def sim_poisson(nums, mean = 600): import numpy as np import numpy.random as nr for n in nums: dist = nr.poisson(lam = mean, size = n) titl = 'Poisson distribution with ' + str(n) + ' values' print(dist_summary(dist, titl)) print('Emperical 95% CIs') print(np.percentile(dist, [2.5, 97.5])) print(' ') return('Done!') def dist_summary(dist, names = 'dist_name'): import pandas as pd import matplotlib.pyplot as plt ser = pd.Series(dist) fig = plt.figure(1, figsize=(9, 6)) ax = fig.gca() ser.hist(ax = ax, bins = 120) ax.set_title('Frequency distribution of ' + names) ax.set_ylabel('Frequency') plt.show() return(ser.describe()) def gen_profits(num): import numpy.random as nr unif = nr.uniform(size = num) out = [5 if x < 0.3 else (3.5 if x < 0.6 else 4) for x in unif] return(out) def gen_tips(num): import numpy.random as nr unif = nr.uniform(size = num) out = [0 if x < 0.5 else (0.25 if x < 0.7 else (1.0 if x < 0.9 else 2.0)) for x in unif] return(out) def sim_lemonade(num, mean = 600, sd = 30, pois = False): ## Simulate the profits and tips for ## a lemonade stand. import numpy.random as nr ## number of customer arrivals if pois: arrivals = nr.poisson(lam = mean, size = num) else: arrivals = nr.normal(loc = mean, scale = sd, size = num) print(dist_summary(arrivals, 'customer arrivals per day')) ## Compute distibution of average profit per arrival proft = gen_profits(num) print(dist_summary(proft, 'profit per arrival')) ## Total profits are profit per arrival ## times number of arrivals. total_profit = arrivals * proft print(dist_summary(total_profit, 'total profit per day')) ## Compute distribution of average tips per arrival tps = gen_tips(num) print(dist_summary(tps, 'tips per arrival')) ## Compute average tips per day total_tips = arrivals * tps print(dist_summary(total_tips, 'total tips per day')) ## Compute total profits plus total tips. total_take = total_profit + total_tips return(dist_summary(total_take, 'total net per day'))
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 318, 4389, 63, 3302, 8, 16084, 12, 4615, 275, 11624, 12, 14613, 275, 4233, 304, 272, 492, 2680, 465, 980, 272, 492, 2680, 14, 2355, 465, 14762, 272, 367, 302, 315, 24047, 26, 267, 2917, 275, 14762, 14, 3302, 8, 2102, 275, 4615, 12, 4666, 275, 14613, 12, 1568, 275, 302, 9, 267, 3367, 5019, 275, 283, 6241, 4084, 543, 283, 435, 620, 8, 78, 9, 435, 283, 1338, 7, 267, 870, 360, 10407, 367, 283, 435, 620, 8, 78, 9, 435, 283, 5845, 358, 267, 870, 8, 2686, 63, 4705, 8, 2686, 12, 3367, 5019, 430, 259, 267, 870, 360, 37, 311, 281, 2652, 16102, 5, 445, 1831, 358, 267, 870, 8, 1590, 14, 21188, 8, 2686, 12, 359, 18, 14, 21, 12, 15997, 14, 21, 2459, 267, 870, 360, 5320, 272, 372, 360, 10759, 10916, 199, 199, 318, 4389, 63, 29606, 8, 16084, 12, 4615, 275, 11624, 304, 272, 492, 2680, 465, 980, 272, 492, 2680, 14, 2355, 465, 14762, 272, 367, 302, 315, 24047, 26, 267, 2917, 275, 14762, 14, 29606, 8, 17984, 275, 4615, 12, 1568, 275, 302, 9, 267, 3367, 5019, 275, 283, 1575, 18571, 4084, 543, 283, 435, 620, 8, 78, 9, 435, 283, 1338, 7, 267, 870, 8, 2686, 63, 4705, 8, 2686, 12, 3367, 5019, 430, 27144, 870, 360, 37, 311, 281, 2652, 16102, 5, 445, 1831, 358, 267, 870, 8, 1590, 14, 21188, 8, 2686, 12, 359, 18, 14, 21, 12, 15997, 14, 21, 2459, 267, 870, 360, 5320, 272, 372, 360, 10759, 10916, 199, 199, 318, 2917, 63, 4705, 8, 2686, 12, 1561, 275, 283, 2686, 63, 354, 735, 272, 492, 10634, 465, 6454, 272, 492, 8027, 14, 13563, 465, 4488, 272, 8926, 275, 6454, 14, 9641, 8, 2686, 9, 272, 6085, 275, 4488, 14, 8941, 8, 17, 12, 6085, 890, 2687, 25, 12, 1227, 430, 272, 2185, 275, 6085, 14, 71, 696, 342, 272, 8926, 14, 11141, 8, 1219, 275, 2185, 12, 13341, 275, 13960, 9, 272, 2185, 14, 409, 63, 1213, 360, 18285, 4084, 402, 283, 435, 1561, 9, 272, 2185, 14, 409, 63, 13849, 360, 18285, 358, 272, 4488, 14, 2384, 342, 272, 372, 8, 332, 14, 11935, 1012, 1362, 199, 318, 3805, 63, 496, 14948, 8, 1507, 304, 23855, 492, 2680, 14, 2355, 465, 14762, 272, 625, 692, 275, 14762, 14, 8830, 8, 890, 275, 1967, 9, 272, 734, 275, 359, 21, 340, 671, 665, 378, 14, 19, 587, 334, 19, 14, 21, 340, 671, 665, 378, 14, 22, 587, 841, 9, 367, 671, 315, 625, 692, 61, 272, 372, 8, 548, 9, 199, 199, 318, 3805, 63, 25842, 8, 1507, 304, 23855, 492, 2680, 14, 2355, 465, 14762, 272, 625, 692, 275, 14762, 14, 8830, 8, 890, 275, 1967, 9, 272, 734, 275, 359, 16, 340, 671, 665, 378, 14, 21, 587, 334, 16, 14, 821, 340, 671, 665, 378, 14, 23, 15166, 587, 334, 17, 14, 16, 340, 671, 665, 378, 14, 25, 587, 499, 14, 16, 430, 367, 671, 315, 625, 692, 61, 272, 372, 8, 548, 9, 199, 199, 318, 4389, 63, 274, 2106, 9587, 8, 1507, 12, 4615, 275, 11624, 12, 14613, 275, 4233, 12, 1115, 374, 275, 756, 304, 523, 925, 10751, 5434, 314, 557, 14948, 436, 3367, 1190, 367, 523, 925, 282, 1026, 2106, 9587, 10584, 14, 523, 492, 2680, 14, 2355, 465, 14762, 12244, 925, 1329, 402, 15229, 601, 322, 3643, 523, 340, 1115, 374, 26, 272, 601, 322, 3643, 275, 14762, 14, 29606, 8, 17984, 275, 4615, 12, 1568, 275, 1967, 9, 523, 587, 26, 2043, 601, 322, 3643, 275, 14762, 14, 3302, 8, 2102, 275, 4615, 12, 4666, 275, 14613, 12, 1568, 275, 1967, 9, 221, 819, 870, 8, 2686, 63, 4705, 8, 285, 322, 3643, 12, 283, 10178, 601, 322, 3643, 1126, 5382, 1333, 12244, 925, 8354, 2917, 73, 464, 296, 402, 8095, 32630, 1126, 601, 26976, 523, 557, 856, 275, 3805, 63, 496, 14948, 8, 1507, 9, 523, 870, 8, 2686, 63, 4705, 8, 496, 856, 12, 283, 496, 3269, 1126, 601, 26976, 1333, 12244, 925, 19271, 557, 14948, 787, 32630, 1126, 601, 26976, 16421, 925, 5431, 1329, 402, 601, 322, 3643, 14, 523, 3141, 63, 496, 3269, 275, 601, 322, 3643, 627, 557, 856, 16421, 870, 8, 2686, 63, 4705, 8, 2923, 63, 496, 3269, 12, 283, 2923, 32630, 1126, 5382, 1333, 12244, 925, 8354, 4084, 402, 8095, 3367, 1190, 1126, 601, 26976, 523, 307, 1190, 275, 3805, 63, 25842, 8, 1507, 9, 523, 870, 8, 2686, 63, 4705, 8, 30543, 12, 283, 25842, 1126, 601, 26976, 1333, 12244, 925, 8354, 8095, 3367, 1190, 1126, 5382, 523, 3141, 63, 25842, 275, 601, 322, 3643, 627, 307, 1190, 523, 870, 8, 2686, 63, 4705, 8, 2923, 63, 25842, 12, 283, 2923, 3367, 1190, 1126, 5382, 1333, 12244, 925, 8354, 3141, 557, 14948, 12254, 3141, 3367, 1190, 14, 523, 3141, 63, 11066, 275, 3141, 63, 496, 3269, 435, 3141, 63, 25842, 16421, 372, 8, 2686, 63, 4705, 8, 2923, 63, 11066, 12, 283, 2923, 1851, 1126, 5382, 1333, 6905, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 318, 4389, 63, 3302, 8, 16084, 12, 4615, 275, 11624, 12, 14613, 275, 4233, 304, 272, 492, 2680, 465, 980, 272, 492, 2680, 14, 2355, 465, 14762, 272, 367, 302, 315, 24047, 26, 267, 2917, 275, 14762, 14, 3302, 8, 2102, 275, 4615, 12, 4666, 275, 14613, 12, 1568, 275, 302, 9, 267, 3367, 5019, 275, 283, 6241, 4084, 543, 283, 435, 620, 8, 78, 9, 435, 283, 1338, 7, 267, 870, 360, 10407, 367, 283, 435, 620, 8, 78, 9, 435, 283, 5845, 358, 267, 870, 8, 2686, 63, 4705, 8, 2686, 12, 3367, 5019, 430, 259, 267, 870, 360, 37, 311, 281, 2652, 16102, 5, 445, 1831, 358, 267, 870, 8, 1590, 14, 21188, 8, 2686, 12, 359, 18, 14, 21, 12, 15997, 14, 21, 2459, 267, 870, 360, 5320, 272, 372, 360, 10759, 10916, 199, 199, 318, 4389, 63, 29606, 8, 16084, 12, 4615, 275, 11624, 304, 272, 492, 2680, 465, 980, 272, 492, 2680, 14, 2355, 465, 14762, 272, 367, 302, 315, 24047, 26, 267, 2917, 275, 14762, 14, 29606, 8, 17984, 275, 4615, 12, 1568, 275, 302, 9, 267, 3367, 5019, 275, 283, 1575, 18571, 4084, 543, 283, 435, 620, 8, 78, 9, 435, 283, 1338, 7, 267, 870, 8, 2686, 63, 4705, 8, 2686, 12, 3367, 5019, 430, 27144, 870, 360, 37, 311, 281, 2652, 16102, 5, 445, 1831, 358, 267, 870, 8, 1590, 14, 21188, 8, 2686, 12, 359, 18, 14, 21, 12, 15997, 14, 21, 2459, 267, 870, 360, 5320, 272, 372, 360, 10759, 10916, 199, 199, 318, 2917, 63, 4705, 8, 2686, 12, 1561, 275, 283, 2686, 63, 354, 735, 272, 492, 10634, 465, 6454, 272, 492, 8027, 14, 13563, 465, 4488, 272, 8926, 275, 6454, 14, 9641, 8, 2686, 9, 272, 6085, 275, 4488, 14, 8941, 8, 17, 12, 6085, 890, 2687, 25, 12, 1227, 430, 272, 2185, 275, 6085, 14, 71, 696, 342, 272, 8926, 14, 11141, 8, 1219, 275, 2185, 12, 13341, 275, 13960, 9, 272, 2185, 14, 409, 63, 1213, 360, 18285, 4084, 402, 283, 435, 1561, 9, 272, 2185, 14, 409, 63, 13849, 360, 18285, 358, 272, 4488, 14, 2384, 342, 272, 372, 8, 332, 14, 11935, 1012, 1362, 199, 318, 3805, 63, 496, 14948, 8, 1507, 304, 23855, 492, 2680, 14, 2355, 465, 14762, 272, 625, 692, 275, 14762, 14, 8830, 8, 890, 275, 1967, 9, 272, 734, 275, 359, 21, 340, 671, 665, 378, 14, 19, 587, 334, 19, 14, 21, 340, 671, 665, 378, 14, 22, 587, 841, 9, 367, 671, 315, 625, 692, 61, 272, 372, 8, 548, 9, 199, 199, 318, 3805, 63, 25842, 8, 1507, 304, 23855, 492, 2680, 14, 2355, 465, 14762, 272, 625, 692, 275, 14762, 14, 8830, 8, 890, 275, 1967, 9, 272, 734, 275, 359, 16, 340, 671, 665, 378, 14, 21, 587, 334, 16, 14, 821, 340, 671, 665, 378, 14, 23, 15166, 587, 334, 17, 14, 16, 340, 671, 665, 378, 14, 25, 587, 499, 14, 16, 430, 367, 671, 315, 625, 692, 61, 272, 372, 8, 548, 9, 199, 199, 318, 4389, 63, 274, 2106, 9587, 8, 1507, 12, 4615, 275, 11624, 12, 14613, 275, 4233, 12, 1115, 374, 275, 756, 304, 523, 925, 10751, 5434, 314, 557, 14948, 436, 3367, 1190, 367, 523, 925, 282, 1026, 2106, 9587, 10584, 14, 523, 492, 2680, 14, 2355, 465, 14762, 12244, 925, 1329, 402, 15229, 601, 322, 3643, 523, 340, 1115, 374, 26, 272, 601, 322, 3643, 275, 14762, 14, 29606, 8, 17984, 275, 4615, 12, 1568, 275, 1967, 9, 523, 587, 26, 2043, 601, 322, 3643, 275, 14762, 14, 3302, 8, 2102, 275, 4615, 12, 4666, 275, 14613, 12, 1568, 275, 1967, 9, 221, 819, 870, 8, 2686, 63, 4705, 8, 285, 322, 3643, 12, 283, 10178, 601, 322, 3643, 1126, 5382, 1333, 12244, 925, 8354, 2917, 73, 464, 296, 402, 8095, 32630, 1126, 601, 26976, 523, 557, 856, 275, 3805, 63, 496, 14948, 8, 1507, 9, 523, 870, 8, 2686, 63, 4705, 8, 496, 856, 12, 283, 496, 3269, 1126, 601, 26976, 1333, 12244, 925, 19271, 557, 14948, 787, 32630, 1126, 601, 26976, 16421, 925, 5431, 1329, 402, 601, 322, 3643, 14, 523, 3141, 63, 496, 3269, 275, 601, 322, 3643, 627, 557, 856, 16421, 870, 8, 2686, 63, 4705, 8, 2923, 63, 496, 3269, 12, 283, 2923, 32630, 1126, 5382, 1333, 12244, 925, 8354, 4084, 402, 8095, 3367, 1190, 1126, 601, 26976, 523, 307, 1190, 275, 3805, 63, 25842, 8, 1507, 9, 523, 870, 8, 2686, 63, 4705, 8, 30543, 12, 283, 25842, 1126, 601, 26976, 1333, 12244, 925, 8354, 8095, 3367, 1190, 1126, 5382, 523, 3141, 63, 25842, 275, 601, 322, 3643, 627, 307, 1190, 523, 870, 8, 2686, 63, 4705, 8, 2923, 63, 25842, 12, 283, 2923, 3367, 1190, 1126, 5382, 1333, 12244, 925, 8354, 3141, 557, 14948, 12254, 3141, 3367, 1190, 14, 523, 3141, 63, 11066, 275, 3141, 63, 496, 3269, 435, 3141, 63, 25842, 16421, 372, 8, 2686, 63, 4705, 8, 2923, 63, 11066, 12, 283, 2923, 1851, 1126, 5382, 1333, 6905, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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c/piel
catkin_ws/src/piel/scripts/venv/lib/python2.7/site-packages/pip/_vendor/colorama/ansi.py
640
2524
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. ''' This module generates ANSI character codes to printing colors to terminals. See: http://en.wikipedia.org/wiki/ANSI_escape_code ''' CSI = '\033[' OSC = '\033]' BEL = '\007' def code_to_chars(code): return CSI + str(code) + 'm' def set_title(title): return OSC + '2;' + title + BEL def clear_screen(mode=2): return CSI + str(mode) + 'J' def clear_line(mode=2): return CSI + str(mode) + 'K' class AnsiCodes(object): def __init__(self): # the subclasses declare class attributes which are numbers. # Upon instantiation we define instance attributes, which are the same # as the class attributes but wrapped with the ANSI escape sequence for name in dir(self): if not name.startswith('_'): value = getattr(self, name) setattr(self, name, code_to_chars(value)) class AnsiCursor(object): def UP(self, n=1): return CSI + str(n) + 'A' def DOWN(self, n=1): return CSI + str(n) + 'B' def FORWARD(self, n=1): return CSI + str(n) + 'C' def BACK(self, n=1): return CSI + str(n) + 'D' def POS(self, x=1, y=1): return CSI + str(y) + ';' + str(x) + 'H' class AnsiFore(AnsiCodes): BLACK = 30 RED = 31 GREEN = 32 YELLOW = 33 BLUE = 34 MAGENTA = 35 CYAN = 36 WHITE = 37 RESET = 39 # These are fairly well supported, but not part of the standard. LIGHTBLACK_EX = 90 LIGHTRED_EX = 91 LIGHTGREEN_EX = 92 LIGHTYELLOW_EX = 93 LIGHTBLUE_EX = 94 LIGHTMAGENTA_EX = 95 LIGHTCYAN_EX = 96 LIGHTWHITE_EX = 97 class AnsiBack(AnsiCodes): BLACK = 40 RED = 41 GREEN = 42 YELLOW = 43 BLUE = 44 MAGENTA = 45 CYAN = 46 WHITE = 47 RESET = 49 # These are fairly well supported, but not part of the standard. LIGHTBLACK_EX = 100 LIGHTRED_EX = 101 LIGHTGREEN_EX = 102 LIGHTYELLOW_EX = 103 LIGHTBLUE_EX = 104 LIGHTMAGENTA_EX = 105 LIGHTCYAN_EX = 106 LIGHTWHITE_EX = 107 class AnsiStyle(AnsiCodes): BRIGHT = 1 DIM = 2 NORMAL = 22 RESET_ALL = 0 Fore = AnsiFore() Back = AnsiBack() Style = AnsiStyle() Cursor = AnsiCursor()
mit
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 2344, 199, 2765, 859, 12821, 25600, 4528, 9479, 370, 16116, 9229, 370, 5537, 2551, 14, 199, 9295, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 879, 2684, 63, 3765, 63, 600, 199, 2344, 199, 199, 35, 2684, 275, 1557, 8762, 459, 199, 31799, 275, 1557, 8762, 6616, 199, 34, 2901, 275, 1557, 8255, 7, 421, 199, 318, 1233, 63, 475, 63, 6574, 8, 600, 304, 272, 372, 445, 2684, 435, 620, 8, 600, 9, 435, 283, 77, 7, 199, 199, 318, 663, 63, 1213, 8, 1213, 304, 272, 372, 4403, 35, 435, 283, 18, 8942, 435, 2538, 435, 699, 2901, 199, 199, 318, 5436, 63, 5410, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 42, 7, 199, 199, 318, 5436, 63, 604, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 43, 7, 421, 199, 533, 31656, 14060, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 314, 9180, 20771, 1021, 3004, 1314, 787, 5579, 14, 267, 327, 738, 678, 26621, 781, 5627, 1256, 3004, 12, 1314, 787, 314, 2011, 267, 327, 465, 314, 1021, 3004, 1325, 8072, 543, 314, 25600, 4772, 3414, 267, 367, 536, 315, 2935, 8, 277, 304, 288, 340, 440, 536, 14, 2460, 30018, 355, 574, 275, 2519, 8, 277, 12, 536, 9, 355, 5371, 8, 277, 12, 536, 12, 1233, 63, 475, 63, 6574, 8, 585, 430, 421, 199, 533, 31656, 8993, 8, 785, 304, 272, 347, 7215, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 33, 7, 272, 347, 10163, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 34, 7, 272, 347, 2381, 2982, 36, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 35, 7, 272, 347, 22658, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 36, 7, 272, 347, 510, 3100, 8, 277, 12, 671, 29, 17, 12, 612, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 89, 9, 435, 20054, 435, 620, 8, 88, 9, 435, 283, 40, 7, 421, 199, 533, 31656, 13099, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 4233, 272, 23443, 3777, 275, 7105, 272, 598, 14824, 3698, 275, 4337, 272, 1488, 23575, 3515, 275, 9404, 272, 31408, 3322, 275, 8177, 272, 603, 14565, 33, 260, 275, 8685, 272, 445, 57, 879, 3322, 275, 8780, 272, 20483, 3698, 275, 6877, 272, 12565, 775, 3698, 275, 10551, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 9137, 272, 9024, 7387, 63, 1438, 258, 275, 21358, 272, 9024, 22501, 63, 1438, 257, 275, 20140, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 18969, 272, 9024, 23536, 63, 1438, 259, 275, 18729, 272, 9024, 45, 14565, 33, 63, 1438, 275, 16102, 272, 9024, 15068, 879, 63, 1438, 259, 275, 15580, 272, 9024, 18817, 63, 1438, 257, 275, 15997, 421, 199, 533, 31656, 4540, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 6335, 272, 23443, 3777, 275, 13385, 272, 598, 14824, 3698, 275, 5685, 272, 1488, 23575, 3515, 275, 11851, 272, 31408, 3322, 275, 10868, 272, 603, 14565, 33, 260, 275, 10416, 272, 445, 57, 879, 3322, 275, 12426, 272, 20483, 3698, 275, 10954, 272, 12565, 775, 3698, 275, 12260, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 2948, 272, 9024, 7387, 63, 1438, 258, 275, 14313, 272, 9024, 22501, 63, 1438, 257, 275, 12996, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 22363, 272, 9024, 23536, 63, 1438, 259, 275, 21083, 272, 9024, 45, 14565, 33, 63, 1438, 275, 20462, 272, 9024, 15068, 879, 63, 1438, 259, 275, 23746, 272, 9024, 18817, 63, 1438, 257, 275, 23543, 421, 199, 533, 31656, 6609, 8, 2493, 338, 14060, 304, 272, 11713, 2830, 259, 275, 413, 272, 577, 1469, 755, 275, 499, 272, 653, 9623, 259, 275, 6928, 272, 12565, 775, 63, 1761, 275, 378, 199, 199, 13099, 257, 275, 31656, 13099, 342, 199, 4540, 257, 275, 31656, 4540, 342, 199, 6609, 221, 275, 31656, 6609, 342, 199, 8993, 275, 31656, 8993, 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 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 2344, 199, 2765, 859, 12821, 25600, 4528, 9479, 370, 16116, 9229, 370, 5537, 2551, 14, 199, 9295, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 879, 2684, 63, 3765, 63, 600, 199, 2344, 199, 199, 35, 2684, 275, 1557, 8762, 459, 199, 31799, 275, 1557, 8762, 6616, 199, 34, 2901, 275, 1557, 8255, 7, 421, 199, 318, 1233, 63, 475, 63, 6574, 8, 600, 304, 272, 372, 445, 2684, 435, 620, 8, 600, 9, 435, 283, 77, 7, 199, 199, 318, 663, 63, 1213, 8, 1213, 304, 272, 372, 4403, 35, 435, 283, 18, 8942, 435, 2538, 435, 699, 2901, 199, 199, 318, 5436, 63, 5410, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 42, 7, 199, 199, 318, 5436, 63, 604, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 43, 7, 421, 199, 533, 31656, 14060, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 314, 9180, 20771, 1021, 3004, 1314, 787, 5579, 14, 267, 327, 738, 678, 26621, 781, 5627, 1256, 3004, 12, 1314, 787, 314, 2011, 267, 327, 465, 314, 1021, 3004, 1325, 8072, 543, 314, 25600, 4772, 3414, 267, 367, 536, 315, 2935, 8, 277, 304, 288, 340, 440, 536, 14, 2460, 30018, 355, 574, 275, 2519, 8, 277, 12, 536, 9, 355, 5371, 8, 277, 12, 536, 12, 1233, 63, 475, 63, 6574, 8, 585, 430, 421, 199, 533, 31656, 8993, 8, 785, 304, 272, 347, 7215, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 33, 7, 272, 347, 10163, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 34, 7, 272, 347, 2381, 2982, 36, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 35, 7, 272, 347, 22658, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 36, 7, 272, 347, 510, 3100, 8, 277, 12, 671, 29, 17, 12, 612, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 89, 9, 435, 20054, 435, 620, 8, 88, 9, 435, 283, 40, 7, 421, 199, 533, 31656, 13099, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 4233, 272, 23443, 3777, 275, 7105, 272, 598, 14824, 3698, 275, 4337, 272, 1488, 23575, 3515, 275, 9404, 272, 31408, 3322, 275, 8177, 272, 603, 14565, 33, 260, 275, 8685, 272, 445, 57, 879, 3322, 275, 8780, 272, 20483, 3698, 275, 6877, 272, 12565, 775, 3698, 275, 10551, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 9137, 272, 9024, 7387, 63, 1438, 258, 275, 21358, 272, 9024, 22501, 63, 1438, 257, 275, 20140, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 18969, 272, 9024, 23536, 63, 1438, 259, 275, 18729, 272, 9024, 45, 14565, 33, 63, 1438, 275, 16102, 272, 9024, 15068, 879, 63, 1438, 259, 275, 15580, 272, 9024, 18817, 63, 1438, 257, 275, 15997, 421, 199, 533, 31656, 4540, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 6335, 272, 23443, 3777, 275, 13385, 272, 598, 14824, 3698, 275, 5685, 272, 1488, 23575, 3515, 275, 11851, 272, 31408, 3322, 275, 10868, 272, 603, 14565, 33, 260, 275, 10416, 272, 445, 57, 879, 3322, 275, 12426, 272, 20483, 3698, 275, 10954, 272, 12565, 775, 3698, 275, 12260, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 2948, 272, 9024, 7387, 63, 1438, 258, 275, 14313, 272, 9024, 22501, 63, 1438, 257, 275, 12996, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 22363, 272, 9024, 23536, 63, 1438, 259, 275, 21083, 272, 9024, 45, 14565, 33, 63, 1438, 275, 20462, 272, 9024, 15068, 879, 63, 1438, 259, 275, 23746, 272, 9024, 18817, 63, 1438, 257, 275, 23543, 421, 199, 533, 31656, 6609, 8, 2493, 338, 14060, 304, 272, 11713, 2830, 259, 275, 413, 272, 577, 1469, 755, 275, 499, 272, 653, 9623, 259, 275, 6928, 272, 12565, 775, 63, 1761, 275, 378, 199, 199, 13099, 257, 275, 31656, 13099, 342, 199, 4540, 257, 275, 31656, 4540, 342, 199, 6609, 221, 275, 31656, 6609, 342, 199, 8993, 275, 31656, 8993, 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, 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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 ]
rancher/cattle
tests/integration-v1/cattletest/core/test_authorization.py
5
80090
from common import * # NOQA @pytest.fixture(scope='module') def user_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='user').user_client @pytest.fixture(scope='module') def read_admin_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='readAdmin').user_client @pytest.fixture(scope='module') def project_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='project').user_client @pytest.fixture(scope='module') def token_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='token').user_client @pytest.fixture(scope='module') def agent_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='agent').user_client @pytest.fixture(scope='module') def agent_register_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='agentRegister').user_client @pytest.fixture(scope='module') def service_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='service').user_client @pytest.fixture(scope='module') def project_admin_client(admin_user_client): return create_context(admin_user_client, create_project=False, add_host=False, kind='projectadmin').user_client def _clean_types(types): for i in ['openstackConfig', 'ubiquityConfig', 'packetConfig', 'notThere', 'azureConfig', 'vmwarevcloudairConfig', 'exoscaleConfig', 'rackspaceConfig', 'hypervConfig', 'googleConfig', 'vmwarevsphereConfig', 'virtualboxConfig', 'amazonec2Config', 'genericConfig', 'vmwarefusionConfig', 'digitaloceanConfig', 'softlayerConfig', 'noneConfig']: try: types.remove(i) except ValueError: pass except KeyError: pass return types def test_user_types(user_client, adds=set(), removes=set()): types = { 'account', 'addOutputsInput', 'addRemoveServiceLinkInput', 'apiKey', 'auditLog', 'backup', 'backupTarget', 'baseMachineConfig', 'certificate', 'changeSecretInput', 'composeService', 'composeProject', 'composeConfig', 'composeConfigInput', 'container', 'containerEvent', 'containerExec', 'containerLogs', 'containerProxy', 'credential', 'dnsService', 'environment', 'environmentUpgrade', 'externalService', 'externalEvent', 'externalServiceEvent', 'externalStoragePoolEvent', 'externalVolumeEvent', 'externalDnsEvent', 'externalHostEvent', 'fieldDocumentation', 'host', 'hostAccess', 'identity', 'image', 'instance', 'instanceConsole', 'instanceConsoleInput', 'instanceHealthCheck', 'instanceLink', 'instanceStop', 'ipAddress', 'ipAddressAssociateInput', 'kubernetesService', 'kubernetesStack', 'kubernetesStackUpgrade', 'label', 'loadBalancerAppCookieStickinessPolicy', 'loadBalancerConfig', 'loadBalancerCookieStickinessPolicy', 'loadBalancerService', 'logConfig', 'machine', 'machineDriver', 'mount', 'network', 'password', 'physicalHost', 'port', 'project', 'projectMember', 'pullTask', 'register', 'registrationToken', 'registry', 'registryCredential', 'restartPolicy', 'restoreFromBackupInput', 'revertToSnapshotInput', 'schema', 'service', 'serviceExposeMap', 'serviceProxy', 'setLabelsInput', 'setLabelsInput', 'setProjectMembersInput', 'setServiceLinksInput', 'snapshot', 'snapshotBackupInput', 'statsAccess', 'storagePool', 'typeDocumentation', 'userPreference', 'volume', 'launchConfig', 'serviceEvent', 'activeSetting', 'serviceConsumeMap', 'setting', 'dockerBuild', 'secondaryLaunchConfig', 'serviceLink', 'loadBalancerServiceLink', 'addRemoveLoadBalancerServiceLinkInput', 'setLoadBalancerServiceLinksInput', 'serviceUpgrade', 'serviceUpgradeStrategy', 'toServiceUpgradeStrategy', 'inServiceUpgradeStrategy', 'virtualMachine', 'virtualMachineDisk', 'publicEndpoint', 'haproxyConfig', 'serviceRestart', 'rollingRestartStrategy', 'servicesPortRange', 'healthcheckInstanceHostMap', 'recreateOnQuorumStrategyConfig', 'volumeSnapshotInput', 'nfsConfig', 'blkioDeviceOption', 'scalePolicy', } types.update(adds) types.difference_update(removes) assert set(_clean_types(user_client.schema.types.keys())) == types return types def test_project_types(project_client): # Almost the same as user test_user_types(project_client, adds={'subscribe'}, removes={'userPreference'}) def test_readonly_types(admin_user_client): context = create_context(admin_user_client, kind='readonly') client = context.user_client test_user_types(client, adds={'subscribe'}, removes={'userPreference', 'registrationToken'}) for type in _clean_types(set(client.schema.types.keys())): type = client.schema.types[type] assert len(type['actions']) == 0 if type.id == 'container': assert type['resourceActions'].keys() == ['logs'] elif type.id == 'virtualMachine': assert type['resourceActions'].keys() == ['logs'] else: print type.id assert len(type['resourceActions']) == 0 assert len(type['collectionActions']) == 0 if type.resourceFields is not None: for k, field in type.resourceFields.items(): assert field.create is False assert field.update is False def test_agent_register_types(agent_register_client): assert set(_clean_types(agent_register_client.schema.types.keys())) == { 'agent', 'error', 'schema', } def test_agent_types(agent_client): assert set(_clean_types(agent_client.schema.types.keys())) == { 'agent', 'configContent', 'containerEvent', 'error', 'externalEvent', 'externalVolumeEvent', 'externalServiceEvent', 'externalStoragePoolEvent', 'externalDnsEvent', 'hostApiProxyToken', 'publish', 'schema', 'subscribe', 'serviceEvent', 'storagePool', 'volume', } def test_token_types(token_client): assert set(token_client.schema.types.keys()) == { 'schema', 'token', } def test_service_types(service_client): # Almost the same as admin user test_admin_types(service_client, adds={'subscribe', 'dynamicSchema'}, removes={'userPreference'}) def test_read_admin_types(read_admin_client): # same as admin user test_admin_types(read_admin_client) def test_admin_types(admin_user_client, adds=set(), removes=set()): types = { 'account', 'activeSetting', 'addOutputsInput', 'addRemoveServiceLinkInput', 'agent', 'apiKey', 'auditLog', 'backup', 'backupTarget', 'baseMachineConfig', 'certificate', 'changeSecretInput', 'composeConfig', 'composeConfigInput', 'composeProject', 'composeService', 'configItem', 'configItemStatus', 'container', 'containerEvent', 'containerExec', 'containerLogs', 'containerProxy', 'credential', 'databasechangelog', 'databasechangeloglock', 'dnsService', 'environment', 'environmentUpgrade', 'extensionImplementation', 'extensionPoint', 'externalHandler', 'externalHandlerExternalHandlerProcessMap', 'externalHandlerProcess', 'externalHandlerProcessConfig', 'externalService', 'externalEvent', 'externalVolumeEvent', 'externalServiceEvent', 'externalStoragePoolEvent', 'externalDnsEvent', 'externalHostEvent', 'fieldDocumentation', 'githubconfig', 'azureadconfig', 'haConfig', 'haConfigInput', 'host', 'hostAccess', 'hostApiProxyToken', 'identity', 'image', 'instance', 'instanceConsole', 'instanceConsoleInput', 'instanceHealthCheck', 'instanceLink', 'instanceStop', 'ipAddress', 'ipAddressAssociateInput', 'kubernetesService', 'kubernetesStack', 'kubernetesStackUpgrade', 'label', 'ldapconfig', 'loadBalancerAppCookieStickinessPolicy', 'loadBalancerConfig', 'loadBalancerCookieStickinessPolicy', 'loadBalancerService', 'localAuthConfig', 'logConfig', 'machine', 'machineDriver', 'mount', 'network', 'openldapconfig', 'password', 'physicalHost', 'port', 'processDefinition', 'processExecution', 'processInstance', 'project', 'projectMember', 'publish', 'pullTask', 'register', 'registrationToken', 'registry', 'registryCredential', 'resourceDefinition', 'restartPolicy', 'restoreFromBackupInput', 'revertToSnapshotInput', 'schema', 'service', 'serviceExposeMap', 'serviceProxy', 'serviceUpgrade', 'setLabelsInput', 'setProjectMembersInput', 'setServiceLinksInput', 'setting', 'snapshot', 'snapshotBackupInput', 'stateTransition', 'statsAccess', 'storagePool', 'task', 'taskInstance', 'typeDocumentation', 'userPreference', 'virtualMachine', 'virtualMachineDisk', 'volume', 'launchConfig', 'serviceEvent', 'serviceConsumeMap', 'dockerBuild', 'secondaryLaunchConfig', 'serviceLink', 'loadBalancerServiceLink', 'addRemoveLoadBalancerServiceLinkInput', 'setLoadBalancerServiceLinksInput', 'serviceUpgradeStrategy', 'toServiceUpgradeStrategy', 'inServiceUpgradeStrategy', 'publicEndpoint', 'haproxyConfig', 'serviceRestart', 'rollingRestartStrategy', 'servicesPortRange', 'healthcheckInstanceHostMap', 'recreateOnQuorumStrategyConfig', 'volumeSnapshotInput', 'nfsConfig', 'blkioDeviceOption', 'scalePolicy' } types.update(adds) types.difference_update(removes) assert set(_clean_types(admin_user_client.schema.types.keys())) == types def test_instance_link_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'instanceLink', 'r', { 'accountId': 'r', 'data': 'r', 'instanceId': 'r', 'linkName': 'r', 'ports': 'r', 'targetInstanceId': 'r', }) auth_check(user_client.schema, 'instanceLink', 'r', { 'accountId': 'r', 'instanceId': 'r', 'linkName': 'r', 'targetInstanceId': 'r', }) auth_check(project_client.schema, 'instanceLink', 'ru', { 'accountId': 'r', 'instanceId': 'r', 'linkName': 'r', 'targetInstanceId': 'ru', }) def test_token_auth(token_client): auth_check(token_client.schema, 'token', 'cr', { 'jwt': 'r', 'code': 'cr', 'user': 'r', 'clientId': 'r', 'security': 'r', 'userType': 'r', 'accountId': 'r', 'hostname': 'r', 'scheme': 'r', 'userIdentity': 'r', 'authProvider': 'r', 'enabled': 'r' }) def test_github_auth(admin_user_client, user_client, project_client): assert 'githubconfig' not in user_client.schema.types assert 'githubconfig' not in project_client.schema.types auth_check(admin_user_client.schema, 'githubconfig', 'cru', { 'enabled': 'cr', 'allowedIdentities': 'cr', 'clientId': 'cr', 'clientSecret': 'cro', 'accessMode': 'cr', 'hostname': 'cr', 'scheme': 'cr' }) def test_azure_auth(admin_user_client, user_client, project_client): assert 'azureadconfig' not in user_client.schema.types assert 'azureadconfig' not in project_client.schema.types auth_check(admin_user_client.schema, 'azureadconfig', 'cru', { 'enabled': 'cr', 'clientId': 'cr', 'tenantId': 'cr', 'adminAccountPassword': 'cro', 'adminAccountUsername': 'cr', 'accessMode': 'cr', 'domain': 'cr' }) def test_ldap_auth(admin_user_client, user_client, project_client): assert 'ldapconfig' not in user_client.schema.types assert 'ldapconfig' not in project_client.schema.types auth_check(admin_user_client.schema, 'ldapconfig', 'cru', { 'accessMode': 'cr', 'domain': 'cr', 'enabled': 'cr', 'groupNameField': 'cr', 'groupObjectClass': 'cr', 'groupSearchField': 'cr', 'loginDomain': 'cr', 'name': 'r', 'port': 'cr', 'server': 'cr', 'serviceAccountPassword': 'cro', 'serviceAccountUsername': 'cr', 'tls': 'cr', 'userDisabledBitMask': 'cr', 'userEnabledAttribute': 'cr', 'userLoginField': 'cr', 'userNameField': 'cr', 'userObjectClass': 'cr', 'userSearchField': 'cr', 'groupMemberMappingAttribute': 'cr', 'userMemberAttribute': 'cr', 'connectionTimeout': 'cr', 'allowedIdentities': 'cr' }) def test_openldap_auth(admin_user_client, user_client, project_client): assert 'openldapconfig' not in user_client.schema.types assert 'openldapconfig' not in project_client.schema.types auth_check(admin_user_client.schema, 'openldapconfig', 'cru', { 'accessMode': 'cr', 'domain': 'cr', 'enabled': 'cr', 'groupNameField': 'cr', 'groupObjectClass': 'cr', 'groupSearchField': 'cr', 'loginDomain': 'cr', 'name': 'r', 'port': 'cr', 'server': 'cr', 'serviceAccountPassword': 'cro', 'serviceAccountUsername': 'cr', 'tls': 'cr', 'userDisabledBitMask': 'cr', 'userEnabledAttribute': 'cr', 'userLoginField': 'cr', 'userNameField': 'cr', 'userObjectClass': 'cr', 'userSearchField': 'cr', 'groupMemberMappingAttribute': 'cr', 'userMemberAttribute': 'cr', 'connectionTimeout': 'cr' }) def test_audit_logs(admin_user_client, user_client, project_client): assert 'auditLog' in user_client.schema.types assert 'auditLog' in project_client.schema.types auth_check(user_client.schema, 'auditLog', 'r', { 'accountId': 'r', 'authenticatedAsAccountId': 'r', 'authenticatedAsIdentityId': 'r', 'authType': 'r', 'created': 'r', 'description': 'r', 'eventType': 'r', 'requestObject': 'r', 'resourceId': 'r', 'resourceType': 'r', 'responseCode': 'r', 'responseObject': 'r', 'clientIp': 'r' }) def test_local_auth(admin_user_client, user_client, project_client): assert 'localauthconfig' not in user_client.schema.types assert 'localauthconfig' not in project_client.schema.types auth_check(admin_user_client.schema, 'localAuthConfig', 'cr', { 'accessMode': 'cr', 'name': 'cr', 'username': 'cr', 'password': 'cro', 'enabled': 'cr', }) def test_project_auth(admin_user_client, user_client, service_client, project_client): auth_check(admin_user_client.schema, 'project', 'crud', { 'allowSystemRole': 'cru', 'description': 'cru', 'kind': 'r', 'name': 'cru', 'uuid': 'cr', 'data': 'r', 'members': 'cr', 'swarm': 'cru', 'kubernetes': 'cru', 'mesos': 'cru', 'virtualMachine': 'cru', 'publicDns': 'cru', 'servicesPortRange': 'cru', }) auth_check(user_client.schema, 'project', 'crud', { 'description': 'cru', 'kind': 'r', 'name': 'cru', 'uuid': 'r', 'members': 'cr', 'swarm': 'cru', 'kubernetes': 'cru', 'mesos': 'cru', 'virtualMachine': 'cru', 'publicDns': 'cru', 'servicesPortRange': 'cru', }) auth_check(project_client.schema, 'project', 'r', { 'description': 'r', 'kind': 'r', 'name': 'r', 'uuid': 'r', 'members': 'r', 'swarm': 'r', 'kubernetes': 'r', 'mesos': 'r', 'virtualMachine': 'r', 'publicDns': 'r', 'servicesPortRange': 'r', }) auth_check(service_client.schema, 'project', 'cr', { 'allowSystemRole': 'cr', 'data': 'r', 'kubernetes': 'cr', 'mesos': 'cr', 'virtualMachine': 'cr', 'members': 'cr', 'publicDns': 'cr', 'servicesPortRange': 'cr', 'swarm': 'cr', 'uuid': 'cr', }) def test_project_member_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'projectMember', 'cr', { 'name': 'r', 'role': 'cr', 'externalId': 'cr', 'externalIdType': 'cr', 'projectId': 'r', 'data': 'r' }) auth_check(user_client.schema, 'projectMember', 'cr', { 'name': 'r', 'role': 'cr', 'externalId': 'cr', 'externalIdType': 'cr', 'projectId': 'r', }) auth_check(project_client.schema, 'projectMember', 'r', { 'name': 'r', 'role': 'r', 'externalId': 'r', 'externalIdType': 'r', 'projectId': 'r', }) def test_host_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'host', 'r', { 'accountId': 'r', 'agentState': 'r', 'apiProxy': 'r', 'agentId': 'r', 'computeTotal': 'r', 'data': 'r', 'physicalHostId': 'r', 'hostname': 'r', 'info': 'r', 'labels': 'r', 'publicEndpoints': 'r' }) auth_check(user_client.schema, 'host', 'r', { 'accountId': 'r', 'agentState': 'r', 'computeTotal': 'r', 'physicalHostId': 'r', 'hostname': 'r', 'info': 'r', 'labels': 'r', 'publicEndpoints': 'r' }) auth_check(project_client.schema, 'host', 'rud', { 'accountId': 'r', 'agentState': 'r', 'computeTotal': 'r', 'physicalHostId': 'r', 'hostname': 'r', 'info': 'r', 'labels': 'ru', 'publicEndpoints': 'r' }) def test_ip_address_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'ipAddress', 'r', { 'accountId': 'r', 'networkId': 'r', 'address': 'r', 'data': 'r', }) auth_check(user_client.schema, 'ipAddress', 'r', { 'accountId': 'r', 'address': 'r', 'networkId': 'r', }) auth_check(project_client.schema, 'ipAddress', 'r', { 'accountId': 'r', 'address': 'r', 'networkId': 'r', }) def test_task_instance_auth(admin_user_client, user_client, project_client): assert 'taskInstance' not in user_client.schema.types assert 'taskInstance' not in project_client.schema.types auth_check(admin_user_client.schema, 'taskInstance', 'r', { 'endTime': 'r', 'exception': 'r', 'serverId': 'r', 'startTime': 'r', 'taskId': 'r', }) def test_storagepool_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'storagePool', 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'name': 'r', 'driverName': 'r', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) auth_check(user_client.schema, 'storagePool', 'r', { 'accountId': 'r', 'externalId': 'r', 'name': 'r', 'driverName': 'r', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) auth_check(project_client.schema, 'storagePool', 'r', { 'accountId': 'r', 'externalId': 'r', 'name': 'r', 'driverName': 'r', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) def test_volume_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'volume', 'r', { 'accountId': 'r', 'created': 'r', 'data': 'r', 'description': 'r', 'externalId': 'r', 'id': 'r', 'imageId': 'r', 'instanceId': 'r', 'kind': 'r', 'name': 'r', 'removeTime': 'r', 'removed': 'r', 'state': 'r', 'uri': 'r', 'uuid': 'r', 'driver': 'r', 'driverOpts': 'r', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r', 'isHostPath': 'r', 'accessMode': 'r', }) auth_check(user_client.schema, 'volume', 'r', { 'accountId': 'r', 'created': 'r', 'description': 'r', 'externalId': 'r', 'id': 'r', 'imageId': 'r', 'instanceId': 'r', 'kind': 'r', 'name': 'r', 'removed': 'r', 'state': 'r', 'uri': 'r', 'uuid': 'r', 'driver': 'r', 'driverOpts': 'r', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r', 'isHostPath': 'r', 'accessMode': 'r', }) auth_check(project_client.schema, 'volume', 'crd', { 'accountId': 'r', 'created': 'r', 'description': 'cr', 'externalId': 'r', 'id': 'r', 'imageId': 'r', 'instanceId': 'r', 'kind': 'r', 'name': 'cr', 'removed': 'r', 'state': 'r', 'uri': 'r', 'uuid': 'r', 'driver': 'cr', 'driverOpts': 'cr', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r', 'isHostPath': 'r', 'accessMode': 'r', }) def test_container_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'container', 'r', { 'accountId': 'r', 'agentId': 'r', 'allocationState': 'r', 'blkioDeviceOptions': 'r', 'build': 'r', 'capAdd': 'r', 'capDrop': 'r', 'command': 'r', 'count': 'r', 'cpuSet': 'r', 'cpuShares': 'r', 'created': 'r', 'data': 'r', 'dataVolumes': 'r', 'dataVolumeMounts': 'r', 'dataVolumesFrom': 'r', 'description': 'r', 'devices': 'r', 'workingDir': 'r', 'dns': 'r', 'dnsSearch': 'r', 'domainName': 'r', 'entryPoint': 'r', 'environment': 'r', 'firstRunning': 'r', 'hostname': 'r', 'hostId': 'r', 'id': 'r', 'imageUuid': 'r', 'instanceLinks': 'r', 'lxcConf': 'r', 'memory': 'r', 'memorySwap': 'r', 'networkIds': 'r', 'networkMode': 'r', 'networkContainerId': 'r', 'ports': 'r', 'primaryIpAddress': 'r', 'privileged': 'r', 'publishAllPorts': 'r', 'removeTime': 'r', 'registryCredentialId': 'r', 'requestedHostId': 'r', 'restartPolicy': 'r', 'startOnCreate': 'r', 'stdinOpen': 'r', 'token': 'r', 'tty': 'r', 'user': 'r', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'r', 'healthCheck': 'r', 'healthState': 'r', 'securityOpt': 'r', 'logConfig': 'r', 'pidMode': 'r', 'volumeDriver': 'r', 'extraHosts': 'r', 'readOnly': 'r', 'expose': 'r', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r' }) auth_check(user_client.schema, 'container', 'r', { 'accountId': 'r', 'blkioDeviceOptions': 'r', 'build': 'r', 'capAdd': 'r', 'capDrop': 'r', 'command': 'r', 'count': 'r', 'cpuSet': 'r', 'cpuShares': 'r', 'created': 'r', 'dataVolumes': 'r', 'dataVolumeMounts': 'r', 'dataVolumesFrom': 'r', 'description': 'r', 'devices': 'r', 'workingDir': 'r', 'dns': 'r', 'dnsSearch': 'r', 'domainName': 'r', 'entryPoint': 'r', 'environment': 'r', 'firstRunning': 'r', 'hostId': 'r', 'hostname': 'r', 'id': 'r', 'imageUuid': 'r', 'instanceLinks': 'r', 'lxcConf': 'r', 'memory': 'r', 'memorySwap': 'r', 'networkIds': 'r', 'networkMode': 'r', 'networkContainerId': 'r', 'ports': 'r', 'primaryIpAddress': 'r', 'privileged': 'r', 'publishAllPorts': 'r', 'registryCredentialId': 'r', 'requestedHostId': 'r', 'restartPolicy': 'r', 'startOnCreate': 'r', 'stdinOpen': 'r', 'tty': 'r', 'user': 'r', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'r', 'healthCheck': 'r', 'healthState': 'r', 'securityOpt': 'r', 'logConfig': 'r', 'pidMode': 'r', 'extraHosts': 'r', 'volumeDriver': 'r', 'readOnly': 'r', 'expose': 'r', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r' }) auth_check(project_client.schema, 'container', 'crud', { 'accountId': 'r', 'blkioDeviceOptions': 'cr', 'build': 'cr', 'capAdd': 'cr', 'capDrop': 'cr', 'command': 'cr', 'count': 'cr', 'cpuSet': 'cr', 'cpuShares': 'cr', 'created': 'r', 'dataVolumes': 'cr', 'dataVolumesFrom': 'cr', 'dataVolumeMounts': 'cr', 'description': 'cru', 'devices': 'cr', 'workingDir': 'cr', 'dns': 'cr', 'dnsSearch': 'cr', 'domainName': 'cr', 'entryPoint': 'cr', 'environment': 'cr', 'firstRunning': 'r', 'hostId': 'r', 'hostname': 'cr', 'id': 'r', 'imageUuid': 'cr', 'instanceLinks': 'cr', 'lxcConf': 'cr', 'memory': 'cr', 'memorySwap': 'cr', 'networkIds': 'cr', 'networkMode': 'cr', 'networkContainerId': 'cr', 'ports': 'cr', 'primaryIpAddress': 'r', 'privileged': 'cr', 'publishAllPorts': 'cr', 'registryCredentialId': 'cr', 'requestedHostId': 'cr', 'restartPolicy': 'cr', 'startOnCreate': 'cr', 'stdinOpen': 'cr', 'tty': 'cr', 'user': 'cr', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'cr', 'healthCheck': 'cr', 'healthState': 'r', 'securityOpt': 'cr', 'logConfig': 'cr', 'pidMode': 'cr', 'extraHosts': 'cr', 'volumeDriver': 'cr', 'readOnly': 'cr', 'expose': 'cr', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r' }) auth_check(project_client.schema, 'dockerBuild', 'cr', { 'dockerfile': 'cr', 'context': 'cr', 'remote': 'cr', 'nocache': 'cr', 'rm': 'cr', 'forcerm': 'cr', }) def test_port_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'port', 'r', { 'accountId': 'r', 'data': 'r', 'instanceId': 'r', 'privateIpAddressId': 'r', 'privatePort': 'r', 'protocol': 'r', 'publicIpAddressId': 'r', 'publicPort': 'r', 'bindAddress': 'r', }) auth_check(user_client.schema, 'port', 'r', { 'accountId': 'r', 'instanceId': 'r', 'privateIpAddressId': 'r', 'privatePort': 'r', 'protocol': 'r', 'publicIpAddressId': 'r', 'publicPort': 'r', 'bindAddress': 'r', }) auth_check(project_client.schema, 'port', 'ru', { 'accountId': 'r', 'instanceId': 'r', 'privateIpAddressId': 'r', 'privatePort': 'r', 'protocol': 'r', 'publicIpAddressId': 'r', 'publicPort': 'ru', 'bindAddress': 'r', }) def test_mount_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'mount', 'r', { 'name': 'r', 'description': 'r', 'data': 'r', 'accountId': 'r', 'instanceId': 'r', 'volumeId': 'r', 'kind': 'r', 'uuid': 'r', 'removeTime': 'r', 'id': 'r', 'created': 'r', 'path': 'r', 'permissions': 'r', 'removed': 'r', 'state': 'r', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r' }) auth_check(user_client.schema, 'mount', 'r', { 'accountId': 'r', 'name': 'r', 'description': 'r', 'instanceId': 'r', 'volumeId': 'r', 'kind': 'r', 'uuid': 'r', 'id': 'r', 'created': 'r', 'path': 'r', 'permissions': 'r', 'removed': 'r', 'state': 'r', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r' }) auth_check(project_client.schema, 'mount', 'r', { 'accountId': 'r', 'name': 'r', 'description': 'r', 'instanceId': 'r', 'volumeId': 'r', 'kind': 'r', 'uuid': 'r', 'id': 'r', 'created': 'r', 'path': 'r', 'permissions': 'r', 'removed': 'r', 'state': 'r', 'transitioning': 'r', 'transitioningMessage': 'r', 'transitioningProgress': 'r' }) def test_process_instance_auth(admin_user_client, user_client, project_client): assert 'processInstance' not in user_client.schema.types assert 'processInstance' not in project_client.schema.types auth_check(admin_user_client.schema, 'processInstance', 'r', { 'endTime': 'r', 'exitReason': 'r', 'phase': 'r', 'priority': 'r', 'processName': 'r', 'resourceId': 'r', 'resourceType': 'r', 'result': 'r', 'runningProcessServerId': 'r', 'startProcessServerId': 'r', 'startTime': 'r', 'data': 'r', }) def test_process_execution(admin_user_client, user_client, project_client): assert 'processExecution' not in user_client.schema.types assert 'processExecution' not in project_client.schema.types auth_check(admin_user_client.schema, 'processExecution', 'r', { 'log': 'r', 'processInstanceId': 'r', }) def test_process_definition(admin_user_client, user_client, project_client): assert 'processDefinition' not in user_client.schema.types assert 'processDefinition' not in project_client.schema.types auth_check(admin_user_client.schema, 'processDefinition', 'r', { 'extensionBased': 'r', 'preProcessListeners': 'r', 'postProcessListeners': 'r', 'processHandlers': 'r', 'resourceType': 'r', 'stateTransitions': 'r', }) def test_config_item(admin_user_client, user_client, project_client): assert 'configItem' not in user_client.schema.types assert 'configItem' not in project_client.schema.types auth_check(admin_user_client.schema, 'configItem', 'r', { 'sourceVersion': 'r', }) def test_config_item_status_auth(admin_user_client, user_client, project_client): assert 'configItemStatus' not in user_client.schema.types assert 'configItemStatus' not in project_client.schema.types auth_check(admin_user_client.schema, 'configItemStatus', 'ru', { 'agentId': 'r', 'accountId': 'r', 'appliedUpdated': 'r', 'appliedVersion': 'ru', 'requestedUpdated': 'r', 'requestedVersion': 'r', 'sourceVersion': 'r', }) def test_setting_auth(admin_user_client, user_client, project_client): auth_check(user_client.schema, 'activeSetting', 'r', { 'name': 'r', 'activeValue': 'r', 'value': 'r', }) auth_check(project_client.schema, 'activeSetting', 'r', { 'name': 'r', 'activeValue': 'r', 'value': 'r', }) auth_check(admin_user_client.schema, 'activeSetting', 'rud', { 'name': 'r', 'activeValue': 'r', 'value': 'ru', 'source': 'r', 'inDb': 'r', }) auth_check(user_client.schema, 'setting', 'r', { 'name': 'r', 'activeValue': 'r', 'value': 'r', }) auth_check(project_client.schema, 'setting', 'r', { 'name': 'r', 'activeValue': 'r', 'value': 'r', }) auth_check(admin_user_client.schema, 'setting', 'crud', { 'name': 'cr', 'activeValue': 'r', 'value': 'cru', 'source': 'r', 'inDb': 'r', }) def test_schema_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'schema', 'r', { 'collectionActions': 'r', 'collectionFields': 'r', 'collectionFilters': 'r', 'collectionMethods': 'r', 'includeableLinks': 'r', 'pluralName': 'r', 'resourceActions': 'r', 'resourceFields': 'r', 'resourceMethods': 'r', }) auth_check(user_client.schema, 'schema', 'r', { 'collectionActions': 'r', 'collectionFields': 'r', 'collectionFilters': 'r', 'collectionMethods': 'r', 'includeableLinks': 'r', 'pluralName': 'r', 'resourceActions': 'r', 'resourceFields': 'r', 'resourceMethods': 'r', }) auth_check(project_client.schema, 'schema', 'r', { 'collectionActions': 'r', 'collectionFields': 'r', 'collectionFilters': 'r', 'collectionMethods': 'r', 'includeableLinks': 'r', 'pluralName': 'r', 'resourceActions': 'r', 'resourceFields': 'r', 'resourceMethods': 'r', }) def test_account_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'account', 'crud', { 'id': 'r', 'externalId': 'cru', 'externalIdType': 'cru', 'identity': 'r', 'removeTime': 'r', 'data': 'r', 'kind': 'cru', 'uuid': 'cr' }) auth_check(user_client.schema, 'account', 'r', { }) auth_check(project_client.schema, 'account', 'r', { }) def test_agent_auth(admin_user_client, user_client, project_client): assert 'agent' not in user_client.schema.types assert 'agent' not in project_client.schema.types auth_check(admin_user_client.schema, 'agent', 'r', { 'managedConfig': 'r', 'uri': 'r', 'accountId': 'r', 'data': 'r', }) def test_extension_point_auth(admin_user_client, user_client, project_client): assert 'extensionPoint' not in user_client.schema.types assert 'extensionPoint' not in project_client.schema.types auth_check(admin_user_client.schema, 'extensionPoint', 'r', { 'excludeSetting': 'r', 'includeSetting': 'r', 'listSetting': 'r', 'implementations': 'r', }) def test_api_key_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'apiKey', 'crud', { 'publicValue': 'cr', 'secretValue': 'cro', 'removeTime': 'r', 'data': 'r', 'accountId': 'cr', }) auth_check(user_client.schema, 'apiKey', 'crud', { 'publicValue': 'r', 'accountId': 'r', 'secretValue': 'ro', }) auth_check(project_client.schema, 'apiKey', 'crud', { 'publicValue': 'r', 'accountId': 'r', 'secretValue': 'ro', }) def test_subscribe_auth(admin_user_client, user_client, project_client): assert 'subscribe' not in admin_user_client.schema.types assert 'subscribe' not in user_client.schema.types auth_check(project_client.schema, 'subscribe', 'cr', { 'eventNames': 'cr', }) def test_registration_tokens_auth(admin_user_client, user_client, project_client, service_client): auth_check(admin_user_client.schema, 'registrationToken', 'r', { 'created': 'r', 'data': 'r', 'description': 'r', 'removeTime': 'r', 'accountId': 'r', 'image': 'r', 'command': 'r', 'registrationUrl': 'r', 'token': 'r', }) auth_check(service_client.schema, 'registrationToken', 'cr', { 'created': 'r', 'data': 'r', 'description': 'cr', 'removeTime': 'r', 'accountId': 'cr', 'image': 'r', 'command': 'r', 'registrationUrl': 'r', 'token': 'r', }) auth_check(user_client.schema, 'registrationToken', 'r', { 'accountId': 'r', 'created': 'r', 'description': 'r', 'uuid': 'r', 'image': 'r', 'command': 'r', 'registrationUrl': 'r', 'token': 'r', }) auth_check(project_client.schema, 'registrationToken', 'cr', { 'accountId': 'r', 'created': 'r', 'description': 'cr', 'uuid': 'r', 'image': 'r', 'command': 'r', 'registrationUrl': 'r', 'token': 'r', }) def test_type_documentation_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'typeDocumentation', 'r', { 'resourceFields': 'r', }) auth_check(user_client.schema, 'typeDocumentation', 'r', { 'resourceFields': 'r', }) auth_check(project_client.schema, 'typeDocumentation', 'r', { 'resourceFields': 'r', }) def test_stats_access_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'statsAccess', 'r', { 'token': 'r', 'url': 'r', }) auth_check(user_client.schema, 'statsAccess', 'r', { 'token': 'r', 'url': 'r', }) auth_check(project_client.schema, 'statsAccess', 'r', { 'token': 'r', 'url': 'r', }) def test_account_resource_auth(admin_user_client): resource_action_check(admin_user_client.schema, 'account', [ 'update', 'activate', 'deactivate', 'restore', 'remove', 'purge', 'create', ]) def test_physical_host(admin_user_client, user_client, service_client, project_client): auth_check(admin_user_client.schema, 'physicalHost', 'r', { 'accountId': 'r', 'data': 'r', 'driver': 'r', 'externalId': 'r', }) auth_check(user_client.schema, 'physicalHost', 'r', { 'accountId': 'r', 'driver': 'r', 'externalId': 'r', }) auth_check(project_client.schema, 'physicalHost', 'r', { 'accountId': 'r', 'driver': 'r', 'externalId': 'r', }) def test_registry_credentials(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'registryCredential', 'r', { 'accountId': 'r', 'data': 'r', 'email': 'r', 'publicValue': 'r', 'secretValue': 'ro', 'registryId': 'r', }) auth_check(user_client.schema, 'registryCredential', 'r', { 'accountId': 'r', 'email': 'r', 'publicValue': 'r', 'secretValue': 'ro', 'registryId': 'r', }) auth_check(project_client.schema, 'registryCredential', 'crud', { 'accountId': 'r', 'email': 'cru', 'publicValue': 'cru', 'secretValue': 'curo', 'registryId': 'cr', }) def test_registry(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'registry', 'r', { 'accountId': 'r', 'data': 'r', 'driverName': 'r', 'externalId': 'r', 'serverAddress': 'r', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) auth_check(user_client.schema, 'registry', 'r', { 'accountId': 'r', 'externalId': 'r', 'driverName': 'r', 'serverAddress': 'r', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) auth_check(project_client.schema, 'registry', 'crud', { 'accountId': 'r', 'driverName': 'r', 'externalId': 'r', 'serverAddress': 'cr', 'volumeAccessMode': 'r', 'blockDevicePath': 'r', 'volumeCapabilities': 'r', }) def test_container_events(admin_user_client, user_client, agent_client, project_client): auth_check(admin_user_client.schema, 'containerEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'accountId': 'r', 'externalFrom': 'r', 'reportedHostUuid': 'r', 'externalId': 'r', 'externalStatus': 'r', 'data': 'r', 'dockerInspect': 'r' }) auth_check(agent_client.schema, 'containerEvent', 'cr', { 'externalTimestamp': 'cr', 'externalFrom': 'cr', 'reportedHostUuid': 'cr', 'externalId': 'cr', 'externalStatus': 'cr', 'dockerInspect': 'cr', 'data': 'cr', 'id': 'r' }) auth_check(user_client.schema, 'containerEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'externalFrom': 'r', 'reportedHostUuid': 'r', 'externalId': 'r', 'externalStatus': 'r', 'accountId': 'r', 'dockerInspect': 'r' }) auth_check(project_client.schema, 'containerEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'externalFrom': 'r', 'reportedHostUuid': 'r', 'externalId': 'r', 'externalStatus': 'r', 'accountId': 'r', 'dockerInspect': 'r' }) def test_service_events(admin_user_client, user_client, agent_client, project_client): auth_check(admin_user_client.schema, 'serviceEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'instanceId': 'r', 'accountId': 'r', 'healthcheckUuid': 'r', 'reportedHealth': 'r', 'data': 'r', }) auth_check(user_client.schema, 'serviceEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'instanceId': 'r', 'accountId': 'r', 'healthcheckUuid': 'r', 'reportedHealth': 'r', }) auth_check(project_client.schema, 'serviceEvent', 'r', { 'externalTimestamp': 'r', 'hostId': 'r', 'instanceId': 'r', 'accountId': 'r', 'healthcheckUuid': 'r', 'reportedHealth': 'r', }) auth_check(agent_client.schema, 'serviceEvent', 'cr', { 'externalTimestamp': 'cr', 'healthcheckUuid': 'cr', 'reportedHealth': 'cr', }) def test_svc_discovery_service(admin_user_client, user_client, project_client, project_admin_client): auth_check(admin_user_client.schema, 'service', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'scale': 'r', 'launchConfig': 'r', 'accountId': 'r', 'data': 'r', 'upgrade': 'r', 'secondaryLaunchConfigs': 'r', 'vip': 'r', 'createIndex': 'r', 'metadata': 'r', 'selectorLink': 'r', 'selectorContainer': 'r', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'r', 'assignServiceIpAddress': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(user_client.schema, 'service', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'scale': 'r', 'launchConfig': 'r', 'accountId': 'r', 'upgrade': 'r', 'secondaryLaunchConfigs': 'r', 'vip': 'r', 'createIndex': 'r', 'metadata': 'r', 'selectorLink': 'r', 'selectorContainer': 'r', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'r', 'assignServiceIpAddress': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(project_client.schema, 'service', 'crud', { 'name': 'cru', 'externalId': 'cr', 'environmentId': 'cr', 'scale': 'cru', 'launchConfig': 'cr', 'accountId': 'r', 'upgrade': 'r', 'secondaryLaunchConfigs': 'cr', 'vip': 'cr', 'createIndex': 'r', 'metadata': 'cru', 'selectorLink': 'cru', 'selectorContainer': 'cru', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'cru', 'assignServiceIpAddress': 'cr', 'healthState': 'r', 'startOnCreate': 'cr', 'scalePolicy': 'cru', 'currentScale': 'r', }) resource_action_check(user_client.schema, 'service', [ 'activate', 'addservicelink', 'cancelupgrade', 'create', 'deactivate', 'finishupgrade', 'remove', 'removeservicelink', 'restart', 'rollback', 'setservicelinks', 'update', 'upgrade', 'cancelrollback', ]) resource_action_check(admin_user_client.schema, 'service', [ 'activate', 'addservicelink', 'cancelupgrade', 'create', 'deactivate', 'finishupgrade', 'remove', 'removeservicelink', 'restart', 'rollback', 'setservicelinks', 'update', 'upgrade', 'cancelrollback', ]) resource_action_check(project_client.schema, 'service', [ 'activate', 'addservicelink', 'cancelupgrade', 'create', 'deactivate', 'finishupgrade', 'remove', 'removeservicelink', 'restart', 'rollback', 'setservicelinks', 'update', 'upgrade', 'cancelrollback', ]) resource_action_check(project_admin_client.schema, 'service', [ 'activate', 'addservicelink', 'cancelupgrade', 'certificate', 'create', 'deactivate', 'finishupgrade', 'remove', 'removeservicelink', 'restart', 'rollback', 'setservicelinks', 'update', 'upgrade', 'cancelrollback', ]) def test_auth_compose_project(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'composeProject', 'r', { 'name': 'r', 'accountId': 'r', 'data': 'r', 'templates': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'healthState': 'r', }) auth_check(user_client.schema, 'composeProject', 'r', { 'name': 'r', 'accountId': 'r', 'templates': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'healthState': 'r', }) auth_check(project_client.schema, 'composeProject', 'crud', { 'name': 'cr', 'accountId': 'r', 'templates': 'cr', 'environment': 'cr', 'externalId': 'cru', 'previousExternalId': 'cru', 'previousEnvironment': 'cru', 'healthState': 'r', }) def test_auth_kubernetes_stack(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'kubernetesStack', 'r', { 'name': 'r', 'accountId': 'r', 'data': 'r', 'namespace': 'r', 'templates': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'healthState': 'r', }) auth_check(user_client.schema, 'kubernetesStack', 'r', { 'name': 'r', 'accountId': 'r', 'namespace': 'r', 'templates': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'healthState': 'r', }) auth_check(project_client.schema, 'kubernetesStack', 'crud', { 'name': 'cr', 'accountId': 'r', 'namespace': 'cr', 'templates': 'cr', 'environment': 'cr', 'externalId': 'cru', 'previousExternalId': 'cru', 'previousEnvironment': 'cru', 'healthState': 'r', }) def test_svc_discovery_environment(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'environment', 'r', { 'name': 'r', 'accountId': 'r', 'data': 'r', 'dockerCompose': 'r', 'rancherCompose': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'outputs': 'r', 'startOnCreate': 'r', 'healthState': 'r', }) auth_check(user_client.schema, 'environment', 'r', { 'name': 'r', 'accountId': 'r', 'dockerCompose': 'r', 'rancherCompose': 'r', 'environment': 'r', 'externalId': 'r', 'previousExternalId': 'r', 'previousEnvironment': 'r', 'outputs': 'r', 'startOnCreate': 'r', 'healthState': 'r', }) auth_check(project_client.schema, 'environment', 'crud', { 'name': 'cru', 'accountId': 'r', 'dockerCompose': 'cr', 'rancherCompose': 'cr', 'environment': 'cr', 'externalId': 'cru', 'previousExternalId': 'cru', 'previousEnvironment': 'cru', 'outputs': 'cru', 'startOnCreate': 'cr', 'healthState': 'r', }) def test_svc_discovery_lb_service(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'loadBalancerService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'scale': 'r', 'launchConfig': 'r', 'accountId': 'r', 'data': 'r', 'upgrade': 'r', 'loadBalancerConfig': 'r', 'vip': 'r', 'defaultCertificateId': 'r', 'certificateIds': 'r', 'metadata': 'r', 'selectorLink': 'r', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'r', 'assignServiceIpAddress': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(user_client.schema, 'loadBalancerService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'scale': 'r', 'launchConfig': 'r', 'accountId': 'r', 'upgrade': 'r', 'loadBalancerConfig': 'r', 'vip': 'r', 'defaultCertificateId': 'r', 'certificateIds': 'r', 'metadata': 'r', 'selectorLink': 'r', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'r', 'assignServiceIpAddress': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(project_client.schema, 'loadBalancerService', 'crud', { 'name': 'cru', 'externalId': 'cr', 'environmentId': 'cr', 'scale': 'cru', 'launchConfig': 'cr', 'accountId': 'r', 'upgrade': 'r', 'loadBalancerConfig': 'cru', 'vip': 'cr', 'defaultCertificateId': 'cru', 'certificateIds': 'cru', 'metadata': 'cru', 'selectorLink': 'cru', 'fqdn': 'r', 'publicEndpoints': 'r', 'retainIp': 'cru', 'assignServiceIpAddress': 'cr', 'healthState': 'r', 'startOnCreate': 'cr', 'scalePolicy': 'cru', 'currentScale': 'r', }) def test_svc_discovery_consume_map(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'serviceConsumeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'consumedServiceId': 'r', 'ports': 'r', 'data': 'r', 'accountId': 'r' }) auth_check(user_client.schema, 'serviceConsumeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'consumedServiceId': 'r', 'ports': 'r', 'accountId': 'r' }) auth_check(project_client.schema, 'serviceConsumeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'consumedServiceId': 'r', 'ports': 'r', 'accountId': 'r', }) def test_auth_k8s_stack_upgrade(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'kubernetesStackUpgrade', 'r', { 'templates': 'r', 'environment': 'r', 'externalId': 'r', }) auth_check(user_client.schema, 'kubernetesStackUpgrade', 'r', { 'templates': 'r', 'environment': 'r', 'externalId': 'r', }) auth_check(project_client.schema, 'kubernetesStackUpgrade', 'cr', { 'templates': 'cr', 'environment': 'cr', 'externalId': 'cr', }) def test_auth_env_upgrade(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'environmentUpgrade', 'r', { 'dockerCompose': 'r', 'rancherCompose': 'r', 'environment': 'r', 'externalId': 'r', }) auth_check(user_client.schema, 'environmentUpgrade', 'r', { 'dockerCompose': 'r', 'rancherCompose': 'r', 'environment': 'r', 'externalId': 'r', }) auth_check(project_client.schema, 'environmentUpgrade', 'cr', { 'dockerCompose': 'cr', 'rancherCompose': 'cr', 'environment': 'cr', 'externalId': 'cr', }) def test_auth_service_upgrade(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'serviceUpgrade', 'r', { 'inServiceStrategy': 'r', 'toServiceStrategy': 'r' }) auth_check(user_client.schema, 'serviceUpgrade', 'r', { 'inServiceStrategy': 'r', 'toServiceStrategy': 'r' }) auth_check(project_client.schema, 'serviceUpgrade', 'cr', { 'inServiceStrategy': 'cr', 'toServiceStrategy': 'cr' }) def test_auth_in_service_upgrade_strategy(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'inServiceUpgradeStrategy', 'r', { 'batchSize': 'r', 'intervalMillis': 'r', 'launchConfig': 'r', 'secondaryLaunchConfigs': 'r', 'previousLaunchConfig': 'r', 'previousSecondaryLaunchConfigs': 'r', 'startFirst': 'r', }) auth_check(user_client.schema, 'inServiceUpgradeStrategy', 'r', { 'batchSize': 'r', 'intervalMillis': 'r', 'launchConfig': 'r', 'secondaryLaunchConfigs': 'r', 'previousLaunchConfig': 'r', 'previousSecondaryLaunchConfigs': 'r', 'startFirst': 'r', }) auth_check(project_client.schema, 'inServiceUpgradeStrategy', 'cr', { 'batchSize': 'cr', 'intervalMillis': 'cr', 'launchConfig': 'cr', 'secondaryLaunchConfigs': 'cr', 'previousLaunchConfig': 'r', 'previousSecondaryLaunchConfigs': 'r', 'startFirst': 'cr', }) def test_auth_to_service_upgrade_strategy(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'toServiceUpgradeStrategy', 'r', { 'updateLinks': 'r', 'toServiceId': 'r', 'batchSize': 'r', 'intervalMillis': 'r', 'finalScale': 'r' }) auth_check(user_client.schema, 'toServiceUpgradeStrategy', 'r', { 'updateLinks': 'r', 'toServiceId': 'r', 'batchSize': 'r', 'intervalMillis': 'r', 'finalScale': 'r' }) auth_check(project_client.schema, 'toServiceUpgradeStrategy', 'cr', { 'updateLinks': 'cr', 'toServiceId': 'cr', 'batchSize': 'cr', 'intervalMillis': 'cr', 'finalScale': 'cr' }) def test_svc_discovery_expose_map(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'serviceExposeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'instanceId': 'r', 'ipAddress': 'r', 'data': 'r', 'accountId': 'r', 'managed': 'r' }) auth_check(user_client.schema, 'serviceExposeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'instanceId': 'r', 'ipAddress': 'r', 'accountId': 'r', 'managed': 'r' }) auth_check(project_client.schema, 'serviceExposeMap', 'r', { 'name': 'r', 'serviceId': 'r', 'instanceId': 'r', 'ipAddress': 'r', 'accountId': 'r', 'managed': 'r' }) def test_svc_discovery_external_service(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'externalService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'hostname': 'r', 'externalIpAddresses': 'r', 'accountId': 'r', 'data': 'r', 'upgrade': 'r', 'healthCheck': 'r', 'metadata': 'r', 'launchConfig': 'r', 'fqdn': 'r', 'healthState': 'r', 'startOnCreate': 'r', }) auth_check(user_client.schema, 'externalService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'hostname': 'r', 'externalIpAddresses': 'r', 'accountId': 'r', 'upgrade': 'r', 'healthCheck': 'r', 'metadata': 'r', 'launchConfig': 'r', 'fqdn': 'r', 'healthState': 'r', 'startOnCreate': 'r', }) auth_check(project_client.schema, 'externalService', 'crud', { 'name': 'cru', 'externalId': 'cr', 'environmentId': 'cr', 'hostname': 'cru', 'externalIpAddresses': 'cru', 'accountId': 'r', 'upgrade': 'r', 'healthCheck': 'cr', 'metadata': 'cru', 'launchConfig': 'cr', 'fqdn': 'r', 'healthState': 'r', 'startOnCreate': 'cr', }) def test_pull_task(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'pullTask', 'r', { 'accountId': 'r', 'data': 'r', 'labels': 'r', 'mode': 'r', 'image': 'r', 'status': 'r', }) auth_check(user_client.schema, 'pullTask', 'r', { 'accountId': 'r', 'labels': 'r', 'mode': 'r', 'image': 'r', 'status': 'r', }) auth_check(project_client.schema, 'pullTask', 'cr', { 'accountId': 'r', 'labels': 'cr', 'mode': 'cr', 'image': 'cr', 'status': 'r', }) def test_external_event(agent_client, admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'externalEvent', 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', }) auth_check(user_client.schema, 'externalEvent', 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', }) auth_check(project_client.schema, 'externalEvent', 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', }) auth_check(agent_client.schema, 'externalEvent', 'r', { 'externalId': 'r', 'eventType': 'r', }) def test_external_sp_event(agent_client, admin_user_client, user_client, project_client): type = 'externalStoragePoolEvent' auth_check(admin_user_client.schema, type, 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'hostUuids': 'r', 'reportedAccountId': 'r', 'storagePool': 'r', }) auth_check(user_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'hostUuids': 'r', 'reportedAccountId': 'r', 'storagePool': 'r', }) auth_check(project_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'hostUuids': 'r', 'reportedAccountId': 'r', 'storagePool': 'r', }) auth_check(agent_client.schema, type, 'cr', { 'externalId': 'cr', 'eventType': 'cr', 'hostUuids': 'cr', 'storagePool': 'cr', }) def test_external_volume_event(agent_client, admin_user_client, user_client, project_client): type = 'externalVolumeEvent' auth_check(admin_user_client.schema, type, 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'volume': 'r', }) auth_check(user_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'volume': 'r', }) auth_check(project_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'volume': 'r', }) auth_check(agent_client.schema, type, 'cr', { 'externalId': 'cr', 'eventType': 'cr', 'volume': 'cr', }) def test_external_dns_event(agent_client, admin_user_client, user_client, project_client): type = 'externalDnsEvent' auth_check(admin_user_client.schema, type, 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'stackName': 'r', 'serviceName': 'r', 'fqdn': 'r' }) auth_check(user_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'stackName': 'r', 'serviceName': 'r', 'fqdn': 'r' }) auth_check(project_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'stackName': 'r', 'serviceName': 'r', 'fqdn': 'r' }) auth_check(agent_client.schema, type, 'cr', { 'externalId': 'cr', 'eventType': 'cr', 'stackName': 'cr', 'serviceName': 'cr', 'fqdn': 'cr' }) def test_external_service_event(agent_client, admin_user_client, user_client, project_client): type = 'externalServiceEvent' auth_check(admin_user_client.schema, type, 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'environment': 'r', 'service': 'r', }) auth_check(user_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'environment': 'r', 'service': 'r', }) auth_check(project_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'environment': 'r', 'service': 'r', }) auth_check(agent_client.schema, type, 'cr', { 'externalId': 'cr', 'eventType': 'cr', 'environment': 'cr', 'service': 'cr', }) def test_external_host_event(agent_client, admin_user_client, user_client, project_client): type = 'externalHostEvent' auth_check(admin_user_client.schema, type, 'r', { 'accountId': 'r', 'data': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'hostLabel': 'r', 'deleteHost': 'r', 'hostId': 'r', }) auth_check(user_client.schema, type, 'r', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'r', 'reportedAccountId': 'r', 'hostLabel': 'r', 'deleteHost': 'r', 'hostId': 'r', }) auth_check(project_client.schema, type, 'cr', { 'accountId': 'r', 'externalId': 'r', 'eventType': 'cr', 'reportedAccountId': 'r', 'hostLabel': 'cr', 'deleteHost': 'cr', 'hostId': 'cr', }) def test_virtual_machine(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'virtualMachine', 'r', { 'accountId': 'r', 'agentId': 'r', 'allocationState': 'r', 'blkioDeviceOptions': 'r', 'command': 'r', 'count': 'r', 'cpuSet': 'r', 'cpuShares': 'r', 'created': 'r', 'data': 'r', 'description': 'r', 'dns': 'r', 'dnsSearch': 'r', 'domainName': 'r', 'firstRunning': 'r', 'hostId': 'r', 'hostname': 'r', 'id': 'r', 'imageUuid': 'r', 'instanceLinks': 'r', 'memory': 'r', 'memorySwap': 'r', 'networkIds': 'r', 'networkMode': 'r', 'ports': 'r', 'primaryIpAddress': 'r', 'removeTime': 'r', 'registryCredentialId': 'r', 'requestedHostId': 'r', 'restartPolicy': 'r', 'startOnCreate': 'r', 'token': 'r', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'r', 'healthCheck': 'r', 'healthState': 'r', 'securityOpt': 'r', 'logConfig': 'r', 'volumeDriver': 'r', 'extraHosts': 'r', 'expose': 'r', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r', 'vcpu': 'r', 'userdata': 'r', 'memoryMb': 'r', 'disks': 'r', }) auth_check(user_client.schema, 'virtualMachine', 'r', { 'accountId': 'r', 'blkioDeviceOptions': 'r', 'command': 'r', 'count': 'r', 'cpuSet': 'r', 'cpuShares': 'r', 'created': 'r', 'description': 'r', 'dns': 'r', 'dnsSearch': 'r', 'domainName': 'r', 'firstRunning': 'r', 'hostId': 'r', 'hostname': 'r', 'id': 'r', 'imageUuid': 'r', 'instanceLinks': 'r', 'memory': 'r', 'memorySwap': 'r', 'networkIds': 'r', 'networkMode': 'r', 'ports': 'r', 'primaryIpAddress': 'r', 'registryCredentialId': 'r', 'requestedHostId': 'r', 'restartPolicy': 'r', 'startOnCreate': 'r', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'r', 'healthCheck': 'r', 'healthState': 'r', 'securityOpt': 'r', 'logConfig': 'r', 'extraHosts': 'r', 'volumeDriver': 'r', 'expose': 'r', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r', 'vcpu': 'r', 'userdata': 'r', 'memoryMb': 'r', 'disks': 'r', }) auth_check(project_client.schema, 'virtualMachine', 'crud', { 'accountId': 'r', 'blkioDeviceOptions': 'cr', 'command': 'cr', 'count': 'cr', 'cpuSet': 'cr', 'cpuShares': 'cr', 'created': 'r', 'description': 'cru', 'dns': 'cr', 'dnsSearch': 'cr', 'domainName': 'cr', 'firstRunning': 'r', 'hostId': 'r', 'hostname': 'cr', 'id': 'r', 'imageUuid': 'cr', 'instanceLinks': 'cr', 'memory': 'cr', 'memorySwap': 'cr', 'networkIds': 'cr', 'networkMode': 'cr', 'ports': 'cr', 'primaryIpAddress': 'r', 'registryCredentialId': 'cr', 'requestedHostId': 'cr', 'restartPolicy': 'cr', 'startOnCreate': 'cr', 'systemContainer': 'r', 'nativeContainer': 'r', 'externalId': 'r', 'labels': 'cr', 'healthCheck': 'cr', 'healthState': 'r', 'securityOpt': 'cr', 'logConfig': 'cr', 'extraHosts': 'cr', 'volumeDriver': 'cr', 'expose': 'cr', 'createIndex': 'r', 'deploymentUnitUuid': 'r', 'version': 'r', 'startCount': 'r', 'vcpu': 'cr', 'userdata': 'cr', 'memoryMb': 'cr', 'disks': 'cr', }) def test_virtual_machine_disk(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'virtualMachineDisk', 'r', { 'name': 'r', 'size': 'r', 'readIops': 'r', 'writeIops': 'r', 'opts': 'r', 'driver': 'r', 'root': 'r', }) auth_check(user_client.schema, 'virtualMachineDisk', 'r', { 'name': 'r', 'size': 'r', 'readIops': 'r', 'writeIops': 'r', 'opts': 'r', 'driver': 'r', 'root': 'r', }) auth_check(project_client.schema, 'virtualMachineDisk', 'cr', { 'name': 'cr', 'size': 'cr', 'readIops': 'cr', 'writeIops': 'cr', 'opts': 'cr', 'driver': 'cr', 'root': 'cr', }) def test_compose_service(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'composeService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'data': 'r', 'vip': 'r', 'selectorContainer': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'launchConfig': 'r', 'fqdn': 'r', 'selectorLink': 'r', 'scale': 'r', 'publicEndpoints': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(user_client.schema, 'composeService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'vip': 'r', 'selectorContainer': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'launchConfig': 'r', 'fqdn': 'r', 'selectorLink': 'r', 'scale': 'r', 'publicEndpoints': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) auth_check(project_client.schema, 'composeService', 'rd', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'vip': 'r', 'selectorContainer': 'r', 'healthState': 'r', 'startOnCreate': 'r', 'launchConfig': 'r', 'fqdn': 'r', 'selectorLink': 'r', 'scale': 'r', 'publicEndpoints': 'r', 'scalePolicy': 'r', 'currentScale': 'r', }) def test_machine_driver(admin_user_client, user_client, project_client, service_client): auth_check(admin_user_client.schema, 'machineDriver', 'crud', { 'name': 'r', 'checksum': 'cru', 'externalId': 'cru', 'uiUrl': 'cru', 'data': 'r', 'url': 'cru', 'defaultActive': 'r', 'builtin': 'cr', 'activateOnCreate': 'cr', }) auth_check(service_client.schema, 'machineDriver', 'crud', { 'name': 'cru', 'checksum': 'cru', 'externalId': 'cru', 'uiUrl': 'cru', 'data': 'r', 'url': 'cru', 'defaultActive': 'r', 'builtin': 'cr', 'activateOnCreate': 'cr', }) auth_check(user_client.schema, 'machineDriver', 'r', { 'name': 'r', 'checksum': 'r', 'externalId': 'r', 'uiUrl': 'r', 'url': 'r', 'defaultActive': 'r', 'builtin': 'r', 'activateOnCreate': 'r', }) auth_check(project_client.schema, 'machineDriver', 'r', { 'name': 'r', 'checksum': 'r', 'externalId': 'r', 'uiUrl': 'r', 'url': 'r', 'defaultActive': 'r', 'builtin': 'r', 'activateOnCreate': 'r', }) def test_kubernetes_service(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'kubernetesService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'data': 'r', 'vip': 'r', 'selectorContainer': 'r', 'template': 'r', 'healthState': 'r', }) auth_check(user_client.schema, 'kubernetesService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'vip': 'r', 'selectorContainer': 'r', 'template': 'r', 'healthState': 'r', }) auth_check(project_client.schema, 'kubernetesService', 'r', { 'name': 'r', 'externalId': 'r', 'environmentId': 'r', 'accountId': 'r', 'vip': 'r', 'selectorContainer': 'r', 'template': 'r', 'healthState': 'r', }) def test_machine(admin_user_client, user_client, project_client, service_client): auth_check(project_client.schema, 'machine', 'crd', { 'accountId': 'r', 'name': 'cr', 'driver': 'r', 'externalId': 'r', 'engineRegistryMirror': 'cr', 'authCertificateAuthority': 'cr', 'authKey': 'cr', 'labels': 'cr', 'engineInstallUrl': 'cr', 'dockerVersion': 'cr', 'engineOpt': 'cr', 'engineInsecureRegistry': 'cr', 'engineLabel': 'cr', 'engineStorageDriver': 'cr', 'engineEnv': 'cr', }) auth_check(service_client.schema, 'machine', 'crud', { 'accountId': 'r', 'name': 'cr', 'driver': 'r', 'data': 'r', 'extractedConfig': 'ru', 'externalId': 'r', 'engineRegistryMirror': 'cr', 'authCertificateAuthority': 'cr', 'authKey': 'cr', 'labels': 'cru', 'engineInstallUrl': 'cr', 'dockerVersion': 'cr', 'engineOpt': 'cr', 'engineInsecureRegistry': 'cr', 'engineLabel': 'cr', 'engineStorageDriver': 'cr', 'engineEnv': 'cr', }) auth_check(admin_user_client.schema, 'machine', 'r', { 'accountId': 'r', 'name': 'r', 'data': 'r', 'driver': 'r', 'externalId': 'r', 'engineRegistryMirror': 'r', 'authCertificateAuthority': 'r', 'authKey': 'r', 'labels': 'r', 'engineInstallUrl': 'r', 'dockerVersion': 'r', 'engineOpt': 'r', 'engineInsecureRegistry': 'r', 'engineLabel': 'r', 'engineStorageDriver': 'r', 'engineEnv': 'r', }) auth_check(user_client.schema, 'machine', 'r', { 'accountId': 'r', 'name': 'r', 'driver': 'r', 'externalId': 'r', 'engineRegistryMirror': 'r', 'authCertificateAuthority': 'r', 'authKey': 'r', 'labels': 'r', 'engineInstallUrl': 'r', 'dockerVersion': 'r', 'engineOpt': 'r', 'engineInsecureRegistry': 'r', 'engineLabel': 'r', 'engineStorageDriver': 'r', 'engineEnv': 'r', }) def test_snapshot_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'snapshot', 'r', { 'accountId': 'r', 'data': 'r', 'volumeId': 'r', }) auth_check(user_client.schema, 'snapshot', 'r', { 'accountId': 'r', 'volumeId': 'r', }) auth_check(project_client.schema, 'snapshot', 'rd', { 'accountId': 'r', 'volumeId': 'r', }) def test_backup_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'backup', 'r', { 'accountId': 'r', 'data': 'r', 'backupTargetId': 'r', 'snapshotId': 'r', 'uri': 'r', 'volumeId': 'r', }) auth_check(user_client.schema, 'backup', 'r', { 'accountId': 'r', 'backupTargetId': 'r', 'snapshotId': 'r', 'uri': 'r', 'volumeId': 'r', }) auth_check(project_client.schema, 'backup', 'rd', { 'accountId': 'r', 'backupTargetId': 'r', 'snapshotId': 'r', 'uri': 'r', 'volumeId': 'r', }) def test_backup_target_auth(admin_user_client, user_client, project_client): auth_check(admin_user_client.schema, 'backupTarget', 'r', { 'accountId': 'r', 'data': 'r', 'nfsConfig': 'r', }) auth_check(user_client.schema, 'backupTarget', 'r', { 'accountId': 'r', 'nfsConfig': 'r', }) auth_check(project_client.schema, 'backupTarget', 'crd', { 'accountId': 'r', 'nfsConfig': 'cr', })
apache-2.0
[ 504, 2863, 492, 627, 221, 327, 20432, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 922, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 751, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 1586, 63, 2113, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 739, 4880, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2199, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1715, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 1526, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1418, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 6631, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 4054, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 6631, 63, 2683, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 4054, 7099, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2435, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1364, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2199, 63, 2113, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1715, 2113, 1959, 751, 63, 1258, 421, 199, 318, 485, 3118, 63, 1313, 8, 1313, 304, 272, 367, 284, 315, 788, 8512, 2028, 297, 1598, 283, 456, 73, 783, 369, 2028, 297, 1598, 283, 6253, 2028, 297, 1598, 283, 1397, 10924, 297, 1598, 283, 9078, 2028, 297, 1598, 283, 18970, 86, 1251, 6727, 723, 2028, 297, 1598, 283, 476, 79, 3467, 2028, 297, 1598, 283, 8085, 2638, 2028, 297, 1598, 283, 9547, 86, 2028, 297, 1598, 283, 3098, 2028, 297, 1598, 283, 18970, 86, 14980, 2028, 297, 1598, 283, 2065, 1977, 2028, 297, 1598, 283, 14541, 2619, 67, 18, 2028, 297, 1598, 283, 6767, 2028, 297, 1598, 283, 18970, 70, 12444, 2028, 297, 1598, 283, 8573, 12201, 20867, 2028, 297, 1598, 283, 4617, 1897, 2028, 297, 1598, 283, 3592, 2028, 2565, 267, 862, 26, 288, 2943, 14, 2168, 8, 73, 9, 267, 871, 1722, 26, 288, 986, 267, 871, 4067, 26, 288, 986, 272, 372, 2943, 421, 199, 318, 511, 63, 751, 63, 1313, 8, 751, 63, 1258, 12, 9584, 29, 409, 1062, 14185, 29, 409, 5109, 272, 2943, 275, 469, 267, 283, 2048, 297, 267, 283, 525, 18669, 3205, 297, 267, 283, 525, 5587, 3167, 3834, 3205, 297, 267, 283, 1246, 1197, 297, 267, 283, 14274, 2445, 297, 267, 283, 5751, 297, 267, 283, 5751, 4277, 297, 267, 283, 1095, 8412, 2028, 297, 267, 283, 6999, 297, 267, 283, 1461, 13790, 3205, 297, 267, 283, 12607, 3167, 297, 267, 283, 12607, 4761, 297, 267, 283, 12607, 2028, 297, 267, 283, 12607, 2028, 3205, 297, 267, 283, 3600, 297, 267, 283, 3600, 2390, 297, 267, 283, 3600, 4858, 297, 267, 283, 3600, 16333, 297, 267, 283, 3600, 4936, 297, 267, 283, 15591, 297, 267, 283, 5797, 3167, 297, 267, 283, 5418, 297, 267, 283, 5418, 19217, 297, 267, 283, 5159, 3167, 297, 267, 283, 5159, 2390, 297, 267, 283, 5159, 3167, 2390, 297, 267, 283, 5159, 6408, 5453, 2390, 297, 267, 283, 5159, 6464, 2390, 297, 267, 283, 5159, 27664, 2390, 297, 267, 283, 5159, 4965, 2390, 297, 267, 283, 698, 17763, 297, 267, 283, 1102, 297, 267, 283, 1102, 3946, 297, 267, 283, 5582, 297, 267, 283, 1569, 297, 267, 283, 842, 297, 267, 283, 842, 9270, 297, 267, 283, 842, 9270, 3205, 297, 267, 283, 842, 18850, 1799, 297, 267, 283, 842, 3834, 297, 267, 283, 842, 6293, 297, 267, 283, 711, 1476, 297, 267, 283, 711, 1476, 14889, 323, 3205, 297, 267, 283, 17422, 3167, 297, 267, 283, 17422, 4851, 297, 267, 283, 17422, 4851, 19217, 297, 267, 283, 1302, 297, 267, 283, 912, 22249, 2640, 7810, 51, 8284, 9585, 4845, 297, 267, 283, 912, 22249, 2028, 297, 267, 283, 912, 22249, 7810, 51, 8284, 9585, 4845, 297, 267, 283, 912, 22249, 3167, 297, 267, 283, 793, 2028, 297, 267, 283, 6744, 297, 267, 283, 6744, 6158, 297, 267, 283, 3956, 297, 267, 283, 1200, 297, 267, 283, 2060, 297, 267, 283, 15020, 4965, 297, 267, 283, 719, 297, 267, 283, 1715, 297, 267, 283, 1715, 7021, 297, 267, 283, 9302, 4476, 297, 267, 283, 2683, 297, 267, 283, 8054, 3264, 297, 267, 283, 5189, 297, 267, 283, 5189, 23330, 297, 267, 283, 10506, 4845, 297, 267, 283, 8011, 2532, 16559, 3205, 297, 267, 283, 19092, 1378, 12038, 3205, 297, 267, 283, 3629, 297, 267, 283, 1364, 297, 267, 283, 1364, 920, 4070, 2956, 297, 267, 283, 1364, 4936, 297, 267, 283, 409, 14016, 3205, 297, 267, 283, 409, 14016, 3205 ]
[ 2863, 492, 627, 221, 327, 20432, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 922, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 751, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 1586, 63, 2113, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 739, 4880, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2199, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1715, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 1526, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1418, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 6631, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 4054, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 6631, 63, 2683, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 4054, 7099, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2435, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1364, 1959, 751, 63, 1258, 421, 199, 32, 4462, 14, 5997, 8, 2645, 534, 578, 358, 199, 318, 2199, 63, 2113, 63, 1258, 8, 2113, 63, 751, 63, 1258, 304, 272, 372, 1218, 63, 1100, 8, 2113, 63, 751, 63, 1258, 12, 1218, 63, 1715, 29, 797, 12, 2079, 1050, 63, 1102, 29, 797, 12, 4928, 534, 1715, 2113, 1959, 751, 63, 1258, 421, 199, 318, 485, 3118, 63, 1313, 8, 1313, 304, 272, 367, 284, 315, 788, 8512, 2028, 297, 1598, 283, 456, 73, 783, 369, 2028, 297, 1598, 283, 6253, 2028, 297, 1598, 283, 1397, 10924, 297, 1598, 283, 9078, 2028, 297, 1598, 283, 18970, 86, 1251, 6727, 723, 2028, 297, 1598, 283, 476, 79, 3467, 2028, 297, 1598, 283, 8085, 2638, 2028, 297, 1598, 283, 9547, 86, 2028, 297, 1598, 283, 3098, 2028, 297, 1598, 283, 18970, 86, 14980, 2028, 297, 1598, 283, 2065, 1977, 2028, 297, 1598, 283, 14541, 2619, 67, 18, 2028, 297, 1598, 283, 6767, 2028, 297, 1598, 283, 18970, 70, 12444, 2028, 297, 1598, 283, 8573, 12201, 20867, 2028, 297, 1598, 283, 4617, 1897, 2028, 297, 1598, 283, 3592, 2028, 2565, 267, 862, 26, 288, 2943, 14, 2168, 8, 73, 9, 267, 871, 1722, 26, 288, 986, 267, 871, 4067, 26, 288, 986, 272, 372, 2943, 421, 199, 318, 511, 63, 751, 63, 1313, 8, 751, 63, 1258, 12, 9584, 29, 409, 1062, 14185, 29, 409, 5109, 272, 2943, 275, 469, 267, 283, 2048, 297, 267, 283, 525, 18669, 3205, 297, 267, 283, 525, 5587, 3167, 3834, 3205, 297, 267, 283, 1246, 1197, 297, 267, 283, 14274, 2445, 297, 267, 283, 5751, 297, 267, 283, 5751, 4277, 297, 267, 283, 1095, 8412, 2028, 297, 267, 283, 6999, 297, 267, 283, 1461, 13790, 3205, 297, 267, 283, 12607, 3167, 297, 267, 283, 12607, 4761, 297, 267, 283, 12607, 2028, 297, 267, 283, 12607, 2028, 3205, 297, 267, 283, 3600, 297, 267, 283, 3600, 2390, 297, 267, 283, 3600, 4858, 297, 267, 283, 3600, 16333, 297, 267, 283, 3600, 4936, 297, 267, 283, 15591, 297, 267, 283, 5797, 3167, 297, 267, 283, 5418, 297, 267, 283, 5418, 19217, 297, 267, 283, 5159, 3167, 297, 267, 283, 5159, 2390, 297, 267, 283, 5159, 3167, 2390, 297, 267, 283, 5159, 6408, 5453, 2390, 297, 267, 283, 5159, 6464, 2390, 297, 267, 283, 5159, 27664, 2390, 297, 267, 283, 5159, 4965, 2390, 297, 267, 283, 698, 17763, 297, 267, 283, 1102, 297, 267, 283, 1102, 3946, 297, 267, 283, 5582, 297, 267, 283, 1569, 297, 267, 283, 842, 297, 267, 283, 842, 9270, 297, 267, 283, 842, 9270, 3205, 297, 267, 283, 842, 18850, 1799, 297, 267, 283, 842, 3834, 297, 267, 283, 842, 6293, 297, 267, 283, 711, 1476, 297, 267, 283, 711, 1476, 14889, 323, 3205, 297, 267, 283, 17422, 3167, 297, 267, 283, 17422, 4851, 297, 267, 283, 17422, 4851, 19217, 297, 267, 283, 1302, 297, 267, 283, 912, 22249, 2640, 7810, 51, 8284, 9585, 4845, 297, 267, 283, 912, 22249, 2028, 297, 267, 283, 912, 22249, 7810, 51, 8284, 9585, 4845, 297, 267, 283, 912, 22249, 3167, 297, 267, 283, 793, 2028, 297, 267, 283, 6744, 297, 267, 283, 6744, 6158, 297, 267, 283, 3956, 297, 267, 283, 1200, 297, 267, 283, 2060, 297, 267, 283, 15020, 4965, 297, 267, 283, 719, 297, 267, 283, 1715, 297, 267, 283, 1715, 7021, 297, 267, 283, 9302, 4476, 297, 267, 283, 2683, 297, 267, 283, 8054, 3264, 297, 267, 283, 5189, 297, 267, 283, 5189, 23330, 297, 267, 283, 10506, 4845, 297, 267, 283, 8011, 2532, 16559, 3205, 297, 267, 283, 19092, 1378, 12038, 3205, 297, 267, 283, 3629, 297, 267, 283, 1364, 297, 267, 283, 1364, 920, 4070, 2956, 297, 267, 283, 1364, 4936, 297, 267, 283, 409, 14016, 3205, 297, 267, 283, 409, 14016, 3205, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
samdroid-apps/sugar-toolkit-gtk3
src/sugar3/bundle/activitybundle.py
1
14091
# Copyright (C) 2007, Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. """Sugar activity bundles UNSTABLE. """ from ConfigParser import ConfigParser from locale import normalize import os import shutil import tempfile import logging from sugar3 import env from sugar3.bundle.bundle import Bundle, \ MalformedBundleException, NotInstalledException from sugar3.bundle.bundleversion import NormalizedVersion from sugar3.bundle.bundleversion import InvalidVersionError def _expand_lang(locale): # Private method from gettext.py locale = normalize(locale) COMPONENT_CODESET = 1 << 0 COMPONENT_TERRITORY = 1 << 1 COMPONENT_MODIFIER = 1 << 2 # split up the locale into its base components mask = 0 pos = locale.find('@') if pos >= 0: modifier = locale[pos:] locale = locale[:pos] mask |= COMPONENT_MODIFIER else: modifier = '' pos = locale.find('.') if pos >= 0: codeset = locale[pos:] locale = locale[:pos] mask |= COMPONENT_CODESET else: codeset = '' pos = locale.find('_') if pos >= 0: territory = locale[pos:] locale = locale[:pos] mask |= COMPONENT_TERRITORY else: territory = '' language = locale ret = [] for i in range(mask + 1): if not (i & ~mask): # if all components for this combo exist ... val = language if i & COMPONENT_TERRITORY: val += territory if i & COMPONENT_CODESET: val += codeset if i & COMPONENT_MODIFIER: val += modifier ret.append(val) ret.reverse() return ret class ActivityBundle(Bundle): """A Sugar activity bundle See http://wiki.laptop.org/go/Activity_bundles for details """ MIME_TYPE = 'application/vnd.olpc-sugar' _zipped_extension = '.xo' _unzipped_extension = '.activity' _infodir = 'activity' def __init__(self, path, translated=True): Bundle.__init__(self, path) self.activity_class = None self.bundle_exec = None self._name = None self._icon = None self._bundle_id = None self._mime_types = None self._show_launcher = True self._tags = None self._activity_version = '0' self._summary = None self._single_instance = False info_file = self.get_file('activity/activity.info') if info_file is None: raise MalformedBundleException('No activity.info file') self._parse_info(info_file) if translated: linfo_file = self._get_linfo_file() if linfo_file: self._parse_linfo(linfo_file) def _parse_info(self, info_file): cp = ConfigParser() cp.readfp(info_file) section = 'Activity' if cp.has_option(section, 'bundle_id'): self._bundle_id = cp.get(section, 'bundle_id') else: if cp.has_option(section, 'service_name'): self._bundle_id = cp.get(section, 'service_name') logging.error('ATTENTION: service_name property in the ' 'activity.info file is deprecated, should be ' ' changed to bundle_id') else: raise MalformedBundleException( 'Activity bundle %s does not specify a bundle id' % self._path) if cp.has_option(section, 'name'): self._name = cp.get(section, 'name') else: raise MalformedBundleException( 'Activity bundle %s does not specify a name' % self._path) if cp.has_option(section, 'exec'): self.bundle_exec = cp.get(section, 'exec') else: raise MalformedBundleException( 'Activity bundle %s must specify either class or exec' % self._path) if cp.has_option(section, 'mime_types'): mime_list = cp.get(section, 'mime_types').strip(';') self._mime_types = [mime.strip() for mime in mime_list.split(';')] if cp.has_option(section, 'show_launcher'): if cp.get(section, 'show_launcher') == 'no': self._show_launcher = False if cp.has_option(section, 'tags'): tag_list = cp.get(section, 'tags').strip(';') self._tags = [tag.strip() for tag in tag_list.split(';')] if cp.has_option(section, 'icon'): self._icon = cp.get(section, 'icon') if cp.has_option(section, 'activity_version'): version = cp.get(section, 'activity_version') try: NormalizedVersion(version) except InvalidVersionError: raise MalformedBundleException( 'Activity bundle %s has invalid version number %s' % (self._path, version)) self._activity_version = version if cp.has_option(section, 'summary'): self._summary = cp.get(section, 'summary') if cp.has_option(section, 'single_instance'): if cp.get(section, 'single_instance') == 'yes': self._single_instance = True def _get_linfo_file(self): # Using method from gettext.py, first find languages from environ languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): val = os.environ.get(envar) if val: languages = val.split(':') break # Next, normalize and expand the languages nelangs = [] for lang in languages: for nelang in _expand_lang(lang): if nelang not in nelangs: nelangs.append(nelang) # Finally, select a language for lang in nelangs: linfo_path = os.path.join('locale', lang, 'activity.linfo') linfo_file = self.get_file(linfo_path) if linfo_file is not None: return linfo_file return None def _parse_linfo(self, linfo_file): cp = ConfigParser() cp.readfp(linfo_file) section = 'Activity' if cp.has_option(section, 'name'): self._name = cp.get(section, 'name') if cp.has_option(section, 'summary'): self._summary = cp.get(section, 'summary') if cp.has_option(section, 'tags'): tag_list = cp.get(section, 'tags').strip(';') self._tags = [tag.strip() for tag in tag_list.split(';')] def get_locale_path(self): """Get the locale path inside the (installed) activity bundle.""" if self._zip_file is not None: raise NotInstalledException return os.path.join(self._path, 'locale') def get_icons_path(self): """Get the icons path inside the (installed) activity bundle.""" if self._zip_file is not None: raise NotInstalledException return os.path.join(self._path, 'icons') def get_name(self): """Get the activity user-visible name.""" return self._name def get_bundle_id(self): """Get the activity bundle id""" return self._bundle_id def get_icon(self): """Get the activity icon name""" # FIXME: this should return the icon data, not a filename, so that # we don't need to create a temp file in the zip case icon_path = os.path.join('activity', self._icon + '.svg') if self._zip_file is None: return os.path.join(self._path, icon_path) else: icon_data = self.get_file(icon_path).read() temp_file, temp_file_path = tempfile.mkstemp(prefix=self._icon, suffix='.svg') os.write(temp_file, icon_data) os.close(temp_file) return temp_file_path def get_activity_version(self): """Get the activity version""" return self._activity_version def get_command(self): """Get the command to execute to launch the activity factory""" if self.bundle_exec: command = os.path.expandvars(self.bundle_exec) else: command = 'sugar-activity ' + self.activity_class return command def get_mime_types(self): """Get the MIME types supported by the activity""" return self._mime_types def get_tags(self): """Get the tags that describe the activity""" return self._tags def get_summary(self): """Get the summary that describe the activity""" return self._summary def get_single_instance(self): """Get whether there should be a single instance for the activity""" return self._single_instance def get_show_launcher(self): """Get whether there should be a visible launcher for the activity""" return self._show_launcher def install(self): install_dir = env.get_user_activities_path() self._unzip(install_dir) install_path = os.path.join(install_dir, self._zip_root_dir) self.install_mime_type(install_path) return install_path def install_mime_type(self, install_path): """ Update the mime type database and install the mime type icon """ xdg_data_home = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share')) mime_path = os.path.join(install_path, 'activity', 'mimetypes.xml') if os.path.isfile(mime_path): mime_dir = os.path.join(xdg_data_home, 'mime') mime_pkg_dir = os.path.join(mime_dir, 'packages') if not os.path.isdir(mime_pkg_dir): os.makedirs(mime_pkg_dir) installed_mime_path = os.path.join(mime_pkg_dir, '%s.xml' % self._bundle_id) self._symlink(mime_path, installed_mime_path) os.spawnlp(os.P_WAIT, 'update-mime-database', 'update-mime-database', mime_dir) mime_types = self.get_mime_types() if mime_types is not None: installed_icons_dir = \ os.path.join(xdg_data_home, 'icons/sugar/scalable/mimetypes') if not os.path.isdir(installed_icons_dir): os.makedirs(installed_icons_dir) for mime_type in mime_types: mime_icon_base = os.path.join(install_path, 'activity', mime_type.replace('/', '-')) svg_file = mime_icon_base + '.svg' info_file = mime_icon_base + '.icon' self._symlink(svg_file, os.path.join(installed_icons_dir, os.path.basename(svg_file))) self._symlink(info_file, os.path.join(installed_icons_dir, os.path.basename(info_file))) def _symlink(self, src, dst): if not os.path.isfile(src): return if not os.path.islink(dst) and os.path.exists(dst): raise RuntimeError('Do not remove %s if it was not ' 'installed by sugar', dst) logging.debug('Link resource %s to %s', src, dst) if os.path.lexists(dst): logging.debug('Relink %s', dst) os.unlink(dst) os.symlink(src, dst) def uninstall(self, force=False, delete_profile=False): install_path = self.get_path() if os.path.islink(install_path): # Don't remove the actual activity dir if it's a symbolic link # because we may be removing user data. os.unlink(install_path) return xdg_data_home = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share')) mime_dir = os.path.join(xdg_data_home, 'mime') installed_mime_path = os.path.join(mime_dir, 'packages', '%s.xml' % self._bundle_id) if os.path.exists(installed_mime_path): os.remove(installed_mime_path) os.spawnlp(os.P_WAIT, 'update-mime-database', 'update-mime-database', mime_dir) mime_types = self.get_mime_types() if mime_types is not None: installed_icons_dir = \ os.path.join(xdg_data_home, 'icons/sugar/scalable/mimetypes') if os.path.isdir(installed_icons_dir): for f in os.listdir(installed_icons_dir): path = os.path.join(installed_icons_dir, f) if os.path.islink(path) and \ os.readlink(path).startswith(install_path): os.remove(path) if delete_profile: bundle_profile_path = env.get_profile_path(self._bundle_id) if os.path.exists(bundle_profile_path): os.chmod(bundle_profile_path, 0775) shutil.rmtree(bundle_profile_path, ignore_errors=True) self._uninstall(install_path) def is_user_activity(self): return self.get_path().startswith(env.get_user_activities_path())
lgpl-2.1
[ 3, 1898, 334, 35, 9, 10219, 12, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 199, 3, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 51, 21922, 10679, 27206, 199, 199, 1734, 840, 2617, 14, 199, 624, 199, 199, 504, 14196, 492, 14196, 199, 504, 5867, 492, 7666, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 2050, 199, 199, 504, 308, 21922, 19, 492, 2589, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 492, 29311, 12, 971, 272, 603, 24012, 12320, 1726, 12, 2832, 21268, 1726, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 1023, 492, 11514, 1759, 3353, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 1023, 492, 6378, 3353, 547, 421, 199, 318, 485, 4441, 63, 4159, 8, 5508, 304, 272, 327, 18551, 1083, 687, 9796, 14, 647, 272, 5867, 275, 7666, 8, 5508, 9, 272, 16503, 17877, 63, 15639, 775, 275, 413, 5213, 378, 272, 16503, 17877, 63, 1157, 50, 649, 5347, 275, 413, 5213, 413, 272, 16503, 17877, 63, 16422, 29315, 275, 413, 5213, 499, 339, 327, 3715, 1536, 314, 5867, 1901, 2399, 1300, 7323, 272, 3656, 275, 378, 272, 2086, 275, 5867, 14, 1623, 16591, 358, 272, 340, 2086, 2356, 378, 26, 267, 17880, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 16422, 29315, 272, 587, 26, 267, 17880, 275, 2125, 339, 2086, 275, 5867, 14, 1623, 7563, 272, 340, 2086, 2356, 378, 26, 267, 1233, 409, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 15639, 775, 272, 587, 26, 267, 1233, 409, 275, 2125, 339, 2086, 275, 5867, 14, 1623, 26341, 272, 340, 2086, 2356, 378, 26, 267, 2044, 26425, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 1157, 50, 649, 5347, 272, 587, 26, 267, 2044, 26425, 275, 2125, 339, 2637, 275, 5867, 272, 2203, 275, 942, 272, 367, 284, 315, 1425, 8, 2629, 435, 413, 304, 267, 340, 440, 334, 73, 1253, 6146, 2629, 304, 221, 327, 340, 1006, 7323, 367, 642, 20972, 2187, 2263, 288, 1139, 275, 2637, 288, 340, 284, 1253, 16503, 17877, 63, 1157, 50, 649, 5347, 26, 355, 1139, 847, 2044, 26425, 288, 340, 284, 1253, 16503, 17877, 63, 15639, 775, 26, 355, 1139, 847, 1233, 409, 288, 340, 284, 1253, 16503, 17877, 63, 16422, 29315, 26, 355, 1139, 847, 17880, 288, 2203, 14, 740, 8, 637, 9, 272, 2203, 14, 4471, 342, 272, 372, 2203, 421, 199, 533, 21885, 12320, 8, 12320, 304, 272, 408, 33, 428, 21922, 10679, 8844, 339, 1666, 1455, 921, 6797, 14, 416, 541, 411, 14, 1308, 15, 1939, 15, 14350, 63, 66, 18793, 367, 2436, 272, 408, 339, 14735, 63, 2711, 275, 283, 3578, 15, 26379, 14, 393, 2352, 13, 83, 21922, 7, 339, 485, 3065, 1915, 63, 3435, 275, 1987, 15987, 7, 272, 485, 26700, 1915, 63, 3435, 275, 1987, 8240, 7, 272, 485, 815, 694, 275, 283, 8240, 7, 339, 347, 636, 826, 721, 277, 12, 931, 12, 14598, 29, 549, 304, 267, 29311, 855, 826, 721, 277, 12, 931, 9, 267, 291, 14, 8240, 63, 533, 275, 488, 267, 291, 14, 6469, 63, 1628, 275, 488, 398, 291, 423, 354, 275, 488, 267, 291, 423, 4677, 275, 488, 267, 291, 423, 6469, 63, 344, 275, 488, 267, 291, 423, 7626, 63, 1313, 275, 488, 267, 291, 423, 2384, 63, 27326, 275, 715, 267, 291, 423, 2969, 275, 488, 267, 291, 423, 8240, 63, 1023, 275, 283, 16, 7, 267, 291, 423, 4705, 275, 488, 267, 291, 423, 4780, 63, 842, 275, 756, 398, 2256, 63, 493, 275, 291, 14, 362, 63, 493, 360, 8240, 15, 8240, 14, 815, 358, 267, 340, 2256, 63, 493, 365, 488, 26, 288, 746, 603, 24012, 12320, 1726, 360, 1944, 10679, 14, 815, 570, 358, 267, 291, 423, 1122, 63, 815, 8, 815, 63, 493, 9, 398, 340, 14598, 26, 288, 7403, 545, 63, 493, 275, 291, 423, 362, 63, 472, 545, 63, 493, 342, 288, 340, 7403, 545, 63, 493, 26, 355, 291, 423, 1122, 63, 472, 545, 8, 472, 545, 63, 493, 9, 339, 347, 485, 1122, 63, 815, 8, 277, 12, 2256, 63, 493, 304, 267, 7667, 275, 14196, 342, 267, 7667, 14, 739, 3997, 8, 815, 63, 493, 9, 398, 3420, 275, 283, 14350, 7, 398, 340, 7667, 14, 1989, 63, 1422, 8, 2792, 12, 283, 6469, 63, 344, 735, 288, 291, 423, 6469, 63, 344, 275, 7667, 14, 362, 8, 2792, 12, 283, 6469, 63, 344, 358, 267, 587, 26, 288, 340, 7667, 14, 1989, 63, 1422, 8, 2792, 12, 283, 1364, 63, 354, 735, 355, 291, 423, 6469, 63, 344, 275, 7667, 14, 362, 8, 2792, 12, 283, 1364, 63, 354, 358, 355, 2050, 14, 705, 360, 11712, 1309, 1075, 26, 2435, 63, 354, 3324, 315, 314, 283, 2892, 283, 8240, 14, 815, 570, 365, 5906, 12, 1077, 506, 283, 2892, 283, 2896, 370, 8844, 63, 344, 358, 288, 587, 26, 355, 746, 603, 24012, 12320, 1726, 8, 490, 283, 14350, 8844, 450, 83, 1630, 440, 4165, 282, 8844, 1305, 7, 450, 490, 291, 423, 515 ]
[ 1898, 334, 35, 9, 10219, 12, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 199, 3, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 51, 21922, 10679, 27206, 199, 199, 1734, 840, 2617, 14, 199, 624, 199, 199, 504, 14196, 492, 14196, 199, 504, 5867, 492, 7666, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 2050, 199, 199, 504, 308, 21922, 19, 492, 2589, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 492, 29311, 12, 971, 272, 603, 24012, 12320, 1726, 12, 2832, 21268, 1726, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 1023, 492, 11514, 1759, 3353, 199, 504, 308, 21922, 19, 14, 6469, 14, 6469, 1023, 492, 6378, 3353, 547, 421, 199, 318, 485, 4441, 63, 4159, 8, 5508, 304, 272, 327, 18551, 1083, 687, 9796, 14, 647, 272, 5867, 275, 7666, 8, 5508, 9, 272, 16503, 17877, 63, 15639, 775, 275, 413, 5213, 378, 272, 16503, 17877, 63, 1157, 50, 649, 5347, 275, 413, 5213, 413, 272, 16503, 17877, 63, 16422, 29315, 275, 413, 5213, 499, 339, 327, 3715, 1536, 314, 5867, 1901, 2399, 1300, 7323, 272, 3656, 275, 378, 272, 2086, 275, 5867, 14, 1623, 16591, 358, 272, 340, 2086, 2356, 378, 26, 267, 17880, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 16422, 29315, 272, 587, 26, 267, 17880, 275, 2125, 339, 2086, 275, 5867, 14, 1623, 7563, 272, 340, 2086, 2356, 378, 26, 267, 1233, 409, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 15639, 775, 272, 587, 26, 267, 1233, 409, 275, 2125, 339, 2086, 275, 5867, 14, 1623, 26341, 272, 340, 2086, 2356, 378, 26, 267, 2044, 26425, 275, 5867, 59, 1712, 2938, 267, 5867, 275, 5867, 1491, 1712, 61, 267, 3656, 8901, 16503, 17877, 63, 1157, 50, 649, 5347, 272, 587, 26, 267, 2044, 26425, 275, 2125, 339, 2637, 275, 5867, 272, 2203, 275, 942, 272, 367, 284, 315, 1425, 8, 2629, 435, 413, 304, 267, 340, 440, 334, 73, 1253, 6146, 2629, 304, 221, 327, 340, 1006, 7323, 367, 642, 20972, 2187, 2263, 288, 1139, 275, 2637, 288, 340, 284, 1253, 16503, 17877, 63, 1157, 50, 649, 5347, 26, 355, 1139, 847, 2044, 26425, 288, 340, 284, 1253, 16503, 17877, 63, 15639, 775, 26, 355, 1139, 847, 1233, 409, 288, 340, 284, 1253, 16503, 17877, 63, 16422, 29315, 26, 355, 1139, 847, 17880, 288, 2203, 14, 740, 8, 637, 9, 272, 2203, 14, 4471, 342, 272, 372, 2203, 421, 199, 533, 21885, 12320, 8, 12320, 304, 272, 408, 33, 428, 21922, 10679, 8844, 339, 1666, 1455, 921, 6797, 14, 416, 541, 411, 14, 1308, 15, 1939, 15, 14350, 63, 66, 18793, 367, 2436, 272, 408, 339, 14735, 63, 2711, 275, 283, 3578, 15, 26379, 14, 393, 2352, 13, 83, 21922, 7, 339, 485, 3065, 1915, 63, 3435, 275, 1987, 15987, 7, 272, 485, 26700, 1915, 63, 3435, 275, 1987, 8240, 7, 272, 485, 815, 694, 275, 283, 8240, 7, 339, 347, 636, 826, 721, 277, 12, 931, 12, 14598, 29, 549, 304, 267, 29311, 855, 826, 721, 277, 12, 931, 9, 267, 291, 14, 8240, 63, 533, 275, 488, 267, 291, 14, 6469, 63, 1628, 275, 488, 398, 291, 423, 354, 275, 488, 267, 291, 423, 4677, 275, 488, 267, 291, 423, 6469, 63, 344, 275, 488, 267, 291, 423, 7626, 63, 1313, 275, 488, 267, 291, 423, 2384, 63, 27326, 275, 715, 267, 291, 423, 2969, 275, 488, 267, 291, 423, 8240, 63, 1023, 275, 283, 16, 7, 267, 291, 423, 4705, 275, 488, 267, 291, 423, 4780, 63, 842, 275, 756, 398, 2256, 63, 493, 275, 291, 14, 362, 63, 493, 360, 8240, 15, 8240, 14, 815, 358, 267, 340, 2256, 63, 493, 365, 488, 26, 288, 746, 603, 24012, 12320, 1726, 360, 1944, 10679, 14, 815, 570, 358, 267, 291, 423, 1122, 63, 815, 8, 815, 63, 493, 9, 398, 340, 14598, 26, 288, 7403, 545, 63, 493, 275, 291, 423, 362, 63, 472, 545, 63, 493, 342, 288, 340, 7403, 545, 63, 493, 26, 355, 291, 423, 1122, 63, 472, 545, 8, 472, 545, 63, 493, 9, 339, 347, 485, 1122, 63, 815, 8, 277, 12, 2256, 63, 493, 304, 267, 7667, 275, 14196, 342, 267, 7667, 14, 739, 3997, 8, 815, 63, 493, 9, 398, 3420, 275, 283, 14350, 7, 398, 340, 7667, 14, 1989, 63, 1422, 8, 2792, 12, 283, 6469, 63, 344, 735, 288, 291, 423, 6469, 63, 344, 275, 7667, 14, 362, 8, 2792, 12, 283, 6469, 63, 344, 358, 267, 587, 26, 288, 340, 7667, 14, 1989, 63, 1422, 8, 2792, 12, 283, 1364, 63, 354, 735, 355, 291, 423, 6469, 63, 344, 275, 7667, 14, 362, 8, 2792, 12, 283, 1364, 63, 354, 358, 355, 2050, 14, 705, 360, 11712, 1309, 1075, 26, 2435, 63, 354, 3324, 315, 314, 283, 2892, 283, 8240, 14, 815, 570, 365, 5906, 12, 1077, 506, 283, 2892, 283, 2896, 370, 8844, 63, 344, 358, 288, 587, 26, 355, 746, 603, 24012, 12320, 1726, 8, 490, 283, 14350, 8844, 450, 83, 1630, 440, 4165, 282, 8844, 1305, 7, 450, 490, 291, 423, 515, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
shashank971/edx-platform
common/djangoapps/embargo/models.py
53
25524
""" Models for embargoing visits to certain courses by IP address. WE'RE USING MIGRATIONS! If you make changes to this model, be sure to create an appropriate migration file and check it in at the same time as your model changes. To do that, 1. Go to the edx-platform dir 2. ./manage.py lms schemamigration embargo --auto description_of_your_change 3. Add the migration file created in edx-platform/common/djangoapps/embargo/migrations/ """ import ipaddr import json import logging from django.db import models from django.utils.translation import ugettext as _, ugettext_lazy from django.core.cache import cache from django.core.urlresolvers import reverse from django.db.models.signals import post_save, post_delete from django_countries.fields import CountryField from django_countries import countries from config_models.models import ConfigurationModel from xmodule_django.models import CourseKeyField, NoneToEmptyManager from embargo.exceptions import InvalidAccessPoint from embargo.messages import ENROLL_MESSAGES, COURSEWARE_MESSAGES log = logging.getLogger(__name__) class EmbargoedCourse(models.Model): """ Enable course embargo on a course-by-course basis. Deprecated by `RestrictedCourse` """ objects = NoneToEmptyManager() # The course to embargo course_id = CourseKeyField(max_length=255, db_index=True, unique=True) # Whether or not to embargo embargoed = models.BooleanField(default=False) @classmethod def is_embargoed(cls, course_id): """ Returns whether or not the given course id is embargoed. If course has not been explicitly embargoed, returns False. """ try: record = cls.objects.get(course_id=course_id) return record.embargoed except cls.DoesNotExist: return False def __unicode__(self): not_em = "Not " if self.embargoed: not_em = "" # pylint: disable=no-member return u"Course '{}' is {}Embargoed".format(self.course_id.to_deprecated_string(), not_em) class EmbargoedState(ConfigurationModel): """ Register countries to be embargoed. Deprecated by `Country`. """ # The countries to embargo embargoed_countries = models.TextField( blank=True, help_text="A comma-separated list of country codes that fall under U.S. embargo restrictions" ) @property def embargoed_countries_list(self): """ Return a list of upper case country codes """ if self.embargoed_countries == '': return [] return [country.strip().upper() for country in self.embargoed_countries.split(',')] # pylint: disable=no-member class RestrictedCourse(models.Model): """Course with access restrictions. Restricted courses can block users at two points: 1) When enrolling in a course. 2) When attempting to access a course the user is already enrolled in. The second case can occur when new restrictions are put into place; for example, when new countries are embargoed. Restricted courses can be configured to display messages to users when they are blocked. These displayed on pages served by the embargo app. """ COURSE_LIST_CACHE_KEY = 'embargo.restricted_courses' MESSAGE_URL_CACHE_KEY = 'embargo.message_url_path.{access_point}.{course_key}' ENROLL_MSG_KEY_CHOICES = tuple([ (msg_key, msg.description) for msg_key, msg in ENROLL_MESSAGES.iteritems() ]) COURSEWARE_MSG_KEY_CHOICES = tuple([ (msg_key, msg.description) for msg_key, msg in COURSEWARE_MESSAGES.iteritems() ]) course_key = CourseKeyField( max_length=255, db_index=True, unique=True, help_text=ugettext_lazy(u"The course key for the restricted course.") ) enroll_msg_key = models.CharField( max_length=255, choices=ENROLL_MSG_KEY_CHOICES, default='default', help_text=ugettext_lazy(u"The message to show when a user is blocked from enrollment.") ) access_msg_key = models.CharField( max_length=255, choices=COURSEWARE_MSG_KEY_CHOICES, default='default', help_text=ugettext_lazy(u"The message to show when a user is blocked from accessing a course.") ) disable_access_check = models.BooleanField( default=False, help_text=ugettext_lazy( u"Allow users who enrolled in an allowed country " u"to access restricted courses from excluded countries." ) ) @classmethod def is_restricted_course(cls, course_id): """ Check if the course is in restricted list Args: course_id (str): course_id to look for Returns: Boolean True if course is in restricted course list. """ return unicode(course_id) in cls._get_restricted_courses_from_cache() @classmethod def is_disabled_access_check(cls, course_id): """ Check if the course is in restricted list has disabled_access_check Args: course_id (str): course_id to look for Returns: Boolean disabled_access_check attribute of restricted course """ # checking is_restricted_course method also here to make sure course exists in the list otherwise in case of # no course found it will throw the key not found error on 'disable_access_check' return ( cls.is_restricted_course(unicode(course_id)) and cls._get_restricted_courses_from_cache().get(unicode(course_id))["disable_access_check"] ) @classmethod def _get_restricted_courses_from_cache(cls): """ Cache all restricted courses and returns the dict of course_keys and disable_access_check that are restricted """ restricted_courses = cache.get(cls.COURSE_LIST_CACHE_KEY) if restricted_courses is None: restricted_courses = { unicode(course.course_key): { 'disable_access_check': course.disable_access_check } for course in RestrictedCourse.objects.all() } cache.set(cls.COURSE_LIST_CACHE_KEY, restricted_courses) return restricted_courses def snapshot(self): """Return a snapshot of all access rules for this course. This is useful for recording an audit trail of rule changes. The returned dictionary is JSON-serializable. Returns: dict Example Usage: >>> restricted_course.snapshot() { 'enroll_msg': 'default', 'access_msg': 'default', 'country_rules': [ {'country': 'IR', 'rule_type': 'blacklist'}, {'country': 'CU', 'rule_type': 'blacklist'} ] } """ country_rules_for_course = ( CountryAccessRule.objects ).select_related('restricted_country').filter(restricted_course=self) return { 'enroll_msg': self.enroll_msg_key, 'access_msg': self.access_msg_key, 'country_rules': [ { 'country': unicode(rule.country.country), 'rule_type': rule.rule_type } for rule in country_rules_for_course ] } def message_key_for_access_point(self, access_point): """Determine which message to show the user. The message can be configured per-course and depends on how the user is trying to access the course (trying to enroll or accessing courseware). Arguments: access_point (str): Either "courseware" or "enrollment" Returns: str: The message key. If the access point is not valid, returns None instead. """ if access_point == 'enrollment': return self.enroll_msg_key elif access_point == 'courseware': return self.access_msg_key def __unicode__(self): return unicode(self.course_key) @classmethod def message_url_path(cls, course_key, access_point): """Determine the URL path for the message explaining why the user was blocked. This is configured per-course. See `RestrictedCourse` in the `embargo.models` module for more details. Arguments: course_key (CourseKey): The location of the course. access_point (str): How the user was trying to access the course. Can be either "enrollment" or "courseware". Returns: unicode: The URL path to a page explaining why the user was blocked. Raises: InvalidAccessPoint: Raised if access_point is not a supported value. """ if access_point not in ['enrollment', 'courseware']: raise InvalidAccessPoint(access_point) # First check the cache to see if we already have # a URL for this (course_key, access_point) tuple cache_key = cls.MESSAGE_URL_CACHE_KEY.format( access_point=access_point, course_key=course_key ) url = cache.get(cache_key) # If there's a cache miss, we'll need to retrieve the message # configuration from the database if url is None: url = cls._get_message_url_path_from_db(course_key, access_point) cache.set(cache_key, url) return url @classmethod def _get_message_url_path_from_db(cls, course_key, access_point): """Retrieve the "blocked" message from the database. Arguments: course_key (CourseKey): The location of the course. access_point (str): How the user was trying to access the course. Can be either "enrollment" or "courseware". Returns: unicode: The URL path to a page explaining why the user was blocked. """ # Fallback in case we're not able to find a message path # Presumably if the caller is requesting a URL, the caller # has already determined that the user should be blocked. # We use generic messaging unless we find something more specific, # but *always* return a valid URL path. default_path = reverse( 'embargo_blocked_message', kwargs={ 'access_point': 'courseware', 'message_key': 'default' } ) # First check whether this is a restricted course. # The list of restricted courses is cached, so this does # not require a database query. if not cls.is_restricted_course(course_key): return default_path # Retrieve the message key from the restricted course # for this access point, then determine the URL. try: course = cls.objects.get(course_key=course_key) msg_key = course.message_key_for_access_point(access_point) return reverse( 'embargo_blocked_message', kwargs={ 'access_point': access_point, 'message_key': msg_key } ) except cls.DoesNotExist: # This occurs only if there's a race condition # between cache invalidation and database access. return default_path @classmethod def invalidate_cache_for_course(cls, course_key): """Invalidate the caches for the restricted course. """ cache.delete(cls.COURSE_LIST_CACHE_KEY) log.info("Invalidated cached list of restricted courses.") for access_point in ['enrollment', 'courseware']: msg_cache_key = cls.MESSAGE_URL_CACHE_KEY.format( access_point=access_point, course_key=course_key ) cache.delete(msg_cache_key) log.info("Invalidated cached messaging URLs ") class Country(models.Model): """Representation of a country. This is used to define country-based access rules. There is a data migration that creates entries for each country code. """ country = CountryField( db_index=True, unique=True, help_text=ugettext_lazy(u"Two character ISO country code.") ) def __unicode__(self): return u"{name} ({code})".format( name=unicode(self.country.name), code=unicode(self.country) ) class Meta(object): """Default ordering is ascending by country code """ ordering = ['country'] class CountryAccessRule(models.Model): """Course access rule based on the user's country. The rule applies to a particular course-country pair. Countries can either be whitelisted or blacklisted, but not both. To determine whether a user has access to a course based on the user's country: 1) Retrieve the list of whitelisted countries for the course. (If there aren't any, then include every possible country.) 2) From the initial list, remove all blacklisted countries for the course. """ WHITELIST_RULE = 'whitelist' BLACKLIST_RULE = 'blacklist' RULE_TYPE_CHOICES = ( (WHITELIST_RULE, 'Whitelist (allow only these countries)'), (BLACKLIST_RULE, 'Blacklist (block these countries)'), ) rule_type = models.CharField( max_length=255, choices=RULE_TYPE_CHOICES, default=BLACKLIST_RULE, help_text=ugettext_lazy( u"Whether to include or exclude the given course. " u"If whitelist countries are specified, then ONLY users from whitelisted countries " u"will be able to access the course. If blacklist countries are specified, then " u"users from blacklisted countries will NOT be able to access the course." ) ) restricted_course = models.ForeignKey( "RestrictedCourse", help_text=ugettext_lazy(u"The course to which this rule applies.") ) country = models.ForeignKey( "Country", help_text=ugettext_lazy(u"The country to which this rule applies.") ) CACHE_KEY = u"embargo.allowed_countries.{course_key}" ALL_COUNTRIES = set(code[0] for code in list(countries)) @classmethod def check_country_access(cls, course_id, country): """ Check if the country is either in whitelist or blacklist of countries for the course_id Args: course_id (str): course_id to look for country (str): A 2 characters code of country Returns: Boolean True if country found in allowed country otherwise check given country exists in list """ # If the country code is not in the list of all countries, # we don't want to automatically exclude the user. # This can happen, for example, when GeoIP falls back # to using a continent code because it cannot determine # the specific country. if country not in cls.ALL_COUNTRIES: return True cache_key = cls.CACHE_KEY.format(course_key=course_id) allowed_countries = cache.get(cache_key) if allowed_countries is None: allowed_countries = cls._get_country_access_list(course_id) cache.set(cache_key, allowed_countries) return country == '' or country in allowed_countries @classmethod def _get_country_access_list(cls, course_id): """ if a course is blacklist for two countries then course can be accessible from any where except these two countries. if a course is whitelist for two countries then course can be accessible from these countries only. Args: course_id (str): course_id to look for Returns: List Consolidated list of accessible countries for given course """ whitelist_countries = set() blacklist_countries = set() # Retrieve all rules in one database query, performing the "join" with the Country table rules_for_course = CountryAccessRule.objects.select_related('country').filter( restricted_course__course_key=course_id ) # Filter the rules into a whitelist and blacklist in one pass for rule in rules_for_course: if rule.rule_type == cls.WHITELIST_RULE: whitelist_countries.add(rule.country.country.code) elif rule.rule_type == cls.BLACKLIST_RULE: blacklist_countries.add(rule.country.country.code) # If there are no whitelist countries, default to all countries if not whitelist_countries: whitelist_countries = cls.ALL_COUNTRIES # Consolidate the rules into a single list of countries # that have access to the course. return list(whitelist_countries - blacklist_countries) def __unicode__(self): if self.rule_type == self.WHITELIST_RULE: return _(u"Whitelist {country} for {course}").format( course=unicode(self.restricted_course.course_key), country=unicode(self.country), ) elif self.rule_type == self.BLACKLIST_RULE: return _(u"Blacklist {country} for {course}").format( course=unicode(self.restricted_course.course_key), country=unicode(self.country), ) @classmethod def invalidate_cache_for_course(cls, course_key): """Invalidate the cache. """ cache_key = cls.CACHE_KEY.format(course_key=course_key) cache.delete(cache_key) log.info("Invalidated country access list for course %s", course_key) class Meta(object): """a course can be added with either black or white list. """ unique_together = ( # This restriction ensures that a country is on # either the whitelist or the blacklist, but # not both (for a particular course). ("restricted_course", "country") ) def invalidate_country_rule_cache(sender, instance, **kwargs): # pylint: disable=unused-argument """Invalidate cached rule information on changes to the rule models. We need to handle this in a Django receiver, because Django admin doesn't always call the model's `delete()` method directly during a bulk delete operation. Arguments: sender: Not used, but required by Django receivers. instance (RestrictedCourse or CountryAccessRule): The instance being saved or deleted. """ if isinstance(instance, RestrictedCourse): # If a restricted course changed, we need to update the list # of which courses are restricted as well as any rules # associated with the course. RestrictedCourse.invalidate_cache_for_course(instance.course_key) CountryAccessRule.invalidate_cache_for_course(instance.course_key) if isinstance(instance, CountryAccessRule): try: restricted_course = instance.restricted_course except RestrictedCourse.DoesNotExist: # If the restricted course and its rules are being deleted, # the restricted course may not exist at this point. # However, the cache should have been invalidated # when the restricted course was deleted. pass else: # Invalidate the cache of countries for the course. CountryAccessRule.invalidate_cache_for_course(restricted_course.course_key) # Hook up the cache invalidation receivers to the appropriate # post_save and post_delete signals. post_save.connect(invalidate_country_rule_cache, sender=CountryAccessRule) post_save.connect(invalidate_country_rule_cache, sender=RestrictedCourse) post_delete.connect(invalidate_country_rule_cache, sender=CountryAccessRule) post_delete.connect(invalidate_country_rule_cache, sender=RestrictedCourse) class CourseAccessRuleHistory(models.Model): """History of course access rule changes. """ timestamp = models.DateTimeField(db_index=True, auto_now_add=True) course_key = CourseKeyField(max_length=255, db_index=True) snapshot = models.TextField(null=True, blank=True) DELETED_PLACEHOLDER = "DELETED" @classmethod def save_snapshot(cls, restricted_course, deleted=False): """Save a snapshot of access rules for a course. Arguments: restricted_course (RestrictedCourse) Keyword Arguments: deleted (boolean): If True, the restricted course is about to be deleted. Create a placeholder snapshot recording that the course and all its rules was deleted. Returns: None """ course_key = restricted_course.course_key # At the point this is called, the access rules may not have # been deleted yet. When the rules *are* deleted, the # restricted course entry may no longer exist, so we # won't be able to take a snapshot of the rules. # To handle this, we save a placeholder "DELETED" entry # so that it's clear in the audit that the restricted # course (along with all its rules) was deleted. snapshot = ( CourseAccessRuleHistory.DELETED_PLACEHOLDER if deleted else json.dumps(restricted_course.snapshot()) ) cls.objects.create( course_key=course_key, snapshot=snapshot ) @staticmethod def snapshot_post_save_receiver(sender, instance, **kwargs): # pylint: disable=unused-argument """Create a snapshot of course access rules when the rules are updated. """ if isinstance(instance, RestrictedCourse): CourseAccessRuleHistory.save_snapshot(instance) elif isinstance(instance, CountryAccessRule): CourseAccessRuleHistory.save_snapshot(instance.restricted_course) @staticmethod def snapshot_post_delete_receiver(sender, instance, **kwargs): # pylint: disable=unused-argument """Create a snapshot of course access rules when rules are deleted. """ if isinstance(instance, RestrictedCourse): CourseAccessRuleHistory.save_snapshot(instance, deleted=True) elif isinstance(instance, CountryAccessRule): try: restricted_course = instance.restricted_course except RestrictedCourse.DoesNotExist: # When Django admin deletes a restricted course, it will # also delete the rules associated with that course. # At this point, we can't access the restricted course # from the rule beause it may already have been deleted. # If this happens, we don't need to record anything, # since we already record a placeholder "DELETED" # entry when the restricted course record is deleted. pass else: CourseAccessRuleHistory.save_snapshot(restricted_course) class Meta(object): # pylint: disable=missing-docstring get_latest_by = 'timestamp' # Connect the signals to the receivers so we record a history # of changes to the course access rules. post_save.connect(CourseAccessRuleHistory.snapshot_post_save_receiver, sender=RestrictedCourse) post_save.connect(CourseAccessRuleHistory.snapshot_post_save_receiver, sender=CountryAccessRule) post_delete.connect(CourseAccessRuleHistory.snapshot_post_delete_receiver, sender=RestrictedCourse) post_delete.connect(CourseAccessRuleHistory.snapshot_post_delete_receiver, sender=CountryAccessRule) class IPFilter(ConfigurationModel): """ Register specific IP addresses to explicitly block or unblock. """ whitelist = models.TextField( blank=True, help_text="A comma-separated list of IP addresses that should not fall under embargo restrictions." ) blacklist = models.TextField( blank=True, help_text="A comma-separated list of IP addresses that should fall under embargo restrictions." ) class IPFilterList(object): """ Represent a list of IP addresses with support of networks. """ def __init__(self, ips): self.networks = [ipaddr.IPNetwork(ip) for ip in ips] def __iter__(self): for network in self.networks: yield network def __contains__(self, ip): try: ip = ipaddr.IPAddress(ip) except ValueError: return False for network in self.networks: if network.Contains(ip): return True return False @property def whitelist_ips(self): """ Return a list of valid IP addresses to whitelist """ if self.whitelist == '': return [] return self.IPFilterList([addr.strip() for addr in self.whitelist.split(',')]) # pylint: disable=no-member @property def blacklist_ips(self): """ Return a list of valid IP addresses to blacklist """ if self.blacklist == '': return [] return self.IPFilterList([addr.strip() for addr in self.blacklist.split(',')]) # pylint: disable=no-member
agpl-3.0
[ 624, 199, 20474, 367, 25316, 16308, 316, 1321, 30066, 370, 9842, 13588, 701, 3531, 2287, 14, 199, 199, 5408, 7, 907, 32210, 603, 1277, 50, 12969, 1, 199, 199, 3917, 1265, 1852, 4493, 370, 642, 1402, 12, 506, 3238, 370, 1218, 376, 5827, 8367, 199, 493, 436, 1104, 652, 315, 737, 314, 2011, 900, 465, 2195, 1402, 4493, 14, 4005, 886, 626, 12, 199, 199, 17, 14, 3971, 370, 314, 22435, 13, 3246, 2935, 199, 18, 14, 16605, 9053, 14, 647, 21577, 4177, 8998, 25316, 16308, 1553, 2495, 1369, 63, 1618, 63, 12695, 63, 1461, 199, 19, 14, 2654, 314, 8367, 570, 2737, 315, 22435, 13, 3246, 15, 2330, 15, 16432, 15, 31889, 15, 7685, 15, 199, 624, 199, 199, 646, 21249, 199, 646, 2022, 199, 646, 2050, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 2963, 63, 2117, 12, 2963, 63, 1807, 199, 199, 504, 1639, 63, 23598, 14, 955, 492, 19453, 792, 199, 504, 1639, 63, 23598, 492, 26013, 199, 199, 504, 1101, 63, 992, 14, 992, 492, 11595, 1685, 199, 504, 9872, 63, 1176, 14, 992, 492, 22574, 792, 12, 488, 1378, 4699, 2988, 199, 199, 504, 25316, 16308, 14, 3924, 492, 6378, 3946, 3428, 199, 504, 25316, 16308, 14, 3431, 492, 5070, 14881, 63, 23229, 12, 5099, 14302, 3695, 63, 23229, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 662, 887, 16308, 379, 6979, 8, 992, 14, 1685, 304, 272, 408, 272, 12030, 2518, 25316, 16308, 641, 282, 2518, 13, 991, 13, 1972, 5597, 14, 339, 17993, 701, 658, 28850, 6979, 64, 272, 408, 272, 2251, 275, 488, 1378, 4699, 2988, 342, 339, 327, 710, 2518, 370, 25316, 16308, 272, 2518, 63, 344, 275, 22574, 792, 8, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 12, 3747, 29, 549, 9, 339, 327, 7480, 503, 440, 370, 25316, 16308, 272, 25316, 16308, 379, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 768, 3744, 272, 347, 365, 63, 31889, 379, 8, 1886, 12, 2518, 63, 344, 304, 267, 408, 267, 1803, 3775, 503, 440, 314, 1627, 2518, 1305, 365, 25316, 16308, 379, 14, 398, 982, 2518, 965, 440, 2757, 7662, 25316, 16308, 379, 12, 2529, 756, 14, 267, 408, 267, 862, 26, 288, 2777, 275, 843, 14, 1462, 14, 362, 8, 1972, 63, 344, 29, 1972, 63, 344, 9, 288, 372, 2777, 14, 31889, 379, 267, 871, 843, 14, 7400, 26, 288, 372, 756, 339, 347, 636, 2975, 721, 277, 304, 267, 440, 63, 5633, 275, 298, 1763, 298, 267, 340, 291, 14, 31889, 379, 26, 288, 440, 63, 5633, 275, 3087, 267, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 372, 399, 2, 6979, 19574, 365, 1052, 37, 887, 16308, 379, 1674, 908, 8, 277, 14, 1972, 63, 344, 14, 475, 63, 6667, 63, 875, 1062, 440, 63, 5633, 9, 421, 199, 533, 662, 887, 16308, 379, 2223, 8, 5688, 1685, 304, 272, 408, 272, 11828, 26013, 370, 506, 25316, 16308, 379, 14, 339, 17993, 701, 658, 17393, 2313, 272, 408, 272, 327, 710, 26013, 370, 25316, 16308, 272, 25316, 16308, 379, 63, 23598, 275, 1709, 14, 6254, 8, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 628, 33, 10029, 13, 12794, 769, 402, 9023, 9479, 626, 11264, 1334, 738, 14, 51, 14, 25316, 16308, 24488, 2, 272, 776, 339, 768, 1829, 272, 347, 25316, 16308, 379, 63, 23598, 63, 513, 8, 277, 304, 267, 408, 267, 1432, 282, 769, 402, 7008, 1930, 9023, 9479, 267, 408, 267, 340, 291, 14, 31889, 379, 63, 23598, 508, 8061, 288, 372, 942, 267, 372, 359, 6063, 14, 1913, 1252, 4142, 342, 367, 9023, 315, 291, 14, 31889, 379, 63, 23598, 14, 1294, 29972, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 421, 199, 533, 32491, 1522, 6979, 8, 992, 14, 1685, 304, 272, 408, 6979, 543, 2879, 24488, 14, 339, 32491, 1522, 13588, 883, 1853, 4390, 737, 2877, 4501, 26, 339, 413, 9, 3979, 26361, 316, 315, 282, 2518, 14, 272, 499, 9, 3979, 19595, 370, 2879, 282, 2518, 314, 922, 365, 2575, 26802, 315, 14, 339, 710, 3499, 1930, 883, 4781, 1380, 892, 24488, 272, 787, 5324, 1901, 4192, 27, 367, 2893, 12, 1380, 892, 26013, 272, 787, 25316, 16308, 379, 14, 339, 32491, 1522, 13588, 883, 506, 7526, 370, 2929, 272, 3788, 370, 4390, 1380, 2985, 787, 19697, 14, 272, 5723, 9080, 641, 6497, 19733, 701, 314, 25316, 16308, 1145, 14, 339, 408, 272, 5099, 14302, 63, 4924, 63, 8677, 63, 3078, 275, 283, 31889, 14, 17973, 63, 11653, 7, 272, 603, 1608, 2962, 63, 2632, 63, 8677, 63, 3078, 275, 283, 31889, 14, 1188, 63, 633, 63, 515, 23379, 2732, 63, 1403, 26944, 1972, 63, 498, 6834, 339, 5070, 14881, 63, 9740, 63, 3078, 63, 16236, 275, 2008, 779, 267, 334, 1328, 63, 498, 12, 1499, 14, 1802, 9, 267, 367, 1499, 63, 498, 12, 1499, 315, 5070, 14881, 63, 23229, 14, 4611, 342, 272, 4794, 339, 5099, 14302, 3695, 63, 9740, 63, 3078, 63, 16236, 275, 2008, 779, 267, 334, 1328, 63, 498, 12, 1499, 14, 1802, 9, 267, 367, 1499, 63, 498, 12, 1499, 315, 5099, 14302, 3695, 63, 23229, 14, 4611, 342, 272, 4794, 339, 2518, 63, 498, 275, 22574, 792, 8, 267, 1390, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 12, 3747, 29, 549, 12, 267, 1720, 63, 505, 29, 23499, 63, 6395, 8, 85, 2, 1918, 2518, 790, 367, 314, 15297, 2518, 2685, 272, 776, 339, 26361, 63, 1328, 63, 498, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 3415, 29, 742, 14881, 63, 9740, 63, 3078, 63, 16236, 12, 267, 849, 534, 885, 297, 267, 1720, 63, 505, 29, 23499, 63, 6395, 8, 85, 2, 1918, 1245, 370, 2498, 1380, 282, 922, 365, 19697, 687, 14869, 2685, 272, 776, 339, 2879, 63, 1328, 63, 498, 275, 1709, 14, 2183, 8, 267 ]
[ 199, 20474, 367, 25316, 16308, 316, 1321, 30066, 370, 9842, 13588, 701, 3531, 2287, 14, 199, 199, 5408, 7, 907, 32210, 603, 1277, 50, 12969, 1, 199, 199, 3917, 1265, 1852, 4493, 370, 642, 1402, 12, 506, 3238, 370, 1218, 376, 5827, 8367, 199, 493, 436, 1104, 652, 315, 737, 314, 2011, 900, 465, 2195, 1402, 4493, 14, 4005, 886, 626, 12, 199, 199, 17, 14, 3971, 370, 314, 22435, 13, 3246, 2935, 199, 18, 14, 16605, 9053, 14, 647, 21577, 4177, 8998, 25316, 16308, 1553, 2495, 1369, 63, 1618, 63, 12695, 63, 1461, 199, 19, 14, 2654, 314, 8367, 570, 2737, 315, 22435, 13, 3246, 15, 2330, 15, 16432, 15, 31889, 15, 7685, 15, 199, 624, 199, 199, 646, 21249, 199, 646, 2022, 199, 646, 2050, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 2963, 63, 2117, 12, 2963, 63, 1807, 199, 199, 504, 1639, 63, 23598, 14, 955, 492, 19453, 792, 199, 504, 1639, 63, 23598, 492, 26013, 199, 199, 504, 1101, 63, 992, 14, 992, 492, 11595, 1685, 199, 504, 9872, 63, 1176, 14, 992, 492, 22574, 792, 12, 488, 1378, 4699, 2988, 199, 199, 504, 25316, 16308, 14, 3924, 492, 6378, 3946, 3428, 199, 504, 25316, 16308, 14, 3431, 492, 5070, 14881, 63, 23229, 12, 5099, 14302, 3695, 63, 23229, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 662, 887, 16308, 379, 6979, 8, 992, 14, 1685, 304, 272, 408, 272, 12030, 2518, 25316, 16308, 641, 282, 2518, 13, 991, 13, 1972, 5597, 14, 339, 17993, 701, 658, 28850, 6979, 64, 272, 408, 272, 2251, 275, 488, 1378, 4699, 2988, 342, 339, 327, 710, 2518, 370, 25316, 16308, 272, 2518, 63, 344, 275, 22574, 792, 8, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 12, 3747, 29, 549, 9, 339, 327, 7480, 503, 440, 370, 25316, 16308, 272, 25316, 16308, 379, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 768, 3744, 272, 347, 365, 63, 31889, 379, 8, 1886, 12, 2518, 63, 344, 304, 267, 408, 267, 1803, 3775, 503, 440, 314, 1627, 2518, 1305, 365, 25316, 16308, 379, 14, 398, 982, 2518, 965, 440, 2757, 7662, 25316, 16308, 379, 12, 2529, 756, 14, 267, 408, 267, 862, 26, 288, 2777, 275, 843, 14, 1462, 14, 362, 8, 1972, 63, 344, 29, 1972, 63, 344, 9, 288, 372, 2777, 14, 31889, 379, 267, 871, 843, 14, 7400, 26, 288, 372, 756, 339, 347, 636, 2975, 721, 277, 304, 267, 440, 63, 5633, 275, 298, 1763, 298, 267, 340, 291, 14, 31889, 379, 26, 288, 440, 63, 5633, 275, 3087, 267, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 372, 399, 2, 6979, 19574, 365, 1052, 37, 887, 16308, 379, 1674, 908, 8, 277, 14, 1972, 63, 344, 14, 475, 63, 6667, 63, 875, 1062, 440, 63, 5633, 9, 421, 199, 533, 662, 887, 16308, 379, 2223, 8, 5688, 1685, 304, 272, 408, 272, 11828, 26013, 370, 506, 25316, 16308, 379, 14, 339, 17993, 701, 658, 17393, 2313, 272, 408, 272, 327, 710, 26013, 370, 25316, 16308, 272, 25316, 16308, 379, 63, 23598, 275, 1709, 14, 6254, 8, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 628, 33, 10029, 13, 12794, 769, 402, 9023, 9479, 626, 11264, 1334, 738, 14, 51, 14, 25316, 16308, 24488, 2, 272, 776, 339, 768, 1829, 272, 347, 25316, 16308, 379, 63, 23598, 63, 513, 8, 277, 304, 267, 408, 267, 1432, 282, 769, 402, 7008, 1930, 9023, 9479, 267, 408, 267, 340, 291, 14, 31889, 379, 63, 23598, 508, 8061, 288, 372, 942, 267, 372, 359, 6063, 14, 1913, 1252, 4142, 342, 367, 9023, 315, 291, 14, 31889, 379, 63, 23598, 14, 1294, 29972, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 421, 199, 533, 32491, 1522, 6979, 8, 992, 14, 1685, 304, 272, 408, 6979, 543, 2879, 24488, 14, 339, 32491, 1522, 13588, 883, 1853, 4390, 737, 2877, 4501, 26, 339, 413, 9, 3979, 26361, 316, 315, 282, 2518, 14, 272, 499, 9, 3979, 19595, 370, 2879, 282, 2518, 314, 922, 365, 2575, 26802, 315, 14, 339, 710, 3499, 1930, 883, 4781, 1380, 892, 24488, 272, 787, 5324, 1901, 4192, 27, 367, 2893, 12, 1380, 892, 26013, 272, 787, 25316, 16308, 379, 14, 339, 32491, 1522, 13588, 883, 506, 7526, 370, 2929, 272, 3788, 370, 4390, 1380, 2985, 787, 19697, 14, 272, 5723, 9080, 641, 6497, 19733, 701, 314, 25316, 16308, 1145, 14, 339, 408, 272, 5099, 14302, 63, 4924, 63, 8677, 63, 3078, 275, 283, 31889, 14, 17973, 63, 11653, 7, 272, 603, 1608, 2962, 63, 2632, 63, 8677, 63, 3078, 275, 283, 31889, 14, 1188, 63, 633, 63, 515, 23379, 2732, 63, 1403, 26944, 1972, 63, 498, 6834, 339, 5070, 14881, 63, 9740, 63, 3078, 63, 16236, 275, 2008, 779, 267, 334, 1328, 63, 498, 12, 1499, 14, 1802, 9, 267, 367, 1499, 63, 498, 12, 1499, 315, 5070, 14881, 63, 23229, 14, 4611, 342, 272, 4794, 339, 5099, 14302, 3695, 63, 9740, 63, 3078, 63, 16236, 275, 2008, 779, 267, 334, 1328, 63, 498, 12, 1499, 14, 1802, 9, 267, 367, 1499, 63, 498, 12, 1499, 315, 5099, 14302, 3695, 63, 23229, 14, 4611, 342, 272, 4794, 339, 2518, 63, 498, 275, 22574, 792, 8, 267, 1390, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 12, 3747, 29, 549, 12, 267, 1720, 63, 505, 29, 23499, 63, 6395, 8, 85, 2, 1918, 2518, 790, 367, 314, 15297, 2518, 2685, 272, 776, 339, 26361, 63, 1328, 63, 498, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 3415, 29, 742, 14881, 63, 9740, 63, 3078, 63, 16236, 12, 267, 849, 534, 885, 297, 267, 1720, 63, 505, 29, 23499, 63, 6395, 8, 85, 2, 1918, 1245, 370, 2498, 1380, 282, 922, 365, 19697, 687, 14869, 2685, 272, 776,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
txemagon/1984
modules/Telegram-bot-python/telegram/inputmessagecontent.py
3
1952
#!/usr/bin/env python # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2017 # Leandro Toledo de Souza <devs@python-telegram-bot.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser 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 Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InputMessageContent""" from telegram import TelegramObject class InputMessageContent(TelegramObject): """Base class for Telegram InputMessageContent Objects""" @staticmethod def de_json(data, bot): data = super(InputMessageContent, InputMessageContent).de_json(data, bot) if not data: return None try: from telegram import InputTextMessageContent return InputTextMessageContent.de_json(data, bot) except TypeError: pass try: from telegram import InputVenueMessageContent return InputVenueMessageContent.de_json(data, bot) except TypeError: pass try: from telegram import InputLocationMessageContent return InputLocationMessageContent.de_json(data, bot) except TypeError: pass try: from telegram import InputContactMessageContent return InputContactMessageContent.de_json(data, bot) except TypeError: pass return None
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 437, 3555, 626, 6571, 282, 2018, 3217, 370, 314, 23884, 1679, 24896, 3261, 199, 3, 1898, 334, 35, 9, 6900, 13, 10680, 199, 3, 7005, 460, 293, 4005, 274, 1117, 477, 428, 810, 8076, 665, 18804, 32, 1548, 13, 15253, 1679, 13, 3018, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 359, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1055, 199, 624, 2765, 859, 3509, 314, 3992, 626, 2954, 23884, 1679, 199, 3205, 2209, 2714, 624, 199, 199, 504, 14001, 1679, 492, 23884, 1679, 1692, 421, 199, 533, 6924, 2209, 2714, 8, 24944, 1679, 1692, 304, 272, 408, 1563, 1021, 367, 23884, 1679, 6924, 2209, 2714, 26794, 624, 339, 768, 4639, 272, 347, 477, 63, 1001, 8, 576, 12, 5888, 304, 267, 666, 275, 1613, 8, 3205, 2209, 2714, 12, 6924, 2209, 2714, 680, 271, 63, 1001, 8, 576, 12, 5888, 9, 398, 340, 440, 666, 26, 288, 372, 488, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 1872, 2209, 2714, 288, 372, 6924, 1872, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 54, 287, 310, 2209, 2714, 288, 372, 6924, 54, 287, 310, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 6592, 2209, 2714, 288, 372, 6924, 6592, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 14499, 2209, 2714, 288, 372, 6924, 14499, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 437, 3555, 626, 6571, 282, 2018, 3217, 370, 314, 23884, 1679, 24896, 3261, 199, 3, 1898, 334, 35, 9, 6900, 13, 10680, 199, 3, 7005, 460, 293, 4005, 274, 1117, 477, 428, 810, 8076, 665, 18804, 32, 1548, 13, 15253, 1679, 13, 3018, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 359, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1055, 199, 624, 2765, 859, 3509, 314, 3992, 626, 2954, 23884, 1679, 199, 3205, 2209, 2714, 624, 199, 199, 504, 14001, 1679, 492, 23884, 1679, 1692, 421, 199, 533, 6924, 2209, 2714, 8, 24944, 1679, 1692, 304, 272, 408, 1563, 1021, 367, 23884, 1679, 6924, 2209, 2714, 26794, 624, 339, 768, 4639, 272, 347, 477, 63, 1001, 8, 576, 12, 5888, 304, 267, 666, 275, 1613, 8, 3205, 2209, 2714, 12, 6924, 2209, 2714, 680, 271, 63, 1001, 8, 576, 12, 5888, 9, 398, 340, 440, 666, 26, 288, 372, 488, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 1872, 2209, 2714, 288, 372, 6924, 1872, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 54, 287, 310, 2209, 2714, 288, 372, 6924, 54, 287, 310, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 6592, 2209, 2714, 288, 372, 6924, 6592, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 862, 26, 288, 687, 14001, 1679, 492, 6924, 14499, 2209, 2714, 288, 372, 6924, 14499, 2209, 2714, 14, 271, 63, 1001, 8, 576, 12, 5888, 9, 267, 871, 3146, 26, 288, 986, 398, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
diofeher/django-nfa
build/lib/django/views/defaults.py
3
3482
from django.core.exceptions import ObjectDoesNotExist from django.template import Context, RequestContext, loader from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django import http def shortcut(request, content_type_id, object_id): "Redirect to an object's page based on a content-type ID and an object ID." # Look up the object, making sure it's got a get_absolute_url() function. try: content_type = ContentType.objects.get(pk=content_type_id) obj = content_type.get_object_for_this_type(pk=object_id) except ObjectDoesNotExist: raise http.Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id) try: absurl = obj.get_absolute_url() except AttributeError: raise http.Http404, "%s objects don't have get_absolute_url() methods" % content_type.name # Try to figure out the object's domain, so we can do a cross-site redirect # if necessary. # If the object actually defines a domain, we're done. if absurl.startswith('http://') or absurl.startswith('https://'): return http.HttpResponseRedirect(absurl) object_domain = None # Otherwise, we need to introspect the object's relationships for a # relation to the Site object opts = obj._meta # First, look for an many-to-many relationship to sites for field in opts.many_to_many: if field.rel.to is Site: try: object_domain = getattr(obj, field.name).all()[0].domain except IndexError: pass if object_domain is not None: break # Next look for a many-to-one relationship to site if object_domain is None: for field in obj._meta.fields: if field.rel and field.rel.to is Site: try: object_domain = getattr(obj, field.name).domain except Site.DoesNotExist: pass if object_domain is not None: break # Fall back to the current site (if possible) if object_domain is None: try: object_domain = Site.objects.get_current().domain except Site.DoesNotExist: pass # If all that malarkey found an object domain, use it; otherwise fall back # to whatever get_absolute_url() returned. if object_domain is not None: protocol = request.is_secure() and 'https' or 'http' return http.HttpResponseRedirect('%s://%s%s' % (protocol, object_domain, absurl)) else: return http.HttpResponseRedirect(absurl) def page_not_found(request, template_name='404.html'): """ Default 404 handler, which looks for the requested URL in the redirects table, redirects if found, and displays 404 page if not redirected. Templates: `404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ t = loader.get_template(template_name) # You need to create a 404.html template. return http.HttpResponseNotFound(t.render(RequestContext(request, {'request_path': request.path}))) def server_error(request, template_name='500.html'): """ 500 error handler. Templates: `500.html` Context: None """ t = loader.get_template(template_name) # You need to create a 500.html template. return http.HttpResponseServerError(t.render(Context({})))
bsd-3-clause
[ 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1160, 492, 9470, 12, 22538, 12, 5077, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 492, 1455, 199, 199, 318, 17522, 8, 1069, 12, 1564, 63, 466, 63, 344, 12, 909, 63, 344, 304, 272, 298, 7071, 370, 376, 909, 1159, 2034, 4079, 641, 282, 1564, 13, 466, 2870, 436, 376, 909, 2870, 2122, 272, 327, 12077, 1536, 314, 909, 12, 10663, 3238, 652, 1159, 4788, 282, 664, 63, 6116, 63, 633, 342, 805, 14, 272, 862, 26, 267, 1564, 63, 466, 275, 14501, 14, 1462, 14, 362, 8, 2051, 29, 1317, 63, 466, 63, 344, 9, 267, 1559, 275, 1564, 63, 466, 14, 362, 63, 785, 63, 509, 63, 3749, 63, 466, 8, 2051, 29, 785, 63, 344, 9, 272, 871, 24803, 26, 267, 746, 1455, 14, 5779, 5188, 12, 298, 2714, 730, 450, 83, 909, 450, 83, 3181, 1133, 2187, 2, 450, 334, 1317, 63, 466, 63, 344, 12, 909, 63, 344, 9, 272, 862, 26, 267, 2853, 633, 275, 1559, 14, 362, 63, 6116, 63, 633, 342, 272, 871, 4281, 26, 267, 746, 1455, 14, 5779, 5188, 12, 2071, 83, 2251, 2793, 1133, 1172, 664, 63, 6116, 63, 633, 342, 3102, 2, 450, 1564, 63, 466, 14, 354, 339, 327, 7649, 370, 9658, 734, 314, 909, 1159, 2881, 12, 880, 781, 883, 886, 282, 8059, 13, 2124, 4660, 272, 327, 340, 5784, 14, 339, 327, 982, 314, 909, 5965, 7890, 282, 2881, 12, 781, 3984, 4224, 14, 272, 340, 2853, 633, 14, 2460, 360, 1014, 921, 358, 503, 2853, 633, 14, 2460, 360, 2859, 921, 735, 267, 372, 1455, 14, 16287, 7071, 8, 2101, 633, 9, 339, 909, 63, 2261, 275, 488, 339, 327, 6630, 12, 781, 1929, 370, 1109, 21302, 314, 909, 1159, 20045, 367, 282, 272, 327, 5850, 370, 314, 11666, 909, 272, 3999, 275, 1559, 423, 2024, 339, 327, 7758, 12, 3648, 367, 376, 5002, 13, 475, 13, 3479, 8931, 370, 15424, 272, 367, 901, 315, 3999, 14, 3479, 63, 475, 63, 3479, 26, 267, 340, 901, 14, 3369, 14, 475, 365, 11666, 26, 288, 862, 26, 355, 909, 63, 2261, 275, 2519, 8, 1113, 12, 901, 14, 354, 680, 452, 3430, 16, 1055, 2261, 288, 871, 7888, 26, 355, 986, 288, 340, 909, 63, 2261, 365, 440, 488, 26, 355, 2059, 339, 327, 16840, 3648, 367, 282, 5002, 13, 475, 13, 368, 8931, 370, 4770, 272, 340, 909, 63, 2261, 365, 488, 26, 267, 367, 901, 315, 1559, 423, 2024, 14, 955, 26, 288, 340, 901, 14, 3369, 436, 901, 14, 3369, 14, 475, 365, 11666, 26, 355, 862, 26, 490, 909, 63, 2261, 275, 2519, 8, 1113, 12, 901, 14, 354, 680, 2261, 355, 871, 11666, 14, 7400, 26, 490, 986, 355, 340, 909, 63, 2261, 365, 440, 488, 26, 490, 2059, 339, 327, 481, 452, 1771, 370, 314, 1453, 4770, 334, 692, 3962, 9, 272, 340, 909, 63, 2261, 365, 488, 26, 267, 862, 26, 288, 909, 63, 2261, 275, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 267, 871, 11666, 14, 7400, 26, 288, 986, 339, 327, 982, 1006, 626, 333, 279, 285, 498, 1911, 376, 909, 2881, 12, 675, 652, 27, 4257, 11264, 1771, 272, 327, 370, 15685, 664, 63, 6116, 63, 633, 342, 2138, 14, 272, 340, 909, 63, 2261, 365, 440, 488, 26, 267, 4113, 275, 1056, 14, 374, 63, 7817, 342, 436, 283, 2859, 7, 503, 283, 1014, 7, 267, 372, 1455, 14, 16287, 7071, 3508, 83, 13827, 83, 5, 83, 7, 450, 334, 3922, 12, 909, 63, 2261, 12, 2853, 633, 430, 272, 587, 26, 267, 372, 1455, 14, 16287, 7071, 8, 2101, 633, 9, 199, 199, 318, 2034, 63, 1397, 63, 4214, 8, 1069, 12, 1978, 63, 354, 534, 5188, 14, 1360, 735, 272, 408, 272, 3758, 7901, 3016, 12, 1314, 10734, 367, 314, 5839, 2851, 315, 314, 17784, 272, 1817, 12, 17784, 340, 1911, 12, 436, 17561, 7901, 2034, 340, 440, 20884, 14, 339, 31273, 26, 658, 5188, 14, 1360, 64, 272, 9470, 26, 267, 1056, 63, 515, 288, 710, 931, 402, 314, 5839, 2851, 334, 69, 14, 71, 2020, 1994, 571, 15, 5856, 15, 4087, 63, 1606, 6217, 272, 408, 272, 307, 275, 5077, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 327, 2047, 1929, 370, 1218, 282, 7901, 14, 1360, 1978, 14, 272, 372, 1455, 14, 16287, 4667, 8, 84, 14, 3352, 8, 17679, 8, 1069, 12, 791, 1069, 63, 515, 356, 1056, 14, 515, 93, 1724, 199, 199, 318, 1654, 63, 705, 8, 1069, 12, 1978, 63, 354, 534, 5783, 14, 1360, 735, 272, 408, 272, 6891, 1125, 3016, 14, 339, 31273, 26, 658, 5783, 14, 1360, 64, 272, 9470, 26, 488, 272, 408, 272, 307, 275, 5077, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 327, 2047, 1929, 370, 1218, 282, 6891, 14, 1360, 1978, 14, 272, 372, 1455, 14, 16287, 17692, 8, 84, 14, 3352, 8, 2998, 24692, 1724, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1160, 492, 9470, 12, 22538, 12, 5077, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 492, 1455, 199, 199, 318, 17522, 8, 1069, 12, 1564, 63, 466, 63, 344, 12, 909, 63, 344, 304, 272, 298, 7071, 370, 376, 909, 1159, 2034, 4079, 641, 282, 1564, 13, 466, 2870, 436, 376, 909, 2870, 2122, 272, 327, 12077, 1536, 314, 909, 12, 10663, 3238, 652, 1159, 4788, 282, 664, 63, 6116, 63, 633, 342, 805, 14, 272, 862, 26, 267, 1564, 63, 466, 275, 14501, 14, 1462, 14, 362, 8, 2051, 29, 1317, 63, 466, 63, 344, 9, 267, 1559, 275, 1564, 63, 466, 14, 362, 63, 785, 63, 509, 63, 3749, 63, 466, 8, 2051, 29, 785, 63, 344, 9, 272, 871, 24803, 26, 267, 746, 1455, 14, 5779, 5188, 12, 298, 2714, 730, 450, 83, 909, 450, 83, 3181, 1133, 2187, 2, 450, 334, 1317, 63, 466, 63, 344, 12, 909, 63, 344, 9, 272, 862, 26, 267, 2853, 633, 275, 1559, 14, 362, 63, 6116, 63, 633, 342, 272, 871, 4281, 26, 267, 746, 1455, 14, 5779, 5188, 12, 2071, 83, 2251, 2793, 1133, 1172, 664, 63, 6116, 63, 633, 342, 3102, 2, 450, 1564, 63, 466, 14, 354, 339, 327, 7649, 370, 9658, 734, 314, 909, 1159, 2881, 12, 880, 781, 883, 886, 282, 8059, 13, 2124, 4660, 272, 327, 340, 5784, 14, 339, 327, 982, 314, 909, 5965, 7890, 282, 2881, 12, 781, 3984, 4224, 14, 272, 340, 2853, 633, 14, 2460, 360, 1014, 921, 358, 503, 2853, 633, 14, 2460, 360, 2859, 921, 735, 267, 372, 1455, 14, 16287, 7071, 8, 2101, 633, 9, 339, 909, 63, 2261, 275, 488, 339, 327, 6630, 12, 781, 1929, 370, 1109, 21302, 314, 909, 1159, 20045, 367, 282, 272, 327, 5850, 370, 314, 11666, 909, 272, 3999, 275, 1559, 423, 2024, 339, 327, 7758, 12, 3648, 367, 376, 5002, 13, 475, 13, 3479, 8931, 370, 15424, 272, 367, 901, 315, 3999, 14, 3479, 63, 475, 63, 3479, 26, 267, 340, 901, 14, 3369, 14, 475, 365, 11666, 26, 288, 862, 26, 355, 909, 63, 2261, 275, 2519, 8, 1113, 12, 901, 14, 354, 680, 452, 3430, 16, 1055, 2261, 288, 871, 7888, 26, 355, 986, 288, 340, 909, 63, 2261, 365, 440, 488, 26, 355, 2059, 339, 327, 16840, 3648, 367, 282, 5002, 13, 475, 13, 368, 8931, 370, 4770, 272, 340, 909, 63, 2261, 365, 488, 26, 267, 367, 901, 315, 1559, 423, 2024, 14, 955, 26, 288, 340, 901, 14, 3369, 436, 901, 14, 3369, 14, 475, 365, 11666, 26, 355, 862, 26, 490, 909, 63, 2261, 275, 2519, 8, 1113, 12, 901, 14, 354, 680, 2261, 355, 871, 11666, 14, 7400, 26, 490, 986, 355, 340, 909, 63, 2261, 365, 440, 488, 26, 490, 2059, 339, 327, 481, 452, 1771, 370, 314, 1453, 4770, 334, 692, 3962, 9, 272, 340, 909, 63, 2261, 365, 488, 26, 267, 862, 26, 288, 909, 63, 2261, 275, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 267, 871, 11666, 14, 7400, 26, 288, 986, 339, 327, 982, 1006, 626, 333, 279, 285, 498, 1911, 376, 909, 2881, 12, 675, 652, 27, 4257, 11264, 1771, 272, 327, 370, 15685, 664, 63, 6116, 63, 633, 342, 2138, 14, 272, 340, 909, 63, 2261, 365, 440, 488, 26, 267, 4113, 275, 1056, 14, 374, 63, 7817, 342, 436, 283, 2859, 7, 503, 283, 1014, 7, 267, 372, 1455, 14, 16287, 7071, 3508, 83, 13827, 83, 5, 83, 7, 450, 334, 3922, 12, 909, 63, 2261, 12, 2853, 633, 430, 272, 587, 26, 267, 372, 1455, 14, 16287, 7071, 8, 2101, 633, 9, 199, 199, 318, 2034, 63, 1397, 63, 4214, 8, 1069, 12, 1978, 63, 354, 534, 5188, 14, 1360, 735, 272, 408, 272, 3758, 7901, 3016, 12, 1314, 10734, 367, 314, 5839, 2851, 315, 314, 17784, 272, 1817, 12, 17784, 340, 1911, 12, 436, 17561, 7901, 2034, 340, 440, 20884, 14, 339, 31273, 26, 658, 5188, 14, 1360, 64, 272, 9470, 26, 267, 1056, 63, 515, 288, 710, 931, 402, 314, 5839, 2851, 334, 69, 14, 71, 2020, 1994, 571, 15, 5856, 15, 4087, 63, 1606, 6217, 272, 408, 272, 307, 275, 5077, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 327, 2047, 1929, 370, 1218, 282, 7901, 14, 1360, 1978, 14, 272, 372, 1455, 14, 16287, 4667, 8, 84, 14, 3352, 8, 17679, 8, 1069, 12, 791, 1069, 63, 515, 356, 1056, 14, 515, 93, 1724, 199, 199, 318, 1654, 63, 705, 8, 1069, 12, 1978, 63, 354, 534, 5783, 14, 1360, 735, 272, 408, 272, 6891, 1125, 3016, 14, 339, 31273, 26, 658, 5783, 14, 1360, 64, 272, 9470, 26, 488, 272, 408, 272, 307, 275, 5077, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 327, 2047, 1929, 370, 1218, 282, 6891, 14, 1360, 1978, 14, 272, 372, 1455, 14, 16287, 17692, 8, 84, 14, 3352, 8, 2998, 24692, 1724, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
specify/specify7
specifyweb/stored_queries/tests.py
1
11203
from sqlalchemy import orm from unittest import skip from specifyweb.specify.api_tests import ApiTests from .queryfieldspec import QueryFieldSpec from . import models @skip("These tests are out of date.") class StoredQueriesTests(ApiTests): # def setUp(self): # super(StoredQueriesTests, self).setUp() # self.q = models.Spquery.objects.create( # contextname='CollectionObject', # contexttableid=1, # name='test query', # specifyuser=self.specifyuser) def test_id_field(self): self.assertEqual(models.Taxon._id, 'taxonId') def test_basic(self): fs = FieldSpec(field_name='lastName', date_part=None, root_table=models.CollectionObject, join_path=[('cataloger', models.Agent)], is_relation=False, op_num=1, value='Bentley', negate=False, display=True, sort_type=0, spqueryfieldid=None) q, f = fs.add_to_query(orm.Query(models.CollectionObject.collectionObjectId)) sql = str(q) self.assertTrue('WHERE agent_1."LastName" = :LastName_1' in sql) def test_year_equal_predicate(self): fs = FieldSpec(field_name='startDate', date_part='year', root_table=models.CollectionObject, join_path=[('collectingEvent', models.CollectingEvent)], is_relation=False, op_num=1, value='2000', negate=False, display=True, sort_type=0, spqueryfieldid=None) q, f = fs.add_to_query(orm.Query(models.CollectionObject.collectionObjectId)) sql = str(q) self.assertTrue('WHERE EXTRACT(year FROM collectingevent_1."StartDate") = :param_1' in sql) def test_tree_predicate(self): fs = FieldSpec(field_name='Family', date_part=None, root_table=models.Taxon, join_path=[], is_relation=False, op_num=1, value='Percidae', negate=False, display=True, sort_type=0, spqueryfieldid=None) q, f = fs.add_to_query(orm.Query(models.Taxon.taxonId)) sql = str(q) self.assertEqual(sql, 'SELECT taxon."TaxonID" AS "taxon_TaxonID" \n' 'FROM taxon ' 'JOIN taxon AS taxon_1 ' 'ON taxon."TaxonTreeDefID" = taxon_1."TaxonTreeDefID" ' 'AND taxon."NodeNumber" BETWEEN taxon_1."NodeNumber" AND taxon_1."HighestChildNodeNumber" ' 'JOIN taxontreedefitem AS taxontreedefitem_1 ' 'ON taxontreedefitem_1."TaxonTreeDefItemID" = taxon_1."TaxonTreeDefItemID" \n' 'WHERE taxontreedefitem_1."Name" = :Name_1 AND taxon_1."Name" = :Name_2') # def test_month_between_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=9, # position=0, # sorttype=0, # startvalue='3,9', # stringid='1,10.collectingevent.startDateNumericMonth', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE (MONTH("collectingevent"."StartDate") BETWEEN %s and %s AND ' # '"collectingevent"."StartDatePrecision" IN (%s, %s))' in sql) # self.assertEqual(params, (3, 9, 1, 2)) def test_date_part_filter_combined(self): fs1 = FieldSpec(field_name='startDate', date_part='year', root_table=models.CollectionObject, join_path=[('collectingEvent', models.CollectingEvent)], is_relation=False, op_num=1, value='2000', negate=False, display=True, sort_type=0, spqueryfieldid=None) fs2 = FieldSpec(field_name='lastName', date_part=None, root_table=models.CollectionObject, join_path=[('cataloger', models.Agent)], is_relation=False, op_num=1, value='Bentley', negate=False, display=True, sort_type=0, spqueryfieldid=None) q = orm.Query(models.CollectionObject.collectionObjectId) q, f1 = fs1.add_to_query(q) q, f2 = fs2.add_to_query(q) sql = str(q) self.assertTrue('agent_1."LastName" = :LastName_1' in sql) self.assertTrue('EXTRACT(year FROM collectingevent_1."StartDate") = :param_1' in sql) # def test_year_between_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=9, # position=0, # sorttype=0, # startvalue='2000,1990', # stringid='1,10.collectingevent.startDateNumericYear', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE YEAR("collectingevent"."StartDate") BETWEEN %s and %s' in sql) # self.assertEqual(params, (2000, 1990)) # def test_year_in_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=10, # position=0, # sorttype=0, # startvalue='2000,1990,1980', # stringid='1,10.collectingevent.startDateNumericYear', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE YEAR("collectingevent"."StartDate") IN (%s, %s, %s)' in sql) # self.assertEqual(params, (2000, 1990, 1980)) # def test_year_empty_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=12, # position=0, # sorttype=0, # startvalue='ignored', # stringid='1,10.collectingevent.startDateNumericYear', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE ("collectingevent"."StartDate" IS NULL)' in sql) # def test_month_empty_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=12, # position=0, # sorttype=0, # startvalue='ignored', # stringid='1,10.collectingevent.startDateNumericMonth', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE ("collectingevent"."StartDate" IS NULL OR ' # 'NOT (("collectingevent"."StartDatePrecision" IN (%s, %s) AND ' # 'NOT ("collectingevent"."CollectingEventID" IS NULL) AND ' # '"collectingevent"."StartDatePrecision" IS NOT NULL)))' in sql) # self.assertEqual(params, (1,2)) # def test_day_empty_predicate(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=12, # position=0, # sorttype=0, # startvalue='ignored', # stringid='1,10.collectingevent.startDateNumericDay', # tablelist='1,10') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE ("collectingevent"."StartDate" IS NULL OR ' # 'NOT (("collectingevent"."StartDatePrecision" = %s AND ' # 'NOT ("collectingevent"."CollectingEventID" IS NULL) AND ' # '"collectingevent"."StartDatePrecision" IS NOT NULL)))' in sql) # self.assertEqual(params, (1,)) # def test_aliased_columns_year(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=1, # position=0, # sorttype=0, # startvalue='2000', # stringid='1,9-determinations.determination.determinedDateNumericYear', # tablelist='1,9-determinations') # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=1, # position=0, # sorttype=0, # startvalue='1990', # stringid='1,10,1-collectionObjects,9-determinations.determination.determinedDateNumericYear', # tablelist='1,10,1-collectionObjects,9-determinations') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE (YEAR("determination"."DeterminedDate") = %s AND ' # 'YEAR(T5."DeterminedDate") = %s )' in sql) # self.assertEqual(params, (2000, 1990)) # def test_aliased_columns_month(self): # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=1, # position=0, # sorttype=0, # startvalue='7', # stringid='1,9-determinations.determination.determinedDateNumericMonth', # tablelist='1,9-determinations') # self.q.fields.create( # fieldname='startDate', # isdisplay=True, # isnot=False, # operstart=1, # position=0, # sorttype=0, # startvalue='8', # stringid='1,10,1-collectionObjects,9-determinations.determination.determinedDateNumericMonth', # tablelist='1,10,1-collectionObjects,9-determinations') # qs = execute(self.q) # sql, params = qs.query.sql_with_params() # self.assertTrue('WHERE ((MONTH("determination"."DeterminedDate") = %s AND ' # '"determination"."DeterminedDatePrecision" IN (%s, %s)) AND ' # '(MONTH(T5."DeterminedDate") = %s AND ' # 'T5."DeterminedDatePrecision" IN (%s, %s)))' in sql) # self.assertEqual(params, (7, 1, 2, 8, 1, 2))
gpl-2.0
[ 504, 8335, 492, 9813, 199, 504, 2882, 492, 3372, 199, 199, 504, 4165, 2520, 14, 26164, 14, 1246, 63, 2219, 492, 13986, 2925, 199, 504, 1275, 1131, 955, 733, 492, 8133, 792, 5307, 199, 504, 1275, 492, 1709, 199, 199, 32, 2759, 480, 20676, 2295, 787, 734, 402, 1434, 2685, 199, 533, 9785, 581, 13611, 2925, 8, 7394, 2925, 304, 272, 327, 347, 3613, 8, 277, 304, 272, 327, 258, 1613, 8, 4759, 581, 13611, 2925, 12, 291, 680, 5996, 342, 272, 327, 258, 291, 14, 81, 275, 1709, 14, 5058, 1131, 14, 1462, 14, 981, 8, 272, 327, 260, 1067, 354, 534, 7768, 1692, 297, 272, 327, 260, 1067, 1224, 344, 29, 17, 12, 272, 327, 260, 536, 534, 396, 1827, 297, 272, 327, 260, 4165, 751, 29, 277, 14, 26164, 751, 9, 339, 347, 511, 63, 344, 63, 698, 8, 277, 304, 267, 291, 14, 629, 8, 992, 14, 26019, 265, 423, 344, 12, 283, 5530, 265, 1304, 358, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 2019, 985, 297, 2432, 1434, 63, 2064, 29, 403, 12, 2432, 1738, 63, 1224, 29, 992, 14, 7768, 1692, 12, 2432, 4263, 63, 515, 11699, 3385, 12201, 836, 297, 1709, 14, 7788, 4360, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 34, 484, 15515, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 7768, 1692, 14, 3627, 1692, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 1815, 360, 17688, 6631, 63, 17, 2122, 6090, 985, 2, 275, 520, 6090, 985, 63, 17, 7, 315, 3875, 9, 339, 347, 511, 63, 3403, 63, 1452, 63, 14463, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 928, 2506, 297, 2432, 1434, 63, 2064, 534, 3403, 297, 2432, 1738, 63, 1224, 29, 992, 14, 7768, 1692, 12, 2432, 4263, 63, 515, 11699, 7112, 316, 2390, 297, 1709, 14, 25023, 316, 2390, 4360, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 8269, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 7768, 1692, 14, 3627, 1692, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 1815, 360, 17688, 3651, 22280, 8, 3403, 4442, 8775, 17081, 782, 63, 17, 2122, 3162, 2506, 531, 275, 520, 635, 63, 17, 7, 315, 3875, 9, 339, 347, 511, 63, 2350, 63, 14463, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 16345, 297, 2432, 1434, 63, 2064, 29, 403, 12, 2432, 1738, 63, 1224, 29, 992, 14, 26019, 265, 12, 2432, 4263, 63, 515, 6034, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 2623, 7504, 3624, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 26019, 265, 14, 5530, 265, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 629, 8, 3009, 12, 586, 283, 4859, 9067, 265, 2122, 26019, 265, 998, 2, 4319, 298, 5530, 265, 63, 26019, 265, 998, 2, 971, 78, 7, 586, 283, 12491, 9067, 265, 283, 586, 283, 23321, 9067, 265, 4319, 9067, 265, 63, 17, 283, 586, 283, 615, 9067, 265, 2122, 26019, 265, 3987, 6172, 998, 2, 275, 9067, 265, 63, 17, 2122, 26019, 265, 3987, 6172, 998, 2, 283, 586, 283, 3649, 9067, 265, 2122, 1716, 3259, 2, 699, 29056, 9067, 265, 63, 17, 2122, 1716, 3259, 2, 2401, 9067, 265, 63, 17, 2122, 40, 12527, 3493, 1716, 3259, 2, 283, 586, 283, 23321, 9067, 1888, 850, 318, 1053, 4319, 9067, 1888, 850, 318, 1053, 63, 17, 283, 586, 283, 615, 9067, 1888, 850, 318, 1053, 63, 17, 2122, 26019, 265, 3987, 6172, 2081, 998, 2, 275, 9067, 265, 63, 17, 2122, 26019, 265, 3987, 6172, 2081, 998, 2, 971, 78, 7, 586, 283, 17688, 9067, 1888, 850, 318, 1053, 63, 17, 2122, 985, 2, 275, 520, 985, 63, 17, 2401, 9067, 265, 63, 17, 2122, 985, 2, 275, 520, 985, 63, 18, 358, 339, 327, 347, 511, 63, 4482, 63, 13007, 63, 14463, 8, 277, 304, 272, 327, 258, 291, 14, 81, 14, 955, 14, 981, 8, 272, 327, 260, 18887, 534, 928, 2506, 297, 272, 327, 260, 365, 2918, 29, 549, 12, 272, 327, 260, 365, 1397, 29, 797, 12, 272, 327, 260, 1758, 928, 29, 25, 12, 272, 327, 260, 3421, 29, 16, 12, 272, 327, 260, 4069, 466, 29, 16, 12, 272, 327, 260, 1343, 585, 534, 19, 12, 25, 297, 272, 327, 260, 1059, 344, 534, 17, 12, 709, 14, 7112, 17081, 782, 14, 928, 2506, 14687, 14306, 297, 272, 327, 260, 1817, 513, 534, 17, 12, 709, 358, 339, 327, 258, 6377, 275, 5341, 8, 277, 14, 81, 9, 272, 327, 258, 3875, 12, 1862, 275, 6377, 14, 1131, 14, 3009, 63, 1045, 63, 1162, 342, 272, 327, 258, 291, 14, 1815, 360, 17688, 334, 16413, 480, 7112, 17081, 782, 21176, 3162, 2506, 531, 699, 29056, 450, 83, 436, 450, 83, 2401, 283, 272, 327, 9326, 5522, 7112, 17081, 782, 21176, 3162, 2506, 28984, 2, 1621, 4366, 83, 12, 450, 83, 23089, 315, 3875, 9, 272, 327, 258, 291, 14, 629, 8, 1162, 12, 334, 19, 12, 1749, 12, 413, 12, 499, 430, 339, 347, 511, 63, 602, 63, 2064, 63, 1541, 63, 17583, 8, 277, 304, 267, 7449, 17, 275, 5024, 5307, 8, 698, 63, 354, 534, 928, 2506, 297, 717, 1434 ]
[ 8335, 492, 9813, 199, 504, 2882, 492, 3372, 199, 199, 504, 4165, 2520, 14, 26164, 14, 1246, 63, 2219, 492, 13986, 2925, 199, 504, 1275, 1131, 955, 733, 492, 8133, 792, 5307, 199, 504, 1275, 492, 1709, 199, 199, 32, 2759, 480, 20676, 2295, 787, 734, 402, 1434, 2685, 199, 533, 9785, 581, 13611, 2925, 8, 7394, 2925, 304, 272, 327, 347, 3613, 8, 277, 304, 272, 327, 258, 1613, 8, 4759, 581, 13611, 2925, 12, 291, 680, 5996, 342, 272, 327, 258, 291, 14, 81, 275, 1709, 14, 5058, 1131, 14, 1462, 14, 981, 8, 272, 327, 260, 1067, 354, 534, 7768, 1692, 297, 272, 327, 260, 1067, 1224, 344, 29, 17, 12, 272, 327, 260, 536, 534, 396, 1827, 297, 272, 327, 260, 4165, 751, 29, 277, 14, 26164, 751, 9, 339, 347, 511, 63, 344, 63, 698, 8, 277, 304, 267, 291, 14, 629, 8, 992, 14, 26019, 265, 423, 344, 12, 283, 5530, 265, 1304, 358, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 2019, 985, 297, 2432, 1434, 63, 2064, 29, 403, 12, 2432, 1738, 63, 1224, 29, 992, 14, 7768, 1692, 12, 2432, 4263, 63, 515, 11699, 3385, 12201, 836, 297, 1709, 14, 7788, 4360, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 34, 484, 15515, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 7768, 1692, 14, 3627, 1692, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 1815, 360, 17688, 6631, 63, 17, 2122, 6090, 985, 2, 275, 520, 6090, 985, 63, 17, 7, 315, 3875, 9, 339, 347, 511, 63, 3403, 63, 1452, 63, 14463, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 928, 2506, 297, 2432, 1434, 63, 2064, 534, 3403, 297, 2432, 1738, 63, 1224, 29, 992, 14, 7768, 1692, 12, 2432, 4263, 63, 515, 11699, 7112, 316, 2390, 297, 1709, 14, 25023, 316, 2390, 4360, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 8269, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 7768, 1692, 14, 3627, 1692, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 1815, 360, 17688, 3651, 22280, 8, 3403, 4442, 8775, 17081, 782, 63, 17, 2122, 3162, 2506, 531, 275, 520, 635, 63, 17, 7, 315, 3875, 9, 339, 347, 511, 63, 2350, 63, 14463, 8, 277, 304, 267, 7449, 275, 5024, 5307, 8, 698, 63, 354, 534, 16345, 297, 2432, 1434, 63, 2064, 29, 403, 12, 2432, 1738, 63, 1224, 29, 992, 14, 26019, 265, 12, 2432, 4263, 63, 515, 6034, 2432, 365, 63, 5690, 29, 797, 12, 2432, 1687, 63, 1507, 29, 17, 12, 2432, 574, 534, 2623, 7504, 3624, 297, 2432, 30112, 29, 797, 12, 2432, 2929, 29, 549, 12, 2432, 4069, 63, 466, 29, 16, 12, 2432, 2249, 1131, 329, 352, 14887, 29, 403, 9, 398, 1894, 12, 289, 275, 7449, 14, 525, 63, 475, 63, 1131, 8, 1025, 14, 3227, 8, 992, 14, 26019, 265, 14, 5530, 265, 1304, 430, 267, 3875, 275, 620, 8, 81, 9, 267, 291, 14, 629, 8, 3009, 12, 586, 283, 4859, 9067, 265, 2122, 26019, 265, 998, 2, 4319, 298, 5530, 265, 63, 26019, 265, 998, 2, 971, 78, 7, 586, 283, 12491, 9067, 265, 283, 586, 283, 23321, 9067, 265, 4319, 9067, 265, 63, 17, 283, 586, 283, 615, 9067, 265, 2122, 26019, 265, 3987, 6172, 998, 2, 275, 9067, 265, 63, 17, 2122, 26019, 265, 3987, 6172, 998, 2, 283, 586, 283, 3649, 9067, 265, 2122, 1716, 3259, 2, 699, 29056, 9067, 265, 63, 17, 2122, 1716, 3259, 2, 2401, 9067, 265, 63, 17, 2122, 40, 12527, 3493, 1716, 3259, 2, 283, 586, 283, 23321, 9067, 1888, 850, 318, 1053, 4319, 9067, 1888, 850, 318, 1053, 63, 17, 283, 586, 283, 615, 9067, 1888, 850, 318, 1053, 63, 17, 2122, 26019, 265, 3987, 6172, 2081, 998, 2, 275, 9067, 265, 63, 17, 2122, 26019, 265, 3987, 6172, 2081, 998, 2, 971, 78, 7, 586, 283, 17688, 9067, 1888, 850, 318, 1053, 63, 17, 2122, 985, 2, 275, 520, 985, 63, 17, 2401, 9067, 265, 63, 17, 2122, 985, 2, 275, 520, 985, 63, 18, 358, 339, 327, 347, 511, 63, 4482, 63, 13007, 63, 14463, 8, 277, 304, 272, 327, 258, 291, 14, 81, 14, 955, 14, 981, 8, 272, 327, 260, 18887, 534, 928, 2506, 297, 272, 327, 260, 365, 2918, 29, 549, 12, 272, 327, 260, 365, 1397, 29, 797, 12, 272, 327, 260, 1758, 928, 29, 25, 12, 272, 327, 260, 3421, 29, 16, 12, 272, 327, 260, 4069, 466, 29, 16, 12, 272, 327, 260, 1343, 585, 534, 19, 12, 25, 297, 272, 327, 260, 1059, 344, 534, 17, 12, 709, 14, 7112, 17081, 782, 14, 928, 2506, 14687, 14306, 297, 272, 327, 260, 1817, 513, 534, 17, 12, 709, 358, 339, 327, 258, 6377, 275, 5341, 8, 277, 14, 81, 9, 272, 327, 258, 3875, 12, 1862, 275, 6377, 14, 1131, 14, 3009, 63, 1045, 63, 1162, 342, 272, 327, 258, 291, 14, 1815, 360, 17688, 334, 16413, 480, 7112, 17081, 782, 21176, 3162, 2506, 531, 699, 29056, 450, 83, 436, 450, 83, 2401, 283, 272, 327, 9326, 5522, 7112, 17081, 782, 21176, 3162, 2506, 28984, 2, 1621, 4366, 83, 12, 450, 83, 23089, 315, 3875, 9, 272, 327, 258, 291, 14, 629, 8, 1162, 12, 334, 19, 12, 1749, 12, 413, 12, 499, 430, 339, 347, 511, 63, 602, 63, 2064, 63, 1541, 63, 17583, 8, 277, 304, 267, 7449, 17, 275, 5024, 5307, 8, 698, 63, 354, 534, 928, 2506, 297, 717, 1434, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
uclouvain/osis
learning_unit/ddd/domain/description_fiche.py
1
2627
############################################################################## # # OSIS stands for Open Student Information System. It's an application # designed to manage the core business of higher education institutions, # such as universities, faculties, institutes and professional schools. # The core business involves the administration of students, teachers, # courses, programs and so on. # # Copyright (C) 2015-2020 Université catholique de Louvain (http://www.uclouvain.be) # # 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. # # A copy of this license - GNU General Public License - is available # at the root of the source code of this program. If not, # see http://www.gnu.org/licenses/. # ############################################################################## import datetime import attr @attr.s(slots=True) class DescriptionFiche: resume = attr.ib(type=str, default=None) resume_en = attr.ib(type=str, default=None) teaching_methods = attr.ib(type=str, default=None) teaching_methods_en = attr.ib(type=str, default=None) evaluation_methods = attr.ib(type=str, default=None) evaluation_methods_en = attr.ib(type=str, default=None) other_informations = attr.ib(type=str, default=None) other_informations_en = attr.ib(type=str, default=None) online_resources = attr.ib(type=str, default=None) online_resources_en = attr.ib(type=str, default=None) bibliography = attr.ib(type=str, default=None) mobility = attr.ib(type=str, default=None) last_update = attr.ib(type=datetime.datetime, default=None) author = attr.ib(type=str, default=None) @attr.s(slots=True) class DescriptionFicheForceMajeure: teaching_methods = attr.ib(type=str, default=None) teaching_methods_en = attr.ib(type=str, default=None) evaluation_methods = attr.ib(type=str, default=None) evaluation_methods_en = attr.ib(type=str, default=None) other_informations = attr.ib(type=str, default=None) other_informations_en = attr.ib(type=str, default=None) last_update = attr.ib(type=datetime.datetime, default=None) author = attr.ib(type=str, default=None)
agpl-3.0
[ 4605, 199, 3, 199, 3, 259, 4403, 1311, 410, 5915, 367, 3232, 17246, 17064, 6187, 14, 2779, 1159, 376, 4223, 199, 3, 259, 19829, 370, 9635, 314, 6170, 26440, 402, 10948, 3988, 30500, 2727, 390, 8653, 12, 199, 3, 259, 4066, 465, 625, 4380, 338, 1417, 12, 21625, 1141, 397, 12, 2727, 390, 3862, 436, 22398, 28661, 308, 2239, 1446, 14, 199, 3, 259, 710, 6170, 26440, 25613, 2310, 314, 4628, 4633, 402, 18557, 12, 1565, 1225, 1192, 12, 199, 3, 259, 13588, 12, 18572, 436, 880, 641, 14, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6900, 13, 13934, 1910, 4380, 2221, 5741, 286, 1619, 23711, 544, 477, 491, 810, 86, 1581, 334, 1014, 921, 1544, 14, 947, 320, 9154, 1581, 14, 1235, 9, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 437, 1331, 402, 642, 4190, 446, 1664, 1696, 1684, 844, 446, 365, 2808, 199, 3, 259, 737, 314, 1738, 402, 314, 1350, 1233, 402, 642, 2240, 14, 221, 982, 440, 12, 199, 3, 259, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 3, 199, 4605, 199, 646, 2197, 199, 646, 1921, 421, 199, 32, 962, 14, 83, 8, 7257, 29, 549, 9, 199, 533, 11994, 9047, 595, 26, 272, 14604, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 14604, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 18470, 63, 4435, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 18470, 63, 4435, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11314, 14437, 9773, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1303, 3195, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 2061, 63, 873, 275, 1921, 14, 1892, 8, 466, 29, 2083, 14, 2083, 12, 849, 29, 403, 9, 272, 4132, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 421, 199, 32, 962, 14, 83, 8, 7257, 29, 549, 9, 199, 533, 11994, 9047, 595, 13606, 11903, 6532, 608, 26, 272, 1565, 23302, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 2061, 63, 873, 275, 1921, 14, 1892, 8, 466, 29, 2083, 14, 2083, 12, 849, 29, 403, 9, 272, 4132, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 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 ]
[ 199, 3, 199, 3, 259, 4403, 1311, 410, 5915, 367, 3232, 17246, 17064, 6187, 14, 2779, 1159, 376, 4223, 199, 3, 259, 19829, 370, 9635, 314, 6170, 26440, 402, 10948, 3988, 30500, 2727, 390, 8653, 12, 199, 3, 259, 4066, 465, 625, 4380, 338, 1417, 12, 21625, 1141, 397, 12, 2727, 390, 3862, 436, 22398, 28661, 308, 2239, 1446, 14, 199, 3, 259, 710, 6170, 26440, 25613, 2310, 314, 4628, 4633, 402, 18557, 12, 1565, 1225, 1192, 12, 199, 3, 259, 13588, 12, 18572, 436, 880, 641, 14, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6900, 13, 13934, 1910, 4380, 2221, 5741, 286, 1619, 23711, 544, 477, 491, 810, 86, 1581, 334, 1014, 921, 1544, 14, 947, 320, 9154, 1581, 14, 1235, 9, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 437, 1331, 402, 642, 4190, 446, 1664, 1696, 1684, 844, 446, 365, 2808, 199, 3, 259, 737, 314, 1738, 402, 314, 1350, 1233, 402, 642, 2240, 14, 221, 982, 440, 12, 199, 3, 259, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 3, 199, 4605, 199, 646, 2197, 199, 646, 1921, 421, 199, 32, 962, 14, 83, 8, 7257, 29, 549, 9, 199, 533, 11994, 9047, 595, 26, 272, 14604, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 14604, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 18470, 63, 4435, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 18470, 63, 4435, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11314, 14437, 9773, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1303, 3195, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 2061, 63, 873, 275, 1921, 14, 1892, 8, 466, 29, 2083, 14, 2083, 12, 849, 29, 403, 9, 272, 4132, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 421, 199, 32, 962, 14, 83, 8, 7257, 29, 549, 9, 199, 533, 11994, 9047, 595, 13606, 11903, 6532, 608, 26, 272, 1565, 23302, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1565, 23302, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 11735, 63, 2474, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 1163, 63, 262, 17308, 63, 287, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 9, 272, 2061, 63, 873, 275, 1921, 14, 1892, 8, 466, 29, 2083, 14, 2083, 12, 849, 29, 403, 9, 272, 4132, 275, 1921, 14, 1892, 8, 466, 29, 495, 12, 849, 29, 403, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
txemi/ansible
lib/ansible/plugins/lookup/shelvefile.py
89
2496
# (c) 2015, Alejandro Guirao <lekumberri@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. from __future__ import (absolute_import, division, print_function) __metaclass__ = type import shelve from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase from ansible.module_utils._text import to_bytes, to_text class LookupModule(LookupBase): def read_shelve(self, shelve_filename, key): """ Read the value of "key" from a shelve file """ d = shelve.open(to_bytes(shelve_filename)) res = d.get(key, None) d.close() return res def run(self, terms, variables=None, **kwargs): if not isinstance(terms, list): terms = [ terms ] ret = [] for term in terms: paramvals = {"file": None, "key": None} params = term.split() try: for param in params: name, value = param.split('=') assert(name in paramvals) paramvals[name] = value except (ValueError, AssertionError) as e: # In case "file" or "key" are not present raise AnsibleError(e) key = paramvals['key'] # Search also in the role/files directory and in the playbook directory shelvefile = self.find_file_in_search_path(variables, 'files', paramvals['file']) if shelvefile: res = self.read_shelve(shelvefile, key) if res is None: raise AnsibleError("Key %s not found in shelve file %s" % (key, file)) # Convert the value read to string ret.append(to_text(res)) break else: raise AnsibleError("Could not locate shelve file in lookup: %s" % file) return ret
gpl-3.0
[ 3, 334, 67, 9, 6900, 12, 6832, 74, 460, 293, 14425, 345, 79, 665, 274, 75, 884, 322, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 1033, 15320, 199, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 5265, 14, 3892, 492, 12785, 1563, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 505, 421, 199, 533, 12785, 2377, 8, 7521, 1563, 304, 339, 347, 1586, 63, 609, 15320, 8, 277, 12, 1033, 15320, 63, 1501, 12, 790, 304, 267, 408, 267, 5574, 314, 574, 402, 298, 498, 2, 687, 282, 1033, 15320, 570, 267, 408, 267, 366, 275, 1033, 15320, 14, 1490, 8, 475, 63, 2394, 8, 609, 15320, 63, 1501, 430, 267, 522, 275, 366, 14, 362, 8, 498, 12, 488, 9, 267, 366, 14, 1600, 342, 267, 372, 522, 339, 347, 1255, 8, 277, 12, 2895, 12, 2860, 29, 403, 12, 1011, 958, 304, 398, 340, 440, 1228, 8, 9187, 12, 769, 304, 288, 2895, 275, 359, 2895, 1622, 398, 2203, 275, 942, 398, 367, 6707, 315, 2895, 26, 288, 1215, 3643, 275, 2420, 493, 582, 488, 12, 298, 498, 582, 488, 93, 288, 1862, 275, 6707, 14, 1294, 342, 953, 862, 26, 355, 367, 1215, 315, 1862, 26, 490, 536, 12, 574, 275, 1215, 14, 1294, 23917, 490, 702, 8, 354, 315, 1215, 3643, 9, 490, 1215, 3643, 59, 354, 61, 275, 574, 953, 871, 334, 3393, 12, 9070, 9, 465, 325, 26, 355, 327, 1010, 1930, 298, 493, 2, 503, 298, 498, 2, 787, 440, 3451, 355, 746, 13358, 8, 69, 9, 953, 790, 275, 1215, 3643, 459, 498, 418, 953, 327, 8730, 2597, 315, 314, 4719, 15, 1725, 2082, 436, 315, 314, 15695, 2082, 288, 1033, 15320, 493, 275, 291, 14, 1623, 63, 493, 63, 262, 63, 1733, 63, 515, 8, 3669, 12, 283, 1725, 297, 1215, 3643, 459, 493, 1105, 953, 340, 1033, 15320, 493, 26, 355, 522, 275, 291, 14, 739, 63, 609, 15320, 8, 609, 15320, 493, 12, 790, 9, 355, 340, 522, 365, 488, 26, 490, 746, 13358, 480, 1197, 450, 83, 440, 1911, 315, 1033, 15320, 570, 450, 83, 2, 450, 334, 498, 12, 570, 430, 355, 327, 7905, 314, 574, 1586, 370, 1059, 355, 2203, 14, 740, 8, 475, 63, 505, 8, 470, 430, 355, 2059, 288, 587, 26, 355, 746, 13358, 480, 6531, 440, 16592, 1033, 15320, 570, 315, 4237, 26, 450, 83, 2, 450, 570, 9, 398, 372, 2203, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 6900, 12, 6832, 74, 460, 293, 14425, 345, 79, 665, 274, 75, 884, 322, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 1033, 15320, 199, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 5265, 14, 3892, 492, 12785, 1563, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 505, 421, 199, 533, 12785, 2377, 8, 7521, 1563, 304, 339, 347, 1586, 63, 609, 15320, 8, 277, 12, 1033, 15320, 63, 1501, 12, 790, 304, 267, 408, 267, 5574, 314, 574, 402, 298, 498, 2, 687, 282, 1033, 15320, 570, 267, 408, 267, 366, 275, 1033, 15320, 14, 1490, 8, 475, 63, 2394, 8, 609, 15320, 63, 1501, 430, 267, 522, 275, 366, 14, 362, 8, 498, 12, 488, 9, 267, 366, 14, 1600, 342, 267, 372, 522, 339, 347, 1255, 8, 277, 12, 2895, 12, 2860, 29, 403, 12, 1011, 958, 304, 398, 340, 440, 1228, 8, 9187, 12, 769, 304, 288, 2895, 275, 359, 2895, 1622, 398, 2203, 275, 942, 398, 367, 6707, 315, 2895, 26, 288, 1215, 3643, 275, 2420, 493, 582, 488, 12, 298, 498, 582, 488, 93, 288, 1862, 275, 6707, 14, 1294, 342, 953, 862, 26, 355, 367, 1215, 315, 1862, 26, 490, 536, 12, 574, 275, 1215, 14, 1294, 23917, 490, 702, 8, 354, 315, 1215, 3643, 9, 490, 1215, 3643, 59, 354, 61, 275, 574, 953, 871, 334, 3393, 12, 9070, 9, 465, 325, 26, 355, 327, 1010, 1930, 298, 493, 2, 503, 298, 498, 2, 787, 440, 3451, 355, 746, 13358, 8, 69, 9, 953, 790, 275, 1215, 3643, 459, 498, 418, 953, 327, 8730, 2597, 315, 314, 4719, 15, 1725, 2082, 436, 315, 314, 15695, 2082, 288, 1033, 15320, 493, 275, 291, 14, 1623, 63, 493, 63, 262, 63, 1733, 63, 515, 8, 3669, 12, 283, 1725, 297, 1215, 3643, 459, 493, 1105, 953, 340, 1033, 15320, 493, 26, 355, 522, 275, 291, 14, 739, 63, 609, 15320, 8, 609, 15320, 493, 12, 790, 9, 355, 340, 522, 365, 488, 26, 490, 746, 13358, 480, 1197, 450, 83, 440, 1911, 315, 1033, 15320, 570, 450, 83, 2, 450, 334, 498, 12, 570, 430, 355, 327, 7905, 314, 574, 1586, 370, 1059, 355, 2203, 14, 740, 8, 475, 63, 505, 8, 470, 430, 355, 2059, 288, 587, 26, 355, 746, 13358, 480, 6531, 440, 16592, 1033, 15320, 570, 315, 4237, 26, 450, 83, 2, 450, 570, 9, 398, 372, 2203, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yoki/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/port/port_testcase.py
115
28371
# 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. """Unit testing base class for Port implementations.""" import errno import logging import os import socket import sys import time import unittest2 as unittest from webkitpy.common.system.executive_mock import MockExecutive from webkitpy.common.system.filesystem_mock import MockFileSystem from webkitpy.common.system.outputcapture import OutputCapture from webkitpy.common.system.systemhost_mock import MockSystemHost from webkitpy.port.base import Port from webkitpy.port.server_process_mock import MockServerProcess from webkitpy.layout_tests.servers import http_server_base from webkitpy.tool.mocktool import MockOptions # FIXME: get rid of this fixture class TestWebKitPort(Port): port_name = "testwebkitport" def __init__(self, port_name=None, symbols_string=None, expectations_file=None, skips_file=None, host=None, config=None, **kwargs): port_name = port_name or TestWebKitPort.port_name self.symbols_string = symbols_string # Passing "" disables all staticly-detectable features. host = host or MockSystemHost() super(TestWebKitPort, self).__init__(host, port_name=port_name, **kwargs) def all_test_configurations(self): return [self.test_configuration()] def _symbols_string(self): return self.symbols_string def _tests_for_other_platforms(self): return ["media", ] def _tests_for_disabled_features(self): return ["accessibility", ] class PortTestCase(unittest.TestCase): """Tests that all Port implementations must pass.""" HTTP_PORTS = (8000, 8080, 8443) WEBSOCKET_PORTS = (8880,) # Subclasses override this to point to their Port subclass. os_name = None os_version = None port_maker = TestWebKitPort port_name = None def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs): host = host or MockSystemHost(os_name=(os_name or self.os_name), os_version=(os_version or self.os_version)) options = options or MockOptions(configuration='Release') port_name = port_name or self.port_name port_name = self.port_maker.determine_full_port_name(host, options, port_name) port = self.port_maker(host, port_name, options=options, **kwargs) port._config.build_directory = lambda configuration: '/mock-build' return port def test_default_max_locked_shards(self): port = self.make_port() port.default_child_processes = lambda: 16 self.assertEqual(port.default_max_locked_shards(), 1) port.default_child_processes = lambda: 2 self.assertEqual(port.default_max_locked_shards(), 1) def test_default_timeout_ms(self): self.assertEqual(self.make_port(options=MockOptions(configuration='Release')).default_timeout_ms(), 35000) self.assertEqual(self.make_port(options=MockOptions(configuration='Debug')).default_timeout_ms(), 35000) def test_default_pixel_tests(self): self.assertEqual(self.make_port().default_pixel_tests(), False) def test_driver_cmd_line(self): port = self.make_port() self.assertTrue(len(port.driver_cmd_line())) options = MockOptions(additional_drt_flag=['--foo=bar', '--foo=baz']) port = self.make_port(options=options) cmd_line = port.driver_cmd_line() self.assertTrue('--foo=bar' in cmd_line) self.assertTrue('--foo=baz' in cmd_line) def assert_servers_are_down(self, host, ports): for port in ports: try: test_socket = socket.socket() test_socket.connect((host, port)) self.fail() except IOError, e: self.assertTrue(e.errno in (errno.ECONNREFUSED, errno.ECONNRESET)) finally: test_socket.close() def assert_servers_are_up(self, host, ports): for port in ports: try: test_socket = socket.socket() test_socket.connect((host, port)) except IOError, e: self.fail('failed to connect to %s:%d' % (host, port)) finally: test_socket.close() def integration_test_http_lock(self): port = self.make_port() # Only checking that no exception is raised. port.acquire_http_lock() port.release_http_lock() def integration_test_check_sys_deps(self): port = self.make_port() # Only checking that no exception is raised. port.check_sys_deps(True) def integration_test_helper(self): port = self.make_port() # Only checking that no exception is raised. port.start_helper() port.stop_helper() def integration_test_http_server__normal(self): port = self.make_port() self.assert_servers_are_down('localhost', self.HTTP_PORTS) port.start_http_server() self.assert_servers_are_up('localhost', self.HTTP_PORTS) port.stop_http_server() self.assert_servers_are_down('localhost', self.HTTP_PORTS) def integration_test_http_server__fails(self): port = self.make_port() # Test that if a port isn't available, the call fails. for port_number in self.HTTP_PORTS: test_socket = socket.socket() try: try: test_socket.bind(('localhost', port_number)) except socket.error, e: if e.errno in (errno.EADDRINUSE, errno.EALREADY): self.fail('could not bind to port %d' % port_number) raise try: port.start_http_server() self.fail('should not have been able to start the server while bound to %d' % port_number) except http_server_base.ServerError, e: pass finally: port.stop_http_server() test_socket.close() # Test that calling start() twice fails. try: port.start_http_server() self.assertRaises(AssertionError, port.start_http_server) finally: port.stop_http_server() def integration_test_http_server__two_servers(self): # Test that calling start() on two different ports causes the # first port to be treated as stale and killed. port = self.make_port() # Test that if a port isn't available, the call fails. port.start_http_server() new_port = self.make_port() try: new_port.start_http_server() # Check that the first server was killed. self.assertFalse(port._executive.check_running_pid(port._http_server._pid)) # Check that there is something running. self.assert_servers_are_up('localhost', self.HTTP_PORTS) # Test that calling stop() on a killed server is harmless. port.stop_http_server() finally: port.stop_http_server() new_port.stop_http_server() # Test that calling stop() twice is harmless. new_port.stop_http_server() def integration_test_image_diff(self): port = self.make_port() # FIXME: This test will never run since we are using a MockFilesystem for these tests!?!? if not port.check_image_diff(): # The port hasn't been built - don't run the tests. return dir = port.layout_tests_dir() file1 = port._filesystem.join(dir, 'fast', 'css', 'button_center.png') contents1 = port._filesystem.read_binary_file(file1) file2 = port._filesystem.join(dir, 'fast', 'css', 'remove-shorthand-expected.png') contents2 = port._filesystem.read_binary_file(file2) tmpfd, tmpfile = port._filesystem.open_binary_tempfile('') tmpfd.close() self.assertFalse(port.diff_image(contents1, contents1)[0]) self.assertTrue(port.diff_image(contents1, contents2)[0]) self.assertTrue(port.diff_image(contents1, contents2, tmpfile)[0]) port._filesystem.remove(tmpfile) def test_diff_image__missing_both(self): port = self.make_port() self.assertFalse(port.diff_image(None, None)[0]) self.assertFalse(port.diff_image(None, '')[0]) self.assertFalse(port.diff_image('', None)[0]) self.assertFalse(port.diff_image('', '')[0]) def test_diff_image__missing_actual(self): port = self.make_port() self.assertTrue(port.diff_image(None, 'foo')[0]) self.assertTrue(port.diff_image('', 'foo')[0]) def test_diff_image__missing_expected(self): port = self.make_port() self.assertTrue(port.diff_image('foo', None)[0]) self.assertTrue(port.diff_image('foo', '')[0]) def test_diff_image(self): port = self.make_port() self.proc = None def make_proc(port, nm, cmd, env): self.proc = MockServerProcess(port, nm, cmd, env, lines=['diff: 100% failed\n', 'diff: 100% failed\n']) return self.proc port._server_process_constructor = make_proc port.setup_test_run() self.assertEqual(port.diff_image('foo', 'bar'), ('', 100.0, None)) self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0.1"]) self.assertEqual(port.diff_image('foo', 'bar', None), ('', 100.0, None)) self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0.1"]) self.assertEqual(port.diff_image('foo', 'bar', 0), ('', 100.0, None)) self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0"]) port.clean_up_test_run() self.assertTrue(self.proc.stopped) self.assertEqual(port._image_differ, None) def test_diff_image_crashed(self): port = self.make_port() self.proc = None def make_proc(port, nm, cmd, env): self.proc = MockServerProcess(port, nm, cmd, env, crashed=True) return self.proc port._server_process_constructor = make_proc port.setup_test_run() self.assertEqual(port.diff_image('foo', 'bar'), ('', 0, 'ImageDiff crashed\n')) port.clean_up_test_run() def test_check_wdiff(self): port = self.make_port() port.check_wdiff() def integration_test_websocket_server__normal(self): port = self.make_port() self.assert_servers_are_down('localhost', self.WEBSOCKET_PORTS) port.start_websocket_server() self.assert_servers_are_up('localhost', self.WEBSOCKET_PORTS) port.stop_websocket_server() self.assert_servers_are_down('localhost', self.WEBSOCKET_PORTS) def integration_test_websocket_server__fails(self): port = self.make_port() # Test that start() fails if a port isn't available. for port_number in self.WEBSOCKET_PORTS: test_socket = socket.socket() try: test_socket.bind(('localhost', port_number)) try: port.start_websocket_server() self.fail('should not have been able to start the server while bound to %d' % port_number) except http_server_base.ServerError, e: pass finally: port.stop_websocket_server() test_socket.close() # Test that calling start() twice fails. try: port.start_websocket_server() self.assertRaises(AssertionError, port.start_websocket_server) finally: port.stop_websocket_server() def integration_test_websocket_server__two_servers(self): port = self.make_port() # Test that calling start() on two different ports causes the # first port to be treated as stale and killed. port.start_websocket_server() new_port = self.make_port() try: new_port.start_websocket_server() # Check that the first server was killed. self.assertFalse(port._executive.check_running_pid(port._websocket_server._pid)) # Check that there is something running. self.assert_servers_are_up('localhost', self.WEBSOCKET_PORTS) # Test that calling stop() on a killed server is harmless. port.stop_websocket_server() finally: port.stop_websocket_server() new_port.stop_websocket_server() # Test that calling stop() twice is harmless. new_port.stop_websocket_server() def test_test_configuration(self): port = self.make_port() self.assertTrue(port.test_configuration()) def test_all_test_configurations(self): port = self.make_port() self.assertTrue(len(port.all_test_configurations()) > 0) self.assertTrue(port.test_configuration() in port.all_test_configurations(), "%s not in %s" % (port.test_configuration(), port.all_test_configurations())) def integration_test_http_server__loop(self): port = self.make_port() i = 0 while i < 10: self.assert_servers_are_down('localhost', self.HTTP_PORTS) port.start_http_server() # We sleep in between alternating runs to ensure that this # test handles both back-to-back starts and stops and # starts and stops separated by a delay. if i % 2: time.sleep(0.1) self.assert_servers_are_up('localhost', self.HTTP_PORTS) port.stop_http_server() if i % 2: time.sleep(0.1) i += 1 def test_get_crash_log(self): port = self.make_port() self.assertEqual(port._get_crash_log(None, None, None, None, newer_than=None), (None, 'crash log for <unknown process name> (pid <unknown>):\n' 'STDOUT: <empty>\n' 'STDERR: <empty>\n')) self.assertEqual(port._get_crash_log('foo', 1234, 'out bar\nout baz', 'err bar\nerr baz\n', newer_than=None), ('err bar\nerr baz\n', 'crash log for foo (pid 1234):\n' 'STDOUT: out bar\n' 'STDOUT: out baz\n' 'STDERR: err bar\n' 'STDERR: err baz\n')) self.assertEqual(port._get_crash_log('foo', 1234, 'foo\xa6bar', 'foo\xa6bar', newer_than=None), ('foo\xa6bar', u'crash log for foo (pid 1234):\n' u'STDOUT: foo\ufffdbar\n' u'STDERR: foo\ufffdbar\n')) self.assertEqual(port._get_crash_log('foo', 1234, 'foo\xa6bar', 'foo\xa6bar', newer_than=1.0), ('foo\xa6bar', u'crash log for foo (pid 1234):\n' u'STDOUT: foo\ufffdbar\n' u'STDERR: foo\ufffdbar\n')) def assert_build_path(self, options, dirs, expected_path): port = self.make_port(options=options) for directory in dirs: port.host.filesystem.maybe_make_directory(directory) self.assertEqual(port._build_path(), expected_path) def test_expectations_ordering(self): port = self.make_port() for path in port.expectations_files(): port._filesystem.write_text_file(path, '') ordered_dict = port.expectations_dict() self.assertEqual(port.path_to_generic_test_expectations_file(), ordered_dict.keys()[0]) self.assertEqual(port.path_to_test_expectations_file(), ordered_dict.keys()[1]) options = MockOptions(additional_expectations=['/tmp/foo', '/tmp/bar']) port = self.make_port(options=options) for path in port.expectations_files(): port._filesystem.write_text_file(path, '') port._filesystem.write_text_file('/tmp/foo', 'foo') port._filesystem.write_text_file('/tmp/bar', 'bar') ordered_dict = port.expectations_dict() self.assertEqual(ordered_dict.keys()[-2:], options.additional_expectations) # pylint: disable=E1101 self.assertEqual(ordered_dict.values()[-2:], ['foo', 'bar']) def test_path_to_test_expectations_file(self): port = TestWebKitPort() port._options = MockOptions(webkit_test_runner=False) self.assertEqual(port.path_to_test_expectations_file(), '/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations') port = TestWebKitPort() port._options = MockOptions(webkit_test_runner=True) self.assertEqual(port.path_to_test_expectations_file(), '/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations') port = TestWebKitPort() port.host.filesystem.files['/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations'] = 'some content' port._options = MockOptions(webkit_test_runner=False) self.assertEqual(port.path_to_test_expectations_file(), '/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations') def test_skipped_directories_for_features(self): supported_features = ["Accelerated Compositing", "Foo Feature"] expected_directories = set(["animations/3d", "transforms/3d"]) port = TestWebKitPort(supported_features=supported_features) port._runtime_feature_list = lambda: supported_features result_directories = set(port._skipped_tests_for_unsupported_features(test_list=["animations/3d/foo.html"])) self.assertEqual(result_directories, expected_directories) def test_skipped_directories_for_features_no_matching_tests_in_test_list(self): supported_features = ["Accelerated Compositing", "Foo Feature"] expected_directories = set([]) result_directories = set(TestWebKitPort(supported_features=supported_features)._skipped_tests_for_unsupported_features(test_list=['foo.html'])) self.assertEqual(result_directories, expected_directories) def test_skipped_tests_for_unsupported_features_empty_test_list(self): supported_features = ["Accelerated Compositing", "Foo Feature"] expected_directories = set([]) result_directories = set(TestWebKitPort(supported_features=supported_features)._skipped_tests_for_unsupported_features(test_list=None)) self.assertEqual(result_directories, expected_directories) def test_skipped_layout_tests(self): self.assertEqual(TestWebKitPort().skipped_layout_tests(test_list=[]), set(['media'])) def test_expectations_files(self): port = TestWebKitPort() def platform_dirs(port): return [port.host.filesystem.basename(port.host.filesystem.dirname(f)) for f in port.expectations_files()] self.assertEqual(platform_dirs(port), ['LayoutTests', 'testwebkitport']) port = TestWebKitPort(port_name="testwebkitport-version") self.assertEqual(platform_dirs(port), ['LayoutTests', 'testwebkitport', 'testwebkitport-version']) port = TestWebKitPort(port_name="testwebkitport-version-wk2") self.assertEqual(platform_dirs(port), ['LayoutTests', 'testwebkitport', 'testwebkitport-version', 'wk2', 'testwebkitport-wk2']) port = TestWebKitPort(port_name="testwebkitport-version", options=MockOptions(additional_platform_directory=["internal-testwebkitport"])) self.assertEqual(platform_dirs(port), ['LayoutTests', 'testwebkitport', 'testwebkitport-version', 'internal-testwebkitport']) def test_root_option(self): port = TestWebKitPort() port._options = MockOptions(root='/foo') self.assertEqual(port._path_to_driver(), "/foo/DumpRenderTree") def test_test_expectations(self): # Check that we read the expectations file host = MockSystemHost() host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations', 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n') port = TestWebKitPort(host=host) self.assertEqual(''.join(port.expectations_dict().values()), 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n') def test_build_driver(self): output = OutputCapture() port = TestWebKitPort() # Delay setting _executive to avoid logging during construction port._executive = MockExecutive(should_log=True) port._options = MockOptions(configuration="Release") # This should not be necessary, but I think TestWebKitPort is actually reading from disk (and thus detects the current configuration). expected_logs = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n" self.assertTrue(output.assert_outputs(self, port._build_driver, expected_logs=expected_logs)) # Make sure when passed --webkit-test-runner we build the right tool. port._options = MockOptions(webkit_test_runner=True, configuration="Release") expected_logs = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\nMOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n" self.assertTrue(output.assert_outputs(self, port._build_driver, expected_logs=expected_logs)) # Make sure we show the build log when --verbose is passed, which we simulate by setting the logging level to DEBUG. output.set_log_level(logging.DEBUG) port._options = MockOptions(configuration="Release") expected_logs = """MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'} Output of ['Tools/Scripts/build-dumprendertree', '--release']: MOCK output of child process """ self.assertTrue(output.assert_outputs(self, port._build_driver, expected_logs=expected_logs)) output.set_log_level(logging.INFO) # Make sure that failure to build returns False. port._executive = MockExecutive(should_log=True, should_throw=True) # Because WK2 currently has to build both webkittestrunner and DRT, if DRT fails, that's the only one it tries. expected_logs = """MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'} MOCK ScriptError MOCK output of child process """ self.assertFalse(output.assert_outputs(self, port._build_driver, expected_logs=expected_logs)) def _assert_config_file_for_platform(self, port, platform, config_file): self.assertEqual(port._apache_config_file_name_for_platform(platform), config_file) def test_linux_distro_detection(self): port = TestWebKitPort() self.assertFalse(port._is_redhat_based()) self.assertFalse(port._is_debian_based()) port._filesystem = MockFileSystem({'/etc/redhat-release': ''}) self.assertTrue(port._is_redhat_based()) self.assertFalse(port._is_debian_based()) port._filesystem = MockFileSystem({'/etc/debian_version': ''}) self.assertFalse(port._is_redhat_based()) self.assertTrue(port._is_debian_based()) port._filesystem = MockFileSystem({'/etc/arch-release': ''}) self.assertFalse(port._is_redhat_based()) self.assertTrue(port._is_arch_based()) def test_apache_config_file_name_for_platform(self): port = TestWebKitPort() self._assert_config_file_for_platform(port, 'cygwin', 'cygwin-httpd.conf') self._assert_config_file_for_platform(port, 'linux2', 'apache2-httpd.conf') self._assert_config_file_for_platform(port, 'linux3', 'apache2-httpd.conf') port._is_redhat_based = lambda: True port._apache_version = lambda: '2.2' self._assert_config_file_for_platform(port, 'linux2', 'fedora-httpd-2.2.conf') port = TestWebKitPort() port._is_debian_based = lambda: True port._apache_version = lambda: '2.2' self._assert_config_file_for_platform(port, 'linux2', 'debian-httpd-2.2.conf') self._assert_config_file_for_platform(port, 'mac', 'apache2-httpd.conf') self._assert_config_file_for_platform(port, 'win32', 'apache2-httpd.conf') # win32 isn't a supported sys.platform. AppleWin/WinCairo/WinCE ports all use cygwin. self._assert_config_file_for_platform(port, 'barf', 'apache2-httpd.conf') def test_path_to_apache_config_file(self): port = TestWebKitPort() saved_environ = os.environ.copy() try: os.environ['WEBKIT_HTTP_SERVER_CONF_PATH'] = '/path/to/httpd.conf' self.assertRaises(IOError, port._path_to_apache_config_file) port._filesystem.write_text_file('/existing/httpd.conf', 'Hello, world!') os.environ['WEBKIT_HTTP_SERVER_CONF_PATH'] = '/existing/httpd.conf' self.assertEqual(port._path_to_apache_config_file(), '/existing/httpd.conf') finally: os.environ = saved_environ.copy() # Mock out _apache_config_file_name_for_platform to ignore the passed sys.platform value. port._apache_config_file_name_for_platform = lambda platform: 'httpd.conf' self.assertEqual(port._path_to_apache_config_file(), '/mock-checkout/LayoutTests/http/conf/httpd.conf') # Check that even if we mock out _apache_config_file_name, the environment variable takes precedence. saved_environ = os.environ.copy() try: os.environ['WEBKIT_HTTP_SERVER_CONF_PATH'] = '/existing/httpd.conf' self.assertEqual(port._path_to_apache_config_file(), '/existing/httpd.conf') finally: os.environ = saved_environ.copy() def test_check_build(self): port = self.make_port(options=MockOptions(build=True)) self.build_called = False def build_driver_called(): self.build_called = True return True port._build_driver = build_driver_called port.check_build(False) self.assertTrue(self.build_called) port = self.make_port(options=MockOptions(root='/tmp', build=True)) self.build_called = False port._build_driver = build_driver_called port.check_build(False) self.assertFalse(self.build_called, None) port = self.make_port(options=MockOptions(build=False)) self.build_called = False port._build_driver = build_driver_called port.check_build(False) self.assertFalse(self.build_called, None) def test_additional_platform_directory(self): port = self.make_port(options=MockOptions(additional_platform_directory=['/tmp/foo'])) self.assertEqual(port.baseline_search_path()[0], '/tmp/foo')
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, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 5072, 5343, 1300, 1021, 367, 10977, 12591, 1041, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 646, 2882, 18, 465, 2882, 199, 199, 504, 18007, 14, 2330, 14, 2253, 14, 1628, 13441, 63, 1805, 492, 4420, 4858, 13441, 199, 504, 18007, 14, 2330, 14, 2253, 14, 11381, 63, 1805, 492, 4420, 17521, 199, 504, 18007, 14, 2330, 14, 2253, 14, 1199, 12685, 492, 7242, 16640, 199, 504, 18007, 14, 2330, 14, 2253, 14, 2253, 1102, 63, 1805, 492, 4420, 3989, 4965, 199, 504, 18007, 14, 719, 14, 1095, 492, 10977, 199, 504, 18007, 14, 719, 14, 1000, 63, 1412, 63, 1805, 492, 4420, 3120, 3498, 199, 504, 18007, 14, 4209, 63, 2219, 14, 5871, 492, 1455, 63, 1000, 63, 1095, 199, 504, 18007, 14, 3557, 14, 1805, 3557, 492, 4420, 4558, 421, 199, 3, 7600, 26, 664, 16146, 402, 642, 10949, 199, 533, 1379, 21666, 4313, 8, 4313, 304, 272, 1844, 63, 354, 275, 298, 396, 12554, 719, 2, 339, 347, 636, 826, 721, 277, 12, 1844, 63, 354, 29, 403, 12, 6698, 63, 875, 29, 403, 12, 326, 21851, 63, 493, 29, 403, 12, 30505, 63, 493, 29, 403, 12, 1591, 29, 403, 12, 1101, 29, 403, 12, 326, 1011, 958, 304, 267, 1844, 63, 354, 275, 1844, 63, 354, 503, 1379, 21666, 4313, 14, 719, 63, 354, 267, 291, 14, 7450, 63, 875, 275, 6698, 63, 875, 221, 327, 31755, 3087, 28421, 1006, 8753, 429, 89, 13, 13552, 461, 4534, 14, 267, 1591, 275, 1591, 503, 4420, 3989, 4965, 342, 267, 1613, 8, 774, 21666, 4313, 12, 291, 2843, 826, 721, 1102, 12, 1844, 63, 354, 29, 719, 63, 354, 12, 1011, 958, 9, 339, 347, 1006, 63, 396, 63, 10057, 8, 277, 304, 267, 372, 359, 277, 14, 396, 63, 4758, 5106, 339, 347, 485, 7450, 63, 875, 8, 277, 304, 267, 372, 291, 14, 7450, 63, 875, 339, 347, 485, 2219, 63, 509, 63, 1848, 63, 19601, 8, 277, 304, 267, 372, 2097, 4603, 401, 1622, 339, 347, 485, 2219, 63, 509, 63, 7011, 63, 3179, 8, 277, 304, 267, 372, 2097, 645, 823, 4783, 401, 1622, 421, 199, 533, 10977, 1746, 8, 2796, 14, 1746, 304, 272, 408, 2925, 626, 1006, 10977, 12591, 1471, 986, 1041, 272, 3101, 63, 3657, 51, 275, 334, 15214, 12, 30220, 12, 8264, 2824, 9, 272, 644, 14138, 17462, 63, 3657, 51, 275, 334, 1299, 1257, 4258, 339, 327, 20196, 4278, 642, 370, 2376, 370, 3932, 10977, 5516, 14, 272, 747, 63, 354, 275, 488, 272, 747, 63, 1023, 275, 488, 272, 1844, 63, 14367, 275, 1379, 21666, 4313, 272, 1844, 63, 354, 275, 488, 339, 347, 1852, 63, 719, 8, 277, 12, 1591, 29, 403, 12, 1844, 63, 354, 29, 403, 12, 1511, 29, 403, 12, 747, 63, 354, 29, 403, 12, 747, 63, 1023, 29, 403, 12, 1011, 958, 304, 267, 1591, 275, 1591, 503, 4420, 3989, 4965, 8, 736, 63, 354, 2687, 736, 63, 354, 503, 291, 14, 736, 63, 354, 395, 747, 63, 1023, 2687, 736, 63, 1023, 503, 291, 14, 736, 63, 1023, 430, 267, 1511, 275, 1511, 503, 4420, 4558, 8, 4758, 534, 9625, 358, 267, 1844, 63, 354, 275, 1844, 63, 354, 503, 291, 14, 719, 63, 354, 267, 1844, 63, 354, 275, 291, 14, 719, 63, 14367, 14, 22189, 63, 2861, 63, 719, 63, 354, 8, 1102, 12, 1511, 12, 1844, 63, 354, 9, 267, 1844, 275, 291, 14, 719, 63, 14367, 8, 1102, 12, 1844, 63, 354, 12, 1511, 29, 1419, 12, 1011, 958, 9, 267, 1844, 423, 888, 14, 1506, 63, 3619, 275, 2400, 2897, 26, 1994, 1805, 13, 1506, 7, 267, 372, 1844, 339, 347, 511, 63, 885, 63, 988, 63, 9325, 63, 15570, 8, 277, 304, 267, 1844, 275, 291, 14, 1875, 63, 719, 342, 267, 1844, 14, 885, 63, 1739, 63, 11816, 275, 2400, 26, 3193, 267, 291, 14, 629, 8, 719, 14, 885, 63, 988, 63, 9325, 63, 15570, 1062, 413, 9, 267, 1844, 14, 885, 63, 1739, 63, 11816, 275, 2400, 26, 499, 267, 291, 14, 629, 8, 719, 14, 885, 63, 988, 63, 9325, 63, 15570, 1062, 413, 9, 339, 347, 511, 63 ]
[ 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, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 5072, 5343, 1300, 1021, 367, 10977, 12591, 1041, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 646, 2882, 18, 465, 2882, 199, 199, 504, 18007, 14, 2330, 14, 2253, 14, 1628, 13441, 63, 1805, 492, 4420, 4858, 13441, 199, 504, 18007, 14, 2330, 14, 2253, 14, 11381, 63, 1805, 492, 4420, 17521, 199, 504, 18007, 14, 2330, 14, 2253, 14, 1199, 12685, 492, 7242, 16640, 199, 504, 18007, 14, 2330, 14, 2253, 14, 2253, 1102, 63, 1805, 492, 4420, 3989, 4965, 199, 504, 18007, 14, 719, 14, 1095, 492, 10977, 199, 504, 18007, 14, 719, 14, 1000, 63, 1412, 63, 1805, 492, 4420, 3120, 3498, 199, 504, 18007, 14, 4209, 63, 2219, 14, 5871, 492, 1455, 63, 1000, 63, 1095, 199, 504, 18007, 14, 3557, 14, 1805, 3557, 492, 4420, 4558, 421, 199, 3, 7600, 26, 664, 16146, 402, 642, 10949, 199, 533, 1379, 21666, 4313, 8, 4313, 304, 272, 1844, 63, 354, 275, 298, 396, 12554, 719, 2, 339, 347, 636, 826, 721, 277, 12, 1844, 63, 354, 29, 403, 12, 6698, 63, 875, 29, 403, 12, 326, 21851, 63, 493, 29, 403, 12, 30505, 63, 493, 29, 403, 12, 1591, 29, 403, 12, 1101, 29, 403, 12, 326, 1011, 958, 304, 267, 1844, 63, 354, 275, 1844, 63, 354, 503, 1379, 21666, 4313, 14, 719, 63, 354, 267, 291, 14, 7450, 63, 875, 275, 6698, 63, 875, 221, 327, 31755, 3087, 28421, 1006, 8753, 429, 89, 13, 13552, 461, 4534, 14, 267, 1591, 275, 1591, 503, 4420, 3989, 4965, 342, 267, 1613, 8, 774, 21666, 4313, 12, 291, 2843, 826, 721, 1102, 12, 1844, 63, 354, 29, 719, 63, 354, 12, 1011, 958, 9, 339, 347, 1006, 63, 396, 63, 10057, 8, 277, 304, 267, 372, 359, 277, 14, 396, 63, 4758, 5106, 339, 347, 485, 7450, 63, 875, 8, 277, 304, 267, 372, 291, 14, 7450, 63, 875, 339, 347, 485, 2219, 63, 509, 63, 1848, 63, 19601, 8, 277, 304, 267, 372, 2097, 4603, 401, 1622, 339, 347, 485, 2219, 63, 509, 63, 7011, 63, 3179, 8, 277, 304, 267, 372, 2097, 645, 823, 4783, 401, 1622, 421, 199, 533, 10977, 1746, 8, 2796, 14, 1746, 304, 272, 408, 2925, 626, 1006, 10977, 12591, 1471, 986, 1041, 272, 3101, 63, 3657, 51, 275, 334, 15214, 12, 30220, 12, 8264, 2824, 9, 272, 644, 14138, 17462, 63, 3657, 51, 275, 334, 1299, 1257, 4258, 339, 327, 20196, 4278, 642, 370, 2376, 370, 3932, 10977, 5516, 14, 272, 747, 63, 354, 275, 488, 272, 747, 63, 1023, 275, 488, 272, 1844, 63, 14367, 275, 1379, 21666, 4313, 272, 1844, 63, 354, 275, 488, 339, 347, 1852, 63, 719, 8, 277, 12, 1591, 29, 403, 12, 1844, 63, 354, 29, 403, 12, 1511, 29, 403, 12, 747, 63, 354, 29, 403, 12, 747, 63, 1023, 29, 403, 12, 1011, 958, 304, 267, 1591, 275, 1591, 503, 4420, 3989, 4965, 8, 736, 63, 354, 2687, 736, 63, 354, 503, 291, 14, 736, 63, 354, 395, 747, 63, 1023, 2687, 736, 63, 1023, 503, 291, 14, 736, 63, 1023, 430, 267, 1511, 275, 1511, 503, 4420, 4558, 8, 4758, 534, 9625, 358, 267, 1844, 63, 354, 275, 1844, 63, 354, 503, 291, 14, 719, 63, 354, 267, 1844, 63, 354, 275, 291, 14, 719, 63, 14367, 14, 22189, 63, 2861, 63, 719, 63, 354, 8, 1102, 12, 1511, 12, 1844, 63, 354, 9, 267, 1844, 275, 291, 14, 719, 63, 14367, 8, 1102, 12, 1844, 63, 354, 12, 1511, 29, 1419, 12, 1011, 958, 9, 267, 1844, 423, 888, 14, 1506, 63, 3619, 275, 2400, 2897, 26, 1994, 1805, 13, 1506, 7, 267, 372, 1844, 339, 347, 511, 63, 885, 63, 988, 63, 9325, 63, 15570, 8, 277, 304, 267, 1844, 275, 291, 14, 1875, 63, 719, 342, 267, 1844, 14, 885, 63, 1739, 63, 11816, 275, 2400, 26, 3193, 267, 291, 14, 629, 8, 719, 14, 885, 63, 988, 63, 9325, 63, 15570, 1062, 413, 9, 267, 1844, 14, 885, 63, 1739, 63, 11816, 275, 2400, 26, 499, 267, 291, 14, 629, 8, 719, 14, 885, 63, 988, 63, 9325, 63, 15570, 1062, 413, 9, 339, 347, 511, 63, 0 ]
[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]
roger-zhao/ardupilot-3.3
Tools/LogAnalyzer/tests/TestVibration.py
261
3069
from LogAnalyzer import Test,TestResult import DataflashLog import numpy class TestVibration(Test): '''test for accelerometer vibration (accX/accY/accZ) within recommendations''' def __init__(self): Test.__init__(self) self.name = "Vibration" def run(self, logdata, verbose): self.result = TestResult() if logdata.vehicleType != "ArduCopter": self.result.status = TestResult.StatusType.NA return # constants gravity = -9.81 aimRangeWarnXY = 1.5 aimRangeFailXY = 3.0 aimRangeWarnZ = 2.0 # gravity +/- aim range aimRangeFailZ = 5.0 # gravity +/- aim range if not "IMU" in logdata.channels: self.result.status = TestResult.StatusType.UNKNOWN self.result.statusMessage = "No IMU log data" return # find some stable LOITER data to analyze, at least 10 seconds chunks = DataflashLog.DataflashLogHelper.findLoiterChunks(logdata, minLengthSeconds=10, noRCInputs=True) if not chunks: self.result.status = TestResult.StatusType.UNKNOWN self.result.statusMessage = "No stable LOITER log data found" return # for now we'll just use the first (largest) chunk of LOITER data # TODO: ignore the first couple of secs to avoid bad data during transition - or can we check more analytically that we're stable? # TODO: accumulate all LOITER chunks over min size, or just use the largest one? startLine = chunks[0][0] endLine = chunks[0][1] #print "TestVibration using LOITER chunk from lines %s to %s" % (`startLine`, `endLine`) def getStdDevIMU(logdata, channelName, startLine,endLine): loiterData = logdata.channels["IMU"][channelName].getSegment(startLine,endLine) numpyData = numpy.array(loiterData.dictData.values()) return numpy.std(numpyData) # use 2x standard deviations as the metric, so if 95% of samples lie within the aim range we're good stdDevX = abs(2 * getStdDevIMU(logdata,"AccX",startLine,endLine)) stdDevY = abs(2 * getStdDevIMU(logdata,"AccY",startLine,endLine)) stdDevZ = abs(2 * getStdDevIMU(logdata,"AccZ",startLine,endLine)) if (stdDevX > aimRangeFailXY) or (stdDevY > aimRangeFailXY) or (stdDevZ > aimRangeFailZ): self.result.status = TestResult.StatusType.FAIL self.result.statusMessage = "Vibration too high (X:%.2fg, Y:%.2fg, Z:%.2fg)" % (stdDevX,stdDevY,stdDevZ) elif (stdDevX > aimRangeWarnXY) or (stdDevY > aimRangeWarnXY) or (stdDevZ > aimRangeWarnZ): self.result.status = TestResult.StatusType.WARN self.result.statusMessage = "Vibration slightly high (X:%.2fg, Y:%.2fg, Z:%.2fg)" % (stdDevX,stdDevY,stdDevZ) else: self.result.status = TestResult.StatusType.GOOD self.result.statusMessage = "Good vibration values (X:%.2fg, Y:%.2fg, Z:%.2fg)" % (stdDevX,stdDevY,stdDevZ)
gpl-3.0
[ 504, 5297, 17606, 492, 1379, 12, 13120, 199, 646, 3918, 11331, 2445, 199, 199, 646, 2680, 421, 199, 533, 1379, 54, 1892, 1754, 8, 774, 304, 272, 1449, 396, 367, 1066, 15421, 5864, 351, 1321, 66, 1754, 334, 5470, 56, 15, 5470, 57, 15, 5470, 58, 9, 4453, 27747, 1298, 2344, 339, 347, 636, 826, 721, 277, 304, 267, 1379, 855, 826, 721, 277, 9, 267, 291, 14, 354, 275, 298, 54, 1892, 1754, 2, 2378, 347, 1255, 8, 277, 12, 943, 576, 12, 3376, 304, 267, 291, 14, 1099, 275, 23795, 342, 398, 340, 943, 576, 14, 20073, 804, 1137, 298, 31924, 18268, 351, 582, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 7170, 288, 372, 398, 327, 5262, 267, 1999, 18936, 263, 275, 446, 25, 14, 2835, 267, 282, 1017, 4709, 22673, 8195, 275, 413, 14, 21, 267, 282, 1017, 4709, 4874, 8195, 275, 650, 14, 16, 267, 282, 1017, 4709, 22673, 58, 221, 275, 499, 14, 16, 221, 327, 1999, 18936, 435, 22551, 282, 1017, 1425, 267, 282, 1017, 4709, 4874, 58, 221, 275, 959, 14, 16, 221, 327, 1999, 18936, 435, 22551, 282, 1017, 1425, 398, 340, 440, 298, 1469, 53, 2, 315, 943, 576, 14, 6324, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 11588, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 1944, 18211, 53, 943, 666, 2, 288, 372, 398, 327, 2342, 2005, 17830, 3412, 11084, 666, 370, 19897, 12, 737, 5210, 1616, 4696, 267, 8291, 275, 3918, 11331, 2445, 14, 1451, 11331, 2445, 4433, 14, 1623, 2041, 1661, 9856, 83, 8, 793, 576, 12, 1748, 4625, 13165, 29, 709, 12, 949, 8205, 15124, 29, 549, 9, 267, 340, 440, 8291, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 11588, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 1944, 17830, 3412, 11084, 943, 666, 1911, 2, 263, 288, 372, 398, 327, 367, 3063, 781, 7171, 2951, 675, 314, 1642, 334, 9828, 3199, 9, 3728, 402, 3412, 11084, 666, 267, 327, 3254, 26, 3686, 314, 1642, 17535, 402, 20091, 370, 5126, 4875, 666, 5309, 14116, 446, 503, 883, 781, 1104, 1655, 5909, 17269, 626, 781, 3984, 17830, 31, 267, 327, 3254, 26, 30535, 1006, 3412, 11084, 8291, 1806, 1748, 1568, 12, 503, 2951, 675, 314, 17451, 1373, 31, 267, 1343, 3049, 275, 8291, 59, 16, 1527, 16, 61, 267, 1284, 3049, 257, 275, 8291, 59, 16, 1527, 17, 61, 267, 327, 1361, 298, 774, 54, 1892, 1754, 1808, 3412, 11084, 3728, 687, 2385, 450, 83, 370, 450, 83, 2, 450, 13493, 928, 3049, 3559, 658, 500, 3049, 10522, 398, 347, 664, 11976, 12680, 1469, 53, 8, 793, 576, 12, 3623, 985, 12, 1343, 3049, 12, 500, 3049, 304, 288, 560, 1661, 1451, 275, 943, 576, 14, 6324, 905, 1469, 53, 9210, 2775, 985, 1055, 362, 12520, 8, 928, 3049, 12, 500, 3049, 9, 288, 2680, 1451, 221, 275, 2680, 14, 1144, 8, 320, 1661, 1451, 14, 807, 1451, 14, 1459, 1012, 288, 372, 2680, 14, 1516, 8, 4714, 1451, 9, 398, 327, 675, 499, 88, 4465, 29052, 1298, 465, 314, 6370, 12, 880, 340, 16102, 5, 402, 5845, 1212, 69, 4453, 314, 282, 1017, 1425, 781, 3984, 6954, 267, 2418, 12680, 56, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 56, 401, 928, 3049, 12, 500, 3049, 430, 267, 2418, 12680, 57, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 57, 401, 928, 3049, 12, 500, 3049, 430, 267, 2418, 12680, 58, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 58, 401, 928, 3049, 12, 500, 3049, 430, 267, 340, 334, 1516, 12680, 56, 690, 282, 1017, 4709, 4874, 8195, 9, 503, 334, 1516, 12680, 57, 690, 282, 1017, 4709, 4874, 8195, 9, 503, 334, 1516, 12680, 58, 690, 282, 1017, 4709, 4874, 58, 304, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 8784, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 54, 1892, 1754, 4634, 4721, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 267, 916, 334, 1516, 12680, 56, 690, 282, 1017, 4709, 22673, 8195, 9, 503, 334, 1516, 12680, 57, 690, 282, 1017, 4709, 22673, 8195, 9, 503, 334, 1516, 12680, 58, 690, 282, 1017, 4709, 22673, 58, 304, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 17449, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 54, 1892, 1754, 18023, 4721, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 267, 587, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 17316, 36, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 20652, 1321, 66, 1754, 1338, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 13359, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5297, 17606, 492, 1379, 12, 13120, 199, 646, 3918, 11331, 2445, 199, 199, 646, 2680, 421, 199, 533, 1379, 54, 1892, 1754, 8, 774, 304, 272, 1449, 396, 367, 1066, 15421, 5864, 351, 1321, 66, 1754, 334, 5470, 56, 15, 5470, 57, 15, 5470, 58, 9, 4453, 27747, 1298, 2344, 339, 347, 636, 826, 721, 277, 304, 267, 1379, 855, 826, 721, 277, 9, 267, 291, 14, 354, 275, 298, 54, 1892, 1754, 2, 2378, 347, 1255, 8, 277, 12, 943, 576, 12, 3376, 304, 267, 291, 14, 1099, 275, 23795, 342, 398, 340, 943, 576, 14, 20073, 804, 1137, 298, 31924, 18268, 351, 582, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 7170, 288, 372, 398, 327, 5262, 267, 1999, 18936, 263, 275, 446, 25, 14, 2835, 267, 282, 1017, 4709, 22673, 8195, 275, 413, 14, 21, 267, 282, 1017, 4709, 4874, 8195, 275, 650, 14, 16, 267, 282, 1017, 4709, 22673, 58, 221, 275, 499, 14, 16, 221, 327, 1999, 18936, 435, 22551, 282, 1017, 1425, 267, 282, 1017, 4709, 4874, 58, 221, 275, 959, 14, 16, 221, 327, 1999, 18936, 435, 22551, 282, 1017, 1425, 398, 340, 440, 298, 1469, 53, 2, 315, 943, 576, 14, 6324, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 11588, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 1944, 18211, 53, 943, 666, 2, 288, 372, 398, 327, 2342, 2005, 17830, 3412, 11084, 666, 370, 19897, 12, 737, 5210, 1616, 4696, 267, 8291, 275, 3918, 11331, 2445, 14, 1451, 11331, 2445, 4433, 14, 1623, 2041, 1661, 9856, 83, 8, 793, 576, 12, 1748, 4625, 13165, 29, 709, 12, 949, 8205, 15124, 29, 549, 9, 267, 340, 440, 8291, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 11588, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 1944, 17830, 3412, 11084, 943, 666, 1911, 2, 263, 288, 372, 398, 327, 367, 3063, 781, 7171, 2951, 675, 314, 1642, 334, 9828, 3199, 9, 3728, 402, 3412, 11084, 666, 267, 327, 3254, 26, 3686, 314, 1642, 17535, 402, 20091, 370, 5126, 4875, 666, 5309, 14116, 446, 503, 883, 781, 1104, 1655, 5909, 17269, 626, 781, 3984, 17830, 31, 267, 327, 3254, 26, 30535, 1006, 3412, 11084, 8291, 1806, 1748, 1568, 12, 503, 2951, 675, 314, 17451, 1373, 31, 267, 1343, 3049, 275, 8291, 59, 16, 1527, 16, 61, 267, 1284, 3049, 257, 275, 8291, 59, 16, 1527, 17, 61, 267, 327, 1361, 298, 774, 54, 1892, 1754, 1808, 3412, 11084, 3728, 687, 2385, 450, 83, 370, 450, 83, 2, 450, 13493, 928, 3049, 3559, 658, 500, 3049, 10522, 398, 347, 664, 11976, 12680, 1469, 53, 8, 793, 576, 12, 3623, 985, 12, 1343, 3049, 12, 500, 3049, 304, 288, 560, 1661, 1451, 275, 943, 576, 14, 6324, 905, 1469, 53, 9210, 2775, 985, 1055, 362, 12520, 8, 928, 3049, 12, 500, 3049, 9, 288, 2680, 1451, 221, 275, 2680, 14, 1144, 8, 320, 1661, 1451, 14, 807, 1451, 14, 1459, 1012, 288, 372, 2680, 14, 1516, 8, 4714, 1451, 9, 398, 327, 675, 499, 88, 4465, 29052, 1298, 465, 314, 6370, 12, 880, 340, 16102, 5, 402, 5845, 1212, 69, 4453, 314, 282, 1017, 1425, 781, 3984, 6954, 267, 2418, 12680, 56, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 56, 401, 928, 3049, 12, 500, 3049, 430, 267, 2418, 12680, 57, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 57, 401, 928, 3049, 12, 500, 3049, 430, 267, 2418, 12680, 58, 275, 2853, 8, 18, 627, 664, 11976, 12680, 1469, 53, 8, 793, 576, 4589, 26828, 58, 401, 928, 3049, 12, 500, 3049, 430, 267, 340, 334, 1516, 12680, 56, 690, 282, 1017, 4709, 4874, 8195, 9, 503, 334, 1516, 12680, 57, 690, 282, 1017, 4709, 4874, 8195, 9, 503, 334, 1516, 12680, 58, 690, 282, 1017, 4709, 4874, 58, 304, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 8784, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 54, 1892, 1754, 4634, 4721, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 267, 916, 334, 1516, 12680, 56, 690, 282, 1017, 4709, 22673, 8195, 9, 503, 334, 1516, 12680, 57, 690, 282, 1017, 4709, 22673, 8195, 9, 503, 334, 1516, 12680, 58, 690, 282, 1017, 4709, 22673, 58, 304, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 17449, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 54, 1892, 1754, 18023, 4721, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 267, 587, 26, 288, 291, 14, 1099, 14, 1205, 275, 23795, 14, 3694, 804, 14, 17316, 36, 288, 291, 14, 1099, 14, 1205, 2209, 275, 298, 20652, 1321, 66, 1754, 1338, 334, 56, 2689, 14, 18, 9681, 12, 1488, 2689, 14, 18, 9681, 12, 3107, 2689, 14, 18, 9681, 2924, 450, 334, 1516, 12680, 56, 12, 1516, 12680, 57, 12, 1516, 12680, 58, 9, 13359, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GeekBoy666/VGCS
ExtLibs/Mavlink/pymavlink/generator/lib/minixsv/xsvalErrorHandler.py
82
5624
# # minixsv, Release 0.9.0 # file: xsvalErrorHandler.py # # XML schema validator classes # # history: # 2004-09-23 rl created # # Copyright (c) 2004-2008 by Roland Leuthe. All rights reserved. # # -------------------------------------------------------------------- # The minixsv XML schema validator is # # Copyright (c) 2004-2008 by Roland Leuthe # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- import string import os IGNORE_WARNINGS = 0 PRINT_WARNINGS = 1 STOP_ON_WARNINGS = 2 ######################################## # Error-Handler class for XML schema validator # handles only validator errors, no parser errors! class ErrorHandler: def __init__(self, errorLimit, warningProc, verbose): self.errorLimit = errorLimit self.warningProc = warningProc self.verbose = verbose self.errorList = [] self.noOfErrors = 0 self.warningList = [] self.infoDict = {} ######################################## # check if errors have already been reported def hasErrors (self): return self.errorList != [] ######################################## # add error to errorList (raise exception only if error limit is reached) def addError (self, errstr, element=None, endTag=0): filePath = "" lineNo = 0 if element: filePath = element.getFilePath() if endTag: lineNo = element.getEndLineNumber() else: lineNo = element.getStartLineNumber() self.errorList.append ((filePath, lineNo, "ERROR", "%s" %errstr)) self.noOfErrors += 1 if self.noOfErrors == self.errorLimit: self._raiseXsvalException ("\nError Limit reached!!") ######################################## # add warning to warningList def addWarning (self, warnstr, element=None): filePath = "" lineNo = 0 if element: filePath = element.getFilePath() lineNo = element.getStartLineNumber() self.warningList.append ((filePath, lineNo, "WARNING", warnstr)) ######################################## # add info string to errorList def addInfo (self, infostr, element=None): self.infoDict.setdefault("INFO: %s" %infostr, 1) ######################################## # add error to errorList (if given) and raise exception def raiseError (self, errstr, element=None): self.addError (errstr, element) self._raiseXsvalException () ######################################## # raise exception with complete errorList as exception string # (only if errors occurred) def flushOutput (self): if self.infoDict != {}: print string.join (self.infoDict.keys(), "\n") self.infoList = [] if self.warningProc == PRINT_WARNINGS and self.warningList != []: print self._assembleOutputList(self.warningList, sorted=1) self.warningList = [] elif self.warningProc == STOP_ON_WARNINGS: self.errorList.extend (self.warningList) if self.errorList != []: self._raiseXsvalException () ######################################## # Private methods def _raiseXsvalException (self, additionalInfo=""): output = self._assembleOutputList(self.errorList) + additionalInfo self.errorList = self.warningList = [] raise XsvalError (output) def _assembleOutputList (self, outputList, sorted=0): if sorted: outputList.sort() outputStrList = [] for outElement in outputList: outputStrList.append (self._assembleOutString(outElement)) return string.join (outputStrList, "\n") def _assembleOutString (self, listElement): fileStr = "" lineStr = "" if listElement[0] != "": if self.verbose: fileStr = "%s: " %(listElement[0]) else: fileStr = "%s: " %(os.path.basename(listElement[0])) if listElement[1] != 0: lineStr = "line %d: " %(listElement[1]) return "%s: %s%s%s" %(listElement[2], fileStr, lineStr, listElement[3]) class XsvalError (StandardError): pass
gpl-3.0
[ 3, 202, 199, 3, 1748, 1148, 2772, 12, 17646, 378, 14, 25, 14, 16, 202, 199, 3, 570, 26, 12965, 637, 25933, 14, 647, 202, 199, 3, 202, 199, 3, 4692, 4177, 11822, 3992, 202, 199, 3, 202, 199, 3, 7994, 26, 202, 199, 3, 8353, 13, 1643, 13, 1789, 25717, 257, 2737, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8353, 13, 9300, 701, 820, 393, 460, 7005, 762, 69, 14, 221, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 23567, 202, 199, 3, 710, 1748, 1148, 2772, 4692, 4177, 11822, 365, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8353, 13, 9300, 701, 820, 393, 460, 7005, 762, 69, 202, 199, 3, 202, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 202, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 202, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 202, 199, 3, 202, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 202, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 202, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 202, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 202, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 202, 199, 3, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 202, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 202, 199, 3, 6791, 4983, 14, 202, 199, 3, 202, 199, 3, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 202, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 202, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 202, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 202, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 202, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 202, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 202, 199, 3, 1634, 5749, 4141, 14, 202, 199, 3, 23567, 2999, 199, 646, 1059, 202, 199, 646, 747, 2999, 199, 11209, 63, 17449, 3881, 257, 275, 378, 202, 199, 21754, 63, 17449, 3881, 259, 275, 413, 202, 199, 11632, 63, 615, 63, 17449, 3881, 221, 275, 499, 8065, 199, 26634, 202, 199, 3, 4520, 13, 2461, 1021, 367, 4692, 4177, 11822, 202, 199, 3, 10022, 1454, 11822, 2552, 12, 949, 1798, 2552, 1, 2999, 199, 533, 4520, 2461, 26, 2958, 347, 636, 826, 721, 277, 12, 1125, 8407, 12, 5721, 15019, 12, 3376, 304, 1039, 291, 14, 705, 8407, 221, 275, 1125, 8407, 1039, 291, 14, 3764, 15019, 275, 5721, 15019, 1039, 291, 14, 3832, 258, 275, 3376, 13594, 291, 14, 705, 1296, 275, 942, 1039, 291, 14, 889, 3466, 9298, 275, 378, 1039, 291, 14, 3764, 1296, 275, 942, 1039, 291, 14, 815, 2141, 275, 1052, 18801, 26316, 1128, 327, 1104, 340, 2552, 1172, 2575, 2757, 14581, 2958, 347, 965, 9298, 334, 277, 304, 1039, 372, 291, 14, 705, 1296, 1137, 942, 2958, 26316, 1128, 327, 1050, 1125, 370, 1125, 1296, 334, 3730, 1919, 1454, 340, 1125, 2304, 365, 13075, 9, 2958, 347, 1050, 547, 334, 277, 12, 2329, 495, 12, 1819, 29, 403, 12, 25414, 29, 16, 304, 1039, 570, 2042, 275, 3087, 1039, 1004, 1944, 275, 378, 1039, 340, 1819, 26, 1675, 570, 2042, 275, 1819, 14, 362, 14225, 342, 1675, 340, 25414, 26, 2628, 1004, 1944, 275, 1819, 14, 362, 3005, 3049, 3259, 342, 1675, 587, 26, 2628, 1004, 1944, 275, 1819, 14, 362, 3162, 3049, 3259, 342, 1039, 291, 14, 705, 1296, 14, 740, 3666, 27501, 12, 1004, 1944, 12, 298, 3170, 401, 2071, 83, 2, 450, 1508, 495, 430, 1039, 291, 14, 889, 3466, 9298, 847, 413, 1039, 340, 291, 14, 889, 3466, 9298, 508, 291, 14, 705, 8407, 26, 1675, 291, 423, 3730, 56, 83, 637, 1726, 25381, 78, 547, 22672, 13075, 3480, 531, 18801, 26316, 1128, 327, 1050, 5721, 370, 5721, 1296, 2958, 347, 1050, 3849, 334, 277, 12, 7987, 495, 12, 1819, 29, 403, 304, 1039, 570, 2042, 275, 3087, 1039, 1004, 1944, 275, 378, 1039, 340, 1819, 26, 1675, 570, 2042, 275, 1819, 14, 362, 14225, 342, 1675, 1004, 1944, 275, 1819, 14, 362, 3162, 3049, 3259, 342, 1039, 291, 14, 3764, 1296, 14, 740, 3666, 27501, 12, 1004, 1944, 12, 298, 9171, 401, 7987, 495, 430, 18801, 26316, 1128, 327, 1050, 2256, 1059, 370, 1125, 1296, 2958, 347, 1050, 2354, 334, 277, 12, 2256, 495, 12, 1819, 29, 403, 304, 1039, 291, 14, 815, 2141, 14, 5486, 480, 4531, 26, 450, 83, 2, 450, 815, 495, 12, 413, 9, 18801, 26316, 1128, 327, 1050, 1125, 370, 1125, 1296, 334, 692, 1627, 9, 436, 746, 1919, 2958, 347, 746, 547, 334, 277, 12, 2329, 495, 12, 1819, 29, 403, 304, 1039, 291, 14, 30787, 334, 1508, 495, 12, 1819, 9, 1039, 291, 423, 3730, 56, 83, 637, 1726, 6248, 18801, 26316, 1128, 327, 746, 1919, 543, 4890, 1125, 1296, 465, 1919, 1059, 1128, 327, 334, 2118, 340, 2552, 8920, 9, 2958, 347, 8976, 2959, 334, 277, 304, 1039, 340, 291, 14, 815, 2141, 1137, 24702, 1675, 870, 1059, 14, 904, 334, 277, 14, 815, 2141, 14, 1612, 1062, 1867, 78, 531, 1675, 291, 14, 815, 1296, 275, 942, 4341, 340, 291, 14, 3764, 15019, 508, 12218, 2919, 63, 17449, 3881, 436, 291, 14, 3764, 1296, 1137, 18410, 1675, 870, 291, 423, 21263, 2959, 1296, 8, 277, 14, 3764, 1296, 12, 3355, 29, 17, 9, 1675, 291, 14, 3764, 1296, 275, 942, 1039, 916, 291, 14, 3764, 15019, 508, 22348, 63, 615, 63, 17449, 3881, 26, 1675, 291, 14, 705, 1296, 14, 2880, 334, 277, 14, 3764, 1296, 9, 4341, 340, 291, 14, 705, 1296, 1137, 18410, 1675, 291, 423, 3730, 56, 83, 637, 1726, 6248, 18801 ]
[ 202, 199, 3, 1748, 1148, 2772, 12, 17646, 378, 14, 25, 14, 16, 202, 199, 3, 570, 26, 12965, 637, 25933, 14, 647, 202, 199, 3, 202, 199, 3, 4692, 4177, 11822, 3992, 202, 199, 3, 202, 199, 3, 7994, 26, 202, 199, 3, 8353, 13, 1643, 13, 1789, 25717, 257, 2737, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8353, 13, 9300, 701, 820, 393, 460, 7005, 762, 69, 14, 221, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 23567, 202, 199, 3, 710, 1748, 1148, 2772, 4692, 4177, 11822, 365, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8353, 13, 9300, 701, 820, 393, 460, 7005, 762, 69, 202, 199, 3, 202, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 202, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 202, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 202, 199, 3, 202, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 202, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 202, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 202, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 202, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 202, 199, 3, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 202, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 202, 199, 3, 6791, 4983, 14, 202, 199, 3, 202, 199, 3, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 202, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 202, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 202, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 202, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 202, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 202, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 202, 199, 3, 1634, 5749, 4141, 14, 202, 199, 3, 23567, 2999, 199, 646, 1059, 202, 199, 646, 747, 2999, 199, 11209, 63, 17449, 3881, 257, 275, 378, 202, 199, 21754, 63, 17449, 3881, 259, 275, 413, 202, 199, 11632, 63, 615, 63, 17449, 3881, 221, 275, 499, 8065, 199, 26634, 202, 199, 3, 4520, 13, 2461, 1021, 367, 4692, 4177, 11822, 202, 199, 3, 10022, 1454, 11822, 2552, 12, 949, 1798, 2552, 1, 2999, 199, 533, 4520, 2461, 26, 2958, 347, 636, 826, 721, 277, 12, 1125, 8407, 12, 5721, 15019, 12, 3376, 304, 1039, 291, 14, 705, 8407, 221, 275, 1125, 8407, 1039, 291, 14, 3764, 15019, 275, 5721, 15019, 1039, 291, 14, 3832, 258, 275, 3376, 13594, 291, 14, 705, 1296, 275, 942, 1039, 291, 14, 889, 3466, 9298, 275, 378, 1039, 291, 14, 3764, 1296, 275, 942, 1039, 291, 14, 815, 2141, 275, 1052, 18801, 26316, 1128, 327, 1104, 340, 2552, 1172, 2575, 2757, 14581, 2958, 347, 965, 9298, 334, 277, 304, 1039, 372, 291, 14, 705, 1296, 1137, 942, 2958, 26316, 1128, 327, 1050, 1125, 370, 1125, 1296, 334, 3730, 1919, 1454, 340, 1125, 2304, 365, 13075, 9, 2958, 347, 1050, 547, 334, 277, 12, 2329, 495, 12, 1819, 29, 403, 12, 25414, 29, 16, 304, 1039, 570, 2042, 275, 3087, 1039, 1004, 1944, 275, 378, 1039, 340, 1819, 26, 1675, 570, 2042, 275, 1819, 14, 362, 14225, 342, 1675, 340, 25414, 26, 2628, 1004, 1944, 275, 1819, 14, 362, 3005, 3049, 3259, 342, 1675, 587, 26, 2628, 1004, 1944, 275, 1819, 14, 362, 3162, 3049, 3259, 342, 1039, 291, 14, 705, 1296, 14, 740, 3666, 27501, 12, 1004, 1944, 12, 298, 3170, 401, 2071, 83, 2, 450, 1508, 495, 430, 1039, 291, 14, 889, 3466, 9298, 847, 413, 1039, 340, 291, 14, 889, 3466, 9298, 508, 291, 14, 705, 8407, 26, 1675, 291, 423, 3730, 56, 83, 637, 1726, 25381, 78, 547, 22672, 13075, 3480, 531, 18801, 26316, 1128, 327, 1050, 5721, 370, 5721, 1296, 2958, 347, 1050, 3849, 334, 277, 12, 7987, 495, 12, 1819, 29, 403, 304, 1039, 570, 2042, 275, 3087, 1039, 1004, 1944, 275, 378, 1039, 340, 1819, 26, 1675, 570, 2042, 275, 1819, 14, 362, 14225, 342, 1675, 1004, 1944, 275, 1819, 14, 362, 3162, 3049, 3259, 342, 1039, 291, 14, 3764, 1296, 14, 740, 3666, 27501, 12, 1004, 1944, 12, 298, 9171, 401, 7987, 495, 430, 18801, 26316, 1128, 327, 1050, 2256, 1059, 370, 1125, 1296, 2958, 347, 1050, 2354, 334, 277, 12, 2256, 495, 12, 1819, 29, 403, 304, 1039, 291, 14, 815, 2141, 14, 5486, 480, 4531, 26, 450, 83, 2, 450, 815, 495, 12, 413, 9, 18801, 26316, 1128, 327, 1050, 1125, 370, 1125, 1296, 334, 692, 1627, 9, 436, 746, 1919, 2958, 347, 746, 547, 334, 277, 12, 2329, 495, 12, 1819, 29, 403, 304, 1039, 291, 14, 30787, 334, 1508, 495, 12, 1819, 9, 1039, 291, 423, 3730, 56, 83, 637, 1726, 6248, 18801, 26316, 1128, 327, 746, 1919, 543, 4890, 1125, 1296, 465, 1919, 1059, 1128, 327, 334, 2118, 340, 2552, 8920, 9, 2958, 347, 8976, 2959, 334, 277, 304, 1039, 340, 291, 14, 815, 2141, 1137, 24702, 1675, 870, 1059, 14, 904, 334, 277, 14, 815, 2141, 14, 1612, 1062, 1867, 78, 531, 1675, 291, 14, 815, 1296, 275, 942, 4341, 340, 291, 14, 3764, 15019, 508, 12218, 2919, 63, 17449, 3881, 436, 291, 14, 3764, 1296, 1137, 18410, 1675, 870, 291, 423, 21263, 2959, 1296, 8, 277, 14, 3764, 1296, 12, 3355, 29, 17, 9, 1675, 291, 14, 3764, 1296, 275, 942, 1039, 916, 291, 14, 3764, 15019, 508, 22348, 63, 615, 63, 17449, 3881, 26, 1675, 291, 14, 705, 1296, 14, 2880, 334, 277, 14, 3764, 1296, 9, 4341, 340, 291, 14, 705, 1296, 1137, 18410, 1675, 291, 423, 3730, 56, 83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 1, 1, 1, 1, 1, 1, 1, 1 ]
jaor/bigmler
bigmler/anomaly/dispatcher.py
1
10221
# -*- coding: utf-8 -*- # # Copyright 2014-2020 BigML # # 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. """BigMLer - anomaly subcommand processing dispatching """ import sys import os import bigml.api from bigml.anomaly import Anomaly import bigmler.utils as u import bigmler.resourcesapi.common as r import bigmler.resourcesapi.anomalies as ra import bigmler.pre_model_steps as pms import bigmler.processing.args as a import bigmler.processing.anomalies as pa import bigmler.processing.sources as ps import bigmler.processing.datasets as pd from bigmler.resourcesapi.datasets import set_basic_dataset_args from bigmler.resourcesapi.batch_anomaly_scores import \ set_batch_anomaly_score_args from bigmler.defaults import DEFAULTS_FILE from bigmler.anomaly_score import anomaly_score, remote_anomaly_score from bigmler.reports import clear_reports, upload_reports from bigmler.command import get_context from bigmler.dispatcher import SESSIONS_LOG, clear_log_files, get_test_dataset from bigmler.options.anomaly import ANOMALIES_IN COMMAND_LOG = ".bigmler_anomaly" DIRS_LOG = ".bigmler_anomaly_dir_stack" LOG_FILES = [COMMAND_LOG, DIRS_LOG, u.NEW_DIRS_LOG] MINIMUM_MODEL = "full=false" EXCLUDE_TREES = "exclude=trees" DEFAULT_OUTPUT = "anomaly_scores.csv" SETTINGS = { "command_log": COMMAND_LOG, "sessions_log": SESSIONS_LOG, "dirs_log": DIRS_LOG, "default_output": DEFAULT_OUTPUT, "defaults_file": DEFAULTS_FILE} def anomaly_dispatcher(args=sys.argv[1:]): """Parses command line and calls the different processing functions """ # If --clear-logs the log files are cleared if "--clear-logs" in args: clear_log_files(LOG_FILES) command_args, _, api, session_file, resume = get_context(args, SETTINGS) # Selects the action to perform if (a.has_train(command_args) or a.has_test(command_args) or command_args.score or a.has_anomaly(command_args)): output_args = a.get_output_args(api, command_args, resume) compute_output(**output_args) u.log_message("_" * 80 + "\n", log_file=session_file) def compute_output(api, args): """ Creates one or more anomaly detectors using the `training_set` or uses the ids of previously created BigML models to make predictions for the `test_set`. """ anomaly = None anomalies = None # no multi-label support at present # variables from command-line options resume = args.resume_ anomaly_ids = args.anomaly_ids_ output = args.predictions # there's only one anomaly detector to be generated at present args.max_parallel_anomalies = 1 # anomalies cannot be published yet. args.public_anomaly = False # It is compulsory to have a description to publish either datasets or # anomalies if (not args.description_ and (args.public_anomaly or args.public_dataset)): sys.exit("You should provide a description to publish.") # When using --new-fields, it is compulsory to specify also a dataset # id if args.new_fields and not args.dataset: sys.exit("To use --new-fields you must also provide a dataset id" " to generate the new dataset from it.") path = u.check_dir(output) session_file = "%s%s%s" % (path, os.sep, SESSIONS_LOG) csv_properties = {} # If logging is required set the file for logging log = None if args.log_file: u.check_dir(args.log_file) log = args.log_file # If --clear_logs the log files are cleared clear_log_files([log]) # basic pre-model step: creating or retrieving the source related info source, resume, csv_properties, fields = pms.get_source_info( api, args, resume, csv_properties, session_file, path, log) # basic pre-model step: creating or retrieving the dataset related info dataset_properties = pms.get_dataset_info( api, args, resume, source, csv_properties, fields, session_file, path, log) (_, datasets, test_dataset, resume, csv_properties, fields) = dataset_properties if args.anomaly_file: # anomaly is retrieved from the contents of the given local JSON file anomaly, csv_properties, fields = u.read_local_resource( args.anomaly_file, csv_properties=csv_properties) anomalies = [anomaly] anomaly_ids = [anomaly['resource']] else: # anomaly is retrieved from the remote object anomalies, anomaly_ids, resume = pa.anomalies_processing( datasets, anomalies, anomaly_ids, api, args, resume, fields=fields, session_file=session_file, path=path, log=log) if anomalies: anomaly = anomalies[0] # We update the anomaly's public state if needed if anomaly: if not a.has_test(args) and not args.anomalies_dataset: query_string = MINIMUM_MODEL elif not a.has_test(args): query_string = ";".join([EXCLUDE_TREES, r.ALL_FIELDS_QS]) else: query_string = r.ALL_FIELDS_QS try: anomaly_id = anomaly.get('resource', anomaly) except AttributeError: anomaly_id = anomaly anomaly = u.check_resource(anomaly_id, query_string=query_string, api=api) anomalies[0] = anomaly if (args.public_anomaly or (args.shared_flag and r.shared_changed(args.shared, anomaly))): anomaly_args = {} if args.shared_flag and r.shared_changed(args.shared, anomaly): anomaly_args.update(shared=args.shared) if args.public_anomaly: anomaly_args.update(ra.set_publish_anomaly_args(args)) if anomaly_args: anomaly = ra.update_anomaly(anomaly, anomaly_args, args, api=api, path=path, session_file=session_file) anomalies[0] = anomaly # We get the fields of the anomaly detector if we haven't got # them yet and need them if anomaly and (args.test_set or args.export_fields): fields = pa.get_anomaly_fields(anomaly, csv_properties, args) # If creating a top anomalies excluded/included dataset if args.anomalies_dataset and anomaly: origin_dataset = anomaly['object'].get('dataset') if origin_dataset is None: sys.exit("The dataset used to generate the anomaly detector " "cannot be found. Failed to generate the anomalies " " dataset.") local_anomaly = Anomaly(anomaly) include = args.anomalies_dataset == ANOMALIES_IN args.anomaly_filter_ = local_anomaly.anomalies_filter(include=include) _, resume = pd.create_new_dataset( origin_dataset, api, args, resume, fields=fields, session_file=session_file, path=path, log=log) # If predicting if anomaly and args.score: args.test_dataset = anomaly['object']['dataset'] if anomalies and (a.has_test(args) or (test_dataset and args.remote)): # test dataset can be defined by --test-split or --test-dataset or # --test-datasets if test_dataset is None: test_dataset = get_test_dataset(args) # Remote anomaly scores: scores are computed as batch anomaly scores # in bigml.com except when --no-batch flag is set on if args.remote and not args.no_batch: # create test source from file test_name = "%s - test" % args.name if args.test_source is None: test_properties = ps.test_source_processing( api, args, resume, name=test_name, session_file=session_file, path=path, log=log) (test_source, resume, csv_properties, test_fields) = test_properties else: test_source_id = bigml.api.get_source_id(args.test_source) test_source = api.check_resource(test_source_id) if test_dataset is None: # create test dataset from test source dataset_args = set_basic_dataset_args(args, name=test_name) test_dataset, resume = pd.alternative_dataset_processing( test_source, "test", dataset_args, api, args, resume, session_file=session_file, path=path, log=log) else: test_dataset_id = bigml.api.get_dataset_id(test_dataset) test_dataset = api.check_resource(test_dataset_id) test_fields = pd.get_fields_structure(test_dataset, csv_properties) batch_anomaly_score_args = set_batch_anomaly_score_args( args, fields=fields, dataset_fields=test_fields) remote_anomaly_score(anomaly, test_dataset, batch_anomaly_score_args, args, api, resume, prediction_file=output, session_file=session_file, path=path, log=log) else: anomaly_score(anomalies, fields, args, session_file=session_file) if fields and args.export_fields: fields.summary_csv(os.path.join(path, args.export_fields)) u.print_generated_files(path, log_file=session_file, verbosity=args.verbosity) if args.reports: clear_reports(path) if args.upload: upload_reports(args.reports, path)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6927, 13, 13934, 13123, 1698, 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, 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, 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, 624, 7279, 1698, 281, 446, 28813, 21474, 6661, 7634, 316, 199, 199, 624, 421, 199, 646, 984, 199, 646, 747, 199, 199, 646, 7282, 757, 14, 1246, 199, 199, 504, 7282, 757, 14, 32048, 492, 1626, 16523, 199, 199, 646, 7282, 77, 1435, 14, 1208, 465, 399, 199, 646, 7282, 77, 1435, 14, 4435, 1246, 14, 2330, 465, 519, 199, 646, 7282, 77, 1435, 14, 4435, 1246, 14, 290, 676, 279, 1500, 465, 660, 199, 646, 7282, 77, 1435, 14, 657, 63, 1238, 63, 5895, 465, 299, 706, 199, 646, 7282, 77, 1435, 14, 6338, 14, 589, 465, 282, 199, 646, 7282, 77, 1435, 14, 6338, 14, 290, 676, 279, 1500, 465, 691, 199, 646, 7282, 77, 1435, 14, 6338, 14, 4553, 465, 7347, 199, 646, 7282, 77, 1435, 14, 6338, 14, 12281, 465, 6454, 199, 199, 504, 7282, 77, 1435, 14, 4435, 1246, 14, 12281, 492, 663, 63, 4316, 63, 5214, 63, 589, 199, 504, 7282, 77, 1435, 14, 4435, 1246, 14, 2912, 63, 32048, 63, 7107, 492, 971, 272, 663, 63, 2912, 63, 32048, 63, 3397, 63, 589, 199, 504, 7282, 77, 1435, 14, 4322, 492, 6186, 51, 63, 3817, 199, 504, 7282, 77, 1435, 14, 32048, 63, 3397, 492, 28813, 63, 3397, 12, 3982, 63, 32048, 63, 3397, 199, 504, 7282, 77, 1435, 14, 15629, 492, 5436, 63, 15629, 12, 5802, 63, 15629, 199, 504, 7282, 77, 1435, 14, 1531, 492, 664, 63, 1100, 199, 504, 7282, 77, 1435, 14, 14913, 492, 428, 1608, 2823, 63, 4947, 12, 5436, 63, 793, 63, 1725, 12, 664, 63, 396, 63, 5214, 199, 504, 7282, 77, 1435, 14, 1419, 14, 32048, 492, 1261, 7474, 748, 2563, 63, 568, 199, 199, 10761, 63, 4947, 275, 3680, 5076, 77, 1435, 63, 32048, 2, 199, 14455, 63, 4947, 275, 3680, 5076, 77, 1435, 63, 32048, 63, 694, 63, 2340, 2, 199, 4947, 63, 9472, 275, 359, 10761, 63, 4947, 12, 19253, 51, 63, 4947, 12, 399, 14, 11365, 63, 14455, 63, 4947, 61, 199, 4896, 27078, 63, 11429, 275, 298, 2861, 29, 3910, 2, 199, 1438, 13958, 63, 52, 907, 654, 275, 298, 5473, 29, 14635, 2, 199, 3472, 63, 8414, 275, 298, 32048, 63, 7107, 14, 4737, 2, 199, 199, 13931, 275, 469, 272, 298, 1531, 63, 793, 582, 25965, 63, 4947, 12, 272, 298, 11676, 63, 793, 582, 428, 1608, 2823, 63, 4947, 12, 272, 298, 3220, 63, 793, 582, 19253, 51, 63, 4947, 12, 272, 298, 885, 63, 1199, 582, 6186, 63, 8414, 12, 272, 298, 4322, 63, 493, 582, 6186, 51, 63, 3817, 93, 421, 199, 318, 28813, 63, 14913, 8, 589, 29, 1274, 14, 3020, 59, 17, 28847, 272, 408, 23400, 1414, 1004, 436, 4882, 314, 3365, 6661, 3423, 339, 408, 339, 327, 982, 1553, 3584, 13, 7270, 314, 943, 1584, 787, 20518, 272, 340, 4320, 3584, 13, 7270, 2, 315, 1249, 26, 267, 5436, 63, 793, 63, 1725, 8, 4947, 63, 9472, 9, 339, 1414, 63, 589, 12, 5501, 2986, 12, 2351, 63, 493, 12, 14604, 275, 664, 63, 1100, 8, 589, 12, 18193, 11543, 52, 3881, 9, 272, 327, 9496, 83, 314, 1595, 370, 5147, 272, 340, 334, 65, 14, 1989, 63, 2834, 8, 1531, 63, 589, 9, 503, 282, 14, 1989, 63, 396, 8, 1531, 63, 589, 9, 503, 288, 1414, 63, 589, 14, 3397, 503, 288, 282, 14, 1989, 63, 32048, 8, 1531, 63, 589, 2298, 267, 1072, 63, 589, 275, 282, 14, 362, 63, 1199, 63, 589, 8, 1246, 12, 1414, 63, 589, 12, 14604, 9, 267, 4526, 63, 1199, 3682, 1199, 63, 589, 9, 272, 399, 14, 793, 63, 1188, 11008, 2, 627, 5939, 435, 1867, 78, 401, 943, 63, 493, 29, 1730, 63, 493, 9, 421, 199, 318, 4526, 63, 1199, 8, 1246, 12, 1249, 304, 272, 408, 10560, 1373, 503, 1655, 28813, 17842, 83, 1808, 314, 658, 7588, 63, 409, 64, 267, 503, 4440, 314, 2762, 402, 10889, 2737, 13123, 1698, 1709, 370, 1852, 267, 7914, 367, 314, 658, 396, 63, 409, 2313, 339, 408, 339, 28813, 275, 488, 272, 376, 676, 279, 1500, 275, 488, 272, 327, 949, 3510, 13, 1302, 2291, 737, 3451, 339, 327, 2860, 687, 1414, 13, 604, 1511, 272, 14604, 275, 1249, 14, 9964, 63, 272, 28813, 63, 1580, 275, 1249, 14, 32048, 63, 1580, 63, 272, 1072, 275, 1249, 14, 9869, 272, 327, 2337, 1159, 1454, 1373, 28813, 17842, 370, 506, 4046, 737, 3451, 272, 1249, 14, 988, 63, 11887, 63, 290, 676, 279, 1500, 275, 413, 272, 327, 376, 676, 279, 1500, 3913, 506, 3267, 5966, 14, 272, 1249, 14, 3455, 63, 32048, 275, 756, 339, 327, 2779, 365, 1013, 348, 83, 1089, 370, 1172, 282, 1369, 370, 2780, 1902, 13148, 503, 272, 327, 376, 676, 279, 1500, 272, 340, 334, 1397, 1249, 14, 1802, 63, 436, 334, 589, 14, 3455, 63, 32048, 503, 3521, 1249, 14, 3455, 63, 5214, 2298, 267, 984, 14, 2224, 480, 5556, 1077, 5647, 282, 1369, 370, 2780, 2685, 339, 327, 3979, 1808, 1553, 1222, 13, 955, 12, 652, 365, 1013, 348, 83, 1089, 370, 4165, 2597, 282, 4789, 272, 327, 1305, 272, 340, 1249, 14, 1222, 63, 955, 436, 440, 1249, 14, 5214, 26, 267, 984, 14, 2224, 480, 1378, 675, 1553, 1222, 13, 955, 1265, 1471, 2597, 5647, 282 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6927, 13, 13934, 13123, 1698, 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, 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, 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, 624, 7279, 1698, 281, 446, 28813, 21474, 6661, 7634, 316, 199, 199, 624, 421, 199, 646, 984, 199, 646, 747, 199, 199, 646, 7282, 757, 14, 1246, 199, 199, 504, 7282, 757, 14, 32048, 492, 1626, 16523, 199, 199, 646, 7282, 77, 1435, 14, 1208, 465, 399, 199, 646, 7282, 77, 1435, 14, 4435, 1246, 14, 2330, 465, 519, 199, 646, 7282, 77, 1435, 14, 4435, 1246, 14, 290, 676, 279, 1500, 465, 660, 199, 646, 7282, 77, 1435, 14, 657, 63, 1238, 63, 5895, 465, 299, 706, 199, 646, 7282, 77, 1435, 14, 6338, 14, 589, 465, 282, 199, 646, 7282, 77, 1435, 14, 6338, 14, 290, 676, 279, 1500, 465, 691, 199, 646, 7282, 77, 1435, 14, 6338, 14, 4553, 465, 7347, 199, 646, 7282, 77, 1435, 14, 6338, 14, 12281, 465, 6454, 199, 199, 504, 7282, 77, 1435, 14, 4435, 1246, 14, 12281, 492, 663, 63, 4316, 63, 5214, 63, 589, 199, 504, 7282, 77, 1435, 14, 4435, 1246, 14, 2912, 63, 32048, 63, 7107, 492, 971, 272, 663, 63, 2912, 63, 32048, 63, 3397, 63, 589, 199, 504, 7282, 77, 1435, 14, 4322, 492, 6186, 51, 63, 3817, 199, 504, 7282, 77, 1435, 14, 32048, 63, 3397, 492, 28813, 63, 3397, 12, 3982, 63, 32048, 63, 3397, 199, 504, 7282, 77, 1435, 14, 15629, 492, 5436, 63, 15629, 12, 5802, 63, 15629, 199, 504, 7282, 77, 1435, 14, 1531, 492, 664, 63, 1100, 199, 504, 7282, 77, 1435, 14, 14913, 492, 428, 1608, 2823, 63, 4947, 12, 5436, 63, 793, 63, 1725, 12, 664, 63, 396, 63, 5214, 199, 504, 7282, 77, 1435, 14, 1419, 14, 32048, 492, 1261, 7474, 748, 2563, 63, 568, 199, 199, 10761, 63, 4947, 275, 3680, 5076, 77, 1435, 63, 32048, 2, 199, 14455, 63, 4947, 275, 3680, 5076, 77, 1435, 63, 32048, 63, 694, 63, 2340, 2, 199, 4947, 63, 9472, 275, 359, 10761, 63, 4947, 12, 19253, 51, 63, 4947, 12, 399, 14, 11365, 63, 14455, 63, 4947, 61, 199, 4896, 27078, 63, 11429, 275, 298, 2861, 29, 3910, 2, 199, 1438, 13958, 63, 52, 907, 654, 275, 298, 5473, 29, 14635, 2, 199, 3472, 63, 8414, 275, 298, 32048, 63, 7107, 14, 4737, 2, 199, 199, 13931, 275, 469, 272, 298, 1531, 63, 793, 582, 25965, 63, 4947, 12, 272, 298, 11676, 63, 793, 582, 428, 1608, 2823, 63, 4947, 12, 272, 298, 3220, 63, 793, 582, 19253, 51, 63, 4947, 12, 272, 298, 885, 63, 1199, 582, 6186, 63, 8414, 12, 272, 298, 4322, 63, 493, 582, 6186, 51, 63, 3817, 93, 421, 199, 318, 28813, 63, 14913, 8, 589, 29, 1274, 14, 3020, 59, 17, 28847, 272, 408, 23400, 1414, 1004, 436, 4882, 314, 3365, 6661, 3423, 339, 408, 339, 327, 982, 1553, 3584, 13, 7270, 314, 943, 1584, 787, 20518, 272, 340, 4320, 3584, 13, 7270, 2, 315, 1249, 26, 267, 5436, 63, 793, 63, 1725, 8, 4947, 63, 9472, 9, 339, 1414, 63, 589, 12, 5501, 2986, 12, 2351, 63, 493, 12, 14604, 275, 664, 63, 1100, 8, 589, 12, 18193, 11543, 52, 3881, 9, 272, 327, 9496, 83, 314, 1595, 370, 5147, 272, 340, 334, 65, 14, 1989, 63, 2834, 8, 1531, 63, 589, 9, 503, 282, 14, 1989, 63, 396, 8, 1531, 63, 589, 9, 503, 288, 1414, 63, 589, 14, 3397, 503, 288, 282, 14, 1989, 63, 32048, 8, 1531, 63, 589, 2298, 267, 1072, 63, 589, 275, 282, 14, 362, 63, 1199, 63, 589, 8, 1246, 12, 1414, 63, 589, 12, 14604, 9, 267, 4526, 63, 1199, 3682, 1199, 63, 589, 9, 272, 399, 14, 793, 63, 1188, 11008, 2, 627, 5939, 435, 1867, 78, 401, 943, 63, 493, 29, 1730, 63, 493, 9, 421, 199, 318, 4526, 63, 1199, 8, 1246, 12, 1249, 304, 272, 408, 10560, 1373, 503, 1655, 28813, 17842, 83, 1808, 314, 658, 7588, 63, 409, 64, 267, 503, 4440, 314, 2762, 402, 10889, 2737, 13123, 1698, 1709, 370, 1852, 267, 7914, 367, 314, 658, 396, 63, 409, 2313, 339, 408, 339, 28813, 275, 488, 272, 376, 676, 279, 1500, 275, 488, 272, 327, 949, 3510, 13, 1302, 2291, 737, 3451, 339, 327, 2860, 687, 1414, 13, 604, 1511, 272, 14604, 275, 1249, 14, 9964, 63, 272, 28813, 63, 1580, 275, 1249, 14, 32048, 63, 1580, 63, 272, 1072, 275, 1249, 14, 9869, 272, 327, 2337, 1159, 1454, 1373, 28813, 17842, 370, 506, 4046, 737, 3451, 272, 1249, 14, 988, 63, 11887, 63, 290, 676, 279, 1500, 275, 413, 272, 327, 376, 676, 279, 1500, 3913, 506, 3267, 5966, 14, 272, 1249, 14, 3455, 63, 32048, 275, 756, 339, 327, 2779, 365, 1013, 348, 83, 1089, 370, 1172, 282, 1369, 370, 2780, 1902, 13148, 503, 272, 327, 376, 676, 279, 1500, 272, 340, 334, 1397, 1249, 14, 1802, 63, 436, 334, 589, 14, 3455, 63, 32048, 503, 3521, 1249, 14, 3455, 63, 5214, 2298, 267, 984, 14, 2224, 480, 5556, 1077, 5647, 282, 1369, 370, 2780, 2685, 339, 327, 3979, 1808, 1553, 1222, 13, 955, 12, 652, 365, 1013, 348, 83, 1089, 370, 4165, 2597, 282, 4789, 272, 327, 1305, 272, 340, 1249, 14, 1222, 63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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sirex/Misago
misago/threads/views/labelsadmin.py
8
1455
from django.contrib import messages from django.utils.translation import ugettext_lazy as _ from misago.admin.views import generic from misago.core import cachebuster from misago.threads.models import Label from misago.threads.forms.admin import LabelForm class LabelsAdmin(generic.AdminBaseMixin): root_link = 'misago:admin:forums:labels:index' Model = Label Form = LabelForm templates_dir = 'misago/admin/labels' message_404 = _("Requested thread label does not exist.") def handle_form(self, form, request, target): target.save() target.forums.clear() if form.cleaned_data.get('forums'): target.forums.add(*[f for f in form.cleaned_data.get('forums')]) Label.objects.clear_cache() if self.message_submit: messages.success( request, self.message_submit % {'name': target.name}) class LabelsList(LabelsAdmin, generic.ListView): ordering = (('name', None),) class NewLabel(LabelsAdmin, generic.ModelFormView): message_submit = _('New label "%(name)s" has been saved.') class EditLabel(LabelsAdmin, generic.ModelFormView): message_submit = _('Label "%(name)s" has been edited.') class DeleteLabel(LabelsAdmin, generic.ButtonView): def button_action(self, request, target): target.delete() message = _('Label "%(name)s" has been deleted.') messages.success(request, message % {'name': target.name})
gpl-2.0
[ 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 3201, 14315, 14, 2113, 14, 4196, 492, 7809, 199, 504, 3201, 14315, 14, 1018, 492, 2581, 5610, 351, 199, 199, 504, 3201, 14315, 14, 6962, 14, 992, 492, 10354, 199, 504, 3201, 14315, 14, 6962, 14, 3351, 14, 2113, 492, 10354, 2821, 421, 199, 533, 10354, 83, 4880, 8, 6767, 14, 4880, 1563, 4256, 304, 272, 1738, 63, 1073, 275, 283, 1292, 14315, 26, 2113, 26, 10044, 83, 26, 3512, 26, 1080, 7, 272, 5822, 275, 10354, 272, 8204, 275, 10354, 2821, 272, 7009, 63, 694, 275, 283, 1292, 14315, 15, 2113, 15, 3512, 7, 272, 1245, 63, 5188, 275, 3824, 17935, 2462, 1768, 1630, 440, 2187, 2685, 339, 347, 2429, 63, 964, 8, 277, 12, 1824, 12, 1056, 12, 1347, 304, 267, 1347, 14, 2117, 342, 267, 1347, 14, 10044, 83, 14, 3584, 342, 267, 340, 1824, 14, 8275, 63, 576, 14, 362, 360, 10044, 83, 735, 288, 1347, 14, 10044, 83, 14, 525, 23151, 70, 367, 289, 315, 1824, 14, 8275, 63, 576, 14, 362, 360, 10044, 83, 2023, 267, 10354, 14, 1462, 14, 3584, 63, 1637, 342, 398, 340, 291, 14, 1188, 63, 7275, 26, 288, 3788, 14, 3742, 8, 355, 1056, 12, 291, 14, 1188, 63, 7275, 450, 791, 354, 356, 1347, 14, 354, 1552, 421, 199, 533, 10354, 83, 1296, 8, 14016, 4880, 12, 7809, 14, 23239, 304, 272, 7794, 275, 13636, 354, 297, 488, 16945, 421, 199, 533, 7053, 4314, 8, 14016, 4880, 12, 7809, 14, 15937, 2768, 304, 272, 1245, 63, 7275, 275, 4018, 4665, 1768, 11792, 354, 9, 83, 2, 965, 2757, 6290, 2659, 421, 199, 533, 16407, 4314, 8, 14016, 4880, 12, 7809, 14, 15937, 2768, 304, 272, 1245, 63, 7275, 275, 4018, 4314, 11792, 354, 9, 83, 2, 965, 2757, 21062, 2659, 421, 199, 533, 8496, 4314, 8, 14016, 4880, 12, 7809, 14, 4259, 2768, 304, 272, 347, 5528, 63, 1287, 8, 277, 12, 1056, 12, 1347, 304, 267, 1347, 14, 1807, 342, 267, 1245, 275, 4018, 4314, 11792, 354, 9, 83, 2, 965, 2757, 5463, 2659, 267, 3788, 14, 3742, 8, 1069, 12, 1245, 450, 791, 354, 356, 1347, 14, 354, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2828, 492, 3788, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 3201, 14315, 14, 2113, 14, 4196, 492, 7809, 199, 504, 3201, 14315, 14, 1018, 492, 2581, 5610, 351, 199, 199, 504, 3201, 14315, 14, 6962, 14, 992, 492, 10354, 199, 504, 3201, 14315, 14, 6962, 14, 3351, 14, 2113, 492, 10354, 2821, 421, 199, 533, 10354, 83, 4880, 8, 6767, 14, 4880, 1563, 4256, 304, 272, 1738, 63, 1073, 275, 283, 1292, 14315, 26, 2113, 26, 10044, 83, 26, 3512, 26, 1080, 7, 272, 5822, 275, 10354, 272, 8204, 275, 10354, 2821, 272, 7009, 63, 694, 275, 283, 1292, 14315, 15, 2113, 15, 3512, 7, 272, 1245, 63, 5188, 275, 3824, 17935, 2462, 1768, 1630, 440, 2187, 2685, 339, 347, 2429, 63, 964, 8, 277, 12, 1824, 12, 1056, 12, 1347, 304, 267, 1347, 14, 2117, 342, 267, 1347, 14, 10044, 83, 14, 3584, 342, 267, 340, 1824, 14, 8275, 63, 576, 14, 362, 360, 10044, 83, 735, 288, 1347, 14, 10044, 83, 14, 525, 23151, 70, 367, 289, 315, 1824, 14, 8275, 63, 576, 14, 362, 360, 10044, 83, 2023, 267, 10354, 14, 1462, 14, 3584, 63, 1637, 342, 398, 340, 291, 14, 1188, 63, 7275, 26, 288, 3788, 14, 3742, 8, 355, 1056, 12, 291, 14, 1188, 63, 7275, 450, 791, 354, 356, 1347, 14, 354, 1552, 421, 199, 533, 10354, 83, 1296, 8, 14016, 4880, 12, 7809, 14, 23239, 304, 272, 7794, 275, 13636, 354, 297, 488, 16945, 421, 199, 533, 7053, 4314, 8, 14016, 4880, 12, 7809, 14, 15937, 2768, 304, 272, 1245, 63, 7275, 275, 4018, 4665, 1768, 11792, 354, 9, 83, 2, 965, 2757, 6290, 2659, 421, 199, 533, 16407, 4314, 8, 14016, 4880, 12, 7809, 14, 15937, 2768, 304, 272, 1245, 63, 7275, 275, 4018, 4314, 11792, 354, 9, 83, 2, 965, 2757, 21062, 2659, 421, 199, 533, 8496, 4314, 8, 14016, 4880, 12, 7809, 14, 4259, 2768, 304, 272, 347, 5528, 63, 1287, 8, 277, 12, 1056, 12, 1347, 304, 267, 1347, 14, 1807, 342, 267, 1245, 275, 4018, 4314, 11792, 354, 9, 83, 2, 965, 2757, 5463, 2659, 267, 3788, 14, 3742, 8, 1069, 12, 1245, 450, 791, 354, 356, 1347, 14, 354, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
servo/servo
tests/wpt/web-platform-tests/tools/third_party/h2/examples/asyncio/asyncio-server.py
14
7261
# -*- coding: utf-8 -*- """ asyncio-server.py ~~~~~~~~~~~~~~~~~ A fully-functional HTTP/2 server using asyncio. Requires Python 3.5+. This example demonstrates handling requests with bodies, as well as handling those without. In particular, it demonstrates the fact that DataReceived may be called multiple times, and that applications must handle that possibility. """ import asyncio import io import json import ssl import collections from typing import List, Tuple from h2.config import H2Configuration from h2.connection import H2Connection from h2.events import ( ConnectionTerminated, DataReceived, RemoteSettingsChanged, RequestReceived, StreamEnded, StreamReset, WindowUpdated ) from h2.errors import ErrorCodes from h2.exceptions import ProtocolError, StreamClosedError from h2.settings import SettingCodes RequestData = collections.namedtuple('RequestData', ['headers', 'data']) class H2Protocol(asyncio.Protocol): def __init__(self): config = H2Configuration(client_side=False, header_encoding='utf-8') self.conn = H2Connection(config=config) self.transport = None self.stream_data = {} self.flow_control_futures = {} def connection_made(self, transport: asyncio.Transport): self.transport = transport self.conn.initiate_connection() self.transport.write(self.conn.data_to_send()) def connection_lost(self, exc): for future in self.flow_control_futures.values(): future.cancel() self.flow_control_futures = {} def data_received(self, data: bytes): try: events = self.conn.receive_data(data) except ProtocolError as e: self.transport.write(self.conn.data_to_send()) self.transport.close() else: self.transport.write(self.conn.data_to_send()) for event in events: if isinstance(event, RequestReceived): self.request_received(event.headers, event.stream_id) elif isinstance(event, DataReceived): self.receive_data(event.data, event.stream_id) elif isinstance(event, StreamEnded): self.stream_complete(event.stream_id) elif isinstance(event, ConnectionTerminated): self.transport.close() elif isinstance(event, StreamReset): self.stream_reset(event.stream_id) elif isinstance(event, WindowUpdated): self.window_updated(event.stream_id, event.delta) elif isinstance(event, RemoteSettingsChanged): if SettingCodes.INITIAL_WINDOW_SIZE in event.changed_settings: self.window_updated(None, 0) self.transport.write(self.conn.data_to_send()) def request_received(self, headers: List[Tuple[str, str]], stream_id: int): headers = collections.OrderedDict(headers) method = headers[':method'] # Store off the request data. request_data = RequestData(headers, io.BytesIO()) self.stream_data[stream_id] = request_data def stream_complete(self, stream_id: int): """ When a stream is complete, we can send our response. """ try: request_data = self.stream_data[stream_id] except KeyError: # Just return, we probably 405'd this already return headers = request_data.headers body = request_data.data.getvalue().decode('utf-8') data = json.dumps( {"headers": headers, "body": body}, indent=4 ).encode("utf8") response_headers = ( (':status', '200'), ('content-type', 'application/json'), ('content-length', str(len(data))), ('server', 'asyncio-h2'), ) self.conn.send_headers(stream_id, response_headers) asyncio.ensure_future(self.send_data(data, stream_id)) def receive_data(self, data: bytes, stream_id: int): """ We've received some data on a stream. If that stream is one we're expecting data on, save it off. Otherwise, reset the stream. """ try: stream_data = self.stream_data[stream_id] except KeyError: self.conn.reset_stream( stream_id, error_code=ErrorCodes.PROTOCOL_ERROR ) else: stream_data.data.write(data) def stream_reset(self, stream_id): """ A stream reset was sent. Stop sending data. """ if stream_id in self.flow_control_futures: future = self.flow_control_futures.pop(stream_id) future.cancel() async def send_data(self, data, stream_id): """ Send data according to the flow control rules. """ while data: while self.conn.local_flow_control_window(stream_id) < 1: try: await self.wait_for_flow_control(stream_id) except asyncio.CancelledError: return chunk_size = min( self.conn.local_flow_control_window(stream_id), len(data), self.conn.max_outbound_frame_size, ) try: self.conn.send_data( stream_id, data[:chunk_size], end_stream=(chunk_size == len(data)) ) except (StreamClosedError, ProtocolError): # The stream got closed and we didn't get told. We're done # here. break self.transport.write(self.conn.data_to_send()) data = data[chunk_size:] async def wait_for_flow_control(self, stream_id): """ Waits for a Future that fires when the flow control window is opened. """ f = asyncio.Future() self.flow_control_futures[stream_id] = f await f def window_updated(self, stream_id, delta): """ A window update frame was received. Unblock some number of flow control Futures. """ if stream_id and stream_id in self.flow_control_futures: f = self.flow_control_futures.pop(stream_id) f.set_result(delta) elif not stream_id: for f in self.flow_control_futures.values(): f.set_result(delta) self.flow_control_futures = {} ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.options |= ( ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_COMPRESSION ) ssl_context.load_cert_chain(certfile="cert.crt", keyfile="cert.key") ssl_context.set_alpn_protocols(["h2"]) loop = asyncio.get_event_loop() # Each client connection will create a new protocol instance coro = loop.create_server(H2Protocol, '127.0.0.1', 8443, ssl=ssl_context) server = loop.run_until_complete(coro) # Serve requests until Ctrl+C is pressed print('Serving on {}'.format(server.sockets[0].getsockname())) try: loop.run_forever() except KeyboardInterrupt: pass # Close the server server.close() loop.run_until_complete(server.wait_closed()) loop.close()
mpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 19343, 13, 1000, 14, 647, 199, 9753, 94, 199, 199, 33, 9999, 13, 15481, 3101, 15, 18, 1654, 1808, 16195, 14, 15127, 2018, 650, 14, 21, 26240, 199, 199, 2765, 2893, 23789, 31216, 7252, 4145, 543, 1234, 18245, 12, 465, 5521, 465, 7252, 199, 273, 3362, 1928, 14, 1010, 6770, 12, 652, 23789, 31216, 314, 10572, 626, 3918, 9392, 1443, 199, 1235, 2797, 3663, 5431, 12, 436, 626, 13103, 1471, 2429, 626, 31077, 14, 199, 624, 199, 646, 16195, 199, 646, 5890, 199, 646, 2022, 199, 646, 6149, 199, 646, 5055, 199, 504, 14090, 492, 3820, 12, 11634, 199, 199, 504, 394, 18, 14, 888, 492, 869, 18, 5688, 199, 504, 394, 18, 14, 2105, 492, 869, 18, 3225, 199, 504, 394, 18, 14, 4368, 492, 334, 272, 8113, 12154, 972, 12, 3918, 9392, 12, 17283, 5268, 6970, 12, 272, 4784, 9392, 12, 8271, 32615, 12, 8271, 9637, 12, 15689, 19920, 199, 9, 199, 504, 394, 18, 14, 2550, 492, 4520, 14060, 199, 504, 394, 18, 14, 3924, 492, 30797, 12, 8271, 15190, 547, 199, 504, 394, 18, 14, 1751, 492, 13510, 14060, 421, 199, 2017, 1451, 275, 5055, 14, 18921, 360, 2017, 1451, 297, 788, 2139, 297, 283, 576, 1105, 421, 199, 533, 869, 18, 3658, 8, 19343, 14, 3658, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1101, 275, 869, 18, 5688, 8, 1258, 63, 2441, 29, 797, 12, 1406, 63, 2991, 534, 1624, 13, 24, 358, 267, 291, 14, 1631, 275, 869, 18, 3225, 8, 888, 29, 888, 9, 267, 291, 14, 5545, 275, 488, 267, 291, 14, 1745, 63, 576, 275, 1052, 267, 291, 14, 1659, 63, 2785, 63, 25513, 275, 1052, 339, 347, 1950, 63, 29519, 8, 277, 12, 7773, 26, 16195, 14, 7836, 304, 267, 291, 14, 5545, 275, 7773, 267, 291, 14, 1631, 14, 14188, 323, 63, 2105, 342, 267, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 339, 347, 1950, 63, 22031, 8, 277, 12, 3178, 304, 267, 367, 6466, 315, 291, 14, 1659, 63, 2785, 63, 25513, 14, 1459, 837, 288, 6466, 14, 6406, 342, 267, 291, 14, 1659, 63, 2785, 63, 25513, 275, 1052, 339, 347, 666, 63, 9226, 8, 277, 12, 666, 26, 2783, 304, 267, 862, 26, 288, 4474, 275, 291, 14, 1631, 14, 9391, 63, 576, 8, 576, 9, 267, 871, 30797, 465, 325, 26, 288, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 288, 291, 14, 5545, 14, 1600, 342, 267, 587, 26, 288, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 288, 367, 1566, 315, 4474, 26, 355, 340, 1228, 8, 1430, 12, 4784, 9392, 304, 490, 291, 14, 1069, 63, 9226, 8, 1430, 14, 2139, 12, 1566, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 3918, 9392, 304, 490, 291, 14, 9391, 63, 576, 8, 1430, 14, 576, 12, 1566, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 8271, 32615, 304, 490, 291, 14, 1745, 63, 4883, 8, 1430, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 8113, 12154, 972, 304, 490, 291, 14, 5545, 14, 1600, 342, 355, 916, 1228, 8, 1430, 12, 8271, 9637, 304, 490, 291, 14, 1745, 63, 3958, 8, 1430, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 15689, 19920, 304, 490, 291, 14, 3806, 63, 5334, 8, 1430, 14, 1745, 63, 344, 12, 1566, 14, 3136, 9, 355, 916, 1228, 8, 1430, 12, 17283, 5268, 6970, 304, 490, 340, 13510, 14060, 14, 13768, 63, 15480, 63, 4305, 315, 1566, 14, 2489, 63, 1751, 26, 717, 291, 14, 3806, 63, 5334, 8, 403, 12, 378, 9, 2234, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 339, 347, 1056, 63, 9226, 8, 277, 12, 2323, 26, 3820, 59, 7075, 59, 495, 12, 620, 2365, 2547, 63, 344, 26, 1109, 304, 267, 2323, 275, 5055, 14, 16882, 8, 2139, 9, 267, 1083, 275, 2323, 59, 356, 765, 418, 398, 327, 13874, 2331, 314, 1056, 666, 14, 267, 1056, 63, 576, 275, 4784, 1451, 8, 2139, 12, 5890, 14, 15466, 1012, 267, 291, 14, 1745, 63, 576, 59, 1745, 63, 344, 61, 275, 1056, 63, 576, 339, 347, 2547, 63, 4883, 8, 277, 12, 2547, 63, 344, 26, 1109, 304, 267, 408, 267, 3979, 282, 2547, 365, 4890, 12, 781, 883, 3222, 4154, 1177, 14, 267, 408, 267, 862, 26, 288, 1056, 63, 576, 275, 291, 14, 1745, 63, 576, 59, 1745, 63, 344, 61, 267, 871, 4067, 26, 288, 327, 13870, 372, 12, 781, 8646, 25766, 5121, 642, 2575, 288, 372, 398, 2323, 275, 1056, 63, 576, 14, 2139, 267, 2396, 275, 1056, 63, 576, 14, 576, 14, 7150, 1252, 2708, 360, 1624, 13, 24, 358, 398, 666, 275, 2022, 14, 4180, 8, 288, 2420, 2139, 582, 2323, 12, 298, 2030, 582, 2396, 1386, 4363, 29, 20, 267, 7092, 2143, 480, 1624, 24, 531, 398, 1177, 63, 2139, 275, 334, 288, 334, 356, 1205, 297, 283, 1840, 659, 288, 661, 1317, 13, 466, 297, 283, 3578, 15, 1001, 659, 288, 661, 1317, 13, 1267, 297, 620, 8, 552, 8, 576, 11508, 288, 661, 1000, 297, 283, 19343, 13, 72, 18, 659, 267, 776, 267, 291, 14, 1631, 14, 2254, 63, 2139, 8, 1745, 63, 344, 12, 1177, 63, 2139, 9, 267, 16195, 14, 7505, 63, 2443, 8, 277, 14, 2254, 63, 576, 8, 576, 12, 2547, 63, 344, 430, 339, 347, 9128, 63, 576, 8, 277, 12, 666, 26, 2783, 12, 2547, 63, 344, 26, 1109, 304, 267, 408, 267, 2136, 9064, 3086, 2005, 666, 641, 282, 2547, 14, 982, 626, 2547, 365, 1373, 781, 3984, 267, 21055, 666, 641, 12, 3354, 652, 2331, 14, 6630, 12, 5305, 314, 2547, 14, 267, 408, 267, 862, 26, 288, 2547, 63, 576, 275, 291, 14, 1745, 63, 576, 59, 1745, 63, 344, 61, 267, 871, 4067, 26, 288, 291, 14, 1631, 14, 3958, 63, 1745, 8, 355, 2547, 63, 344, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 19343, 13, 1000, 14, 647, 199, 9753, 94, 199, 199, 33, 9999, 13, 15481, 3101, 15, 18, 1654, 1808, 16195, 14, 15127, 2018, 650, 14, 21, 26240, 199, 199, 2765, 2893, 23789, 31216, 7252, 4145, 543, 1234, 18245, 12, 465, 5521, 465, 7252, 199, 273, 3362, 1928, 14, 1010, 6770, 12, 652, 23789, 31216, 314, 10572, 626, 3918, 9392, 1443, 199, 1235, 2797, 3663, 5431, 12, 436, 626, 13103, 1471, 2429, 626, 31077, 14, 199, 624, 199, 646, 16195, 199, 646, 5890, 199, 646, 2022, 199, 646, 6149, 199, 646, 5055, 199, 504, 14090, 492, 3820, 12, 11634, 199, 199, 504, 394, 18, 14, 888, 492, 869, 18, 5688, 199, 504, 394, 18, 14, 2105, 492, 869, 18, 3225, 199, 504, 394, 18, 14, 4368, 492, 334, 272, 8113, 12154, 972, 12, 3918, 9392, 12, 17283, 5268, 6970, 12, 272, 4784, 9392, 12, 8271, 32615, 12, 8271, 9637, 12, 15689, 19920, 199, 9, 199, 504, 394, 18, 14, 2550, 492, 4520, 14060, 199, 504, 394, 18, 14, 3924, 492, 30797, 12, 8271, 15190, 547, 199, 504, 394, 18, 14, 1751, 492, 13510, 14060, 421, 199, 2017, 1451, 275, 5055, 14, 18921, 360, 2017, 1451, 297, 788, 2139, 297, 283, 576, 1105, 421, 199, 533, 869, 18, 3658, 8, 19343, 14, 3658, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1101, 275, 869, 18, 5688, 8, 1258, 63, 2441, 29, 797, 12, 1406, 63, 2991, 534, 1624, 13, 24, 358, 267, 291, 14, 1631, 275, 869, 18, 3225, 8, 888, 29, 888, 9, 267, 291, 14, 5545, 275, 488, 267, 291, 14, 1745, 63, 576, 275, 1052, 267, 291, 14, 1659, 63, 2785, 63, 25513, 275, 1052, 339, 347, 1950, 63, 29519, 8, 277, 12, 7773, 26, 16195, 14, 7836, 304, 267, 291, 14, 5545, 275, 7773, 267, 291, 14, 1631, 14, 14188, 323, 63, 2105, 342, 267, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 339, 347, 1950, 63, 22031, 8, 277, 12, 3178, 304, 267, 367, 6466, 315, 291, 14, 1659, 63, 2785, 63, 25513, 14, 1459, 837, 288, 6466, 14, 6406, 342, 267, 291, 14, 1659, 63, 2785, 63, 25513, 275, 1052, 339, 347, 666, 63, 9226, 8, 277, 12, 666, 26, 2783, 304, 267, 862, 26, 288, 4474, 275, 291, 14, 1631, 14, 9391, 63, 576, 8, 576, 9, 267, 871, 30797, 465, 325, 26, 288, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 288, 291, 14, 5545, 14, 1600, 342, 267, 587, 26, 288, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 288, 367, 1566, 315, 4474, 26, 355, 340, 1228, 8, 1430, 12, 4784, 9392, 304, 490, 291, 14, 1069, 63, 9226, 8, 1430, 14, 2139, 12, 1566, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 3918, 9392, 304, 490, 291, 14, 9391, 63, 576, 8, 1430, 14, 576, 12, 1566, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 8271, 32615, 304, 490, 291, 14, 1745, 63, 4883, 8, 1430, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 8113, 12154, 972, 304, 490, 291, 14, 5545, 14, 1600, 342, 355, 916, 1228, 8, 1430, 12, 8271, 9637, 304, 490, 291, 14, 1745, 63, 3958, 8, 1430, 14, 1745, 63, 344, 9, 355, 916, 1228, 8, 1430, 12, 15689, 19920, 304, 490, 291, 14, 3806, 63, 5334, 8, 1430, 14, 1745, 63, 344, 12, 1566, 14, 3136, 9, 355, 916, 1228, 8, 1430, 12, 17283, 5268, 6970, 304, 490, 340, 13510, 14060, 14, 13768, 63, 15480, 63, 4305, 315, 1566, 14, 2489, 63, 1751, 26, 717, 291, 14, 3806, 63, 5334, 8, 403, 12, 378, 9, 2234, 291, 14, 5545, 14, 952, 8, 277, 14, 1631, 14, 576, 63, 475, 63, 2254, 1012, 339, 347, 1056, 63, 9226, 8, 277, 12, 2323, 26, 3820, 59, 7075, 59, 495, 12, 620, 2365, 2547, 63, 344, 26, 1109, 304, 267, 2323, 275, 5055, 14, 16882, 8, 2139, 9, 267, 1083, 275, 2323, 59, 356, 765, 418, 398, 327, 13874, 2331, 314, 1056, 666, 14, 267, 1056, 63, 576, 275, 4784, 1451, 8, 2139, 12, 5890, 14, 15466, 1012, 267, 291, 14, 1745, 63, 576, 59, 1745, 63, 344, 61, 275, 1056, 63, 576, 339, 347, 2547, 63, 4883, 8, 277, 12, 2547, 63, 344, 26, 1109, 304, 267, 408, 267, 3979, 282, 2547, 365, 4890, 12, 781, 883, 3222, 4154, 1177, 14, 267, 408, 267, 862, 26, 288, 1056, 63, 576, 275, 291, 14, 1745, 63, 576, 59, 1745, 63, 344, 61, 267, 871, 4067, 26, 288, 327, 13870, 372, 12, 781, 8646, 25766, 5121, 642, 2575, 288, 372, 398, 2323, 275, 1056, 63, 576, 14, 2139, 267, 2396, 275, 1056, 63, 576, 14, 576, 14, 7150, 1252, 2708, 360, 1624, 13, 24, 358, 398, 666, 275, 2022, 14, 4180, 8, 288, 2420, 2139, 582, 2323, 12, 298, 2030, 582, 2396, 1386, 4363, 29, 20, 267, 7092, 2143, 480, 1624, 24, 531, 398, 1177, 63, 2139, 275, 334, 288, 334, 356, 1205, 297, 283, 1840, 659, 288, 661, 1317, 13, 466, 297, 283, 3578, 15, 1001, 659, 288, 661, 1317, 13, 1267, 297, 620, 8, 552, 8, 576, 11508, 288, 661, 1000, 297, 283, 19343, 13, 72, 18, 659, 267, 776, 267, 291, 14, 1631, 14, 2254, 63, 2139, 8, 1745, 63, 344, 12, 1177, 63, 2139, 9, 267, 16195, 14, 7505, 63, 2443, 8, 277, 14, 2254, 63, 576, 8, 576, 12, 2547, 63, 344, 430, 339, 347, 9128, 63, 576, 8, 277, 12, 666, 26, 2783, 12, 2547, 63, 344, 26, 1109, 304, 267, 408, 267, 2136, 9064, 3086, 2005, 666, 641, 282, 2547, 14, 982, 626, 2547, 365, 1373, 781, 3984, 267, 21055, 666, 641, 12, 3354, 652, 2331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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 ]
twz915/django
tests/postgres_tests/test_indexes.py
5
4692
from django.contrib.postgres.indexes import BrinIndex, GinIndex from django.db import connection from django.test import skipUnlessDBFeature from . import PostgreSQLTestCase from .models import CharFieldModel, IntegerArrayModel @skipUnlessDBFeature('has_brin_index_support') class BrinIndexTests(PostgreSQLTestCase): def test_repr(self): index = BrinIndex(fields=['title'], pages_per_range=4) another_index = BrinIndex(fields=['title']) self.assertEqual(repr(index), "<BrinIndex: fields='title', pages_per_range=4>") self.assertEqual(repr(another_index), "<BrinIndex: fields='title'>") def test_not_eq(self): index = BrinIndex(fields=['title']) index_with_page_range = BrinIndex(fields=['title'], pages_per_range=16) self.assertNotEqual(index, index_with_page_range) def test_deconstruction(self): index = BrinIndex(fields=['title'], name='test_title_brin') path, args, kwargs = index.deconstruct() self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex') self.assertEqual(args, ()) self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_brin', 'pages_per_range': None}) def test_deconstruction_with_pages_per_range(self): index = BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=16) path, args, kwargs = index.deconstruct() self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex') self.assertEqual(args, ()) self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_brin', 'pages_per_range': 16}) def test_invalid_pages_per_range(self): with self.assertRaisesMessage(ValueError, 'pages_per_range must be None or a positive integer'): BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=0) class GinIndexTests(PostgreSQLTestCase): def test_repr(self): index = GinIndex(fields=['title']) self.assertEqual(repr(index), "<GinIndex: fields='title'>") def test_eq(self): index = GinIndex(fields=['title']) same_index = GinIndex(fields=['title']) another_index = GinIndex(fields=['author']) self.assertEqual(index, same_index) self.assertNotEqual(index, another_index) def test_name_auto_generation(self): index = GinIndex(fields=['field']) index.set_name_with_model(IntegerArrayModel) self.assertEqual(index.name, 'postgres_te_field_def2f8_gin') def test_deconstruction(self): index = GinIndex(fields=['title'], name='test_title_gin') path, args, kwargs = index.deconstruct() self.assertEqual(path, 'django.contrib.postgres.indexes.GinIndex') self.assertEqual(args, ()) self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_gin'}) class SchemaTests(PostgreSQLTestCase): def get_constraints(self, table): """ Get the indexes on the table using a new cursor. """ with connection.cursor() as cursor: return connection.introspection.get_constraints(cursor, table) def test_gin_index(self): # Ensure the table is there and doesn't have an index. self.assertNotIn('field', self.get_constraints(IntegerArrayModel._meta.db_table)) # Add the index index_name = 'integer_array_model_field_gin' index = GinIndex(fields=['field'], name=index_name) with connection.schema_editor() as editor: editor.add_index(IntegerArrayModel, index) constraints = self.get_constraints(IntegerArrayModel._meta.db_table) # Check gin index was added self.assertEqual(constraints[index_name]['type'], 'gin') # Drop the index with connection.schema_editor() as editor: editor.remove_index(IntegerArrayModel, index) self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table)) @skipUnlessDBFeature('has_brin_index_support') def test_brin_index(self): index_name = 'char_field_model_field_brin' index = BrinIndex(fields=['field'], name=index_name, pages_per_range=4) with connection.schema_editor() as editor: editor.add_index(CharFieldModel, index) constraints = self.get_constraints(CharFieldModel._meta.db_table) self.assertEqual(constraints[index_name]['type'], 'brin') self.assertEqual(constraints[index_name]['options'], ['pages_per_range=4']) with connection.schema_editor() as editor: editor.remove_index(CharFieldModel, index) self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table))
bsd-3-clause
[ 504, 1639, 14, 2828, 14, 10675, 14, 10116, 492, 699, 24667, 2681, 12, 598, 262, 2681, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 3372, 5524, 18093, 199, 199, 504, 1275, 492, 20175, 1746, 199, 504, 1275, 992, 492, 12064, 1685, 12, 7225, 3836, 1685, 421, 199, 32, 22424, 360, 1989, 63, 3289, 262, 63, 1080, 63, 4058, 358, 199, 533, 699, 24667, 2681, 2925, 8, 31433, 1746, 304, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 6497, 63, 529, 63, 1842, 29, 20, 9, 267, 4573, 63, 1080, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 1105, 267, 291, 14, 629, 8, 2722, 8, 1080, 395, 3886, 12771, 262, 2681, 26, 1504, 534, 1213, 297, 6497, 63, 529, 63, 1842, 29, 20, 9579, 267, 291, 14, 629, 8, 2722, 8, 13565, 63, 1080, 395, 3886, 12771, 262, 2681, 26, 1504, 534, 1213, 8423, 531, 339, 347, 511, 63, 1397, 63, 4077, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 1105, 267, 1478, 63, 1045, 63, 1606, 63, 1842, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 6497, 63, 529, 63, 1842, 29, 975, 9, 267, 291, 14, 7418, 8, 1080, 12, 1478, 63, 1045, 63, 1606, 63, 1842, 9, 339, 347, 511, 63, 271, 12708, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 358, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 12771, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 3289, 262, 297, 283, 5856, 63, 529, 63, 1842, 356, 488, 1552, 339, 347, 511, 63, 271, 12708, 63, 1045, 63, 5856, 63, 529, 63, 1842, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 297, 6497, 63, 529, 63, 1842, 29, 975, 9, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 12771, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 3289, 262, 297, 283, 5856, 63, 529, 63, 1842, 356, 3193, 1552, 339, 347, 511, 63, 3197, 63, 5856, 63, 529, 63, 1842, 8, 277, 304, 267, 543, 291, 14, 14638, 8, 3393, 12, 283, 5856, 63, 529, 63, 1842, 1471, 506, 488, 503, 282, 7317, 3000, 735, 288, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 297, 6497, 63, 529, 63, 1842, 29, 16, 9, 421, 199, 533, 598, 262, 2681, 2925, 8, 31433, 1746, 304, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 291, 14, 629, 8, 2722, 8, 1080, 395, 3886, 39, 262, 2681, 26, 1504, 534, 1213, 8423, 531, 339, 347, 511, 63, 4077, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 2011, 63, 1080, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 4573, 63, 1080, 275, 598, 262, 2681, 8, 955, 2968, 2502, 1105, 267, 291, 14, 629, 8, 1080, 12, 2011, 63, 1080, 9, 267, 291, 14, 7418, 8, 1080, 12, 4573, 63, 1080, 9, 339, 347, 511, 63, 354, 63, 2495, 63, 15043, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 698, 1105, 267, 1478, 14, 409, 63, 354, 63, 1045, 63, 1238, 8, 2674, 3836, 1685, 9, 267, 291, 14, 629, 8, 1080, 14, 354, 12, 283, 10675, 63, 266, 63, 698, 63, 318, 18, 70, 24, 63, 903, 358, 339, 347, 511, 63, 271, 12708, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 903, 358, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 39, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 903, 3071, 421, 199, 533, 13268, 2925, 8, 31433, 1746, 304, 339, 347, 664, 63, 9882, 8, 277, 12, 1817, 304, 267, 408, 267, 2372, 314, 10507, 641, 314, 1817, 1808, 282, 892, 3920, 14, 267, 408, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 372, 1950, 14, 21627, 14, 362, 63, 9882, 8, 3937, 12, 1817, 9, 339, 347, 511, 63, 903, 63, 1080, 8, 277, 304, 267, 327, 7523, 314, 1817, 365, 2337, 436, 3181, 1133, 1172, 376, 1478, 14, 267, 291, 14, 8795, 360, 698, 297, 291, 14, 362, 63, 9882, 8, 2674, 3836, 1685, 423, 2024, 14, 697, 63, 1224, 430, 267, 327, 2654, 314, 1478, 267, 1478, 63, 354, 275, 283, 4115, 63, 1144, 63, 1238, 63, 698, 63, 903, 7, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 698, 995, 536, 29, 1080, 63, 354, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 8823, 14, 525, 63, 1080, 8, 2674, 3836, 1685, 12, 1478, 9, 267, 9565, 275, 291, 14, 362, 63, 9882, 8, 2674, 3836, 1685, 423, 2024, 14, 697, 63, 1224, 9, 267, 327, 2670, 486, 262, 1478, 1990, 3483, 267, 291, 14, 629, 8, 9882, 59, 1080, 63, 354, 2733, 466, 995, 283, 903, 358, 267, 327, 18110, 314, 1478, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 8823, 14, 2168, 63, 1080, 8, 2674, 3836, 1685, 12, 1478, 9, 267, 291, 14, 8795, 8, 1080, 63, 354, 12, 291, 14, 362, 63, 9882, 8, 2674 ]
[ 1639, 14, 2828, 14, 10675, 14, 10116, 492, 699, 24667, 2681, 12, 598, 262, 2681, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 3372, 5524, 18093, 199, 199, 504, 1275, 492, 20175, 1746, 199, 504, 1275, 992, 492, 12064, 1685, 12, 7225, 3836, 1685, 421, 199, 32, 22424, 360, 1989, 63, 3289, 262, 63, 1080, 63, 4058, 358, 199, 533, 699, 24667, 2681, 2925, 8, 31433, 1746, 304, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 6497, 63, 529, 63, 1842, 29, 20, 9, 267, 4573, 63, 1080, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 1105, 267, 291, 14, 629, 8, 2722, 8, 1080, 395, 3886, 12771, 262, 2681, 26, 1504, 534, 1213, 297, 6497, 63, 529, 63, 1842, 29, 20, 9579, 267, 291, 14, 629, 8, 2722, 8, 13565, 63, 1080, 395, 3886, 12771, 262, 2681, 26, 1504, 534, 1213, 8423, 531, 339, 347, 511, 63, 1397, 63, 4077, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 1105, 267, 1478, 63, 1045, 63, 1606, 63, 1842, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 6497, 63, 529, 63, 1842, 29, 975, 9, 267, 291, 14, 7418, 8, 1080, 12, 1478, 63, 1045, 63, 1606, 63, 1842, 9, 339, 347, 511, 63, 271, 12708, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 358, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 12771, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 3289, 262, 297, 283, 5856, 63, 529, 63, 1842, 356, 488, 1552, 339, 347, 511, 63, 271, 12708, 63, 1045, 63, 5856, 63, 529, 63, 1842, 8, 277, 304, 267, 1478, 275, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 297, 6497, 63, 529, 63, 1842, 29, 975, 9, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 12771, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 3289, 262, 297, 283, 5856, 63, 529, 63, 1842, 356, 3193, 1552, 339, 347, 511, 63, 3197, 63, 5856, 63, 529, 63, 1842, 8, 277, 304, 267, 543, 291, 14, 14638, 8, 3393, 12, 283, 5856, 63, 529, 63, 1842, 1471, 506, 488, 503, 282, 7317, 3000, 735, 288, 699, 24667, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 3289, 262, 297, 6497, 63, 529, 63, 1842, 29, 16, 9, 421, 199, 533, 598, 262, 2681, 2925, 8, 31433, 1746, 304, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 291, 14, 629, 8, 2722, 8, 1080, 395, 3886, 39, 262, 2681, 26, 1504, 534, 1213, 8423, 531, 339, 347, 511, 63, 4077, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 2011, 63, 1080, 275, 598, 262, 2681, 8, 955, 2968, 1213, 1105, 267, 4573, 63, 1080, 275, 598, 262, 2681, 8, 955, 2968, 2502, 1105, 267, 291, 14, 629, 8, 1080, 12, 2011, 63, 1080, 9, 267, 291, 14, 7418, 8, 1080, 12, 4573, 63, 1080, 9, 339, 347, 511, 63, 354, 63, 2495, 63, 15043, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 698, 1105, 267, 1478, 14, 409, 63, 354, 63, 1045, 63, 1238, 8, 2674, 3836, 1685, 9, 267, 291, 14, 629, 8, 1080, 14, 354, 12, 283, 10675, 63, 266, 63, 698, 63, 318, 18, 70, 24, 63, 903, 358, 339, 347, 511, 63, 271, 12708, 8, 277, 304, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 1213, 995, 536, 534, 396, 63, 1213, 63, 903, 358, 267, 931, 12, 1249, 12, 2074, 275, 1478, 14, 23693, 342, 267, 291, 14, 629, 8, 515, 12, 283, 1176, 14, 2828, 14, 10675, 14, 10116, 14, 39, 262, 2681, 358, 267, 291, 14, 629, 8, 589, 12, 14515, 267, 291, 14, 629, 8, 958, 12, 791, 955, 356, 788, 1213, 995, 283, 354, 356, 283, 396, 63, 1213, 63, 903, 3071, 421, 199, 533, 13268, 2925, 8, 31433, 1746, 304, 339, 347, 664, 63, 9882, 8, 277, 12, 1817, 304, 267, 408, 267, 2372, 314, 10507, 641, 314, 1817, 1808, 282, 892, 3920, 14, 267, 408, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 372, 1950, 14, 21627, 14, 362, 63, 9882, 8, 3937, 12, 1817, 9, 339, 347, 511, 63, 903, 63, 1080, 8, 277, 304, 267, 327, 7523, 314, 1817, 365, 2337, 436, 3181, 1133, 1172, 376, 1478, 14, 267, 291, 14, 8795, 360, 698, 297, 291, 14, 362, 63, 9882, 8, 2674, 3836, 1685, 423, 2024, 14, 697, 63, 1224, 430, 267, 327, 2654, 314, 1478, 267, 1478, 63, 354, 275, 283, 4115, 63, 1144, 63, 1238, 63, 698, 63, 903, 7, 267, 1478, 275, 598, 262, 2681, 8, 955, 2968, 698, 995, 536, 29, 1080, 63, 354, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 8823, 14, 525, 63, 1080, 8, 2674, 3836, 1685, 12, 1478, 9, 267, 9565, 275, 291, 14, 362, 63, 9882, 8, 2674, 3836, 1685, 423, 2024, 14, 697, 63, 1224, 9, 267, 327, 2670, 486, 262, 1478, 1990, 3483, 267, 291, 14, 629, 8, 9882, 59, 1080, 63, 354, 2733, 466, 995, 283, 903, 358, 267, 327, 18110, 314, 1478, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 8823, 14, 2168, 63, 1080, 8, 2674, 3836, 1685, 12, 1478, 9, 267, 291, 14, 8795, 8, 1080, 63, 354, 12, 291, 14, 362, 63, 9882, 8, 2674, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Weuxel/cjdns
node_build/dependencies/libuv/build/gyp/test/mac/gyptest-strip.py
83
1991
#!/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. """ Verifies that stripping works. """ import TestGyp import TestMac import re import subprocess import sys import time if sys.platform == 'darwin': test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) test.run_gyp('test.gyp', chdir='strip') test.build('test.gyp', test.ALL, chdir='strip') # Lightweight check if stripping was done. def OutPath(s): return test.built_file_path(s, type=test.SHARED_LIB, chdir='strip') def CheckNsyms(p, n_expected): r = re.compile(r'nsyms\s+(\d+)') o = subprocess.check_output(['otool', '-l', p]) m = r.search(o) n = int(m.group(1)) if n != n_expected: print 'Stripping: Expected %d symbols, got %d' % (n_expected, n) test.fail_test() # Starting with Xcode 5.0, clang adds an additional symbols to the compiled # file when using a relative path to the input file. So when using ninja # with Xcode 5.0 or higher, take this additional symbol into consideration # for unstripped builds (it is stripped by all strip commands). expected_extra_symbol_count = 0 if test.format in ['ninja', 'xcode-ninja'] \ and TestMac.Xcode.Version() >= '0500': expected_extra_symbol_count = 1 # The actual numbers here are not interesting, they just need to be the same # in both the xcode and the make build. CheckNsyms(OutPath('no_postprocess'), 29 + expected_extra_symbol_count) CheckNsyms(OutPath('no_strip'), 29 + expected_extra_symbol_count) CheckNsyms(OutPath('strip_all'), 0) CheckNsyms(OutPath('strip_nonglobal'), 6) CheckNsyms(OutPath('strip_debugging'), 7) CheckNsyms(OutPath('strip_all_custom_flags'), 0) CheckNsyms(test.built_file_path( 'strip_all_bundle.framework/Versions/A/strip_all_bundle', chdir='strip'), 0) CheckNsyms(OutPath('strip_save'), 7) 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, 21168, 626, 4024, 3637, 5419, 14, 199, 624, 199, 199, 646, 25688, 199, 646, 1379, 3399, 199, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 692, 984, 14, 3246, 508, 283, 13245, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 297, 283, 1875, 297, 283, 8701, 1105, 819, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 13097, 534, 1913, 358, 819, 511, 14, 1506, 360, 396, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 1913, 358, 819, 327, 29684, 3463, 1104, 340, 4024, 3637, 1990, 4224, 14, 523, 347, 6219, 2042, 8, 83, 304, 272, 372, 511, 14, 11730, 63, 493, 63, 515, 8, 83, 12, 730, 29, 396, 14, 13772, 63, 5617, 12, 13097, 534, 1913, 358, 819, 347, 2670, 46, 13807, 8, 80, 12, 302, 63, 2062, 304, 272, 519, 275, 295, 14, 2014, 8, 82, 7, 21320, 706, 60, 83, 20900, 68, 11, 5942, 272, 312, 275, 3873, 14, 1074, 63, 1199, 2941, 3459, 393, 297, 2475, 76, 297, 299, 566, 272, 333, 275, 519, 14, 1733, 8, 79, 9, 272, 302, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 272, 340, 302, 1137, 302, 63, 2062, 26, 489, 870, 283, 24125, 3637, 26, 13796, 450, 68, 6698, 12, 4788, 450, 68, 7, 450, 334, 78, 63, 2062, 12, 302, 9, 489, 511, 14, 1633, 63, 396, 342, 819, 327, 24175, 543, 10602, 959, 14, 16, 12, 25444, 9584, 376, 4722, 6698, 370, 314, 10311, 523, 327, 570, 1380, 1808, 282, 3847, 931, 370, 314, 1324, 570, 14, 2002, 1380, 1808, 14822, 523, 327, 543, 10602, 959, 14, 16, 503, 10948, 12, 5452, 642, 4722, 5272, 1901, 8219, 1754, 523, 327, 367, 625, 25382, 14723, 334, 390, 365, 14489, 701, 1006, 6202, 3718, 680, 523, 1420, 63, 2911, 63, 5155, 63, 835, 275, 378, 523, 340, 511, 14, 908, 315, 788, 8675, 297, 283, 8701, 13, 8675, 418, 971, 489, 436, 1379, 3399, 14, 18442, 14, 3353, 342, 2356, 283, 1717, 383, 356, 272, 1420, 63, 2911, 63, 5155, 63, 835, 275, 413, 819, 327, 710, 3503, 5579, 2348, 787, 440, 19604, 12, 2985, 2951, 1929, 370, 506, 314, 2011, 523, 327, 315, 3865, 314, 13592, 436, 314, 1852, 1900, 14, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 889, 63, 32238, 659, 7349, 435, 1420, 63, 2911, 63, 5155, 63, 835, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 889, 63, 1913, 659, 7349, 435, 1420, 63, 2911, 63, 5155, 63, 835, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 452, 659, 378, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 78, 951, 1498, 659, 1227, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 24913, 659, 1520, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 452, 63, 4229, 63, 2469, 659, 378, 9, 523, 2670, 46, 13807, 8, 396, 14, 11730, 63, 493, 63, 515, 8, 489, 283, 1913, 63, 452, 63, 6469, 14, 4857, 15, 21167, 15, 33, 15, 1913, 63, 452, 63, 6469, 297, 13097, 534, 1913, 659, 489, 378, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 2117, 659, 1520, 9, 819, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 21168, 626, 4024, 3637, 5419, 14, 199, 624, 199, 199, 646, 25688, 199, 646, 1379, 3399, 199, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 692, 984, 14, 3246, 508, 283, 13245, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 297, 283, 1875, 297, 283, 8701, 1105, 819, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 13097, 534, 1913, 358, 819, 511, 14, 1506, 360, 396, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 1913, 358, 819, 327, 29684, 3463, 1104, 340, 4024, 3637, 1990, 4224, 14, 523, 347, 6219, 2042, 8, 83, 304, 272, 372, 511, 14, 11730, 63, 493, 63, 515, 8, 83, 12, 730, 29, 396, 14, 13772, 63, 5617, 12, 13097, 534, 1913, 358, 819, 347, 2670, 46, 13807, 8, 80, 12, 302, 63, 2062, 304, 272, 519, 275, 295, 14, 2014, 8, 82, 7, 21320, 706, 60, 83, 20900, 68, 11, 5942, 272, 312, 275, 3873, 14, 1074, 63, 1199, 2941, 3459, 393, 297, 2475, 76, 297, 299, 566, 272, 333, 275, 519, 14, 1733, 8, 79, 9, 272, 302, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 272, 340, 302, 1137, 302, 63, 2062, 26, 489, 870, 283, 24125, 3637, 26, 13796, 450, 68, 6698, 12, 4788, 450, 68, 7, 450, 334, 78, 63, 2062, 12, 302, 9, 489, 511, 14, 1633, 63, 396, 342, 819, 327, 24175, 543, 10602, 959, 14, 16, 12, 25444, 9584, 376, 4722, 6698, 370, 314, 10311, 523, 327, 570, 1380, 1808, 282, 3847, 931, 370, 314, 1324, 570, 14, 2002, 1380, 1808, 14822, 523, 327, 543, 10602, 959, 14, 16, 503, 10948, 12, 5452, 642, 4722, 5272, 1901, 8219, 1754, 523, 327, 367, 625, 25382, 14723, 334, 390, 365, 14489, 701, 1006, 6202, 3718, 680, 523, 1420, 63, 2911, 63, 5155, 63, 835, 275, 378, 523, 340, 511, 14, 908, 315, 788, 8675, 297, 283, 8701, 13, 8675, 418, 971, 489, 436, 1379, 3399, 14, 18442, 14, 3353, 342, 2356, 283, 1717, 383, 356, 272, 1420, 63, 2911, 63, 5155, 63, 835, 275, 413, 819, 327, 710, 3503, 5579, 2348, 787, 440, 19604, 12, 2985, 2951, 1929, 370, 506, 314, 2011, 523, 327, 315, 3865, 314, 13592, 436, 314, 1852, 1900, 14, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 889, 63, 32238, 659, 7349, 435, 1420, 63, 2911, 63, 5155, 63, 835, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 889, 63, 1913, 659, 7349, 435, 1420, 63, 2911, 63, 5155, 63, 835, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 452, 659, 378, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 78, 951, 1498, 659, 1227, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 24913, 659, 1520, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 452, 63, 4229, 63, 2469, 659, 378, 9, 523, 2670, 46, 13807, 8, 396, 14, 11730, 63, 493, 63, 515, 8, 489, 283, 1913, 63, 452, 63, 6469, 14, 4857, 15, 21167, 15, 33, 15, 1913, 63, 452, 63, 6469, 297, 13097, 534, 1913, 659, 489, 378, 9, 523, 2670, 46, 13807, 8, 2204, 2042, 360, 1913, 63, 2117, 659, 1520, 9, 819, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
LordDamionDevil/Lony
lib/discord/ext/commands/errors.py
18
4513
# -*- coding: utf-8 -*- """ The MIT License (MIT) Copyright (c) 2015-2016 Rapptz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from discord.errors import DiscordException __all__ = [ 'CommandError', 'MissingRequiredArgument', 'BadArgument', 'NoPrivateMessage', 'CheckFailure', 'CommandNotFound', 'DisabledCommand', 'CommandInvokeError', 'TooManyArguments', 'UserInputError', 'CommandOnCooldown' ] class CommandError(DiscordException): """The base exception type for all command related errors. This inherits from :exc:`discord.DiscordException`. This exception and exceptions derived from it are handled in a special way as they are caught and passed into a special event from :class:`Bot`\, :func:`on_command_error`. """ def __init__(self, message=None, *args): if message is not None: # clean-up @everyone and @here mentions m = message.replace('@everyone', '@\u200beveryone').replace('@here', '@\u200bhere') super().__init__(m, *args) else: super().__init__(*args) class UserInputError(CommandError): """The base exception type for errors that involve errors regarding user input. This inherits from :exc:`CommandError`. """ pass class CommandNotFound(CommandError): """Exception raised when a command is attempted to be invoked but no command under that name is found. This is not raised for invalid subcommands, rather just the initial main command that is attempted to be invoked. """ pass class MissingRequiredArgument(UserInputError): """Exception raised when parsing a command and a parameter that is required is not encountered. """ pass class TooManyArguments(UserInputError): """Exception raised when the command was passed too many arguments and its :attr:`Command.ignore_extra` attribute was not set to ``True``. """ pass class BadArgument(UserInputError): """Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command. """ pass class NoPrivateMessage(CommandError): """Exception raised when an operation does not work in private message contexts. """ pass class CheckFailure(CommandError): """Exception raised when the predicates in :attr:`Command.checks` have failed.""" pass class DisabledCommand(CommandError): """Exception raised when the command being invoked is disabled.""" pass class CommandInvokeError(CommandError): """Exception raised when the command being invoked raised an exception. Attributes ----------- original The original exception that was raised. You can also get this via the ``__cause__`` attribute. """ def __init__(self, e): self.original = e super().__init__('Command raised an exception: {0.__class__.__name__}: {0}'.format(e)) class CommandOnCooldown(CommandError): """Exception raised when the command being invoked is on cooldown. Attributes ----------- cooldown: Cooldown A class with attributes ``rate``, ``per``, and ``type`` similar to the :func:`cooldown` decorator. retry_after: float The amount of seconds to wait before you can retry again. """ def __init__(self, cooldown, retry_after): self.cooldown = cooldown self.retry_after = retry_after super().__init__('You are on cooldown. Try again in {:.2f}s'.format(retry_after))
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 13, 9261, 820, 439, 541, 90, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 1574, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 199, 475, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 460, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 10337, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 452, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 726, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 12491, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 1093, 13157, 1621, 2334, 4141, 14, 199, 624, 199, 199, 504, 4339, 2181, 14, 2550, 492, 5289, 1577, 1726, 421, 199, 363, 452, 363, 275, 359, 283, 31542, 297, 283, 7718, 8030, 5201, 297, 283, 5725, 5201, 297, 1779, 283, 1944, 12185, 2209, 297, 283, 1799, 6782, 297, 283, 3110, 4667, 297, 1779, 283, 15049, 3110, 297, 283, 3110, 27736, 547, 297, 283, 13749, 4089, 14517, 297, 1779, 283, 1899, 3205, 547, 297, 283, 3110, 3314, 967, 27898, 7, 1622, 199, 199, 533, 14393, 8, 2825, 1577, 1726, 304, 272, 408, 1918, 1300, 1919, 730, 367, 1006, 1414, 4048, 2552, 14, 339, 961, 21592, 687, 520, 2804, 1705, 6409, 2181, 14, 2825, 1577, 1726, 2313, 339, 961, 1919, 436, 4967, 7131, 687, 652, 787, 8860, 272, 315, 282, 4539, 4340, 465, 2985, 787, 15604, 436, 3032, 1901, 282, 4539, 1566, 272, 687, 520, 533, 1705, 14026, 25502, 12, 520, 1532, 1705, 265, 63, 1531, 63, 705, 2313, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 29, 403, 12, 627, 589, 304, 267, 340, 1245, 365, 440, 488, 26, 288, 327, 3633, 13, 384, 768, 14287, 368, 436, 768, 1681, 12953, 852, 288, 333, 275, 1245, 14, 1814, 16591, 14287, 368, 297, 10267, 60, 85, 1840, 1235, 2588, 368, 1959, 1814, 16591, 1681, 297, 10267, 60, 85, 1840, 66, 1681, 358, 288, 1613, 11027, 826, 721, 77, 12, 627, 589, 9, 267, 587, 26, 288, 1613, 11027, 826, 9308, 589, 9, 199, 199, 533, 2876, 3205, 547, 8, 31542, 304, 272, 408, 1918, 1300, 1919, 730, 367, 2552, 626, 4572, 3344, 2552, 272, 12602, 922, 1324, 14, 339, 961, 21592, 687, 520, 2804, 1705, 31542, 2313, 272, 408, 272, 986, 199, 199, 533, 5817, 4667, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 282, 1414, 365, 22040, 370, 506, 10302, 272, 1325, 949, 1414, 1334, 626, 536, 365, 1911, 14, 339, 961, 365, 440, 4915, 367, 3866, 1007, 4405, 12, 7830, 2951, 314, 272, 2536, 2446, 1414, 626, 365, 22040, 370, 506, 10302, 14, 272, 408, 272, 986, 199, 199, 533, 15626, 8030, 5201, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 6057, 282, 1414, 436, 282, 2725, 272, 626, 365, 1415, 365, 440, 14556, 14, 272, 408, 272, 986, 199, 199, 533, 22893, 4089, 14517, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 1990, 3032, 4634, 5002, 2368, 436, 2399, 272, 520, 962, 1705, 3110, 14, 4247, 63, 2911, 64, 2225, 1990, 440, 663, 370, 1124, 549, 4345, 272, 408, 272, 986, 199, 199, 533, 8857, 5201, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 282, 6057, 503, 8603, 5988, 365, 14556, 272, 641, 376, 1423, 370, 986, 1901, 282, 1414, 14, 272, 408, 272, 986, 199, 199, 533, 3091, 12185, 2209, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 376, 3439, 1630, 440, 1736, 315, 5726, 1245, 272, 18191, 14, 272, 408, 272, 986, 199, 199, 533, 2670, 6782, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 11944, 83, 315, 520, 962, 1705, 3110, 14, 8625, 64, 1172, 3405, 1041, 272, 986, 199, 199, 533, 5289, 1909, 3110, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 365, 6980, 1041, 272, 986, 199, 199, 533, 5817, 27736, 547, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 4915, 376, 1919, 14, 339, 9382, 272, 3001, 2595, 272, 3379, 267, 710, 3379, 1919, 626, 1990, 4915, 14, 2047, 883, 2597, 664, 642, 4799, 267, 314, 9035, 2651, 18762, 2225, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 325, 304, 267, 291, 14, 5043, 275, 325, 267, 1613, 11027, 826, 19734, 3110, 4915, 376, 1919, 26, 469, 16, 855, 533, 4914, 354, 363, 9160, 469, 16, 5285, 908, 8, 69, 430, 199, 199, 533, 5817, 3314, 967, 27898, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 365, 641, 512, 27898, 14, 339, 9382, 272, 3001, 2595, 272, 512, 27898, 26, 1849, 27898, 267, 437, 1021, 543, 3004, 1124, 1866, 4542, 1124, 529, 4542, 436, 1124, 466, 1040, 8545, 370, 267, 314, 520, 1532, 1705, 331, 27898, 64, 7531, 14, 272, 7269, 63, 4399, 26, 2069, 267, 710, 5982, 402, 4696, 370, 3618, 2544, 1265, 883, 7269, 4020, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 512, 27898, 12, 7269, 63, 4399, 304, 267, 291, 14, 331, 27898, 275, 512, 27898, 267, 291, 14, 7154, 63, 4399, 275, 7269, 63, 4399, 267, 1613, 11027, 826, 19734, 5556, 787, 641, 512, 27898, 14, 7649, 4020, 315, 469, 14010, 18, 70, 93, 83, 1370, 908, 8, 7154, 63, 4399, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 13, 9261, 820, 439, 541, 90, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 1574, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 199, 475, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 460, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 10337, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 452, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 726, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 12491, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 1093, 13157, 1621, 2334, 4141, 14, 199, 624, 199, 199, 504, 4339, 2181, 14, 2550, 492, 5289, 1577, 1726, 421, 199, 363, 452, 363, 275, 359, 283, 31542, 297, 283, 7718, 8030, 5201, 297, 283, 5725, 5201, 297, 1779, 283, 1944, 12185, 2209, 297, 283, 1799, 6782, 297, 283, 3110, 4667, 297, 1779, 283, 15049, 3110, 297, 283, 3110, 27736, 547, 297, 283, 13749, 4089, 14517, 297, 1779, 283, 1899, 3205, 547, 297, 283, 3110, 3314, 967, 27898, 7, 1622, 199, 199, 533, 14393, 8, 2825, 1577, 1726, 304, 272, 408, 1918, 1300, 1919, 730, 367, 1006, 1414, 4048, 2552, 14, 339, 961, 21592, 687, 520, 2804, 1705, 6409, 2181, 14, 2825, 1577, 1726, 2313, 339, 961, 1919, 436, 4967, 7131, 687, 652, 787, 8860, 272, 315, 282, 4539, 4340, 465, 2985, 787, 15604, 436, 3032, 1901, 282, 4539, 1566, 272, 687, 520, 533, 1705, 14026, 25502, 12, 520, 1532, 1705, 265, 63, 1531, 63, 705, 2313, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 29, 403, 12, 627, 589, 304, 267, 340, 1245, 365, 440, 488, 26, 288, 327, 3633, 13, 384, 768, 14287, 368, 436, 768, 1681, 12953, 852, 288, 333, 275, 1245, 14, 1814, 16591, 14287, 368, 297, 10267, 60, 85, 1840, 1235, 2588, 368, 1959, 1814, 16591, 1681, 297, 10267, 60, 85, 1840, 66, 1681, 358, 288, 1613, 11027, 826, 721, 77, 12, 627, 589, 9, 267, 587, 26, 288, 1613, 11027, 826, 9308, 589, 9, 199, 199, 533, 2876, 3205, 547, 8, 31542, 304, 272, 408, 1918, 1300, 1919, 730, 367, 2552, 626, 4572, 3344, 2552, 272, 12602, 922, 1324, 14, 339, 961, 21592, 687, 520, 2804, 1705, 31542, 2313, 272, 408, 272, 986, 199, 199, 533, 5817, 4667, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 282, 1414, 365, 22040, 370, 506, 10302, 272, 1325, 949, 1414, 1334, 626, 536, 365, 1911, 14, 339, 961, 365, 440, 4915, 367, 3866, 1007, 4405, 12, 7830, 2951, 314, 272, 2536, 2446, 1414, 626, 365, 22040, 370, 506, 10302, 14, 272, 408, 272, 986, 199, 199, 533, 15626, 8030, 5201, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 6057, 282, 1414, 436, 282, 2725, 272, 626, 365, 1415, 365, 440, 14556, 14, 272, 408, 272, 986, 199, 199, 533, 22893, 4089, 14517, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 1990, 3032, 4634, 5002, 2368, 436, 2399, 272, 520, 962, 1705, 3110, 14, 4247, 63, 2911, 64, 2225, 1990, 440, 663, 370, 1124, 549, 4345, 272, 408, 272, 986, 199, 199, 533, 8857, 5201, 8, 1899, 3205, 547, 304, 272, 408, 1726, 4915, 1380, 282, 6057, 503, 8603, 5988, 365, 14556, 272, 641, 376, 1423, 370, 986, 1901, 282, 1414, 14, 272, 408, 272, 986, 199, 199, 533, 3091, 12185, 2209, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 376, 3439, 1630, 440, 1736, 315, 5726, 1245, 272, 18191, 14, 272, 408, 272, 986, 199, 199, 533, 2670, 6782, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 11944, 83, 315, 520, 962, 1705, 3110, 14, 8625, 64, 1172, 3405, 1041, 272, 986, 199, 199, 533, 5289, 1909, 3110, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 365, 6980, 1041, 272, 986, 199, 199, 533, 5817, 27736, 547, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 4915, 376, 1919, 14, 339, 9382, 272, 3001, 2595, 272, 3379, 267, 710, 3379, 1919, 626, 1990, 4915, 14, 2047, 883, 2597, 664, 642, 4799, 267, 314, 9035, 2651, 18762, 2225, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 325, 304, 267, 291, 14, 5043, 275, 325, 267, 1613, 11027, 826, 19734, 3110, 4915, 376, 1919, 26, 469, 16, 855, 533, 4914, 354, 363, 9160, 469, 16, 5285, 908, 8, 69, 430, 199, 199, 533, 5817, 3314, 967, 27898, 8, 31542, 304, 272, 408, 1726, 4915, 1380, 314, 1414, 3769, 10302, 365, 641, 512, 27898, 14, 339, 9382, 272, 3001, 2595, 272, 512, 27898, 26, 1849, 27898, 267, 437, 1021, 543, 3004, 1124, 1866, 4542, 1124, 529, 4542, 436, 1124, 466, 1040, 8545, 370, 267, 314, 520, 1532, 1705, 331, 27898, 64, 7531, 14, 272, 7269, 63, 4399, 26, 2069, 267, 710, 5982, 402, 4696, 370, 3618, 2544, 1265, 883, 7269, 4020, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 512, 27898, 12, 7269, 63, 4399, 304, 267, 291, 14, 331, 27898, 275, 512, 27898, 267, 291, 14, 7154, 63, 4399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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
KohlsTechnology/ansible
test/sanity/code-smell/use-compat-six.py
68
1803
#!/usr/bin/env python import os import re import sys def main(): skip = set([ 'test/sanity/code-smell/%s' % os.path.basename(__file__), # digital_ocean is checking for six because dopy doesn't specify the # requirement on six so it needs to try importing six to give the correct error message 'lib/ansible/modules/cloud/digital_ocean/digital_ocean.py', # correct imports in the following files and remove them from this list 'contrib/inventory/apache-libcloud.py', 'contrib/inventory/cobbler.py', 'contrib/inventory/collins.py', 'contrib/inventory/consul_io.py', 'contrib/inventory/ec2.py', 'contrib/inventory/freeipa.py', 'contrib/inventory/lxd.py', 'contrib/inventory/nova.py', 'contrib/inventory/nsot.py', 'contrib/inventory/packet_net.py', 'contrib/inventory/proxmox.py', 'contrib/inventory/rax.py', 'contrib/inventory/rudder.py', 'contrib/inventory/scaleway.py', 'contrib/inventory/spacewalk.py', 'contrib/inventory/vmware.py', 'contrib/inventory/vmware_inventory.py', 'docs/bin/plugin_formatter.py', ]) for path in sys.argv[1:] or sys.stdin.read().splitlines(): if path in skip: continue if path.startswith('test/sanity/pylint/plugins/'): continue with open(path, 'r') as path_fd: for line, text in enumerate(path_fd.readlines()): match = re.search(r'((^\s*import\s+six\b)|(^\s*from\s+six\b))', text) if match: print('%s:%d:%d: use `ansible.module_utils.six` instead of `six`' % ( path, line + 1, match.start(1) + 1)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 421, 199, 318, 2446, 837, 272, 3372, 275, 663, 779, 267, 283, 396, 15, 21614, 15, 600, 13, 83, 278, 914, 3149, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 10139, 267, 327, 20545, 63, 31737, 365, 7907, 367, 3816, 2952, 366, 927, 3181, 1133, 4165, 314, 267, 327, 10685, 641, 3816, 880, 652, 4839, 370, 862, 16306, 3816, 370, 8120, 314, 3211, 1125, 1245, 267, 283, 773, 15, 4853, 15, 3112, 15, 4091, 15, 25888, 63, 31737, 15, 25888, 63, 31737, 14, 647, 297, 267, 327, 3211, 8925, 315, 314, 2569, 1584, 436, 2813, 3062, 687, 642, 769, 267, 283, 2828, 15, 7212, 15, 3796, 13, 30651, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 331, 26722, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 761, 472, 83, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 8704, 348, 63, 2308, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 825, 18, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 4624, 20014, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 76, 2207, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 6765, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 561, 357, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 6253, 63, 846, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 8221, 6625, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 14495, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 82, 1181, 424, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 3467, 3316, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 2638, 7757, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 18970, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 18970, 63, 7212, 14, 647, 297, 267, 283, 4757, 15, 1393, 15, 2718, 63, 8911, 14, 647, 297, 272, 4794, 339, 367, 931, 315, 984, 14, 3020, 59, 17, 2938, 503, 984, 14, 6626, 14, 739, 1252, 7644, 837, 267, 340, 931, 315, 3372, 26, 288, 1980, 398, 340, 931, 14, 2460, 360, 396, 15, 21614, 15, 26324, 15, 5265, 26985, 288, 1980, 398, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 931, 63, 2592, 26, 288, 367, 1004, 12, 1318, 315, 3874, 8, 515, 63, 2592, 14, 9684, 5109, 355, 1336, 275, 295, 14, 1733, 8, 82, 7, 1332, 12773, 83, 10, 646, 60, 83, 11, 4174, 60, 66, 8636, 8, 12773, 83, 10, 504, 60, 83, 11, 4174, 60, 66, 22629, 1318, 9, 2234, 340, 1336, 26, 490, 870, 3508, 83, 2689, 68, 2689, 68, 26, 675, 658, 4853, 14, 578, 63, 1208, 14, 4174, 64, 3140, 402, 658, 4174, 19097, 450, 334, 717, 931, 12, 1004, 435, 413, 12, 1336, 14, 928, 8, 17, 9, 435, 413, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 421, 199, 318, 2446, 837, 272, 3372, 275, 663, 779, 267, 283, 396, 15, 21614, 15, 600, 13, 83, 278, 914, 3149, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 10139, 267, 327, 20545, 63, 31737, 365, 7907, 367, 3816, 2952, 366, 927, 3181, 1133, 4165, 314, 267, 327, 10685, 641, 3816, 880, 652, 4839, 370, 862, 16306, 3816, 370, 8120, 314, 3211, 1125, 1245, 267, 283, 773, 15, 4853, 15, 3112, 15, 4091, 15, 25888, 63, 31737, 15, 25888, 63, 31737, 14, 647, 297, 267, 327, 3211, 8925, 315, 314, 2569, 1584, 436, 2813, 3062, 687, 642, 769, 267, 283, 2828, 15, 7212, 15, 3796, 13, 30651, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 331, 26722, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 761, 472, 83, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 8704, 348, 63, 2308, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 825, 18, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 4624, 20014, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 76, 2207, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 6765, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 561, 357, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 6253, 63, 846, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 8221, 6625, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 14495, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 82, 1181, 424, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 3467, 3316, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 2638, 7757, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 18970, 14, 647, 297, 267, 283, 2828, 15, 7212, 15, 18970, 63, 7212, 14, 647, 297, 267, 283, 4757, 15, 1393, 15, 2718, 63, 8911, 14, 647, 297, 272, 4794, 339, 367, 931, 315, 984, 14, 3020, 59, 17, 2938, 503, 984, 14, 6626, 14, 739, 1252, 7644, 837, 267, 340, 931, 315, 3372, 26, 288, 1980, 398, 340, 931, 14, 2460, 360, 396, 15, 21614, 15, 26324, 15, 5265, 26985, 288, 1980, 398, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 931, 63, 2592, 26, 288, 367, 1004, 12, 1318, 315, 3874, 8, 515, 63, 2592, 14, 9684, 5109, 355, 1336, 275, 295, 14, 1733, 8, 82, 7, 1332, 12773, 83, 10, 646, 60, 83, 11, 4174, 60, 66, 8636, 8, 12773, 83, 10, 504, 60, 83, 11, 4174, 60, 66, 22629, 1318, 9, 2234, 340, 1336, 26, 490, 870, 3508, 83, 2689, 68, 2689, 68, 26, 675, 658, 4853, 14, 578, 63, 1208, 14, 4174, 64, 3140, 402, 658, 4174, 19097, 450, 334, 717, 931, 12, 1004, 435, 413, 12, 1336, 14, 928, 8, 17, 9, 435, 413, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
susilehtola/psi4
tests/pytests/test_zeta.py
7
12752
import pytest from .utils import * import psi4 import numpy as np pytestmark = pytest.mark.skip ref = { "conv": { "ene": { "d": -100.01941126909895, "t": -100.05801143109962, "q": -100.06768524807164, "5": -100.0704303543983, "6": -100.07073832974459, "7": -100.07079540040381, }, "grd": { "d": np.array([[0, 0, -1.97897507e-02], [0, 0, 1.97897507e-02]]), "t": np.array([[0, 0, -2.44719827e-02], [0, 0, 2.44719827e-02]]), "q": np.array([[0, 0, -2.56632476e-02], [0, 0, 2.56632476e-02]]), "5": np.array([[0, 0, -2.55690860e-02], [0, 0, 2.55690860e-02]]), "6": np.array([[0, 0, -2.55202901e-02], [0, 0, 2.55202901e-02]]), "7": np.array([[0, 0, -2.54893228e-02], [0, 0, 2.54893228e-02]]), }, "hss": { "d": np.array( [ [1.14201580e-02, 2.88636997e-16, 3.97687335e-16, -1.14201580e-02, -2.78228656e-16, -3.97687335e-16], [2.88636997e-16, 1.14201580e-02, -5.22281113e-16, -3.80143660e-16, -1.14201580e-02, 5.22281113e-16], [3.97687335e-16, -5.22281113e-16, 6.37133401e-01, -3.97687335e-16, 5.22281113e-16, -6.37133401e-01], [-1.14201580e-02, -3.80143660e-16, -3.97687335e-16, 1.14201580e-02, 3.58459616e-16, 3.97687335e-16], [-2.78228656e-16, -1.14201580e-02, 5.22281113e-16, 3.58459616e-16, 1.14201580e-02, -5.22281113e-16], [-3.97687335e-16, 5.22281113e-16, -6.37133401e-01, 3.97687335e-16, -5.22281113e-16, 6.37133401e-01], ] ), "t": np.array( [ [1.41221543e-02, 3.43562420e-15, -5.56983751e-16, -1.41221543e-02, -8.82111243e-16, 5.56983751e-16], [3.43562420e-15, 1.41221543e-02, -5.72652355e-16, -4.26135257e-15, -1.41221543e-02, 5.72652355e-16], [-5.56983751e-16, -5.72652355e-16, 6.33543175e-01, 5.56983751e-16, 5.72652355e-16, -6.33543175e-01], [-1.41221543e-02, -4.26135257e-15, 5.56983751e-16, 1.41221543e-02, 1.60375621e-15, -5.56983751e-16], [-8.82111243e-16, -1.41221543e-02, 5.72652355e-16, 1.60375621e-15, 1.41221543e-02, -5.72652355e-16], [5.56983751e-16, 5.72652355e-16, -6.33543175e-01, -5.56983751e-16, -5.72652355e-16, 6.33543175e-01], ] ), "q": np.array( [ [1.48096027e-02, -5.90539645e-15, 9.84881270e-16, -1.48096027e-02, 4.75007061e-15, -9.84881270e-16], [-5.90539645e-15, 1.48096027e-02, 9.45937039e-17, 1.76222627e-15, -1.48096027e-02, -9.45937039e-17], [9.84881270e-16, 9.45937039e-17, 6.27190954e-01, -9.84881270e-16, -9.45937039e-17, -6.27190954e-01], [-1.48096027e-02, 1.76222627e-15, -9.84881270e-16, 1.48096027e-02, -7.22703890e-15, 9.84881270e-16], [4.75007061e-15, -1.48096027e-02, -9.45937039e-17, -7.22703890e-15, 1.48096027e-02, 9.45937039e-17], [-9.84881270e-16, -9.45937039e-17, -6.27190954e-01, 9.84881270e-16, 9.45937039e-17, 6.27190954e-01], ] ), "5": np.array( [ [1.47552645e-02, 2.85244420e-13, 4.57266232e-16, -1.47552645e-02, -4.56798164e-13, -4.57266234e-16], [2.85244420e-13, 1.47552645e-02, 4.63692795e-16, -2.69798442e-13, -1.47552645e-02, -4.63692795e-16], [4.57266232e-16, 4.63692795e-16, 6.26827336e-01, -4.57266233e-16, -4.63692795e-16, -6.26827336e-01], [ -1.47552645e-02, -2.69798442e-13, -4.57266233e-16, 1.47552645e-02, -1.26964042e-13, 4.57266233e-16, ], [ -4.56798164e-13, -1.47552645e-02, -4.63692795e-16, -1.26964042e-13, 1.47552645e-02, 4.63692795e-16, ], [-4.57266234e-16, -4.63692795e-16, -6.26827336e-01, 4.57266233e-16, 4.63692795e-16, 6.26827336e-01], ] ), "6": np.array( [ [ 1.47271054e-02, -3.46663981e-13, -6.58652686e-17, -1.47271054e-02, -4.04281331e-13, 6.58652675e-17, ], [-3.46663981e-13, 1.47271054e-02, 9.55744800e-16, 1.12365491e-14, -1.47271054e-02, -9.55744797e-16], [-6.58652686e-17, 9.55744800e-16, 6.26683611e-01, 6.58652679e-17, -9.55744800e-16, -6.26683610e-01], [-1.47271054e-02, 1.12365491e-14, 6.58652679e-17, 1.47271054e-02, 5.85830351e-14, -6.58652754e-17], [-4.04281331e-13, -1.47271054e-02, -9.55744800e-16, 5.85830351e-14, 1.47271054e-02, 9.55744798e-16], [6.58652675e-17, -9.55744797e-16, -6.26683610e-01, -6.58652754e-17, 9.55744798e-16, 6.26683610e-01], ] ), # "7": np.zeros(36).reshape((6, 6)), }, }, "df": { "ene": { "d": -100.01940060570712, "t": -100.05800433992121, "q": -100.06768368288756, "5": -100.0704283042375, "6/5": -100.07073665835942, "6": -100.07073587640389, "7/6": -100.07079295732615, # "7": 0.0, }, "grd": { "d": np.array([[0, 0, -1.97887695e-02], [0, 0, 1.97887695e-02]]), "t": np.array([[0, 0, -2.44674251e-02], [0, 0, 2.44674251e-02]]), "q": np.array([[0, 0, -2.56623539e-02], [0, 0, 2.56623539e-02]]), "5": np.array([[0, 0, -2.55665605e-02], [0, 0, 2.55665605e-02]]), "6/5": np.array([[0, 0, -2.55170642e-02], [0, 0, 2.55170642e-02]]), "6": np.array([[0, 0, -2.55207994e-02], [0, 0, 2.55207994e-02]]), "7/6": np.array([[0, 0, -2.54898158e-02], [0, 0, 2.54898158e-02]]), # "7": np.zeros(6).reshape(2, 3), }, "hss": { "d": np.array( [ [1.14195918e-02, -8.20455290e-15, 8.48376579e-16, -1.14195918e-02, 1.01425643e-14, -8.48376580e-16], [-8.20455290e-15, 1.14195918e-02, 7.87137296e-16, 8.63378854e-15, -1.14195918e-02, -7.87137294e-16], [8.48376579e-16, 7.87137296e-16, 6.37098987e-01, -8.48376579e-16, -7.87137296e-16, -6.37098987e-01], [-1.14195918e-02, 8.63378854e-15, -8.48376579e-16, 1.14195918e-02, -8.52027257e-15, 8.48376579e-16], [1.01425643e-14, -1.14195918e-02, -7.87137296e-16, -8.52027257e-15, 1.14195918e-02, 7.87137295e-16], [-8.48376580e-16, -7.87137294e-16, -6.37098987e-01, 8.48376579e-16, 7.87137295e-16, 6.37098987e-01], ] ), "t": np.array( [ [1.41195242e-02, -1.44279825e-13, -2.62663252e-16, -1.41195242e-02, 2.52178758e-13, 2.62663246e-16], [-1.44279825e-13, 1.41195242e-02, 7.25775059e-16, 1.88123226e-13, -1.41195242e-02, -7.25775063e-16], [-2.62663252e-16, 7.25775059e-16, 6.33561555e-01, 2.62663253e-16, -7.25775060e-16, -6.33561555e-01], [-1.41195242e-02, 1.88123226e-13, 2.62663253e-16, 1.41195242e-02, -3.52532511e-13, -2.62663248e-16], [2.52178758e-13, -1.41195242e-02, -7.25775060e-16, -3.52532511e-13, 1.41195242e-02, 7.25775063e-16], [2.62663246e-16, -7.25775063e-16, -6.33561555e-01, -2.62663248e-16, 7.25775063e-16, 6.33561555e-01], ] ), "q": np.array( [ [1.48090869e-02, 2.05969460e-14, -1.49618888e-15, -1.48090869e-02, 3.81831832e-14, 1.49618913e-15], [2.05969460e-14, 1.48090870e-02, -9.64983006e-16, 1.26240566e-13, -1.48090869e-02, 9.64982950e-16], [-1.49618888e-15, -9.64983006e-16, 6.27200845e-01, 1.49618893e-15, 9.64982952e-16, -6.27200845e-01], [-1.48090869e-02, 1.26240566e-13, 1.49618893e-15, 1.48090869e-02, -8.38158432e-14, -1.49618905e-15], [3.81831832e-14, -1.48090869e-02, 9.64982952e-16, -8.38158432e-14, 1.48090869e-02, -9.64982956e-16], [1.49618913e-15, 9.64982950e-16, -6.27200845e-01, -1.49618905e-15, -9.64982956e-16, 6.27200845e-01], ] ), "5": np.array( [ [1.47538071e-02, 5.47383498e-13, -1.15209254e-15, -1.47538071e-02, -2.32833029e-13, 1.15209256e-15], [5.47383498e-13, 1.47538071e-02, 4.09315798e-16, -5.13303988e-13, -1.47538071e-02, -4.09315765e-16], [-1.15209254e-15, 4.09315798e-16, 6.26827395e-01, 1.15209262e-15, -4.09316413e-16, -6.26827395e-01], [-1.47538071e-02, -5.13303988e-13, 1.15209262e-15, 1.47538071e-02, 4.11866032e-13, -1.15209258e-15], [-2.32833029e-13, -1.47538071e-02, -4.09316413e-16, 4.11866032e-13, 1.47538071e-02, 4.09315929e-16], [1.15209256e-15, -4.09315765e-16, -6.26827395e-01, -1.15209258e-15, 4.09315929e-16, 6.26827395e-01], ] ), "6/5": np.array( [ [1.47252438e-02, 5.92051339e-14, -1.14461969e-15, -1.47252438e-02, 5.68396132e-14, 1.14461967e-15], [5.92051339e-14, 1.47252438e-02, 6.43834765e-16, -9.29323460e-14, -1.47252437e-02, -6.43834148e-16], [-1.14461969e-15, 6.43834765e-16, 6.26683723e-01, 1.14461973e-15, -6.43834668e-16, -6.26683723e-01], [-1.47252438e-02, -9.29323460e-14, 1.14461973e-15, 1.47252438e-02, 3.73113650e-14, -1.14461967e-15], [5.68396132e-14, -1.47252437e-02, -6.43834668e-16, 3.73113650e-14, 1.47252438e-02, 6.43834161e-16], [1.14461967e-15, -6.43834148e-16, -6.26683723e-01, -1.14461967e-15, 6.43834161e-16, 6.26683723e-01], ] ), # "6": np.zeros(36).reshape((6, 6)), # "7/6": np.zeros(36).reshape((6, 6)), # "7": np.zeros(36).reshape((6, 6)), }, }, } # hand-adjust zetas -- what to pass/xfail/fail is NOT read from Libint2 config # * leaving at dtq5 so running pytest from source doesn't catch hours-long 7z # * @pytest.mark.parametrize("zeta", ["d", "t", "q", "5", "6/5", "6", "7/6", "7"]) @pytest.mark.parametrize("zeta", ["d", "t", "q", "5"]) @pytest.mark.parametrize("scftype", ["conv", "df"]) @pytest.mark.parametrize("der", ["ene", "grd", "hss"]) def test_zeta(scftype, zeta, der, request): if zeta not in ref[scftype][der]: pytest.skip() hf = psi4.geometry( """ H 0. 0. -1.64558411 F 0. 0. 0.08729475 symmetry c1 units bohr """ ) if zeta in "dtq56": basis = f"cc-pv{zeta}z" elif zeta == "6/5": basis = "cc-pv6z" elif zeta in ["7/6", "7"]: basis = "7zapa-nr" psi4.set_options( { # "e_convergence": 10, # "d_convergence": 9, "scf_type": { "df": "df", "conv": "direct", }[scftype], "basis": basis, } ) df_basis_scf = None if scftype == "df": if zeta in "dtq5": df_basis_scf = f"cc-pv{zeta}z-jkfit" elif zeta == "6/5": df_basis_scf = "cc-pv5z-jkfit" elif zeta in ["6", "7/6"]: df_basis_scf = "cc-pv6z-ri" elif scftype == "conv": # * only used for preiterations # * 7zapa gets aug-cc-pv6z-ri by default if zeta == "6": df_basis_scf = "cc-pv6z-ri" if df_basis_scf: psi4.set_options({"df_basis_scf": df_basis_scf}) if der == "hss": kwargs = {"ref_gradient": psi4.core.Matrix.from_array(ref[scftype]["grd"][zeta])} else: kwargs = {} ans, wfn = {"ene": psi4.energy, "grd": psi4.gradient, "hss": psi4.hessian,}[ der ]("hf", return_wfn=True, **kwargs) if isinstance(ans, float): print(ans) else: print(ans.np) assert compare_values(ref[scftype][der][zeta], ans, 6, f"Hartree--Fock {scftype} {der} {zeta}-zeta")
lgpl-3.0
[ 646, 4613, 199, 199, 504, 1275, 1208, 492, 627, 199, 199, 646, 20742, 20, 199, 646, 2680, 465, 980, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 2759, 199, 199, 1121, 275, 469, 272, 298, 5598, 582, 469, 267, 298, 6349, 582, 469, 288, 298, 68, 582, 446, 1960, 14, 614, 2635, 6094, 1876, 1643, 11382, 12, 288, 298, 84, 582, 446, 1960, 14, 18009, 614, 12289, 709, 1020, 2789, 12, 288, 298, 81, 582, 446, 1960, 14, 1690, 2114, 2426, 1194, 1257, 3172, 772, 12, 288, 298, 21, 582, 446, 1960, 14, 1780, 12212, 12967, 1355, 2658, 12, 288, 298, 22, 582, 446, 1960, 14, 1780, 1780, 1703, 11685, 15839, 1427, 12, 288, 298, 23, 582, 446, 1960, 14, 1780, 19000, 1477, 7979, 1644, 2835, 12, 267, 1660, 267, 298, 2587, 68, 582, 469, 288, 298, 68, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 17, 14, 2576, 8483, 13583, 69, 13, 996, 467, 359, 16, 12, 378, 12, 413, 14, 2576, 8483, 13583, 69, 13, 996, 13925, 288, 298, 84, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 20773, 10905, 1465, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 20773, 10905, 1465, 69, 13, 996, 13925, 288, 298, 81, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 29982, 12744, 2114, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 29982, 12744, 2114, 69, 13, 996, 13925, 288, 298, 21, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1229, 24495, 14832, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1229, 24495, 14832, 69, 13, 996, 13925, 288, 298, 22, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1229, 4999, 23166, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1229, 4999, 23166, 69, 13, 996, 13925, 288, 298, 23, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1477, 1407, 708, 1651, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1477, 1407, 708, 1651, 69, 13, 996, 13925, 267, 1660, 267, 298, 72, 385, 582, 469, 288, 298, 68, 582, 980, 14, 1144, 8, 355, 359, 490, 359, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 499, 14, 31830, 1344, 13218, 69, 13, 975, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 18, 14, 2277, 1081, 1184, 1367, 69, 13, 975, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 467, 490, 359, 18, 14, 31830, 1344, 13218, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 19, 14, 26172, 2824, 15268, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 467, 490, 359, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 1227, 14, 1401, 969, 1082, 614, 69, 13, 614, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 22, 14, 1401, 969, 1082, 614, 69, 13, 614, 467, 490, 5243, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 19, 14, 26172, 2824, 15268, 69, 13, 975, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 650, 14, 12248, 15112, 975, 69, 13, 975, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 467, 490, 5243, 18, 14, 2277, 1081, 1184, 1367, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 650, 14, 12248, 15112, 975, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 467, 490, 5243, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 22, 14, 1401, 969, 1082, 614, 69, 13, 614, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 1227, 14, 1401, 969, 1082, 614, 69, 13, 614, 467, 355, 1622, 288, 2318, 288, 298, 84, 582, 980, 14, 1144, 8, 355, 359, 490, 359, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 650, 14, 20, 13251, 1194, 1165, 69, 13, 1046, 12, 446, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 446, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 24, 14, 2564, 31558, 2824, 69, 13, 975, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 467, 490, 359, 19, 14, 20, 13251, 1194, 1165, 69, 13, 1046, 12, 413, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 21, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 446, 20, 14, 1479, 8312, 11551, 69, 13, 1046, 12, 446, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 959, 14, 23, 13730, 1789, 1229, 69, 13, 975, 467, 490, 5243, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 446, 21, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 1227, 14, 1153, 20103, 10848, 69, 13, 614, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 959, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 446, 22, 14, 1153, 20103, 10848, 69, 13, 614, 467, 490, 5243, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 20, 14, 1479, 8312, 11551, 69, 13, 1046, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 413, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 413, 14, 2259, 1401, 1367, 2025, 69, 13, 1046, 12, 446, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 467, 490, 5243, 24, 14, 2564, 31558, 2824, 69, 13, 975, 12, 446 ]
[ 4613, 199, 199, 504, 1275, 1208, 492, 627, 199, 199, 646, 20742, 20, 199, 646, 2680, 465, 980, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 2759, 199, 199, 1121, 275, 469, 272, 298, 5598, 582, 469, 267, 298, 6349, 582, 469, 288, 298, 68, 582, 446, 1960, 14, 614, 2635, 6094, 1876, 1643, 11382, 12, 288, 298, 84, 582, 446, 1960, 14, 18009, 614, 12289, 709, 1020, 2789, 12, 288, 298, 81, 582, 446, 1960, 14, 1690, 2114, 2426, 1194, 1257, 3172, 772, 12, 288, 298, 21, 582, 446, 1960, 14, 1780, 12212, 12967, 1355, 2658, 12, 288, 298, 22, 582, 446, 1960, 14, 1780, 1780, 1703, 11685, 15839, 1427, 12, 288, 298, 23, 582, 446, 1960, 14, 1780, 19000, 1477, 7979, 1644, 2835, 12, 267, 1660, 267, 298, 2587, 68, 582, 469, 288, 298, 68, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 17, 14, 2576, 8483, 13583, 69, 13, 996, 467, 359, 16, 12, 378, 12, 413, 14, 2576, 8483, 13583, 69, 13, 996, 13925, 288, 298, 84, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 20773, 10905, 1465, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 20773, 10905, 1465, 69, 13, 996, 13925, 288, 298, 81, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 29982, 12744, 2114, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 29982, 12744, 2114, 69, 13, 996, 13925, 288, 298, 21, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1229, 24495, 14832, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1229, 24495, 14832, 69, 13, 996, 13925, 288, 298, 22, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1229, 4999, 23166, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1229, 4999, 23166, 69, 13, 996, 13925, 288, 298, 23, 582, 980, 14, 1144, 4038, 16, 12, 378, 12, 446, 18, 14, 1477, 1407, 708, 1651, 69, 13, 996, 467, 359, 16, 12, 378, 12, 499, 14, 1477, 1407, 708, 1651, 69, 13, 996, 13925, 267, 1660, 267, 298, 72, 385, 582, 469, 288, 298, 68, 582, 980, 14, 1144, 8, 355, 359, 490, 359, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 499, 14, 31830, 1344, 13218, 69, 13, 975, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 18, 14, 2277, 1081, 1184, 1367, 69, 13, 975, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 467, 490, 359, 18, 14, 31830, 1344, 13218, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 19, 14, 26172, 2824, 15268, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 467, 490, 359, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 1227, 14, 1401, 969, 1082, 614, 69, 13, 614, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 22, 14, 1401, 969, 1082, 614, 69, 13, 614, 467, 490, 5243, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 19, 14, 26172, 2824, 15268, 69, 13, 975, 12, 446, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 650, 14, 12248, 15112, 975, 69, 13, 975, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 467, 490, 5243, 18, 14, 2277, 1081, 1184, 1367, 69, 13, 975, 12, 446, 17, 14, 1079, 7806, 1257, 69, 13, 996, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 650, 14, 12248, 15112, 975, 69, 13, 975, 12, 413, 14, 1079, 7806, 1257, 69, 13, 996, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 467, 490, 5243, 19, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 959, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 446, 22, 14, 1401, 969, 1082, 614, 69, 13, 614, 12, 650, 14, 25, 2114, 1555, 13793, 69, 13, 975, 12, 446, 21, 14, 1081, 1651, 845, 969, 69, 13, 975, 12, 1227, 14, 1401, 969, 1082, 614, 69, 13, 614, 467, 355, 1622, 288, 2318, 288, 298, 84, 582, 980, 14, 1144, 8, 355, 359, 490, 359, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 650, 14, 20, 13251, 1194, 1165, 69, 13, 1046, 12, 446, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 446, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 24, 14, 2564, 31558, 2824, 69, 13, 975, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 467, 490, 359, 19, 14, 20, 13251, 1194, 1165, 69, 13, 1046, 12, 413, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 21, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 446, 20, 14, 1479, 8312, 11551, 69, 13, 1046, 12, 446, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 959, 14, 23, 13730, 1789, 1229, 69, 13, 975, 467, 490, 5243, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 446, 21, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 1227, 14, 1153, 20103, 10848, 69, 13, 614, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 959, 14, 23, 13730, 1789, 1229, 69, 13, 975, 12, 446, 22, 14, 1153, 20103, 10848, 69, 13, 614, 467, 490, 5243, 17, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 446, 20, 14, 1479, 8312, 11551, 69, 13, 1046, 12, 959, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 12, 413, 14, 20, 7507, 1046, 2824, 69, 13, 996, 12, 413, 14, 2259, 1401, 1367, 2025, 69, 13, 1046, 12, 446, 21, 14, 1367, 2905, 1401, 2869, 69, 13, 975, 467, 490, 5243, 24, 14, 2564, 31558, 2824, 69, 13, 975, 12, 446, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
katsko/pybbm
pybb/south_migrations/0015_autosubscribe.py
11
10047
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models from pybb.compat import get_image_field_full_name, get_user_model_path, get_user_frozen_models AUTH_USER = get_user_model_path() class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Profile.autosubscribe' db.add_column('pybb_profile', 'autosubscribe', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) def backwards(self, orm): # Deleting field 'Profile.autosubscribe' db.delete_column('pybb_profile', 'autosubscribe') 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'}) }, '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'}) }, 'pybb.attachment': { 'Meta': {'object_name': 'Attachment'}, 'content_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'hash': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.TextField', [], {}), 'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attachments'", 'to': "orm['pybb.Post']"}), 'size': ('django.db.models.fields.IntegerField', [], {}) }, 'pybb.category': { 'Meta': {'ordering': "['position']", 'object_name': 'Category'}, 'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'position': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}) }, 'pybb.forum': { 'Meta': {'ordering': "['position']", 'object_name': 'Forum'}, 'category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'forums'", 'to': "orm['pybb.Category']"}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'headline': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'moderators': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['%s']"% AUTH_USER, 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'position': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'post_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'readed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'readed_forums'", 'symmetrical': 'False', 'through': "orm['pybb.ForumReadTracker']", 'to': "orm['%s']"% AUTH_USER}), 'topic_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}) }, 'pybb.forumreadtracker': { 'Meta': {'object_name': 'ForumReadTracker'}, 'forum': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['pybb.Forum']", 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'time_stamp': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']"% AUTH_USER}) }, 'pybb.post': { 'Meta': {'ordering': "['created']", 'object_name': 'Post'}, 'body': ('django.db.models.fields.TextField', [], {}), 'body_html': ('django.db.models.fields.TextField', [], {}), 'body_text': ('django.db.models.fields.TextField', [], {}), 'created': ('django.db.models.fields.DateTimeField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'markup': ('django.db.models.fields.CharField', [], {'default': "'bbcode'", 'max_length': '15'}), 'topic': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['pybb.Topic']"}), 'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['%s']"% AUTH_USER}), 'user_ip': ('django.db.models.fields.IPAddressField', [], {'default': "'0.0.0.0'", 'max_length': '15', 'blank': 'True'}) }, 'pybb.profile': { 'Meta': {'object_name': 'Profile'}, 'autosubscribe': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'avatar': (get_image_field_full_name(), [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'default': "'Russian'", 'max_length': '10', 'blank': 'True'}), 'markup': ('django.db.models.fields.CharField', [], {'default': "'bbcode'", 'max_length': '15'}), 'post_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'show_signatures': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'signature': ('django.db.models.fields.TextField', [], {'max_length': '1024', 'blank': 'True'}), 'signature_html': ('django.db.models.fields.TextField', [], {'max_length': '1054', 'blank': 'True'}), 'time_zone': ('django.db.models.fields.FloatField', [], {'default': '3.0'}), 'user': ('annoying.fields.AutoOneToOneField', [], {'related_name': "'pybb_profile'", 'unique': 'True', 'to': "orm['%s']"% AUTH_USER}) }, 'pybb.topic': { 'Meta': {'ordering': "['-created']", 'object_name': 'Topic'}, 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'forum': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'topics'", 'to': "orm['pybb.Forum']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'post_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'readed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'readed_topics'", 'symmetrical': 'False', 'through': "orm['pybb.TopicReadTracker']", 'to': "orm['%s']"% AUTH_USER}), 'sticky': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'subscribers': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subscriptions'", 'blank': 'True', 'to': "orm['%s']"% AUTH_USER}), 'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']"% AUTH_USER}), 'views': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}) }, 'pybb.topicreadtracker': { 'Meta': {'object_name': 'TopicReadTracker'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'time_stamp': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'topic': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['pybb.Topic']", 'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']"% AUTH_USER}) } } models.update(get_user_frozen_models(AUTH_USER)) complete_apps = ['pybb']
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, 504, 1134, 2501, 14, 5819, 492, 664, 63, 1569, 63, 698, 63, 2861, 63, 354, 12, 664, 63, 751, 63, 1238, 63, 515, 12, 664, 63, 751, 63, 11202, 63, 992, 421, 199, 5580, 63, 3791, 275, 664, 63, 751, 63, 1238, 63, 515, 342, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 901, 283, 5736, 14, 29764, 456, 5355, 7, 267, 1592, 14, 525, 63, 2301, 360, 647, 2501, 63, 2913, 297, 283, 29764, 456, 5355, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 901, 283, 5736, 14, 29764, 456, 5355, 7, 267, 1592, 14, 1807, 63, 2301, 360, 647, 2501, 63, 2913, 297, 283, 29764, 456, 5355, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 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, 647, 2501, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 2267, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2167, 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, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 515, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 1932, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 15855, 4662, 283, 475, 356, 298, 1025, 459, 647, 2501, 14, 6564, 6097, 288, 283, 890, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 5009, 267, 1660, 267, 283, 647, 2501, 14, 3710, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 3124, 6256, 283, 785, 63, 354, 356, 283, 7841, 2267, 288, 283, 5642, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 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, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 3124, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 647, 2501, 14, 10044, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 3124, 6256, 283, 785, 63, 354, 356, 283, 1858, 453, 2267, 288, 283, 3710, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 10044, 83, 4662, 283, 475, 356, 298, 1025, 459, 647, 2501, 14, 7841, 6097, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549 ]
[ 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, 504, 1134, 2501, 14, 5819, 492, 664, 63, 1569, 63, 698, 63, 2861, 63, 354, 12, 664, 63, 751, 63, 1238, 63, 515, 12, 664, 63, 751, 63, 11202, 63, 992, 421, 199, 5580, 63, 3791, 275, 664, 63, 751, 63, 1238, 63, 515, 342, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 901, 283, 5736, 14, 29764, 456, 5355, 7, 267, 1592, 14, 525, 63, 2301, 360, 647, 2501, 63, 2913, 297, 283, 29764, 456, 5355, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 901, 283, 5736, 14, 29764, 456, 5355, 7, 267, 1592, 14, 1807, 63, 2301, 360, 647, 2501, 63, 2913, 297, 283, 29764, 456, 5355, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 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, 647, 2501, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 2267, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2167, 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, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 515, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 1932, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 15855, 4662, 283, 475, 356, 298, 1025, 459, 647, 2501, 14, 6564, 6097, 288, 283, 890, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 5009, 267, 1660, 267, 283, 647, 2501, 14, 3710, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 3124, 6256, 283, 785, 63, 354, 356, 283, 7841, 2267, 288, 283, 5642, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 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, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 3124, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 647, 2501, 14, 10044, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 3124, 6256, 283, 785, 63, 354, 356, 283, 1858, 453, 2267, 288, 283, 3710, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 10044, 83, 4662, 283, 475, 356, 298, 1025, 459, 647, 2501, 14, 7841, 6097, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Aplopio/document-converter
converters/utilities.py
1
4138
import sys import re import os import shutil import logging as log sys.path.append('..') from config import OUTPUT_FOLDER, UPLOAD_FOLDER PARENT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) TMP_DIR = os.path.join(PARENT_DIR, UPLOAD_FOLDER) from html_pdf import HtmlPdf from html_txt import HtmlTxt from pdf_html import PdfHtml from txt_html import TxtHtml from doc_pdf import DocPdf from ppt_pdf import PptPdf from rtf_pdf import RtfPdf from utils import get_file_extension from file_manager import FileManager AVAILABLE_CONVERTERS = [(HtmlPdf, 'htmlpdf'), (HtmlTxt, 'htmltxt'), (PdfHtml, 'pdfhtml'), (TxtHtml, 'txthtml'), (DocPdf, 'docpdf'), (PptPdf, 'pptpdf'), (RtfPdf, 'rtfpdf'), ] def class_selector(input_format, output_format, result=None): result = result or [] if input_format == output_format: return result direct_converter = get_direct_converter(input_format, output_format) if direct_converter: result.append(direct_converter) return result input_regex = make_regex(input_format) input_matches = get_input_matches(input_regex) for input_match in input_matches: converter, converter_expression = input_match intermediate_format = get_intermediate_format(converter_expression, input_format) result.append(input_match) converter_list = class_selector(intermediate_format, output_format, result) if converter_list: return converter_list else: result.pop() def get_intermediate_format(converter_expression, input_format): return re.sub(input_format, '', converter_expression) def get_input_matches(input_regex): return [(converter, expression) for converter, expression in AVAILABLE_CONVERTERS if input_regex.match(expression)] def make_regex(format_string): return re.compile('^%s'%format_string) def get_direct_converter(input_format, output_format): converter_expression = '%s%s'%(input_format, output_format) for converter, expression in AVAILABLE_CONVERTERS: if re.match(converter_expression, expression): return (converter, expression) def get_input_format(input_files_objects): sample_input_file = input_files_objects[0].get_input_file_path() input_format = get_file_extension(sample_input_file) return input_format def set_flags_of_file_objects(input_files_objects, output_files_objects): for input_file_object, output_file_object in zip(input_files_objects, output_files_objects): if (not output_file_object) or output_file_object == input_file_object: input_file_object.converted = False else: output_file_name = os.path.basename( output_file_object.get_input_file_path()) os.system('mv %s %s' % ( output_file_object.get_input_file_path(), OUTPUT_FOLDER)) input_file_object.set_output_file_path( os.path.join(OUTPUT_FOLDER, output_file_name)) input_file_object.converted = True return input_files_objects def get_files_objects(files_paths): files_objects = [] for file_path in files_paths: if file_path: file_object = FileManager(None, input_file_path=file_path) files_objects.append(file_object) else: files_objects.append(None) return files_objects def handle_failed_conversion(input_file): if not input_file or not os.path.isfile(input_file): return failed_conversion_dir = os.path.join(TMP_DIR, 'failed_conversions') if not os.path.isdir(failed_conversion_dir): os.makedirs(failed_conversion_dir) filename = os.path.basename(input_file) try: shutil.copyfile(input_file, os.path.join(failed_conversion_dir, filename)) except IOError, ie: log.error(ie)
mit
[ 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 5145, 199, 646, 2050, 465, 943, 199, 199, 1274, 14, 515, 14, 740, 24893, 358, 199, 199, 504, 1101, 492, 18746, 63, 19041, 12, 7215, 7405, 63, 19041, 199, 20562, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 29658, 199, 17983, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 20562, 63, 3022, 12, 7215, 7405, 63, 19041, 9, 199, 199, 504, 3517, 63, 5607, 492, 20880, 48, 1587, 199, 504, 3517, 63, 2424, 492, 20880, 32199, 199, 504, 11249, 63, 1360, 492, 510, 1587, 12957, 199, 504, 9444, 63, 1360, 492, 377, 400, 12957, 199, 504, 1382, 63, 5607, 492, 5454, 48, 1587, 199, 504, 299, 541, 63, 5607, 492, 510, 541, 48, 1587, 199, 504, 519, 3249, 63, 5607, 492, 820, 3249, 48, 1587, 199, 199, 504, 3778, 492, 664, 63, 493, 63, 3435, 199, 199, 504, 570, 63, 2609, 492, 3814, 2988, 421, 199, 17377, 63, 1864, 2111, 1157, 51, 275, 3842, 12957, 48, 1587, 12, 283, 1360, 5607, 659, 334, 12957, 32199, 12, 283, 1360, 2424, 659, 717, 334, 48, 1587, 12957, 12, 283, 5607, 1360, 659, 334, 32199, 12957, 12, 283, 2347, 273, 18866, 659, 717, 334, 3768, 48, 1587, 12, 283, 1301, 5607, 659, 334, 48, 541, 48, 1587, 12, 283, 80, 541, 5607, 659, 717, 334, 50, 3249, 48, 1587, 12, 283, 2591, 3997, 1587, 659, 1622, 421, 199, 318, 1021, 63, 6662, 8, 1210, 63, 908, 12, 1072, 63, 908, 12, 754, 29, 403, 304, 272, 754, 275, 754, 503, 942, 272, 340, 1324, 63, 908, 508, 1072, 63, 908, 26, 267, 372, 754, 272, 4125, 63, 11256, 275, 664, 63, 2275, 63, 11256, 8, 1210, 63, 908, 12, 1072, 63, 908, 9, 272, 340, 4125, 63, 11256, 26, 267, 754, 14, 740, 8, 2275, 63, 11256, 9, 267, 372, 754, 272, 1324, 63, 3821, 275, 1852, 63, 3821, 8, 1210, 63, 908, 9, 272, 1324, 63, 6742, 275, 664, 63, 1210, 63, 6742, 8, 1210, 63, 3821, 9, 272, 367, 1324, 63, 1431, 315, 1324, 63, 6742, 26, 267, 11109, 12, 11109, 63, 5599, 275, 1324, 63, 1431, 267, 13197, 63, 908, 275, 664, 63, 15940, 63, 908, 8, 11256, 63, 5599, 12, 10028, 1324, 63, 908, 9, 267, 754, 14, 740, 8, 1210, 63, 1431, 9, 267, 11109, 63, 513, 275, 1021, 63, 6662, 8, 15940, 63, 908, 12, 1072, 63, 908, 12, 3147, 754, 9, 267, 340, 11109, 63, 513, 26, 288, 372, 11109, 63, 513, 267, 587, 26, 288, 754, 14, 1935, 342, 421, 199, 318, 664, 63, 15940, 63, 908, 8, 11256, 63, 5599, 12, 1324, 63, 908, 304, 272, 372, 295, 14, 954, 8, 1210, 63, 908, 12, 3260, 11109, 63, 5599, 9, 421, 199, 318, 664, 63, 1210, 63, 6742, 8, 1210, 63, 3821, 304, 272, 372, 3842, 11256, 12, 3965, 9, 288, 367, 11109, 12, 3965, 315, 437, 54, 6593, 2617, 63, 1864, 2111, 1157, 51, 288, 340, 1324, 63, 3821, 14, 1431, 8, 5599, 1874, 421, 199, 318, 1852, 63, 3821, 8, 908, 63, 875, 304, 272, 372, 295, 14, 2014, 9097, 5, 83, 5956, 908, 63, 875, 9, 421, 199, 318, 664, 63, 2275, 63, 11256, 8, 1210, 63, 908, 12, 1072, 63, 908, 304, 272, 11109, 63, 5599, 275, 1543, 83, 5, 83, 13328, 1210, 63, 908, 12, 1072, 63, 908, 9, 272, 367, 11109, 12, 3965, 315, 437, 54, 6593, 2617, 63, 1864, 2111, 1157, 51, 26, 267, 340, 295, 14, 1431, 8, 11256, 63, 5599, 12, 3965, 304, 288, 372, 334, 11256, 12, 3965, 9, 421, 199, 318, 664, 63, 1210, 63, 908, 8, 1210, 63, 1725, 63, 1462, 304, 272, 2690, 63, 1210, 63, 493, 275, 1324, 63, 1725, 63, 1462, 59, 16, 1055, 362, 63, 1210, 63, 493, 63, 515, 342, 272, 1324, 63, 908, 275, 664, 63, 493, 63, 3435, 8, 3271, 63, 1210, 63, 493, 9, 272, 372, 1324, 63, 908, 421, 199, 318, 663, 63, 2469, 63, 1618, 63, 493, 63, 1462, 8, 1210, 63, 1725, 63, 1462, 12, 1072, 63, 1725, 63, 1462, 304, 272, 367, 1324, 63, 493, 63, 785, 12, 1072, 63, 493, 63, 785, 315, 3482, 8, 1210, 63, 1725, 63, 1462, 12, 9349, 1072, 63, 1725, 63, 1462, 304, 267, 340, 334, 1397, 1072, 63, 493, 63, 785, 9, 503, 1072, 63, 493, 63, 785, 508, 1324, 63, 493, 63, 785, 26, 288, 1324, 63, 493, 63, 785, 14, 22818, 275, 756, 267, 587, 26, 288, 1072, 63, 493, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 355, 1072, 63, 493, 63, 785, 14, 362, 63, 1210, 63, 493, 63, 515, 1012, 288, 747, 14, 2253, 360, 12393, 450, 83, 450, 83, 7, 450, 334, 355, 1072, 63, 493, 63, 785, 14, 362, 63, 1210, 63, 493, 63, 515, 1062, 18746, 63, 19041, 430, 288, 1324, 63, 493, 63, 785, 14, 409, 63, 1199, 63, 493, 63, 515, 8, 355, 747, 14, 515, 14, 904, 8, 8414, 63, 19041, 12, 1072, 63, 493, 63, 354, 430, 288, 1324, 63, 493, 63, 785, 14, 22818, 275, 715, 272, 372, 1324, 63, 1725, 63, 1462, 421, 199, 318, 664, 63, 1725, 63, 1462, 8, 1725, 63, 3771, 304, 272, 1584, 63, 1462, 275, 942, 272, 367, 570, 63, 515, 315, 1584, 63, 3771, 26, 267, 340, 570, 63, 515, 26, 288, 570, 63, 785, 275, 3814, 2988, 8, 403, 12, 1324, 63, 493, 63, 515, 29, 493, 63, 515, 9, 288, 1584, 63, 1462, 14, 740, 8, 493, 63, 785, 9, 267, 587, 26, 288, 1584, 63, 1462, 14, 740, 8, 403, 9, 272, 372, 1584, 63, 1462, 421, 199, 318, 2429, 63, 4892, 63, 15083, 8, 1210, 63, 493, 304, 272, 340, 440, 1324, 63, 493, 503, 440, 747, 14, 515, 14, 6292, 8, 1210, 63, 493, 304, 267, 372, 272, 3405, 63, 15083, 63, 694, 275, 747, 14, 515, 14, 904, 8, 17983, 63, 3022, 12, 283, 4892, 63, 388, 6234, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 4892, 63, 15083, 63, 694, 304, 267 ]
[ 984, 199, 646, 295, 199, 646, 747, 199, 646, 5145, 199, 646, 2050, 465, 943, 199, 199, 1274, 14, 515, 14, 740, 24893, 358, 199, 199, 504, 1101, 492, 18746, 63, 19041, 12, 7215, 7405, 63, 19041, 199, 20562, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 29658, 199, 17983, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 20562, 63, 3022, 12, 7215, 7405, 63, 19041, 9, 199, 199, 504, 3517, 63, 5607, 492, 20880, 48, 1587, 199, 504, 3517, 63, 2424, 492, 20880, 32199, 199, 504, 11249, 63, 1360, 492, 510, 1587, 12957, 199, 504, 9444, 63, 1360, 492, 377, 400, 12957, 199, 504, 1382, 63, 5607, 492, 5454, 48, 1587, 199, 504, 299, 541, 63, 5607, 492, 510, 541, 48, 1587, 199, 504, 519, 3249, 63, 5607, 492, 820, 3249, 48, 1587, 199, 199, 504, 3778, 492, 664, 63, 493, 63, 3435, 199, 199, 504, 570, 63, 2609, 492, 3814, 2988, 421, 199, 17377, 63, 1864, 2111, 1157, 51, 275, 3842, 12957, 48, 1587, 12, 283, 1360, 5607, 659, 334, 12957, 32199, 12, 283, 1360, 2424, 659, 717, 334, 48, 1587, 12957, 12, 283, 5607, 1360, 659, 334, 32199, 12957, 12, 283, 2347, 273, 18866, 659, 717, 334, 3768, 48, 1587, 12, 283, 1301, 5607, 659, 334, 48, 541, 48, 1587, 12, 283, 80, 541, 5607, 659, 717, 334, 50, 3249, 48, 1587, 12, 283, 2591, 3997, 1587, 659, 1622, 421, 199, 318, 1021, 63, 6662, 8, 1210, 63, 908, 12, 1072, 63, 908, 12, 754, 29, 403, 304, 272, 754, 275, 754, 503, 942, 272, 340, 1324, 63, 908, 508, 1072, 63, 908, 26, 267, 372, 754, 272, 4125, 63, 11256, 275, 664, 63, 2275, 63, 11256, 8, 1210, 63, 908, 12, 1072, 63, 908, 9, 272, 340, 4125, 63, 11256, 26, 267, 754, 14, 740, 8, 2275, 63, 11256, 9, 267, 372, 754, 272, 1324, 63, 3821, 275, 1852, 63, 3821, 8, 1210, 63, 908, 9, 272, 1324, 63, 6742, 275, 664, 63, 1210, 63, 6742, 8, 1210, 63, 3821, 9, 272, 367, 1324, 63, 1431, 315, 1324, 63, 6742, 26, 267, 11109, 12, 11109, 63, 5599, 275, 1324, 63, 1431, 267, 13197, 63, 908, 275, 664, 63, 15940, 63, 908, 8, 11256, 63, 5599, 12, 10028, 1324, 63, 908, 9, 267, 754, 14, 740, 8, 1210, 63, 1431, 9, 267, 11109, 63, 513, 275, 1021, 63, 6662, 8, 15940, 63, 908, 12, 1072, 63, 908, 12, 3147, 754, 9, 267, 340, 11109, 63, 513, 26, 288, 372, 11109, 63, 513, 267, 587, 26, 288, 754, 14, 1935, 342, 421, 199, 318, 664, 63, 15940, 63, 908, 8, 11256, 63, 5599, 12, 1324, 63, 908, 304, 272, 372, 295, 14, 954, 8, 1210, 63, 908, 12, 3260, 11109, 63, 5599, 9, 421, 199, 318, 664, 63, 1210, 63, 6742, 8, 1210, 63, 3821, 304, 272, 372, 3842, 11256, 12, 3965, 9, 288, 367, 11109, 12, 3965, 315, 437, 54, 6593, 2617, 63, 1864, 2111, 1157, 51, 288, 340, 1324, 63, 3821, 14, 1431, 8, 5599, 1874, 421, 199, 318, 1852, 63, 3821, 8, 908, 63, 875, 304, 272, 372, 295, 14, 2014, 9097, 5, 83, 5956, 908, 63, 875, 9, 421, 199, 318, 664, 63, 2275, 63, 11256, 8, 1210, 63, 908, 12, 1072, 63, 908, 304, 272, 11109, 63, 5599, 275, 1543, 83, 5, 83, 13328, 1210, 63, 908, 12, 1072, 63, 908, 9, 272, 367, 11109, 12, 3965, 315, 437, 54, 6593, 2617, 63, 1864, 2111, 1157, 51, 26, 267, 340, 295, 14, 1431, 8, 11256, 63, 5599, 12, 3965, 304, 288, 372, 334, 11256, 12, 3965, 9, 421, 199, 318, 664, 63, 1210, 63, 908, 8, 1210, 63, 1725, 63, 1462, 304, 272, 2690, 63, 1210, 63, 493, 275, 1324, 63, 1725, 63, 1462, 59, 16, 1055, 362, 63, 1210, 63, 493, 63, 515, 342, 272, 1324, 63, 908, 275, 664, 63, 493, 63, 3435, 8, 3271, 63, 1210, 63, 493, 9, 272, 372, 1324, 63, 908, 421, 199, 318, 663, 63, 2469, 63, 1618, 63, 493, 63, 1462, 8, 1210, 63, 1725, 63, 1462, 12, 1072, 63, 1725, 63, 1462, 304, 272, 367, 1324, 63, 493, 63, 785, 12, 1072, 63, 493, 63, 785, 315, 3482, 8, 1210, 63, 1725, 63, 1462, 12, 9349, 1072, 63, 1725, 63, 1462, 304, 267, 340, 334, 1397, 1072, 63, 493, 63, 785, 9, 503, 1072, 63, 493, 63, 785, 508, 1324, 63, 493, 63, 785, 26, 288, 1324, 63, 493, 63, 785, 14, 22818, 275, 756, 267, 587, 26, 288, 1072, 63, 493, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 355, 1072, 63, 493, 63, 785, 14, 362, 63, 1210, 63, 493, 63, 515, 1012, 288, 747, 14, 2253, 360, 12393, 450, 83, 450, 83, 7, 450, 334, 355, 1072, 63, 493, 63, 785, 14, 362, 63, 1210, 63, 493, 63, 515, 1062, 18746, 63, 19041, 430, 288, 1324, 63, 493, 63, 785, 14, 409, 63, 1199, 63, 493, 63, 515, 8, 355, 747, 14, 515, 14, 904, 8, 8414, 63, 19041, 12, 1072, 63, 493, 63, 354, 430, 288, 1324, 63, 493, 63, 785, 14, 22818, 275, 715, 272, 372, 1324, 63, 1725, 63, 1462, 421, 199, 318, 664, 63, 1725, 63, 1462, 8, 1725, 63, 3771, 304, 272, 1584, 63, 1462, 275, 942, 272, 367, 570, 63, 515, 315, 1584, 63, 3771, 26, 267, 340, 570, 63, 515, 26, 288, 570, 63, 785, 275, 3814, 2988, 8, 403, 12, 1324, 63, 493, 63, 515, 29, 493, 63, 515, 9, 288, 1584, 63, 1462, 14, 740, 8, 493, 63, 785, 9, 267, 587, 26, 288, 1584, 63, 1462, 14, 740, 8, 403, 9, 272, 372, 1584, 63, 1462, 421, 199, 318, 2429, 63, 4892, 63, 15083, 8, 1210, 63, 493, 304, 272, 340, 440, 1324, 63, 493, 503, 440, 747, 14, 515, 14, 6292, 8, 1210, 63, 493, 304, 267, 372, 272, 3405, 63, 15083, 63, 694, 275, 747, 14, 515, 14, 904, 8, 17983, 63, 3022, 12, 283, 4892, 63, 388, 6234, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 4892, 63, 15083, 63, 694, 304, 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,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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 ]
codilime/veles
python/veles/scli/client.py
1
13837
# Copyright 2017 CodiLime # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import unicode_literals import socket import ssl import msgpack from veles.proto import messages, msgpackwrap from veles.proto.messages import PROTO_VERSION from veles.schema import nodeid from veles.util import helpers class Client(object): def __init__(self, sock, key, name='scli', version='1.0', description='', type='scli', quit_on_close=False): self.sock = sock wrapper = msgpackwrap.MsgpackWrapper() self.unpacker = wrapper.unpacker self.packer = wrapper.packer self.client_name = name self.client_version = version self.client_description = description self.client_type = type self.quit_on_close = quit_on_close self._authorize(helpers.prepare_auth_key(key)) def _authorize(self, key): self.sock.sendall(key) self.send_msg(messages.MsgConnect( proto_version=PROTO_VERSION, client_name=self.client_name, client_version=self.client_version, client_description=self.client_description, client_type=self.client_type, quit_on_close=self.quit_on_close, )) pkt = self.getpkt() if isinstance(pkt, messages.MsgConnected): print('Connected to server: {}'.format(pkt.server_name)) elif isinstance(pkt, messages.MsgConnectionError): raise pkt.err else: print(pkt) raise Exception('weird reply when attempting to connect') def getpkt(self): while True: try: return messages.MsgpackMsg.load(self.unpacker.unpack()) except msgpack.OutOfData: pass data = self.sock.recv(1024) if not data: raise Exception("end of file") self.unpacker.feed(data) def send_msg(self, msg): self.sock.sendall(self.packer.pack(msg.dump())) def request(self, msg): self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgRequestAck) and pkt.rid == 0: return msg.id elif isinstance(pkt, messages.MsgRequestError) and pkt.rid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to request') def create(self, parent, tags=set(), attr={}, data={}, bindata={}, pos=(None, None)): msg = messages.MsgCreate( id=nodeid.NodeID(), parent=parent, pos_start=pos[0], pos_end=pos[1], tags=tags, attr=attr, data=data, bindata=bindata, rid=0, ) self.request(msg) return msg.id def delete(self, obj): msg = messages.MsgDelete( id=obj, rid=0 ) self.request(msg) def set_parent(self, obj, parent): msg = messages.MsgSetParent( id=obj, parent=parent, rid=0 ) self.request(msg) def set_pos(self, obj, start, end): msg = messages.MsgSetPos( id=obj, pos_start=start, pos_end=end, rid=0 ) self.request(msg) def add_tag(self, obj, tag): msg = messages.MsgAddTag( id=obj, tag=tag, rid=0 ) self.request(msg) def del_tag(self, obj, tag): msg = messages.MsgDelTag( id=obj, tag=tag, rid=0 ) self.request(msg) def set_attr(self, obj, key, data): msg = messages.MsgSetAttr( id=obj, key=key, data=data, rid=0 ) self.request(msg) def set_data(self, obj, key, data): msg = messages.MsgSetData( id=obj, rid=0, key=key, data=data, ) self.request(msg) def set_bindata(self, obj, key, start, data, truncate=False): msg = messages.MsgSetBinData( id=obj, rid=0, key=key, start=start, data=data, truncate=truncate, ) self.request(msg) def get(self, obj): msg = messages.MsgGet( id=obj, qid=0, ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgGetReply) and pkt.qid == 0: return pkt.obj elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get') def get_sub(self, obj): msg = messages.MsgGet( id=obj, qid=0, sub=True, ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgGetReply) and pkt.qid == 0: yield pkt.obj elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get') def get_data(self, obj, key): msg = messages.MsgGetData( id=obj, qid=0, key=key, ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgGetDataReply) and pkt.qid == 0: return pkt.data elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get_data') def get_data_sub(self, obj, key): msg = messages.MsgGetData( id=obj, qid=0, key=key, sub=True ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgGetDataReply) and pkt.qid == 0: yield pkt.data elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get_data') def get_bindata(self, obj, key, start=0, end=None): msg = messages.MsgGetBinData( id=obj, qid=0, key=key, start=start, end=end, ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgGetBinDataReply) and pkt.qid == 0: return pkt.data elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get_bindata') def get_bindata_sub(self, obj, key, start=0, end=None): msg = messages.MsgGetBinData( id=obj, qid=0, key=key, start=start, end=end, sub=True, ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgGetBinDataReply) and pkt.qid == 0: yield pkt.data elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: raise Exception('weird reply to get_bindata') def list(self, obj): msg = messages.MsgGetList( qid=0, parent=obj, ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgGetListReply) and pkt.qid == 0: return pkt.objs elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to list') def list_sub(self, obj): msg = messages.MsgGetList( qid=0, parent=obj, sub=True ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgGetListReply) and pkt.qid == 0: yield pkt elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to list') def query(self, obj, sig, params, checks=None): params = sig.params.dump(params) msg = messages.MsgGetQuery( qid=0, node=obj, query=sig.name, params=params, trace=checks is not None ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgGetQueryReply) and pkt.qid == 0: if checks is not None: checks += pkt.checks return sig.result.load(pkt.result) elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: if checks is not None: checks += pkt.checks raise pkt.err else: print(pkt) raise Exception('weird reply to get_query') def query_sub(self, obj, sig, params, checks=None): params = sig.params.dump(params) msg = messages.MsgGetQuery( qid=0, node=obj, query=sig.name, params=params, trace=checks is not None, sub=True ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgGetQueryReply) and pkt.qid == 0: if checks is not None: checks += pkt.checks yield sig.result.load(pkt.result) elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: if checks is not None: checks += pkt.checks raise pkt.err else: print(pkt) raise Exception('weird reply to get_query') def run_method(self, obj, sig, params): params = sig.params.dump(params) msg = messages.MsgMethodRun( mid=0, node=obj, method=sig.name, params=params ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgMethodResult) and pkt.mid == 0: return sig.result.load(pkt.result) elif isinstance(pkt, messages.MsgMethodError) and pkt.mid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to run_method') def run_broadcast(self, sig, params): params = sig.params.dump(params) msg = messages.MsgBroadcastRun( bid=0, broadcast=sig.name, params=params ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgBroadcastResult) and pkt.bid == 0: return [sig.result.load(result) for result in pkt.results] else: print(pkt) raise Exception('weird reply to run_broadcast') def list_connections(self): msg = messages.MsgListConnections( qid=0, ) self.send_msg(msg) pkt = self.getpkt() if isinstance(pkt, messages.MsgConnectionsReply) and pkt.qid == 0: return pkt.connections elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to list_connections') def list_connections_sub(self): msg = messages.MsgListConnections( qid=0, sub=True ) self.send_msg(msg) while True: pkt = self.getpkt() if isinstance(pkt, messages.MsgConnectionsReply) and pkt.qid == 0: yield pkt elif isinstance(pkt, messages.MsgQueryError) and pkt.qid == 0: raise pkt.err else: print(pkt) raise Exception('weird reply to list_connections') class UnixClient(Client): def __init__(self, path, key, **kwargs): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(path) super(UnixClient, self).__init__(sock, key, **kwargs) class TcpClient(Client): def __init__(self, ip, port, key, **kwargs): sock = socket.create_connection((ip, port)) super(TcpClient, self).__init__(sock, key, **kwargs) class SslClient(Client): def __init__(self, ip, port, key, fingerprint, **kwargs): sock = socket.create_connection((ip, port)) sc = ssl.SSLContext() sock = sc.wrap_socket(sock) cert = sock.getpeercert(True) helpers.validate_cert(cert, fingerprint) super(SslClient, self).__init__(sock, key, **kwargs) def create_client(url): url = helpers.parse_url(url) if url.scheme == helpers.UrlScheme.UNIX_SCHEME: return UnixClient(url.path, url.auth_key) elif url.scheme == helpers.UrlScheme.TCP_SCHEME: return TcpClient(url.host, url.port, url.auth_key) elif url.scheme == helpers.UrlScheme.SSL_SCHEME: return SslClient(url.host, url.port, url.auth_key, url.fingerprint) else: raise ValueError('Wrong scheme provided!')
apache-2.0
[ 3, 1898, 9708, 1849, 328, 44, 1036, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2838, 199, 646, 6149, 199, 199, 646, 26635, 199, 199, 504, 11199, 2978, 14, 2625, 492, 3788, 12, 26635, 3823, 199, 504, 11199, 2978, 14, 2625, 14, 3431, 492, 3611, 2566, 63, 4612, 199, 504, 11199, 2978, 14, 3629, 492, 1031, 344, 199, 504, 11199, 2978, 14, 1974, 492, 10897, 421, 199, 533, 6810, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6771, 12, 790, 12, 536, 534, 551, 317, 297, 1015, 534, 17, 14, 16, 297, 326, 1369, 4581, 730, 534, 551, 317, 297, 17242, 63, 265, 63, 1600, 29, 797, 304, 267, 291, 14, 5096, 275, 6771, 267, 4975, 275, 26635, 3823, 14, 6173, 1389, 4590, 342, 267, 291, 14, 5301, 281, 275, 4975, 14, 5301, 281, 267, 291, 14, 1389, 281, 275, 4975, 14, 1389, 281, 267, 291, 14, 1258, 63, 354, 275, 536, 267, 291, 14, 1258, 63, 1023, 275, 1015, 267, 291, 14, 1258, 63, 1802, 275, 1369, 267, 291, 14, 1258, 63, 466, 275, 730, 267, 291, 14, 10589, 63, 265, 63, 1600, 275, 17242, 63, 265, 63, 1600, 267, 291, 423, 14204, 8, 7546, 14, 6726, 63, 1178, 63, 498, 8, 498, 430, 339, 347, 485, 14204, 8, 277, 12, 790, 304, 267, 291, 14, 5096, 14, 22695, 8, 498, 9, 267, 291, 14, 2254, 63, 1328, 8, 3431, 14, 6173, 8631, 8, 288, 4104, 63, 1023, 29, 7459, 63, 4612, 12, 288, 1890, 63, 354, 29, 277, 14, 1258, 63, 354, 12, 288, 1890, 63, 1023, 29, 277, 14, 1258, 63, 1023, 12, 288, 1890, 63, 1802, 29, 277, 14, 1258, 63, 1802, 12, 288, 1890, 63, 466, 29, 277, 14, 1258, 63, 466, 12, 288, 17242, 63, 265, 63, 1600, 29, 277, 14, 10589, 63, 265, 63, 1600, 12, 267, 5082, 267, 19927, 275, 291, 14, 362, 20573, 342, 267, 340, 1228, 8, 20573, 12, 3788, 14, 6173, 16382, 304, 288, 870, 360, 16382, 370, 1654, 26, 9499, 908, 8, 20573, 14, 1000, 63, 354, 430, 267, 916, 1228, 8, 20573, 12, 3788, 14, 6173, 20349, 304, 288, 746, 19927, 14, 1508, 267, 587, 26, 288, 870, 8, 20573, 9, 288, 746, 2186, 360, 1129, 5428, 9351, 1380, 19595, 370, 4907, 358, 339, 347, 664, 20573, 8, 277, 304, 267, 1830, 715, 26, 288, 862, 26, 355, 372, 3788, 14, 6173, 1389, 6173, 14, 912, 8, 277, 14, 5301, 281, 14, 5301, 1012, 288, 871, 26635, 14, 21383, 1451, 26, 355, 986, 288, 666, 275, 291, 14, 5096, 14, 7637, 8, 7727, 9, 288, 340, 440, 666, 26, 355, 746, 2186, 480, 500, 402, 570, 531, 288, 291, 14, 5301, 281, 14, 3871, 8, 576, 9, 339, 347, 3222, 63, 1328, 8, 277, 12, 1499, 304, 267, 291, 14, 5096, 14, 22695, 8, 277, 14, 1389, 281, 14, 1389, 8, 1328, 14, 2724, 4059, 339, 347, 1056, 8, 277, 12, 1499, 304, 267, 291, 14, 2254, 63, 1328, 8, 1328, 9, 267, 19927, 275, 291, 14, 362, 20573, 342, 267, 340, 1228, 8, 20573, 12, 3788, 14, 6173, 2017, 9940, 9, 436, 19927, 14, 1677, 508, 378, 26, 288, 372, 1499, 14, 344, 267, 916, 1228, 8, 20573, 12, 3788, 14, 6173, 19261, 9, 436, 19927, 14, 1677, 508, 378, 26, 288, 746, 19927, 14, 1508, 267, 587, 26, 288, 870, 8, 20573, 9, 288, 746, 2186, 360, 1129, 5428, 9351, 370, 1056, 358, 339, 347, 1218, 8, 277, 12, 1676, 12, 3762, 29, 409, 1062, 1921, 10324, 666, 10324, 2517, 576, 10324, 2049, 2086, 2687, 403, 12, 488, 2298, 267, 1499, 275, 3788, 14, 6173, 2499, 8, 288, 1305, 29, 32108, 14, 1716, 998, 1062, 288, 1676, 29, 1708, 12, 288, 2086, 63, 928, 29, 1712, 59, 16, 467, 288, 2086, 63, 500, 29, 1712, 59, 17, 467, 288, 3762, 29, 2969, 12, 288, 1921, 29, 962, 12, 288, 666, 29, 576, 12, 288, 2517, 576, 29, 1393, 576, 12, 288, 16146, 29, 16, 12, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 267, 372, 1499, 14, 344, 339, 347, 3145, 8, 277, 12, 1559, 304, 267, 1499, 275, 3788, 14, 6173, 5392, 8, 288, 1305, 29, 1113, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 663, 63, 1708, 8, 277, 12, 1559, 12, 1676, 304, 267, 1499, 275, 3788, 14, 6173, 1084, 6652, 8, 288, 1305, 29, 1113, 12, 288, 1676, 29, 1708, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 663, 63, 1712, 8, 277, 12, 1559, 12, 1343, 12, 1284, 304, 267, 1499, 275, 3788, 14, 6173, 1084, 6981, 8, 288, 1305, 29, 1113, 12, 288, 2086, 63, 928, 29, 928, 12, 288, 2086, 63, 500, 29, 500, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 1050, 63, 1450, 8, 277, 12, 1559, 12, 1947, 304, 267, 1499, 275, 3788, 14, 6173, 1123, 1931, 8, 288, 1305, 29, 1113, 12, 288, 1947, 29, 1450, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 2150, 63, 1450, 8, 277, 12, 1559, 12, 1947, 304, 267, 1499, 275, 3788, 14, 6173, 6994, 1931, 8, 288, 1305, 29, 1113, 12, 288, 1947, 29, 1450, 12, 288, 16146, 29, 16, 267 ]
[ 1898, 9708, 1849, 328, 44, 1036, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2838, 199, 646, 6149, 199, 199, 646, 26635, 199, 199, 504, 11199, 2978, 14, 2625, 492, 3788, 12, 26635, 3823, 199, 504, 11199, 2978, 14, 2625, 14, 3431, 492, 3611, 2566, 63, 4612, 199, 504, 11199, 2978, 14, 3629, 492, 1031, 344, 199, 504, 11199, 2978, 14, 1974, 492, 10897, 421, 199, 533, 6810, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6771, 12, 790, 12, 536, 534, 551, 317, 297, 1015, 534, 17, 14, 16, 297, 326, 1369, 4581, 730, 534, 551, 317, 297, 17242, 63, 265, 63, 1600, 29, 797, 304, 267, 291, 14, 5096, 275, 6771, 267, 4975, 275, 26635, 3823, 14, 6173, 1389, 4590, 342, 267, 291, 14, 5301, 281, 275, 4975, 14, 5301, 281, 267, 291, 14, 1389, 281, 275, 4975, 14, 1389, 281, 267, 291, 14, 1258, 63, 354, 275, 536, 267, 291, 14, 1258, 63, 1023, 275, 1015, 267, 291, 14, 1258, 63, 1802, 275, 1369, 267, 291, 14, 1258, 63, 466, 275, 730, 267, 291, 14, 10589, 63, 265, 63, 1600, 275, 17242, 63, 265, 63, 1600, 267, 291, 423, 14204, 8, 7546, 14, 6726, 63, 1178, 63, 498, 8, 498, 430, 339, 347, 485, 14204, 8, 277, 12, 790, 304, 267, 291, 14, 5096, 14, 22695, 8, 498, 9, 267, 291, 14, 2254, 63, 1328, 8, 3431, 14, 6173, 8631, 8, 288, 4104, 63, 1023, 29, 7459, 63, 4612, 12, 288, 1890, 63, 354, 29, 277, 14, 1258, 63, 354, 12, 288, 1890, 63, 1023, 29, 277, 14, 1258, 63, 1023, 12, 288, 1890, 63, 1802, 29, 277, 14, 1258, 63, 1802, 12, 288, 1890, 63, 466, 29, 277, 14, 1258, 63, 466, 12, 288, 17242, 63, 265, 63, 1600, 29, 277, 14, 10589, 63, 265, 63, 1600, 12, 267, 5082, 267, 19927, 275, 291, 14, 362, 20573, 342, 267, 340, 1228, 8, 20573, 12, 3788, 14, 6173, 16382, 304, 288, 870, 360, 16382, 370, 1654, 26, 9499, 908, 8, 20573, 14, 1000, 63, 354, 430, 267, 916, 1228, 8, 20573, 12, 3788, 14, 6173, 20349, 304, 288, 746, 19927, 14, 1508, 267, 587, 26, 288, 870, 8, 20573, 9, 288, 746, 2186, 360, 1129, 5428, 9351, 1380, 19595, 370, 4907, 358, 339, 347, 664, 20573, 8, 277, 304, 267, 1830, 715, 26, 288, 862, 26, 355, 372, 3788, 14, 6173, 1389, 6173, 14, 912, 8, 277, 14, 5301, 281, 14, 5301, 1012, 288, 871, 26635, 14, 21383, 1451, 26, 355, 986, 288, 666, 275, 291, 14, 5096, 14, 7637, 8, 7727, 9, 288, 340, 440, 666, 26, 355, 746, 2186, 480, 500, 402, 570, 531, 288, 291, 14, 5301, 281, 14, 3871, 8, 576, 9, 339, 347, 3222, 63, 1328, 8, 277, 12, 1499, 304, 267, 291, 14, 5096, 14, 22695, 8, 277, 14, 1389, 281, 14, 1389, 8, 1328, 14, 2724, 4059, 339, 347, 1056, 8, 277, 12, 1499, 304, 267, 291, 14, 2254, 63, 1328, 8, 1328, 9, 267, 19927, 275, 291, 14, 362, 20573, 342, 267, 340, 1228, 8, 20573, 12, 3788, 14, 6173, 2017, 9940, 9, 436, 19927, 14, 1677, 508, 378, 26, 288, 372, 1499, 14, 344, 267, 916, 1228, 8, 20573, 12, 3788, 14, 6173, 19261, 9, 436, 19927, 14, 1677, 508, 378, 26, 288, 746, 19927, 14, 1508, 267, 587, 26, 288, 870, 8, 20573, 9, 288, 746, 2186, 360, 1129, 5428, 9351, 370, 1056, 358, 339, 347, 1218, 8, 277, 12, 1676, 12, 3762, 29, 409, 1062, 1921, 10324, 666, 10324, 2517, 576, 10324, 2049, 2086, 2687, 403, 12, 488, 2298, 267, 1499, 275, 3788, 14, 6173, 2499, 8, 288, 1305, 29, 32108, 14, 1716, 998, 1062, 288, 1676, 29, 1708, 12, 288, 2086, 63, 928, 29, 1712, 59, 16, 467, 288, 2086, 63, 500, 29, 1712, 59, 17, 467, 288, 3762, 29, 2969, 12, 288, 1921, 29, 962, 12, 288, 666, 29, 576, 12, 288, 2517, 576, 29, 1393, 576, 12, 288, 16146, 29, 16, 12, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 267, 372, 1499, 14, 344, 339, 347, 3145, 8, 277, 12, 1559, 304, 267, 1499, 275, 3788, 14, 6173, 5392, 8, 288, 1305, 29, 1113, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 663, 63, 1708, 8, 277, 12, 1559, 12, 1676, 304, 267, 1499, 275, 3788, 14, 6173, 1084, 6652, 8, 288, 1305, 29, 1113, 12, 288, 1676, 29, 1708, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 663, 63, 1712, 8, 277, 12, 1559, 12, 1343, 12, 1284, 304, 267, 1499, 275, 3788, 14, 6173, 1084, 6981, 8, 288, 1305, 29, 1113, 12, 288, 2086, 63, 928, 29, 928, 12, 288, 2086, 63, 500, 29, 500, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 1050, 63, 1450, 8, 277, 12, 1559, 12, 1947, 304, 267, 1499, 275, 3788, 14, 6173, 1123, 1931, 8, 288, 1305, 29, 1113, 12, 288, 1947, 29, 1450, 12, 288, 16146, 29, 16, 267, 776, 267, 291, 14, 1069, 8, 1328, 9, 339, 347, 2150, 63, 1450, 8, 277, 12, 1559, 12, 1947, 304, 267, 1499, 275, 3788, 14, 6173, 6994, 1931, 8, 288, 1305, 29, 1113, 12, 288, 1947, 29, 1450, 12, 288, 16146, 29, 16, 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,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 # 1Mb MAXSIZE = CHUNK * 100 if __name__ == '__main__': if len(sys.argv) != 3: print 'Usage ucsc.py input_params output_file' sys.exit() inp_file = sys.argv[1] out_file = sys.argv[2] DEFAULT_URL = "http://genome.ucsc.edu/hgTables?" # this must stay a list to allow multiple selections for the same widget name (checkboxes) params = [] for line in file(inp_file): line = line.strip() if line: parts = line.split('=') if len(parts) == 0: key = "" value = "" elif len(parts) == 1: key = parts[0] value = "" else: key = parts[0] value = parts[1] if key == 'display': print value # get url from params, refered from proxy.py, initialized by the tool xml elif key == 'proxy_url': DEFAULT_URL = value else: params.append( (key, value) ) #print params encoded_params = urllib.urlencode(params) url = DEFAULT_URL + encoded_params #print url page = urllib.urlopen(url) fp = open(out_file, 'wt') size = 0 while 1: data = page.read(CHUNK) if not data: break if size > MAXSIZE: fp.write('----- maximum datasize exceeded ---\n') break size += len(data) fp.write(data) fp.close()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 4011, 199, 646, 984, 12, 747, 199, 199, 479, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 499, 12, 841, 776, 199, 199, 20512, 257, 275, 499, 538, 1165, 327, 413, 16789, 221, 199, 4283, 4305, 275, 6624, 8019, 627, 2948, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 267, 870, 283, 7692, 399, 17000, 14, 647, 1324, 63, 1162, 1072, 63, 493, 7, 267, 984, 14, 2224, 342, 339, 10702, 63, 493, 275, 984, 14, 3020, 59, 17, 61, 272, 734, 63, 493, 275, 984, 14, 3020, 59, 18, 61, 339, 6186, 63, 2632, 275, 298, 1014, 921, 27776, 14, 947, 551, 14, 8654, 15, 9208, 18845, 13472, 2286, 327, 642, 1471, 25578, 282, 769, 370, 2040, 3663, 7267, 83, 367, 314, 2011, 3938, 536, 334, 1074, 12922, 9, 272, 1862, 221, 275, 942, 272, 367, 1004, 315, 570, 8, 11416, 63, 493, 304, 267, 1004, 275, 1004, 14, 1913, 342, 267, 340, 1004, 26, 288, 4184, 275, 1004, 14, 1294, 23917, 288, 340, 822, 8, 4181, 9, 508, 378, 26, 355, 790, 275, 3087, 355, 574, 275, 3087, 288, 916, 822, 8, 4181, 9, 508, 413, 26, 355, 790, 275, 4184, 59, 16, 61, 355, 574, 275, 3087, 288, 587, 26, 355, 790, 275, 4184, 59, 16, 61, 355, 574, 275, 4184, 59, 17, 61, 288, 340, 790, 508, 283, 2918, 356, 355, 870, 574, 288, 327, 664, 1166, 687, 1862, 12, 295, 22941, 687, 4566, 14, 647, 12, 10038, 701, 314, 4744, 2748, 288, 916, 790, 508, 283, 3280, 63, 633, 356, 355, 6186, 63, 2632, 275, 574, 288, 587, 26, 355, 1862, 14, 740, 8, 334, 498, 12, 574, 9, 776, 2286, 327, 1361, 1862, 2286, 5737, 63, 1162, 275, 4011, 14, 10738, 8, 1162, 9, 272, 1166, 275, 6186, 63, 2632, 435, 5737, 63, 1162, 339, 327, 1361, 1166, 339, 2034, 275, 4011, 14, 10890, 8, 633, 9, 339, 4090, 275, 1551, 8, 548, 63, 493, 12, 283, 9115, 358, 272, 1568, 275, 378, 272, 1830, 413, 26, 267, 666, 275, 2034, 14, 739, 8, 20512, 9, 267, 340, 440, 666, 26, 288, 2059, 267, 340, 1568, 690, 9141, 4305, 26, 288, 4090, 14, 952, 360, 9858, 5696, 15012, 794, 22007, 1553, 2696, 78, 358, 288, 2059, 267, 1568, 847, 822, 8, 576, 9, 267, 4090, 14, 952, 8, 576, 9, 339, 4090, 14, 1600, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 4011, 199, 646, 984, 12, 747, 199, 199, 479, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 499, 12, 841, 776, 199, 199, 20512, 257, 275, 499, 538, 1165, 327, 413, 16789, 221, 199, 4283, 4305, 275, 6624, 8019, 627, 2948, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 267, 870, 283, 7692, 399, 17000, 14, 647, 1324, 63, 1162, 1072, 63, 493, 7, 267, 984, 14, 2224, 342, 339, 10702, 63, 493, 275, 984, 14, 3020, 59, 17, 61, 272, 734, 63, 493, 275, 984, 14, 3020, 59, 18, 61, 339, 6186, 63, 2632, 275, 298, 1014, 921, 27776, 14, 947, 551, 14, 8654, 15, 9208, 18845, 13472, 2286, 327, 642, 1471, 25578, 282, 769, 370, 2040, 3663, 7267, 83, 367, 314, 2011, 3938, 536, 334, 1074, 12922, 9, 272, 1862, 221, 275, 942, 272, 367, 1004, 315, 570, 8, 11416, 63, 493, 304, 267, 1004, 275, 1004, 14, 1913, 342, 267, 340, 1004, 26, 288, 4184, 275, 1004, 14, 1294, 23917, 288, 340, 822, 8, 4181, 9, 508, 378, 26, 355, 790, 275, 3087, 355, 574, 275, 3087, 288, 916, 822, 8, 4181, 9, 508, 413, 26, 355, 790, 275, 4184, 59, 16, 61, 355, 574, 275, 3087, 288, 587, 26, 355, 790, 275, 4184, 59, 16, 61, 355, 574, 275, 4184, 59, 17, 61, 288, 340, 790, 508, 283, 2918, 356, 355, 870, 574, 288, 327, 664, 1166, 687, 1862, 12, 295, 22941, 687, 4566, 14, 647, 12, 10038, 701, 314, 4744, 2748, 288, 916, 790, 508, 283, 3280, 63, 633, 356, 355, 6186, 63, 2632, 275, 574, 288, 587, 26, 355, 1862, 14, 740, 8, 334, 498, 12, 574, 9, 776, 2286, 327, 1361, 1862, 2286, 5737, 63, 1162, 275, 4011, 14, 10738, 8, 1162, 9, 272, 1166, 275, 6186, 63, 2632, 435, 5737, 63, 1162, 339, 327, 1361, 1166, 339, 2034, 275, 4011, 14, 10890, 8, 633, 9, 339, 4090, 275, 1551, 8, 548, 63, 493, 12, 283, 9115, 358, 272, 1568, 275, 378, 272, 1830, 413, 26, 267, 666, 275, 2034, 14, 739, 8, 20512, 9, 267, 340, 440, 666, 26, 288, 2059, 267, 340, 1568, 690, 9141, 4305, 26, 288, 4090, 14, 952, 360, 9858, 5696, 15012, 794, 22007, 1553, 2696, 78, 358, 288, 2059, 267, 1568, 847, 822, 8, 576, 9, 267, 4090, 14, 952, 8, 576, 9, 339, 4090, 14, 1600, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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PY -- COVERAGE TESTING # # Gareth Rees, Ravenbrook Limited, 2001-12-04 # # # 1. INTRODUCTION # # This module provides coverage testing for Python code. # # The intended readership is all Python developers. # # This document is not confidential. # # See [GDR 2001-12-04a] for the command-line interface, programmatic # interface and limitations. See [GDR 2001-12-04b] for requirements and # design. """Usage: coverage.py -x MODULE.py [ARG1 ARG2 ...] Execute module, passing the given command-line arguments, collecting coverage data. coverage.py -e Erase collected coverage data. coverage.py -r [-m] FILE1 FILE2 ... Report on the statement coverage for the given files. With the -m option, show line numbers of the statements that weren't executed. coverage.py -a [-d dir] FILE1 FILE2 ... Make annotated copies of the given files, marking statements that are executed with > and statements that are missed with !. With the -d option, make the copies in that directory. Without the -d option, make each copy in the same directory as the original. Coverage data is saved in the file .coverage by default. Set the COVERAGE_FILE environment variable to save it somewhere else.""" import os import re import string import sys import types # 2. IMPLEMENTATION # # This uses the "singleton" pattern. # # The word "morf" means a module object (from which the source file can # be deduced by suitable manipulation of the __file__ attribute) or a # filename. # # When we generate a coverage report we have to canonicalize every # filename in the coverage dictionary just in case it refers to the # module we are reporting on. It seems a shame to throw away this # information so the data in the coverage dictionary is transferred to # the 'cexecuted' dictionary under the canonical filenames. # # The coverage dictionary is called "c" and the trace function "t". The # reason for these short names is that Python looks up variables by name # at runtime and so execution time depends on the length of variables! # In the bottleneck of this application it's appropriate to abbreviate # names to increase speed. # A dictionary with an entry for (Python source file name, line number # in that file) if that line has been executed. c = {} # t(f, x, y). This method is passed to sys.settrace as a trace # function. See [van Rossum 2001-07-20b, 9.2] for an explanation of # sys.settrace and the arguments and return value of the trace function. # See [van Rossum 2001-07-20a, 3.2] for a description of frame and code # objects. def t(f, x, y): c[(f.f_code.co_filename, f.f_lineno)] = 1 return t the_coverage = None class coverage: error = "coverage error" # Name of the cache file (unless environment variable is set). cache_default = ".coverage" # Environment variable naming the cache file. cache_env = "COVERAGE_FILE" # A map from canonical Python source file name to a dictionary in # which there's an entry for each line number that has been # executed. cexecuted = {} # Cache of results of calling the analysis() method, so that you can # specify both -r and -a without doing double work. analysis_cache = {} # Cache of results of calling the canonical_filename() method, to # avoid duplicating work. canonical_filename_cache = {} def __init__(self): global the_coverage if the_coverage: raise self.error, "Only one coverage object allowed." self.cache = os.environ.get(self.cache_env, self.cache_default) self.restore() self.analysis_cache = {} def help(self, error=None): if error: print error print print __doc__ sys.exit(1) def command_line(self): import getopt settings = {} optmap = { '-a': 'annotate', '-d:': 'directory=', '-e': 'erase', '-h': 'help', '-i': 'ignore-errors', '-m': 'show-missing', '-r': 'report', '-x': 'execute', } short_opts = string.join(map(lambda o: o[1:], optmap.keys()), '') long_opts = optmap.values() options, args = getopt.getopt(sys.argv[1:], short_opts, long_opts) for o, a in options: if optmap.has_key(o): settings[optmap[o]] = 1 elif optmap.has_key(o + ':'): settings[optmap[o + ':']] = a elif o[2:] in long_opts: settings[o[2:]] = 1 elif o[2:] + '=' in long_opts: settings[o[2:]] = a else: self.help("Unknown option: '%s'." % o) if settings.get('help'): self.help() for i in ['erase', 'execute']: for j in ['annotate', 'report']: if settings.get(i) and settings.get(j): self.help("You can't specify the '%s' and '%s' " "options at the same time." % (i, j)) args_needed = (settings.get('execute') or settings.get('annotate') or settings.get('report')) action = settings.get('erase') or args_needed if not action: self.help("You must specify at least one of -e, -x, -r, " "or -a.") if not args_needed and args: self.help("Unexpected arguments %s." % args) if settings.get('erase'): self.erase() if settings.get('execute'): if not args: self.help("Nothing to do.") sys.argv = args self.start() import __main__ # When Python starts a script, sys.path[0] is the directory # in which the Python script was found. So when we run a # script, change sys.path so that it matches what the script # would have found if it had been run normally. sys.path[0] = os.path.dirname(sys.argv[0]) execfile(sys.argv[0], __main__.__dict__) if not args: args = self.cexecuted.keys() ignore_errors = settings.get('ignore-errors') show_missing = settings.get('show-missing') directory = settings.get('directory=') if settings.get('report'): self.report(args, show_missing, ignore_errors) if settings.get('annotate'): self.annotate(args, directory, ignore_errors) def start(self): sys.settrace(t) def stop(self): sys.settrace(None) def erase(self): global c c = {} self.analysis_cache = {} self.cexecuted = {} if os.path.exists(self.cache): os.remove(self.cache) # save(). Save coverage data to the coverage cache. def save(self): self.canonicalize_filenames() cache = open(self.cache, 'wb') import marshal marshal.dump(self.cexecuted, cache) cache.close() # restore(). Restore coverage data from the coverage cache (if it # exists). def restore(self): global c c = {} self.cexecuted = {} if not os.path.exists(self.cache): return try: cache = open(self.cache, 'rb') import marshal cexecuted = marshal.load(cache) cache.close() if isinstance(cexecuted, types.DictType): self.cexecuted = cexecuted except: pass # canonical_filename(filename). Return a canonical filename for the # file (that is, an absolute path with no redundant components and # normalized case). See [GDR 2001-12-04b, 3.3]. def canonical_filename(self, filename): if not self.canonical_filename_cache.has_key(filename): f = filename if os.path.isabs(f) and not os.path.exists(f): f = os.path.basename(f) if not os.path.isabs(f): for path in [os.curdir] + sys.path: g = os.path.join(path, f) if os.path.exists(g): f = g break cf = os.path.normcase(os.path.abspath(f)) self.canonical_filename_cache[filename] = cf return self.canonical_filename_cache[filename] # canonicalize_filenames(). Copy results from "executed" to # "cexecuted", canonicalizing filenames on the way. Clear the # "executed" map. def canonicalize_filenames(self): global c for filename, lineno in c.keys(): f = self.canonical_filename(filename) if not self.cexecuted.has_key(f): self.cexecuted[f] = {} self.cexecuted[f][lineno] = 1 c = {} # morf_filename(morf). Return the filename for a module or file. def morf_filename(self, morf): if isinstance(morf, types.ModuleType): if not hasattr(morf, '__file__'): raise self.error, "Module has no __file__ attribute." file = morf.__file__ else: file = morf return self.canonical_filename(file) # analyze_morf(morf). Analyze the module or filename passed as # the argument. If the source code can't be found, raise an error. # Otherwise, return a pair of (1) the canonical filename of the # source code for the module, and (2) a list of lines of statements # in the source code. def analyze_morf(self, morf): if self.analysis_cache.has_key(morf): return self.analysis_cache[morf] filename = self.morf_filename(morf) ext = os.path.splitext(filename)[1] if ext == '.pyc': if not os.path.exists(filename[0:-1]): raise self.error, ("No source for compiled code '%s'." % filename) filename = filename[0:-1] elif ext != '.py': raise self.error, "File '%s' not Python source." % filename source = open(filename, 'r') import parser tree = parser.suite(source.read()).totuple(1) source.close() statements = {} self.find_statements(tree, statements) lines = statements.keys() lines.sort() result = filename, lines self.analysis_cache[morf] = result return result # find_statements(tree, dict). Find each statement in the parse # tree and record the line on which the statement starts in the # dictionary (by assigning it to 1). # # It works by walking the whole tree depth-first. Every time it # comes across a statement (symbol.stmt -- this includes compound # statements like 'if' and 'while') it calls find_statement, which # descends the tree below the statement to find the first terminal # token in that statement and record the lines on which that token # was found. # # This algorithm may find some lines several times (because of the # grammar production statement -> compound statement -> statement), # but that doesn't matter because we record lines as the keys of the # dictionary. # # See also [GDR 2001-12-04b, 3.2]. def find_statements(self, tree, dict): import symbol, token if token.ISNONTERMINAL(tree[0]): for t in tree[1:]: self.find_statements(t, dict) if tree[0] == symbol.stmt: self.find_statement(tree[1], dict) elif (tree[0] == token.NAME and tree[1] in ['elif', 'except', 'finally']): dict[tree[2]] = 1 def find_statement(self, tree, dict): import token while token.ISNONTERMINAL(tree[0]): tree = tree[1] dict[tree[2]] = 1 # format_lines(statements, lines). Format a list of line numbers # for printing by coalescing groups of lines as long as the lines # represent consecutive statements. This will coalesce even if # there are gaps between statements, so if statements = # [1,2,3,4,5,10,11,12,13,14] and lines = [1,2,5,10,11,13,14] then # format_lines will return "1-2, 5-11, 13-14". def format_lines(self, statements, lines): pairs = [] i = 0 j = 0 start = None pairs = [] while i < len(statements) and j < len(lines): if statements[i] == lines[j]: if start == None: start = lines[j] end = lines[j] j = j + 1 elif start: pairs.append((start, end)) start = None i = i + 1 if start: pairs.append((start, end)) def stringify(pair): start, end = pair if start == end: return "%d" % start else: return "%d-%d" % (start, end) import string return string.join(map(stringify, pairs), ", ") def analysis(self, morf): filename, statements = self.analyze_morf(morf) self.canonicalize_filenames() if not self.cexecuted.has_key(filename): self.cexecuted[filename] = {} missing = [] for line in statements: if not self.cexecuted[filename].has_key(line): missing.append(line) return (filename, statements, missing, self.format_lines(statements, missing)) def morf_name(self, morf): if isinstance(morf, types.ModuleType): return morf.__name__ else: return os.path.splitext(os.path.basename(morf))[0] def report(self, morfs, show_missing=1, ignore_errors=0): if not isinstance(morfs, types.ListType): morfs = [morfs] max_name = max([5,] + map(len, map(self.morf_name, morfs))) fmt_name = "%%- %ds " % max_name fmt_err = fmt_name + "%s: %s" header = fmt_name % "Name" + " Stmts Exec Cover" fmt_coverage = fmt_name + "% 6d % 6d % 5d%%" if show_missing: header = header + " Missing" fmt_coverage = fmt_coverage + " %s" print header print "-" * len(header) total_statements = 0 total_executed = 0 for morf in morfs: name = self.morf_name(morf) try: _, statements, missing, readable = self.analysis(morf) n = len(statements) m = n - len(missing) if n > 0: pc = 100.0 * m / n else: pc = 100.0 args = (name, n, m, pc) if show_missing: args = args + (readable,) print fmt_coverage % args total_statements = total_statements + n total_executed = total_executed + m except KeyboardInterrupt: raise except: if not ignore_errors: type, msg = sys.exc_info()[0:2] print fmt_err % (name, type, msg) if len(morfs) > 1: print "-" * len(header) if total_statements > 0: pc = 100.0 * total_executed / total_statements else: pc = 100.0 args = ("TOTAL", total_statements, total_executed, pc) if show_missing: args = args + ("",) print fmt_coverage % args # annotate(morfs, ignore_errors). blank_re = re.compile("\\s*(#|$)") else_re = re.compile("\\s*else\\s*:\\s*(#|$)") def annotate(self, morfs, directory=None, ignore_errors=0): for morf in morfs: try: filename, statements, missing, _ = self.analysis(morf) source = open(filename, 'r') if directory: dest_file = os.path.join(directory, os.path.basename(filename) + ',cover') else: dest_file = filename + ',cover' dest = open(dest_file, 'w') lineno = 0 i = 0 j = 0 covered = 1 while 1: line = source.readline() if line == '': break lineno = lineno + 1 while i < len(statements) and statements[i] < lineno: i = i + 1 while j < len(missing) and missing[j] < lineno: j = j + 1 if i < len(statements) and statements[i] == lineno: covered = j >= len(missing) or missing[j] > lineno if self.blank_re.match(line): dest.write(' ') elif self.else_re.match(line): # Special logic for lines containing only # 'else:'. See [GDR 2001-12-04b, 3.2]. if i >= len(statements) and j >= len(missing): dest.write('! ') elif i >= len(statements) or j >= len(missing): dest.write('> ') elif statements[i] == missing[j]: dest.write('! ') else: dest.write('> ') elif covered: dest.write('> ') else: dest.write('! ') dest.write(line) source.close() dest.close() except KeyboardInterrupt: raise except: if not ignore_errors: raise # Singleton object. the_coverage = coverage() # Module functions call methods in the singleton object. def start(*args, **kw): return apply(the_coverage.start, args, kw) def stop(*args, **kw): return apply(the_coverage.stop, args, kw) def erase(*args, **kw): return apply(the_coverage.erase, args, kw) def analysis(*args, **kw): return apply(the_coverage.analysis, args, kw) def report(*args, **kw): return apply(the_coverage.report, args, kw) # Save coverage data when Python exits. (The atexit module wasn't # introduced until Python 2.0, so use sys.exitfunc when it's not # available.) try: import atexit atexit.register(the_coverage.save) except ImportError: sys.exitfunc = the_coverage.save # Command-line interface. if __name__ == '__main__': the_coverage.command_line() # A. REFERENCES # # [GDR 2001-12-04a] "Statement coverage for Python"; Gareth Rees; # Ravenbrook Limited; 2001-12-04; # <http://garethrees.org/2001/12/04/python-coverage/>. # # [GDR 2001-12-04b] "Statement coverage for Python: design and # analysis"; Gareth Rees; Ravenbrook Limited; 2001-12-04; # <http://garethrees.org/2001/12/04/python-coverage/design.html>. # # [van Rossum 2001-07-20a] "Python Reference Manual (releae 2.1.1)"; # Guide van Rossum; 2001-07-20; # <http://www.python.org/doc/2.1.1/ref/ref.html>. # # [van Rossum 2001-07-20b] "Python Library Reference"; Guido van Rossum; # 2001-07-20; <http://www.python.org/doc/2.1.1/lib/lib.html>. # # # B. DOCUMENT HISTORY # # 2001-12-04 GDR Created. # # 2001-12-06 GDR Added command-line interface and source code # annotation. # # 2001-12-09 GDR Moved design and interface to separate documents. # # 2001-12-10 GDR Open cache file as binary on Windows. Allow # simultaneous -e and -x, or -a and -r. # # 2001-12-12 GDR Added command-line help. Cache analysis so that it # only needs to be done once when you specify -a and -r. # # 2001-12-13 GDR Improved speed while recording. Portable between # Python 1.5.2 and 2.1.1. # # 2002-01-03 GDR Module-level functions work correctly. # # 2002-01-07 GDR Update sys.path when running a file with the -x option, # so that it matches the value the program would get if it were run on # its own. # # # C. COPYRIGHT AND LICENCE # # Copyright 2001 Gareth Rees. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. # # THIS SOFTWARE IS PROVIDED BY 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 # HOLDERS AND 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. # # # # $Id: //info.ravenbrook.com/user/gdr/www.garethrees.org/2001/12/04/python-coverage/coverage.py#9 $
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 3777, 3492, 3990, 11391, 449, 17507, 316, 27561, 7290, 199, 3, 4519, 665, 1014, 921, 1544, 14, 345, 1856, 20670, 745, 14, 957, 15, 1715, 15, 80, 20, 68, 280, 3133, 199, 3, 199, 3, 7861, 5099, 2111, 2962, 14, 4521, 1553, 5099, 2111, 2962, 7393, 1206, 199, 3, 199, 3, 3777, 598, 1530, 273, 799, 397, 12, 820, 15556, 20670, 745, 23954, 12, 12521, 13, 713, 13, 966, 199, 3, 199, 3, 199, 3, 413, 14, 16429, 1092, 4980, 5430, 199, 3, 199, 3, 961, 859, 6571, 11745, 5343, 367, 2018, 1233, 14, 199, 3, 199, 3, 710, 11619, 7002, 3319, 365, 1006, 2018, 19782, 14, 199, 3, 199, 3, 961, 2213, 365, 440, 406, 329, 3256, 14, 199, 3, 199, 3, 1666, 359, 39, 4564, 12521, 13, 713, 13, 966, 65, 61, 367, 314, 1414, 13, 604, 3217, 12, 2240, 3889, 199, 3, 3217, 436, 4204, 14, 221, 1666, 359, 39, 4564, 12521, 13, 713, 13, 966, 66, 61, 367, 9760, 436, 199, 3, 12899, 14, 199, 199, 624, 7692, 26, 199, 199, 10828, 14, 647, 446, 88, 30223, 14, 647, 359, 11611, 17, 4160, 39, 18, 21214, 272, 17009, 859, 12, 9476, 314, 1627, 1414, 13, 604, 2368, 12, 32223, 272, 11745, 666, 14, 199, 199, 10828, 14, 647, 446, 69, 272, 662, 8062, 13736, 11745, 666, 14, 199, 199, 10828, 14, 647, 446, 82, 5243, 77, 61, 13024, 17, 13024, 18, 2263, 272, 11774, 641, 314, 5164, 11745, 367, 314, 1627, 1584, 14, 221, 8777, 314, 446, 77, 272, 945, 12, 2498, 1004, 5579, 402, 314, 9834, 626, 781, 828, 1133, 7934, 14, 199, 199, 10828, 14, 647, 446, 65, 5243, 68, 2935, 61, 13024, 17, 13024, 18, 2263, 272, 4155, 27526, 6866, 402, 314, 1627, 1584, 12, 31318, 9834, 626, 272, 787, 7934, 543, 690, 436, 9834, 626, 787, 3201, 939, 543, 8546, 14, 221, 8777, 272, 314, 446, 68, 945, 12, 1852, 314, 6866, 315, 626, 2082, 14, 221, 23952, 314, 446, 68, 272, 945, 12, 1852, 1924, 1331, 315, 314, 2011, 2082, 465, 314, 3379, 14, 199, 199, 27444, 666, 365, 6290, 315, 314, 570, 1275, 10828, 701, 849, 14, 221, 2494, 314, 199, 19052, 2962, 63, 3817, 3734, 1750, 370, 3354, 652, 23430, 587, 1041, 199, 199, 646, 747, 199, 646, 295, 199, 646, 1059, 199, 646, 984, 199, 646, 2943, 421, 199, 3, 499, 14, 5025, 10320, 2594, 199, 3, 199, 3, 961, 4440, 314, 298, 24675, 2, 3851, 14, 199, 3, 199, 3, 710, 4349, 298, 12416, 70, 2, 4910, 282, 859, 909, 334, 504, 1314, 314, 1350, 570, 883, 199, 3, 506, 477, 16584, 701, 11233, 26212, 402, 314, 636, 493, 363, 2225, 9, 503, 282, 199, 3, 1788, 14, 199, 3, 199, 3, 3979, 781, 3550, 282, 11745, 3622, 781, 1172, 370, 11358, 794, 4036, 199, 3, 1788, 315, 314, 11745, 2600, 2951, 315, 1930, 652, 15724, 370, 314, 199, 3, 859, 781, 787, 17290, 641, 14, 221, 2779, 12237, 282, 1033, 313, 370, 7978, 13437, 642, 199, 3, 2556, 880, 314, 666, 315, 314, 11745, 2600, 365, 1752, 5057, 370, 199, 3, 314, 283, 301, 9542, 4241, 7, 2600, 1334, 314, 11358, 6203, 14, 199, 3, 199, 3, 710, 11745, 2600, 365, 2797, 298, 67, 2, 436, 314, 3307, 805, 298, 84, 1674, 221, 710, 199, 3, 4499, 367, 3520, 3974, 1561, 365, 626, 2018, 10734, 1536, 2860, 701, 536, 199, 3, 737, 8836, 436, 880, 6451, 900, 8350, 641, 314, 2582, 402, 2860, 1, 199, 3, 1010, 314, 5888, 27412, 402, 642, 4223, 652, 1159, 5827, 370, 2236, 23988, 323, 199, 3, 1561, 370, 19781, 8112, 14, 199, 199, 3, 437, 2600, 543, 376, 2397, 367, 334, 4718, 1350, 570, 536, 12, 1004, 1329, 199, 3, 315, 626, 570, 9, 340, 626, 1004, 965, 2757, 7934, 14, 199, 67, 275, 1052, 199, 199, 3, 307, 8, 70, 12, 671, 12, 612, 680, 221, 961, 1083, 365, 3032, 370, 984, 14, 28434, 465, 282, 3307, 199, 3, 805, 14, 221, 1666, 359, 20662, 6848, 385, 453, 12521, 13, 1780, 13, 1165, 66, 12, 1749, 14, 18, 61, 367, 376, 17531, 402, 199, 3, 984, 14, 28434, 436, 314, 2368, 436, 372, 574, 402, 314, 3307, 805, 14, 199, 3, 1666, 359, 20662, 6848, 385, 453, 12521, 13, 1780, 13, 1165, 65, 12, 650, 14, 18, 61, 367, 282, 1369, 402, 2787, 436, 1233, 199, 3, 2251, 14, 199, 199, 318, 307, 8, 70, 12, 671, 12, 612, 304, 272, 286, 7528, 70, 14, 70, 63, 600, 14, 331, 63, 1501, 12, 289, 14, 70, 63, 3469, 1874, 275, 413, 272, 372, 307, 199, 199, 1589, 63, 10828, 275, 488, 199, 199, 533, 11745, 26, 272, 1125, 275, 298, 10828, 1125, 2, 339, 327, 2812, 402, 314, 2581, 570, 334, 18447, 3734, 1750, 365, 663, 680, 272, 2581, 63, 885, 275, 3680, 10828, 2, 339, 327, 9711, 1750, 19720, 314, 2581, 570, 14, 272, 2581, 63, 1813, 275, 298, 19052, 2962, 63, 3817, 2, 339, 327, 437, 2341, 687, 11358, 2018, 1350, 570, 536, 370, 282, 2600, 315, 272, 327, 1314, 2337, 1159, 376, 2397, 367, 1924, 1004, 1329, 626, 965, 2757, 272, 327, 7934, 14, 272, 286, 22564, 275, 1052, 339, 327, 11977, 402, 2058, 402, 6358, 314, 11284, 342, 1083, 12, 880, 626, 1265, 883, 272, 327, 4165, 3865, 446, 82, 436, 446, 65, 1928, 9689, 4270, 1736, 14, 272, 11284, 63, 1637, 275, 1052, 339, 327, 11977, 402, 2058, 402, 6358, 314, 11358, 63, 1501, 342, 1083, 12, 370, 272, 327, 5126, 366, 4230, 1958, 1736, 14, 272, 11358, 63, 1501, 63, 1637, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 2288, 314, 63, 10828, 267, 340, 314, 63, 10828, 26, 288, 746, 291, 14, 705, 12, 298, 5903, 1373, 11745, 909, 4370, 2122, 267, 291, 14, 1637, 275, 747, 14, 2314, 14, 362, 8, 277, 14, 1637, 63, 1813, 12, 291, 14, 1637, 63, 885, 9, 267, 291, 14, 8011, 342, 267, 291, 14, 10466, 63, 1637, 275, 1052, 339, 347, 1720, 8, 277, 12, 1125, 29, 403, 304, 267, 340, 1125, 26, 288, 870 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 3777, 3492, 3990, 11391, 449, 17507, 316, 27561, 7290, 199, 3, 4519, 665, 1014, 921, 1544, 14, 345, 1856, 20670, 745, 14, 957, 15, 1715, 15, 80, 20, 68, 280, 3133, 199, 3, 199, 3, 7861, 5099, 2111, 2962, 14, 4521, 1553, 5099, 2111, 2962, 7393, 1206, 199, 3, 199, 3, 3777, 598, 1530, 273, 799, 397, 12, 820, 15556, 20670, 745, 23954, 12, 12521, 13, 713, 13, 966, 199, 3, 199, 3, 199, 3, 413, 14, 16429, 1092, 4980, 5430, 199, 3, 199, 3, 961, 859, 6571, 11745, 5343, 367, 2018, 1233, 14, 199, 3, 199, 3, 710, 11619, 7002, 3319, 365, 1006, 2018, 19782, 14, 199, 3, 199, 3, 961, 2213, 365, 440, 406, 329, 3256, 14, 199, 3, 199, 3, 1666, 359, 39, 4564, 12521, 13, 713, 13, 966, 65, 61, 367, 314, 1414, 13, 604, 3217, 12, 2240, 3889, 199, 3, 3217, 436, 4204, 14, 221, 1666, 359, 39, 4564, 12521, 13, 713, 13, 966, 66, 61, 367, 9760, 436, 199, 3, 12899, 14, 199, 199, 624, 7692, 26, 199, 199, 10828, 14, 647, 446, 88, 30223, 14, 647, 359, 11611, 17, 4160, 39, 18, 21214, 272, 17009, 859, 12, 9476, 314, 1627, 1414, 13, 604, 2368, 12, 32223, 272, 11745, 666, 14, 199, 199, 10828, 14, 647, 446, 69, 272, 662, 8062, 13736, 11745, 666, 14, 199, 199, 10828, 14, 647, 446, 82, 5243, 77, 61, 13024, 17, 13024, 18, 2263, 272, 11774, 641, 314, 5164, 11745, 367, 314, 1627, 1584, 14, 221, 8777, 314, 446, 77, 272, 945, 12, 2498, 1004, 5579, 402, 314, 9834, 626, 781, 828, 1133, 7934, 14, 199, 199, 10828, 14, 647, 446, 65, 5243, 68, 2935, 61, 13024, 17, 13024, 18, 2263, 272, 4155, 27526, 6866, 402, 314, 1627, 1584, 12, 31318, 9834, 626, 272, 787, 7934, 543, 690, 436, 9834, 626, 787, 3201, 939, 543, 8546, 14, 221, 8777, 272, 314, 446, 68, 945, 12, 1852, 314, 6866, 315, 626, 2082, 14, 221, 23952, 314, 446, 68, 272, 945, 12, 1852, 1924, 1331, 315, 314, 2011, 2082, 465, 314, 3379, 14, 199, 199, 27444, 666, 365, 6290, 315, 314, 570, 1275, 10828, 701, 849, 14, 221, 2494, 314, 199, 19052, 2962, 63, 3817, 3734, 1750, 370, 3354, 652, 23430, 587, 1041, 199, 199, 646, 747, 199, 646, 295, 199, 646, 1059, 199, 646, 984, 199, 646, 2943, 421, 199, 3, 499, 14, 5025, 10320, 2594, 199, 3, 199, 3, 961, 4440, 314, 298, 24675, 2, 3851, 14, 199, 3, 199, 3, 710, 4349, 298, 12416, 70, 2, 4910, 282, 859, 909, 334, 504, 1314, 314, 1350, 570, 883, 199, 3, 506, 477, 16584, 701, 11233, 26212, 402, 314, 636, 493, 363, 2225, 9, 503, 282, 199, 3, 1788, 14, 199, 3, 199, 3, 3979, 781, 3550, 282, 11745, 3622, 781, 1172, 370, 11358, 794, 4036, 199, 3, 1788, 315, 314, 11745, 2600, 2951, 315, 1930, 652, 15724, 370, 314, 199, 3, 859, 781, 787, 17290, 641, 14, 221, 2779, 12237, 282, 1033, 313, 370, 7978, 13437, 642, 199, 3, 2556, 880, 314, 666, 315, 314, 11745, 2600, 365, 1752, 5057, 370, 199, 3, 314, 283, 301, 9542, 4241, 7, 2600, 1334, 314, 11358, 6203, 14, 199, 3, 199, 3, 710, 11745, 2600, 365, 2797, 298, 67, 2, 436, 314, 3307, 805, 298, 84, 1674, 221, 710, 199, 3, 4499, 367, 3520, 3974, 1561, 365, 626, 2018, 10734, 1536, 2860, 701, 536, 199, 3, 737, 8836, 436, 880, 6451, 900, 8350, 641, 314, 2582, 402, 2860, 1, 199, 3, 1010, 314, 5888, 27412, 402, 642, 4223, 652, 1159, 5827, 370, 2236, 23988, 323, 199, 3, 1561, 370, 19781, 8112, 14, 199, 199, 3, 437, 2600, 543, 376, 2397, 367, 334, 4718, 1350, 570, 536, 12, 1004, 1329, 199, 3, 315, 626, 570, 9, 340, 626, 1004, 965, 2757, 7934, 14, 199, 67, 275, 1052, 199, 199, 3, 307, 8, 70, 12, 671, 12, 612, 680, 221, 961, 1083, 365, 3032, 370, 984, 14, 28434, 465, 282, 3307, 199, 3, 805, 14, 221, 1666, 359, 20662, 6848, 385, 453, 12521, 13, 1780, 13, 1165, 66, 12, 1749, 14, 18, 61, 367, 376, 17531, 402, 199, 3, 984, 14, 28434, 436, 314, 2368, 436, 372, 574, 402, 314, 3307, 805, 14, 199, 3, 1666, 359, 20662, 6848, 385, 453, 12521, 13, 1780, 13, 1165, 65, 12, 650, 14, 18, 61, 367, 282, 1369, 402, 2787, 436, 1233, 199, 3, 2251, 14, 199, 199, 318, 307, 8, 70, 12, 671, 12, 612, 304, 272, 286, 7528, 70, 14, 70, 63, 600, 14, 331, 63, 1501, 12, 289, 14, 70, 63, 3469, 1874, 275, 413, 272, 372, 307, 199, 199, 1589, 63, 10828, 275, 488, 199, 199, 533, 11745, 26, 272, 1125, 275, 298, 10828, 1125, 2, 339, 327, 2812, 402, 314, 2581, 570, 334, 18447, 3734, 1750, 365, 663, 680, 272, 2581, 63, 885, 275, 3680, 10828, 2, 339, 327, 9711, 1750, 19720, 314, 2581, 570, 14, 272, 2581, 63, 1813, 275, 298, 19052, 2962, 63, 3817, 2, 339, 327, 437, 2341, 687, 11358, 2018, 1350, 570, 536, 370, 282, 2600, 315, 272, 327, 1314, 2337, 1159, 376, 2397, 367, 1924, 1004, 1329, 626, 965, 2757, 272, 327, 7934, 14, 272, 286, 22564, 275, 1052, 339, 327, 11977, 402, 2058, 402, 6358, 314, 11284, 342, 1083, 12, 880, 626, 1265, 883, 272, 327, 4165, 3865, 446, 82, 436, 446, 65, 1928, 9689, 4270, 1736, 14, 272, 11284, 63, 1637, 275, 1052, 339, 327, 11977, 402, 2058, 402, 6358, 314, 11358, 63, 1501, 342, 1083, 12, 370, 272, 327, 5126, 366, 4230, 1958, 1736, 14, 272, 11358, 63, 1501, 63, 1637, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 2288, 314, 63, 10828, 267, 340, 314, 63, 10828, 26, 288, 746, 291, 14, 705, 12, 298, 5903, 1373, 11745, 909, 4370, 2122, 267, 291, 14, 1637, 275, 747, 14, 2314, 14, 362, 8, 277, 14, 1637, 63, 1813, 12, 291, 14, 1637, 63, 885, 9, 267, 291, 14, 8011, 342, 267, 291, 14, 10466, 63, 1637, 275, 1052, 339, 347, 1720, 8, 277, 12, 1125, 29, 403, 304, 267, 340, 1125, 26, 288, 870, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alesnav/p2ptv-pi
acestream/ACEStream/Core/Utilities/timeouturlopen.py
4
3362
#Embedded file name: ACEStream\Core\Utilities\timeouturlopen.pyo import sys import httplib import socket import urllib2 import urllib import urlparse from gzip import GzipFile from StringIO import StringIO from ACEStream.version import VERSION USER_AGENT = 'ACEStream/' + VERSION DEBUG = False def urlOpenTimeout(url, timeout = 30, content_type = None, cookiejar = None, *data): class TimeoutHTTPConnection(httplib.HTTPConnection): def connect(self): msg = 'getaddrinfo returns an empty list' for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) self.sock.settimeout(timeout) if self.debuglevel > 0: print 'connect: (%s, %s)' % (self.host, self.port) self.sock.connect(sa) except socket.error as msg: if self.debuglevel > 0: print 'connect fail:', (self.host, self.port) if self.sock: self.sock.close() self.sock = None continue break if not self.sock: raise socket.error, msg class TimeoutHTTPHandler(urllib2.HTTPHandler): def http_open(self, req): return self.do_open(TimeoutHTTPConnection, req) class GZipProcessor(urllib2.BaseHandler): def http_request(self, req): req.add_header('Accept-Encoding', 'gzip') return req https_request = http_request def http_response(self, req, resp): if resp.headers.get('content-encoding') == 'gzip': gzip = GzipFile(fileobj=StringIO(resp.read()), mode='r') prev_resp = resp resp = urllib2.addinfourl(gzip, prev_resp.headers, prev_resp.url) resp.code = prev_resp.code resp.msg = prev_resp.msg return resp https_response = http_response handlers = [GZipProcessor, TimeoutHTTPHandler, urllib2.HTTPDefaultErrorHandler, urllib2.HTTPRedirectHandler] if cookiejar is not None: handlers.append(urllib2.HTTPCookieProcessor(cookiejar)) opener = urllib2.build_opener(*handlers) request = urllib2.Request(url) request.add_header('User-Agent', USER_AGENT) if content_type is not None: request.add_header('Content-Type', content_type) return opener.open(request, *data) def find_proxy(url): scheme, netloc, path, pars, query, fragment = urlparse.urlparse(url) proxies = urllib.getproxies() proxyhost = None if scheme in proxies: if '@' in netloc: sidx = netloc.find('@') + 1 else: sidx = 0 eidx = netloc.find(':') if eidx == -1: eidx = len(netloc) host = netloc[sidx:eidx] if not (host == '127.0.0.1' or urllib.proxy_bypass(host)): proxyurl = proxies[scheme] proxyelems = urlparse.urlparse(proxyurl) proxyhost = proxyelems[1] if DEBUG: print >> sys.stderr, 'find_proxy: Got proxies', proxies, 'selected', proxyhost, 'URL was', url return proxyhost
mit
[ 3, 27395, 570, 536, 26, 6570, 654, 84, 1091, 60, 5402, 60, 22905, 60, 2593, 10890, 14, 22345, 199, 646, 984, 199, 646, 8809, 199, 646, 2838, 199, 646, 4011, 18, 199, 646, 4011, 199, 646, 7097, 199, 504, 11756, 492, 598, 3065, 1173, 199, 504, 5228, 492, 5228, 199, 504, 6570, 654, 84, 1091, 14, 1023, 492, 15945, 199, 3791, 63, 14565, 275, 283, 21287, 84, 1091, 4805, 435, 15945, 199, 5287, 275, 756, 199, 199, 318, 1166, 4299, 6372, 8, 633, 12, 2653, 275, 4233, 12, 1564, 63, 466, 275, 488, 12, 29038, 275, 488, 12, 627, 576, 304, 339, 1021, 12878, 19114, 8, 12942, 14, 19114, 304, 398, 347, 4907, 8, 277, 304, 288, 1499, 275, 283, 27606, 815, 2529, 376, 2701, 769, 7, 288, 367, 522, 315, 2838, 14, 27606, 815, 8, 277, 14, 1102, 12, 291, 14, 719, 12, 378, 12, 2838, 14, 9469, 63, 9484, 304, 355, 15871, 12, 6771, 466, 12, 4104, 12, 883, 265, 354, 12, 2937, 275, 522, 355, 862, 26, 490, 291, 14, 5096, 275, 2838, 14, 3450, 8, 2756, 12, 6771, 466, 12, 4104, 9, 490, 291, 14, 5096, 14, 24630, 8, 2593, 9, 490, 340, 291, 14, 1757, 1896, 690, 378, 26, 717, 870, 283, 2242, 26, 4366, 83, 12, 450, 83, 3171, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 490, 291, 14, 5096, 14, 2242, 8, 2231, 9, 355, 871, 2838, 14, 705, 465, 1499, 26, 490, 340, 291, 14, 1757, 1896, 690, 378, 26, 717, 870, 283, 2242, 2449, 6536, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 490, 340, 291, 14, 5096, 26, 717, 291, 14, 5096, 14, 1600, 342, 490, 291, 14, 5096, 275, 488, 490, 1980, 2234, 2059, 953, 340, 440, 291, 14, 5096, 26, 355, 746, 2838, 14, 705, 12, 1499, 339, 1021, 12878, 2856, 2461, 8, 4078, 18, 14, 2856, 2461, 304, 398, 347, 1455, 63, 1490, 8, 277, 12, 2648, 304, 288, 372, 291, 14, 1117, 63, 1490, 8, 6372, 19114, 12, 2648, 9, 339, 1021, 598, 8674, 10438, 8, 4078, 18, 14, 1563, 2461, 304, 398, 347, 1455, 63, 1069, 8, 277, 12, 2648, 304, 288, 2648, 14, 525, 63, 1291, 360, 8422, 13, 7630, 297, 283, 12256, 358, 288, 372, 2648, 398, 4178, 63, 1069, 275, 1455, 63, 1069, 398, 347, 1455, 63, 1310, 8, 277, 12, 2648, 12, 3085, 304, 288, 340, 3085, 14, 2139, 14, 362, 360, 1317, 13, 2991, 358, 508, 283, 12256, 356, 355, 11756, 275, 598, 3065, 1173, 8, 9234, 29, 6424, 8, 4518, 14, 739, 4000, 818, 534, 82, 358, 355, 5071, 63, 4518, 275, 3085, 355, 3085, 275, 4011, 18, 14, 525, 815, 633, 8, 12256, 12, 5071, 63, 4518, 14, 2139, 12, 5071, 63, 4518, 14, 633, 9, 355, 3085, 14, 600, 275, 5071, 63, 4518, 14, 600, 355, 3085, 14, 1328, 275, 5071, 63, 4518, 14, 1328, 288, 372, 3085, 398, 4178, 63, 1310, 275, 1455, 63, 1310, 339, 8297, 275, 359, 39, 8674, 10438, 12, 1362, 12878, 2856, 2461, 12, 1362, 4011, 18, 14, 2856, 2698, 25933, 12, 1362, 4011, 18, 14, 2856, 7071, 2461, 61, 272, 340, 29038, 365, 440, 488, 26, 267, 8297, 14, 740, 8, 4078, 18, 14, 2856, 7810, 10438, 8, 30552, 430, 272, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 2031, 5586, 9, 272, 1056, 275, 4011, 18, 14, 2017, 8, 633, 9, 272, 1056, 14, 525, 63, 1291, 360, 1899, 13, 7788, 297, 13044, 63, 14565, 9, 272, 340, 1564, 63, 466, 365, 440, 488, 26, 267, 1056, 14, 525, 63, 1291, 360, 2714, 13, 804, 297, 1564, 63, 466, 9, 272, 372, 16088, 14, 1490, 8, 1069, 12, 627, 576, 9, 421, 199, 318, 2342, 63, 3280, 8, 633, 304, 272, 5687, 12, 10154, 12, 931, 12, 30903, 12, 1827, 12, 7956, 275, 7097, 14, 10290, 8, 633, 9, 272, 14942, 275, 4011, 14, 362, 17128, 342, 272, 4566, 1102, 275, 488, 272, 340, 5687, 315, 14942, 26, 267, 340, 22143, 315, 10154, 26, 288, 308, 2996, 275, 10154, 14, 1623, 16591, 358, 435, 413, 267, 587, 26, 288, 308, 2996, 275, 378, 267, 325, 2996, 275, 10154, 14, 1623, 11633, 267, 340, 325, 2996, 508, 446, 17, 26, 288, 325, 2996, 275, 822, 8, 12652, 9, 267, 1591, 275, 10154, 59, 4148, 88, 26, 69, 2996, 61, 267, 340, 440, 334, 1102, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 503, 4011, 14, 3280, 63, 20605, 8, 1102, 2298, 288, 4566, 633, 275, 14942, 59, 5512, 61, 288, 4566, 17482, 275, 7097, 14, 10290, 8, 3280, 633, 9, 288, 4566, 1102, 275, 4566, 17482, 59, 17, 61, 272, 340, 10990, 26, 267, 870, 4331, 984, 14, 3083, 12, 283, 1623, 63, 3280, 26, 24734, 14942, 297, 14942, 12, 283, 5511, 297, 4566, 1102, 12, 283, 2632, 1990, 297, 1166, 272, 372, 4566, 1102, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 27395, 570, 536, 26, 6570, 654, 84, 1091, 60, 5402, 60, 22905, 60, 2593, 10890, 14, 22345, 199, 646, 984, 199, 646, 8809, 199, 646, 2838, 199, 646, 4011, 18, 199, 646, 4011, 199, 646, 7097, 199, 504, 11756, 492, 598, 3065, 1173, 199, 504, 5228, 492, 5228, 199, 504, 6570, 654, 84, 1091, 14, 1023, 492, 15945, 199, 3791, 63, 14565, 275, 283, 21287, 84, 1091, 4805, 435, 15945, 199, 5287, 275, 756, 199, 199, 318, 1166, 4299, 6372, 8, 633, 12, 2653, 275, 4233, 12, 1564, 63, 466, 275, 488, 12, 29038, 275, 488, 12, 627, 576, 304, 339, 1021, 12878, 19114, 8, 12942, 14, 19114, 304, 398, 347, 4907, 8, 277, 304, 288, 1499, 275, 283, 27606, 815, 2529, 376, 2701, 769, 7, 288, 367, 522, 315, 2838, 14, 27606, 815, 8, 277, 14, 1102, 12, 291, 14, 719, 12, 378, 12, 2838, 14, 9469, 63, 9484, 304, 355, 15871, 12, 6771, 466, 12, 4104, 12, 883, 265, 354, 12, 2937, 275, 522, 355, 862, 26, 490, 291, 14, 5096, 275, 2838, 14, 3450, 8, 2756, 12, 6771, 466, 12, 4104, 9, 490, 291, 14, 5096, 14, 24630, 8, 2593, 9, 490, 340, 291, 14, 1757, 1896, 690, 378, 26, 717, 870, 283, 2242, 26, 4366, 83, 12, 450, 83, 3171, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 490, 291, 14, 5096, 14, 2242, 8, 2231, 9, 355, 871, 2838, 14, 705, 465, 1499, 26, 490, 340, 291, 14, 1757, 1896, 690, 378, 26, 717, 870, 283, 2242, 2449, 6536, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 490, 340, 291, 14, 5096, 26, 717, 291, 14, 5096, 14, 1600, 342, 490, 291, 14, 5096, 275, 488, 490, 1980, 2234, 2059, 953, 340, 440, 291, 14, 5096, 26, 355, 746, 2838, 14, 705, 12, 1499, 339, 1021, 12878, 2856, 2461, 8, 4078, 18, 14, 2856, 2461, 304, 398, 347, 1455, 63, 1490, 8, 277, 12, 2648, 304, 288, 372, 291, 14, 1117, 63, 1490, 8, 6372, 19114, 12, 2648, 9, 339, 1021, 598, 8674, 10438, 8, 4078, 18, 14, 1563, 2461, 304, 398, 347, 1455, 63, 1069, 8, 277, 12, 2648, 304, 288, 2648, 14, 525, 63, 1291, 360, 8422, 13, 7630, 297, 283, 12256, 358, 288, 372, 2648, 398, 4178, 63, 1069, 275, 1455, 63, 1069, 398, 347, 1455, 63, 1310, 8, 277, 12, 2648, 12, 3085, 304, 288, 340, 3085, 14, 2139, 14, 362, 360, 1317, 13, 2991, 358, 508, 283, 12256, 356, 355, 11756, 275, 598, 3065, 1173, 8, 9234, 29, 6424, 8, 4518, 14, 739, 4000, 818, 534, 82, 358, 355, 5071, 63, 4518, 275, 3085, 355, 3085, 275, 4011, 18, 14, 525, 815, 633, 8, 12256, 12, 5071, 63, 4518, 14, 2139, 12, 5071, 63, 4518, 14, 633, 9, 355, 3085, 14, 600, 275, 5071, 63, 4518, 14, 600, 355, 3085, 14, 1328, 275, 5071, 63, 4518, 14, 1328, 288, 372, 3085, 398, 4178, 63, 1310, 275, 1455, 63, 1310, 339, 8297, 275, 359, 39, 8674, 10438, 12, 1362, 12878, 2856, 2461, 12, 1362, 4011, 18, 14, 2856, 2698, 25933, 12, 1362, 4011, 18, 14, 2856, 7071, 2461, 61, 272, 340, 29038, 365, 440, 488, 26, 267, 8297, 14, 740, 8, 4078, 18, 14, 2856, 7810, 10438, 8, 30552, 430, 272, 16088, 275, 4011, 18, 14, 1506, 63, 11637, 2031, 5586, 9, 272, 1056, 275, 4011, 18, 14, 2017, 8, 633, 9, 272, 1056, 14, 525, 63, 1291, 360, 1899, 13, 7788, 297, 13044, 63, 14565, 9, 272, 340, 1564, 63, 466, 365, 440, 488, 26, 267, 1056, 14, 525, 63, 1291, 360, 2714, 13, 804, 297, 1564, 63, 466, 9, 272, 372, 16088, 14, 1490, 8, 1069, 12, 627, 576, 9, 421, 199, 318, 2342, 63, 3280, 8, 633, 304, 272, 5687, 12, 10154, 12, 931, 12, 30903, 12, 1827, 12, 7956, 275, 7097, 14, 10290, 8, 633, 9, 272, 14942, 275, 4011, 14, 362, 17128, 342, 272, 4566, 1102, 275, 488, 272, 340, 5687, 315, 14942, 26, 267, 340, 22143, 315, 10154, 26, 288, 308, 2996, 275, 10154, 14, 1623, 16591, 358, 435, 413, 267, 587, 26, 288, 308, 2996, 275, 378, 267, 325, 2996, 275, 10154, 14, 1623, 11633, 267, 340, 325, 2996, 508, 446, 17, 26, 288, 325, 2996, 275, 822, 8, 12652, 9, 267, 1591, 275, 10154, 59, 4148, 88, 26, 69, 2996, 61, 267, 340, 440, 334, 1102, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 503, 4011, 14, 3280, 63, 20605, 8, 1102, 2298, 288, 4566, 633, 275, 14942, 59, 5512, 61, 288, 4566, 17482, 275, 7097, 14, 10290, 8, 3280, 633, 9, 288, 4566, 1102, 275, 4566, 17482, 59, 17, 61, 272, 340, 10990, 26, 267, 870, 4331, 984, 14, 3083, 12, 283, 1623, 63, 3280, 26, 24734, 14942, 297, 14942, 12, 283, 5511, 297, 4566, 1102, 12, 283, 2632, 1990, 297, 1166, 272, 372, 4566, 1102, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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