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
liangwang/m5
configs/example/fs.py
1
5997
# 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: Ali Saidi import optparse import os import sys import m5 from m5.defines import buildEnv from m5.objects import * from m5.util import addToPath, fatal if not buildEnv['FULL_SYSTEM']: fatal("This script requires full-system mode (*_FS).") addToPath('../common') from FSConfig import * from SysPaths import * from Benchmarks import * import Simulation import CacheConfig from Caches import * # Get paths we might need. It's expected this file is in m5/configs/example. config_path = os.path.dirname(os.path.abspath(__file__)) config_root = os.path.dirname(config_path) parser = optparse.OptionParser() # System options parser.add_option("--kernel", action="store", type="string") parser.add_option("--script", action="store", type="string") # Benchmark options parser.add_option("--dual", action="store_true", help="Simulate two systems attached with an ethernet link") parser.add_option("-b", "--benchmark", action="store", type="string", dest="benchmark", help="Specify the benchmark to run. Available benchmarks: %s"\ % DefinedBenchmarks) # Metafile options parser.add_option("--etherdump", action="store", type="string", dest="etherdump", help="Specify the filename to dump a pcap capture of the" \ "ethernet traffic") execfile(os.path.join(config_root, "common", "Options.py")) (options, args) = parser.parse_args() if args: print "Error: script doesn't take any positional arguments" sys.exit(1) # driver system CPU is always simple... note this is an assignment of # a class, not an instance. DriveCPUClass = AtomicSimpleCPU drive_mem_mode = 'atomic' # system under test can be any CPU (TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) TestCPUClass.clock = '2GHz' DriveCPUClass.clock = '2GHz' if options.benchmark: try: bm = Benchmarks[options.benchmark] except KeyError: print "Error benchmark %s has not been defined." % options.benchmark print "Valid benchmarks are: %s" % DefinedBenchmarks sys.exit(1) else: if options.dual: bm = [SysConfig(), SysConfig()] else: bm = [SysConfig()] np = options.num_cpus if buildEnv['TARGET_ISA'] == "alpha": test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0]) elif buildEnv['TARGET_ISA'] == "mips": test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0]) elif buildEnv['TARGET_ISA'] == "sparc": test_sys = makeSparcSystem(test_mem_mode, bm[0]) elif buildEnv['TARGET_ISA'] == "x86": test_sys = makeLinuxX86System(test_mem_mode, np, bm[0]) else: fatal("incapable of building non-alpha or non-sparc full system!") if options.kernel is not None: test_sys.kernel = binary(options.kernel) if options.script is not None: test_sys.readfile = options.script test_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)] CacheConfig.config_cache(options, test_sys) if options.caches or options.l2cache: test_sys.bridge.filter_ranges_a=[AddrRange(0, Addr.max)] test_sys.bridge.filter_ranges_b=[AddrRange(0, size='8GB')] test_sys.iocache = IOCache(addr_range=AddrRange(0, size='8GB')) test_sys.iocache.cpu_side = test_sys.iobus.port test_sys.iocache.mem_side = test_sys.membus.port for i in xrange(np): if options.fastmem: test_sys.cpu[i].physmem_port = test_sys.physmem.port if buildEnv['TARGET_ISA'] == 'mips': setMipsOptions(TestCPUClass) if len(bm) == 2: if buildEnv['TARGET_ISA'] == 'alpha': drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) elif buildEnv['TARGET_ISA'] == 'mips': drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1]) elif buildEnv['TARGET_ISA'] == 'sparc': drive_sys = makeSparcSystem(drive_mem_mode, bm[1]) elif buildEnv['TARGET_ISA'] == 'x86': drive_sys = makeX86System(drive_mem_mode, np, bm[1]) drive_sys.cpu = DriveCPUClass(cpu_id=0) drive_sys.cpu.connectMemPorts(drive_sys.membus) if options.fastmem: drive_sys.cpu.physmem_port = drive_sys.physmem.port if options.kernel is not None: drive_sys.kernel = binary(options.kernel) root = makeDualRoot(test_sys, drive_sys, options.etherdump) elif len(bm) == 1: root = Root(system=test_sys) else: print "Error I don't know how to create more than 2 systems." sys.exit(1) Simulation.run(options, root, test_sys, FutureClass)
bsd-3-clause
[ 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, 15170, 428, 5789, 328, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 333, 21, 14, 1974, 492, 1050, 1378, 2042, 12, 14294, 199, 199, 692, 440, 1900, 7744, 459, 14742, 63, 12711, 2565, 272, 14294, 480, 2765, 2884, 5074, 2615, 13, 2253, 818, 19943, 63, 7079, 26744, 199, 199, 525, 1378, 2042, 24592, 2330, 358, 199, 199, 504, 27500, 2028, 492, 627, 199, 504, 28766, 11804, 492, 627, 199, 504, 27067, 83, 492, 627, 199, 646, 10751, 5332, 199, 646, 11977, 2028, 199, 504, 445, 1225, 397, 492, 627, 199, 199, 3, 2372, 3792, 781, 5594, 1929, 14, 221, 2779, 1159, 1420, 642, 570, 365, 315, 333, 21, 15, 7532, 15, 2694, 14, 199, 888, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 888, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 515, 9, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 199, 3, 6187, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 4989, 401, 1595, 628, 1617, 401, 730, 628, 875, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1579, 401, 1595, 628, 1617, 401, 730, 628, 875, 531, 199, 199, 3, 27067, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 17962, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 7467, 5434, 2877, 10460, 10102, 543, 376, 21944, 2142, 531, 199, 2087, 14, 525, 63, 1422, 6096, 66, 401, 4320, 11861, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2116, 2053, 628, 11861, 401, 2116, 1720, 628, 17768, 314, 12338, 370, 1255, 14, 23840, 12338, 83, 26, 450, 83, 3212, 2116, 450, 11391, 1942, 18644, 83, 9, 199, 199, 3, 6288, 493, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 27732, 2724, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2053, 628, 27732, 2724, 401, 2116, 1720, 628, 17768, 314, 1788, 370, 5461, 282, 18606, 12296, 402, 314, 2, 971, 2116, 298, 20354, 15602, 531, 199, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 888, 63, 1231, 12, 298, 2330, 401, 298, 4558, 14, 647, 2237, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 1249, 26, 272, 870, 298, 547, 26, 2884, 3181, 1133, 5452, 1263, 11333, 2368, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 5253, 2656, 11952, 365, 3544, 3486, 1396, 5317, 642, 365, 376, 9801, 402, 199, 3, 282, 1021, 12, 440, 376, 1256, 14, 199, 24276, 11011, 2543, 275, 18840, 530, 3184, 11011, 199, 9541, 63, 5286, 63, 632, 275, 283, 10910, 7, 199, 199, 3, 2656, 1334, 511, 883, 506, 1263, 11952, 199, 8, 774, 11011, 2543, 12, 511, 63, 5286, 63, 632, 12, 20799, 2543, 9, 275, 10751, 5332, 14, 409, 11011, 2543, 8, 1419, 9, 199, 199, 774, 11011, 2543, 14, 9597, 275, 283, 18, 39, 13026, 7, 199, 24276, 11011, 2543, 14, 9597, 275, 283, 18, 39, 13026, 7, 199, 199, 692, 1511, 14, 11861, 26, 272, 862, 26, 267, 25425, 275, 27067, 83, 59, 1419, 14, 11861, 61, 272, 871, 4067, 26, 267, 870, 298, 547, 12338, 450, 83, 965, 440, 2757, 3247, 2122, 450, 1511, 14, 11861, 267, 870, 298, 3490, 12338, 83, 787, 26, 450, 83, 2, 450, 11391, 1942, 18644, 83, 267, 984, 14, 2224, 8, 17, 9, 199, 2836, 26, 272, 340, 1511, 14, 17962, 26, 267, 25425, 275, 359, 11319, 2028, 1062, 28766, 2028, 5106, 272, 587, 26, 267, 25425, 275, 359, 11319, 2028, 5106, 199, 199, 1590, 275, 1511, 14, 1507, 63, 8896, 199, 199, 692, 1900, 7744, 459, 9268, 63, 1311, 33, 418, 508, 298, 4468, 582, 272, 511, 63, 1274, 275, 1852, 14091, 16192, 3989, 8, 396, 63, 5286, 63, 632, 12, 25425, 59, 16, 566, 199, 4164, 1900, 7744, 459, 9268, 63, 1311, 33, 418, 508, 298, 77, 6142, 582, 272, 511, 63, 1274, 275, 1852, 14091, 45, 6142, 3989, 8, 396, 63, 5286, 63, 632, 12, 25425, 59, 16, 566, 199, 4164, 1900, 7744, 459, 9268, 63, 1311, 33, 418 ]
[ 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, 15170, 428, 5789, 328, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 333, 21, 14, 1974, 492, 1050, 1378, 2042, 12, 14294, 199, 199, 692, 440, 1900, 7744, 459, 14742, 63, 12711, 2565, 272, 14294, 480, 2765, 2884, 5074, 2615, 13, 2253, 818, 19943, 63, 7079, 26744, 199, 199, 525, 1378, 2042, 24592, 2330, 358, 199, 199, 504, 27500, 2028, 492, 627, 199, 504, 28766, 11804, 492, 627, 199, 504, 27067, 83, 492, 627, 199, 646, 10751, 5332, 199, 646, 11977, 2028, 199, 504, 445, 1225, 397, 492, 627, 199, 199, 3, 2372, 3792, 781, 5594, 1929, 14, 221, 2779, 1159, 1420, 642, 570, 365, 315, 333, 21, 15, 7532, 15, 2694, 14, 199, 888, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 888, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 515, 9, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 199, 3, 6187, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 4989, 401, 1595, 628, 1617, 401, 730, 628, 875, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1579, 401, 1595, 628, 1617, 401, 730, 628, 875, 531, 199, 199, 3, 27067, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 17962, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 7467, 5434, 2877, 10460, 10102, 543, 376, 21944, 2142, 531, 199, 2087, 14, 525, 63, 1422, 6096, 66, 401, 4320, 11861, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2116, 2053, 628, 11861, 401, 2116, 1720, 628, 17768, 314, 12338, 370, 1255, 14, 23840, 12338, 83, 26, 450, 83, 3212, 2116, 450, 11391, 1942, 18644, 83, 9, 199, 199, 3, 6288, 493, 1511, 199, 2087, 14, 525, 63, 1422, 6739, 27732, 2724, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2053, 628, 27732, 2724, 401, 2116, 1720, 628, 17768, 314, 1788, 370, 5461, 282, 18606, 12296, 402, 314, 2, 971, 2116, 298, 20354, 15602, 531, 199, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 888, 63, 1231, 12, 298, 2330, 401, 298, 4558, 14, 647, 2237, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 1249, 26, 272, 870, 298, 547, 26, 2884, 3181, 1133, 5452, 1263, 11333, 2368, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 5253, 2656, 11952, 365, 3544, 3486, 1396, 5317, 642, 365, 376, 9801, 402, 199, 3, 282, 1021, 12, 440, 376, 1256, 14, 199, 24276, 11011, 2543, 275, 18840, 530, 3184, 11011, 199, 9541, 63, 5286, 63, 632, 275, 283, 10910, 7, 199, 199, 3, 2656, 1334, 511, 883, 506, 1263, 11952, 199, 8, 774, 11011, 2543, 12, 511, 63, 5286, 63, 632, 12, 20799, 2543, 9, 275, 10751, 5332, 14, 409, 11011, 2543, 8, 1419, 9, 199, 199, 774, 11011, 2543, 14, 9597, 275, 283, 18, 39, 13026, 7, 199, 24276, 11011, 2543, 14, 9597, 275, 283, 18, 39, 13026, 7, 199, 199, 692, 1511, 14, 11861, 26, 272, 862, 26, 267, 25425, 275, 27067, 83, 59, 1419, 14, 11861, 61, 272, 871, 4067, 26, 267, 870, 298, 547, 12338, 450, 83, 965, 440, 2757, 3247, 2122, 450, 1511, 14, 11861, 267, 870, 298, 3490, 12338, 83, 787, 26, 450, 83, 2, 450, 11391, 1942, 18644, 83, 267, 984, 14, 2224, 8, 17, 9, 199, 2836, 26, 272, 340, 1511, 14, 17962, 26, 267, 25425, 275, 359, 11319, 2028, 1062, 28766, 2028, 5106, 272, 587, 26, 267, 25425, 275, 359, 11319, 2028, 5106, 199, 199, 1590, 275, 1511, 14, 1507, 63, 8896, 199, 199, 692, 1900, 7744, 459, 9268, 63, 1311, 33, 418, 508, 298, 4468, 582, 272, 511, 63, 1274, 275, 1852, 14091, 16192, 3989, 8, 396, 63, 5286, 63, 632, 12, 25425, 59, 16, 566, 199, 4164, 1900, 7744, 459, 9268, 63, 1311, 33, 418, 508, 298, 77, 6142, 582, 272, 511, 63, 1274, 275, 1852, 14091, 45, 6142, 3989, 8, 396, 63, 5286, 63, 632, 12, 25425, 59, 16, 566, 199, 4164, 1900, 7744, 459, 9268, 63, 1311, 33, 418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ghickman/django
django/template/defaultfilters.py
13
27084
"""Default variable filters.""" from __future__ import unicode_literals import random as random_module import re from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation from functools import wraps from pprint import pformat from django.conf import settings from django.utils import formats, six from django.utils.dateformat import format, time_format from django.utils.encoding import force_text, iri_to_uri from django.utils.html import ( avoid_wrapping, conditional_escape, escape, escapejs, linebreaks, strip_tags, urlize as _urlize, ) from django.utils.http import urlquote from django.utils.safestring import SafeData, mark_for_escaping, mark_safe from django.utils.text import ( Truncator, normalize_newlines, phone2numeric, slugify as _slugify, wrap, ) from django.utils.timesince import timesince, timeuntil from django.utils.translation import ugettext, ungettext from .base import Variable, VariableDoesNotExist from .library import Library register = Library() ####################### # STRING DECORATOR # ####################### def stringfilter(func): """ Decorator for filters which should only receive unicode objects. The object passed as the first positional argument will be converted to a unicode object. """ def _dec(*args, **kwargs): if args: args = list(args) args[0] = force_text(args[0]) if (isinstance(args[0], SafeData) and getattr(_dec._decorated_function, 'is_safe', False)): return mark_safe(func(*args, **kwargs)) return func(*args, **kwargs) # Include a reference to the real function (used to check original # arguments by the template parser, and to bear the 'is_safe' attribute # when multiple decorators are applied). _dec._decorated_function = getattr(func, '_decorated_function', func) return wraps(func)(_dec) ################### # STRINGS # ################### @register.filter(is_safe=True) @stringfilter def addslashes(value): """ Adds slashes before quotes. Useful for escaping strings in CSV, for example. Less useful for escaping JavaScript; use the ``escapejs`` filter instead. """ return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'") @register.filter(is_safe=True) @stringfilter def capfirst(value): """Capitalizes the first character of the value.""" return value and value[0].upper() + value[1:] @register.filter("escapejs") @stringfilter def escapejs_filter(value): """Hex encodes characters for use in JavaScript strings.""" return escapejs(value) # Values for testing floatformat input against infinity and NaN representations, # which differ across platforms and Python versions. Some (i.e. old Windows # ones) are not recognized by Decimal but we want to return them unchanged vs. # returning an empty string as we do for completely invalid input. Note these # need to be built up from values that are not inf/nan, since inf/nan values do # not reload properly from .pyc files on Windows prior to some level of Python 2.5 # (see Python Issue757815 and Issue1080440). pos_inf = 1e200 * 1e200 neg_inf = -1e200 * 1e200 nan = (1e200 * 1e200) // (1e200 * 1e200) special_floats = [str(pos_inf), str(neg_inf), str(nan)] @register.filter(is_safe=True) def floatformat(text, arg=-1): """ Displays a float to a specified number of decimal places. If called without an argument, it displays the floating point number with one decimal place -- but only if there's a decimal place to be displayed: * num1 = 34.23234 * num2 = 34.00000 * num3 = 34.26000 * {{ num1|floatformat }} displays "34.2" * {{ num2|floatformat }} displays "34" * {{ num3|floatformat }} displays "34.3" If arg is positive, it will always display exactly arg number of decimal places: * {{ num1|floatformat:3 }} displays "34.232" * {{ num2|floatformat:3 }} displays "34.000" * {{ num3|floatformat:3 }} displays "34.260" If arg is negative, it will display arg number of decimal places -- but only if there are places to be displayed: * {{ num1|floatformat:"-3" }} displays "34.232" * {{ num2|floatformat:"-3" }} displays "34" * {{ num3|floatformat:"-3" }} displays "34.260" If the input float is infinity or NaN, the (platform-dependent) string representation of that value will be displayed. """ try: input_val = force_text(text) d = Decimal(input_val) except UnicodeEncodeError: return '' except InvalidOperation: if input_val in special_floats: return input_val try: d = Decimal(force_text(float(text))) except (ValueError, InvalidOperation, TypeError, UnicodeEncodeError): return '' try: p = int(arg) except ValueError: return input_val try: m = int(d) - d except (ValueError, OverflowError, InvalidOperation): return input_val if not m and p < 0: return mark_safe(formats.number_format('%d' % (int(d)), 0)) if p == 0: exp = Decimal(1) else: exp = Decimal('1.0') / (Decimal(10) ** abs(p)) try: # Set the precision high enough to avoid an exception, see #15789. tupl = d.as_tuple() units = len(tupl[1]) - tupl[2] prec = abs(p) + units + 1 # Avoid conversion to scientific notation by accessing `sign`, `digits` # and `exponent` from `Decimal.as_tuple()` directly. sign, digits, exponent = d.quantize(exp, ROUND_HALF_UP, Context(prec=prec)).as_tuple() digits = [six.text_type(digit) for digit in reversed(digits)] while len(digits) <= abs(exponent): digits.append('0') digits.insert(-exponent, '.') if sign: digits.append('-') number = ''.join(reversed(digits)) return mark_safe(formats.number_format(number, abs(p))) except InvalidOperation: return input_val @register.filter(is_safe=True) @stringfilter def iriencode(value): """Escapes an IRI value for use in a URL.""" return force_text(iri_to_uri(value)) @register.filter(is_safe=True, needs_autoescape=True) @stringfilter def linenumbers(value, autoescape=True): """Displays text with line numbers.""" lines = value.split('\n') # Find the maximum width of the line count, for use with zero padding # string format command width = six.text_type(len(six.text_type(len(lines)))) if not autoescape or isinstance(value, SafeData): for i, line in enumerate(lines): lines[i] = ("%0" + width + "d. %s") % (i + 1, line) else: for i, line in enumerate(lines): lines[i] = ("%0" + width + "d. %s") % (i + 1, escape(line)) return mark_safe('\n'.join(lines)) @register.filter(is_safe=True) @stringfilter def lower(value): """Converts a string into all lowercase.""" return value.lower() @register.filter(is_safe=False) @stringfilter def make_list(value): """ Returns the value turned into a list. For an integer, it's a list of digits. For a string, it's a list of characters. """ return list(value) @register.filter(is_safe=True) @stringfilter def slugify(value): """ Converts to ASCII. Converts spaces to hyphens. Removes characters that aren't alphanumerics, underscores, or hyphens. Converts to lowercase. Also strips leading and trailing whitespace. """ return _slugify(value) @register.filter(is_safe=True) def stringformat(value, arg): """ Formats the variable according to the arg, a string formatting specifier. This specifier uses Python string formating syntax, with the exception that the leading "%" is dropped. See http://docs.python.org/lib/typesseq-strings.html for documentation of Python string formatting """ try: return ("%" + six.text_type(arg)) % value except (ValueError, TypeError): return "" @register.filter(is_safe=True) @stringfilter def title(value): """Converts a string into titlecase.""" t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title()) return re.sub("\d([A-Z])", lambda m: m.group(0).lower(), t) @register.filter(is_safe=True) @stringfilter def truncatechars(value, arg): """ Truncates a string after a certain number of characters. Argument: Number of characters to truncate after. """ try: length = int(arg) except ValueError: # Invalid literal for int(). return value # Fail silently. return Truncator(value).chars(length) @register.filter(is_safe=True) @stringfilter def truncatechars_html(value, arg): """ Truncates HTML after a certain number of chars. Argument: Number of chars to truncate after. Newlines in the HTML are preserved. """ try: length = int(arg) except ValueError: # invalid literal for int() return value # Fail silently. return Truncator(value).chars(length, html=True) @register.filter(is_safe=True) @stringfilter def truncatewords(value, arg): """ Truncates a string after a certain number of words. Argument: Number of words to truncate after. Newlines within the string are removed. """ try: length = int(arg) except ValueError: # Invalid literal for int(). return value # Fail silently. return Truncator(value).words(length, truncate=' ...') @register.filter(is_safe=True) @stringfilter def truncatewords_html(value, arg): """ Truncates HTML after a certain number of words. Argument: Number of words to truncate after. Newlines in the HTML are preserved. """ try: length = int(arg) except ValueError: # invalid literal for int() return value # Fail silently. return Truncator(value).words(length, html=True, truncate=' ...') @register.filter(is_safe=False) @stringfilter def upper(value): """Converts a string into all uppercase.""" return value.upper() @register.filter(is_safe=False) @stringfilter def urlencode(value, safe=None): """ Escapes a value for use in a URL. Takes an optional ``safe`` parameter used to determine the characters which should not be escaped by Django's ``urlquote`` method. If not provided, the default safe characters will be used (but an empty string can be provided when *all* characters should be escaped). """ kwargs = {} if safe is not None: kwargs['safe'] = safe return urlquote(value, **kwargs) @register.filter(is_safe=True, needs_autoescape=True) @stringfilter def urlize(value, autoescape=True): """Converts URLs in plain text into clickable links.""" return mark_safe(_urlize(value, nofollow=True, autoescape=autoescape)) @register.filter(is_safe=True, needs_autoescape=True) @stringfilter def urlizetrunc(value, limit, autoescape=True): """ Converts URLs into clickable links, truncating URLs to the given character limit, and adding 'rel=nofollow' attribute to discourage spamming. Argument: Length to truncate URLs to. """ return mark_safe(_urlize(value, trim_url_limit=int(limit), nofollow=True, autoescape=autoescape)) @register.filter(is_safe=False) @stringfilter def wordcount(value): """Returns the number of words.""" return len(value.split()) @register.filter(is_safe=True) @stringfilter def wordwrap(value, arg): """ Wraps words at specified line length. Argument: number of characters to wrap the text at. """ return wrap(value, int(arg)) @register.filter(is_safe=True) @stringfilter def ljust(value, arg): """ Left-aligns the value in a field of a given width. Argument: field size. """ return value.ljust(int(arg)) @register.filter(is_safe=True) @stringfilter def rjust(value, arg): """ Right-aligns the value in a field of a given width. Argument: field size. """ return value.rjust(int(arg)) @register.filter(is_safe=True) @stringfilter def center(value, arg): """Centers the value in a field of a given width.""" return value.center(int(arg)) @register.filter @stringfilter def cut(value, arg): """ Removes all values of arg from the given string. """ safe = isinstance(value, SafeData) value = value.replace(arg, '') if safe and arg != ';': return mark_safe(value) return value ################### # HTML STRINGS # ################### @register.filter("escape", is_safe=True) @stringfilter def escape_filter(value): """ Marks the value as a string that should be auto-escaped. """ return mark_for_escaping(value) @register.filter(is_safe=True) @stringfilter def force_escape(value): """ Escapes a string's HTML. This returns a new string containing the escaped characters (as opposed to "escape", which marks the content for later possible escaping). """ return escape(value) @register.filter("linebreaks", is_safe=True, needs_autoescape=True) @stringfilter def linebreaks_filter(value, autoescape=True): """ Replaces line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (``<br />``) and a new line followed by a blank line becomes a paragraph break (``</p>``). """ autoescape = autoescape and not isinstance(value, SafeData) return mark_safe(linebreaks(value, autoescape)) @register.filter(is_safe=True, needs_autoescape=True) @stringfilter def linebreaksbr(value, autoescape=True): """ Converts all newlines in a piece of plain text to HTML line breaks (``<br />``). """ autoescape = autoescape and not isinstance(value, SafeData) value = normalize_newlines(value) if autoescape: value = escape(value) return mark_safe(value.replace('\n', '<br />')) @register.filter(is_safe=True) @stringfilter def safe(value): """ Marks the value as a string that should not be auto-escaped. """ return mark_safe(value) @register.filter(is_safe=True) def safeseq(value): """ A "safe" filter for sequences. Marks each element in the sequence, individually, as safe, after converting them to unicode. Returns a list with the results. """ return [mark_safe(force_text(obj)) for obj in value] @register.filter(is_safe=True) @stringfilter def striptags(value): """Strips all [X]HTML tags.""" return strip_tags(value) ################### # LISTS # ################### @register.filter(is_safe=False) def dictsort(value, arg): """ Takes a list of dicts, returns that list sorted by the property given in the argument. """ try: return sorted(value, key=Variable(arg).resolve) except (TypeError, VariableDoesNotExist): return '' @register.filter(is_safe=False) def dictsortreversed(value, arg): """ Takes a list of dicts, returns that list sorted in reverse order by the property given in the argument. """ try: return sorted(value, key=Variable(arg).resolve, reverse=True) except (TypeError, VariableDoesNotExist): return '' @register.filter(is_safe=False) def first(value): """Returns the first item in a list.""" try: return value[0] except IndexError: return '' @register.filter(is_safe=True, needs_autoescape=True) def join(value, arg, autoescape=True): """ Joins a list with a string, like Python's ``str.join(list)``. """ value = map(force_text, value) if autoescape: value = [conditional_escape(v) for v in value] try: data = conditional_escape(arg).join(value) except AttributeError: # fail silently but nicely return value return mark_safe(data) @register.filter(is_safe=True) def last(value): "Returns the last item in a list" try: return value[-1] except IndexError: return '' @register.filter(is_safe=False) def length(value): """Returns the length of the value - useful for lists.""" try: return len(value) except (ValueError, TypeError): return 0 @register.filter(is_safe=False) def length_is(value, arg): """Returns a boolean of whether the value's length is the argument.""" try: return len(value) == int(arg) except (ValueError, TypeError): return '' @register.filter(is_safe=True) def random(value): """Returns a random item from the list.""" return random_module.choice(value) @register.filter("slice", is_safe=True) def slice_filter(value, arg): """ Returns a slice of the list. Uses the same syntax as Python's list slicing; see http://www.diveintopython3.net/native-datatypes.html#slicinglists for an introduction. """ try: bits = [] for x in arg.split(':'): if len(x) == 0: bits.append(None) else: bits.append(int(x)) return value[slice(*bits)] except (ValueError, TypeError): return value # Fail silently. @register.filter(is_safe=True, needs_autoescape=True) def unordered_list(value, autoescape=True): """ Recursively takes a self-nested list and returns an HTML unordered list -- WITHOUT opening and closing <ul> tags. The list is assumed to be in the proper format. For example, if ``var`` contains: ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then ``{{ var|unordered_list }}`` would return:: <li>States <ul> <li>Kansas <ul> <li>Lawrence</li> <li>Topeka</li> </ul> </li> <li>Illinois</li> </ul> </li> """ if autoescape: escaper = conditional_escape else: escaper = lambda x: x def walk_items(item_list): item_iterator = iter(item_list) try: item = next(item_iterator) while True: try: next_item = next(item_iterator) except StopIteration: yield item, None break if not isinstance(next_item, six.string_types): try: iter(next_item) except TypeError: pass else: yield item, next_item item = next(item_iterator) continue yield item, None item = next_item except StopIteration: pass def list_formatter(item_list, tabs=1): indent = '\t' * tabs output = [] for item, children in walk_items(item_list): sublist = '' if children: sublist = '\n%s<ul>\n%s\n%s</ul>\n%s' % ( indent, list_formatter(children, tabs + 1), indent, indent) output.append('%s<li>%s%s</li>' % ( indent, escaper(force_text(item)), sublist)) return '\n'.join(output) return mark_safe(list_formatter(value)) ################### # INTEGERS # ################### @register.filter(is_safe=False) def add(value, arg): """Adds the arg to the value.""" try: return int(value) + int(arg) except (ValueError, TypeError): try: return value + arg except Exception: return '' @register.filter(is_safe=False) def get_digit(value, arg): """ Given a whole number, returns the requested digit of it, where 1 is the right-most digit, 2 is the second-right-most digit, etc. Returns the original value for invalid input (if input or argument is not an integer, or if argument is less than 1). Otherwise, output is always an integer. """ try: arg = int(arg) value = int(value) except ValueError: return value # Fail silently for an invalid argument if arg < 1: return value try: return int(str(value)[-arg]) except IndexError: return 0 ################### # DATES # ################### @register.filter(expects_localtime=True, is_safe=False) def date(value, arg=None): """Formats a date according to the given format.""" if value in (None, ''): return '' if arg is None: arg = settings.DATE_FORMAT try: return formats.date_format(value, arg) except AttributeError: try: return format(value, arg) except AttributeError: return '' @register.filter(expects_localtime=True, is_safe=False) def time(value, arg=None): """Formats a time according to the given format.""" if value in (None, ''): return '' if arg is None: arg = settings.TIME_FORMAT try: return formats.time_format(value, arg) except AttributeError: try: return time_format(value, arg) except AttributeError: return '' @register.filter("timesince", is_safe=False) def timesince_filter(value, arg=None): """Formats a date as the time since that date (i.e. "4 days, 6 hours").""" if not value: return '' try: if arg: return timesince(value, arg) return timesince(value) except (ValueError, TypeError): return '' @register.filter("timeuntil", is_safe=False) def timeuntil_filter(value, arg=None): """Formats a date as the time until that date (i.e. "4 days, 6 hours").""" if not value: return '' try: return timeuntil(value, arg) except (ValueError, TypeError): return '' ################### # LOGIC # ################### @register.filter(is_safe=False) def default(value, arg): """If value is unavailable, use given default.""" return value or arg @register.filter(is_safe=False) def default_if_none(value, arg): """If value is None, use given default.""" if value is None: return arg return value @register.filter(is_safe=False) def divisibleby(value, arg): """Returns True if the value is divisible by the argument.""" return int(value) % int(arg) == 0 @register.filter(is_safe=False) def yesno(value, arg=None): """ Given a string mapping values for true, false and (optionally) None, returns one of those strings according to the value: ========== ====================== ================================== Value Argument Outputs ========== ====================== ================================== ``True`` ``"yeah,no,maybe"`` ``yeah`` ``False`` ``"yeah,no,maybe"`` ``no`` ``None`` ``"yeah,no,maybe"`` ``maybe`` ``None`` ``"yeah,no"`` ``"no"`` (converts None to False if no mapping for None is given. ========== ====================== ================================== """ if arg is None: arg = ugettext('yes,no,maybe') bits = arg.split(',') if len(bits) < 2: return value # Invalid arg. try: yes, no, maybe = bits except ValueError: # Unpack list of wrong size (no "maybe" value provided). yes, no, maybe = bits[0], bits[1], bits[1] if value is None: return maybe if value: return yes return no ################### # MISC # ################### @register.filter(is_safe=True) def filesizeformat(bytes_): """ Formats the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc). """ try: bytes_ = float(bytes_) except (TypeError, ValueError, UnicodeDecodeError): value = ungettext("%(size)d byte", "%(size)d bytes", 0) % {'size': 0} return avoid_wrapping(value) filesize_number_format = lambda value: formats.number_format(round(value, 1), 1) KB = 1 << 10 MB = 1 << 20 GB = 1 << 30 TB = 1 << 40 PB = 1 << 50 negative = bytes_ < 0 if negative: bytes_ = -bytes_ # Allow formatting of negative numbers. if bytes_ < KB: value = ungettext("%(size)d byte", "%(size)d bytes", bytes_) % {'size': bytes_} elif bytes_ < MB: value = ugettext("%s KB") % filesize_number_format(bytes_ / KB) elif bytes_ < GB: value = ugettext("%s MB") % filesize_number_format(bytes_ / MB) elif bytes_ < TB: value = ugettext("%s GB") % filesize_number_format(bytes_ / GB) elif bytes_ < PB: value = ugettext("%s TB") % filesize_number_format(bytes_ / TB) else: value = ugettext("%s PB") % filesize_number_format(bytes_ / PB) if negative: value = "-%s" % value return avoid_wrapping(value) @register.filter(is_safe=False) def pluralize(value, arg='s'): """ Returns a plural suffix if the value is not 1. By default, 's' is used as the suffix: * If value is 0, vote{{ value|pluralize }} displays "0 votes". * If value is 1, vote{{ value|pluralize }} displays "1 vote". * If value is 2, vote{{ value|pluralize }} displays "2 votes". If an argument is provided, that string is used instead: * If value is 0, class{{ value|pluralize:"es" }} displays "0 classes". * If value is 1, class{{ value|pluralize:"es" }} displays "1 class". * If value is 2, class{{ value|pluralize:"es" }} displays "2 classes". If the provided argument contains a comma, the text before the comma is used for the singular case and the text after the comma is used for the plural case: * If value is 0, cand{{ value|pluralize:"y,ies" }} displays "0 candies". * If value is 1, cand{{ value|pluralize:"y,ies" }} displays "1 candy". * If value is 2, cand{{ value|pluralize:"y,ies" }} displays "2 candies". """ if ',' not in arg: arg = ',' + arg bits = arg.split(',') if len(bits) > 2: return '' singular_suffix, plural_suffix = bits[:2] try: if float(value) != 1: return plural_suffix except ValueError: # Invalid string that's not a number. pass except TypeError: # Value isn't a string or a number; maybe it's a list? try: if len(value) != 1: return plural_suffix except TypeError: # len() of unsized object. pass return singular_suffix @register.filter("phone2numeric", is_safe=True) def phone2numeric_filter(value): """Takes a phone number and converts it in to its numerical equivalent.""" return phone2numeric(value) @register.filter(is_safe=True) def pprint(value): """A wrapper around pprint.pprint -- for debugging, really.""" try: return pformat(value) except Exception as e: return "Error in formatting: %s: %s" % (e.__class__.__name__, force_text(e, errors="replace"))
bsd-3-clause
[ 624, 2698, 1750, 4766, 1041, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2196, 465, 2196, 63, 578, 199, 646, 295, 199, 504, 6107, 492, 9769, 6131, 63, 30323, 63, 2160, 12, 9470, 12, 6345, 12, 6378, 6044, 199, 504, 9143, 492, 14018, 199, 504, 10933, 492, 30843, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 6752, 12, 3816, 199, 504, 1639, 14, 1208, 14, 602, 908, 492, 1475, 12, 900, 63, 908, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 1360, 492, 334, 272, 5126, 63, 87, 15521, 12, 12303, 63, 3765, 12, 4772, 12, 4772, 3596, 12, 1004, 18566, 12, 272, 6202, 63, 2969, 12, 7629, 13559, 465, 485, 300, 13559, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1166, 3513, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1451, 12, 2216, 63, 509, 63, 26306, 12, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 505, 492, 334, 272, 25594, 67, 707, 12, 7666, 63, 13839, 12, 14617, 18, 6677, 12, 29864, 465, 485, 5464, 2021, 12, 4816, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 32524, 492, 5431, 2855, 12, 900, 8111, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 12, 26843, 199, 199, 504, 1275, 1095, 492, 4905, 12, 4905, 7400, 199, 504, 1275, 4342, 492, 11243, 199, 199, 2683, 275, 11243, 342, 421, 199, 749, 14776, 199, 3, 18661, 3265, 18650, 6467, 259, 327, 199, 749, 14776, 199, 199, 318, 1059, 1541, 8, 1532, 304, 272, 408, 272, 30684, 367, 4766, 1314, 1077, 1454, 9128, 2649, 2251, 14, 710, 909, 272, 3032, 465, 314, 1642, 11333, 1423, 911, 506, 6702, 370, 282, 2649, 272, 909, 14, 272, 408, 272, 347, 485, 7778, 2031, 589, 12, 1011, 958, 304, 267, 340, 1249, 26, 288, 1249, 275, 769, 8, 589, 9, 288, 1249, 59, 16, 61, 275, 3542, 63, 505, 8, 589, 59, 16, 566, 288, 340, 334, 6074, 8, 589, 59, 16, 467, 14969, 1451, 9, 436, 490, 2519, 1547, 7778, 423, 29299, 63, 1593, 12, 283, 374, 63, 3489, 297, 756, 2298, 355, 372, 2216, 63, 3489, 8, 1532, 2031, 589, 12, 1011, 958, 430, 267, 372, 2562, 2031, 589, 12, 1011, 958, 9, 339, 327, 15783, 282, 3659, 370, 314, 3363, 805, 334, 2972, 370, 1104, 3379, 272, 327, 2368, 701, 314, 1978, 1798, 12, 436, 370, 506, 285, 314, 283, 374, 63, 3489, 7, 2225, 272, 327, 1380, 3663, 20419, 787, 6781, 680, 272, 485, 7778, 423, 29299, 63, 1593, 275, 2519, 8, 1532, 12, 2513, 29299, 63, 1593, 297, 2562, 9, 339, 372, 14018, 8, 1532, 9, 1547, 7778, 9, 421, 199, 749, 5680, 199, 3, 7553, 3881, 260, 327, 199, 749, 5680, 199, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 32, 875, 1541, 199, 318, 1050, 24032, 8, 585, 304, 272, 408, 272, 15747, 20275, 2544, 9344, 14, 18491, 367, 21375, 3326, 315, 14689, 12, 367, 272, 2893, 14, 7005, 385, 2997, 367, 21375, 15250, 27, 675, 314, 1124, 3765, 3596, 1040, 272, 2457, 3140, 14, 272, 408, 272, 372, 574, 14, 1814, 20786, 31375, 1959, 1814, 20630, 6468, 2, 1959, 1814, 27769, 9926, 9859, 421, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 32, 875, 1541, 199, 318, 4021, 2246, 8, 585, 304, 272, 408, 9155, 6910, 6491, 314, 1642, 4528, 402, 314, 574, 1041, 272, 372, 574, 436, 574, 59, 16, 1055, 4142, 342, 435, 574, 59, 17, 2938, 421, 199, 32, 2683, 14, 1541, 480, 3765, 3596, 531, 199, 32, 875, 1541, 199, 318, 4772, 3596, 63, 1541, 8, 585, 304, 272, 408, 10373, 3752, 83, 4110, 367, 675, 315, 15250, 3326, 1041, 272, 372, 4772, 3596, 8, 585, 9, 421, 199, 3, 13468, 367, 5343, 2069, 908, 1324, 6169, 23573, 436, 16046, 30580, 12, 199, 3, 1314, 14460, 9371, 10677, 436, 2018, 5459, 14, 221, 6601, 334, 73, 14, 69, 14, 2269, 5417, 199, 3, 7869, 9, 787, 440, 18054, 701, 6345, 1325, 781, 2934, 370, 372, 3062, 14874, 8118, 14, 199, 3, 8152, 376, 2701, 1059, 465, 781, 886, 367, 14793, 3866, 1324, 14, 221, 3390, 3520, 199, 3, 1929, 370, 506, 6137, 1536, 687, 1338, 626, 787, 440, 10739, 15, 4304, 12, 3967, 10739, 15, 4304, 1338, 886, 199, 3, 440, 13101, 7684, 687, 1275, 11357, 1584, 641, 5417, 6791, 370, 2005, 2166, 402, 2018, 499, 14, 21, 199, 3, 334, 3239, 2018, 13383, 23, 14992, 1046, 436, 13383, 8079, 16113, 680, 199, 1712, 63, 4904, 275, 413, 69, 1840, 627, 413, 69, 1840, 199, 8705, 63, 4904, 275, 446, 17, 69, 1840, 627, 413, 69, 1840, 199, 4304, 275, 334, 17, 69, 1840, 627, 413, 69, 1840, 9, 5001, 334, 17, 69, 1840, 627, 413, 69, 1840, 9, 199, 6664, 63, 1609, 83, 275, 359, 495, 8, 1712, 63, 4904, 395, 620, 8, 8705, 63, 4904, 395, 620, 8, 4304, 1874, 421, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 318, 2069, 908, 8, 505, 12, 1680, 4022, 17, 304, 272, 408, 272, 28750, 282, 2069, 370, 282, 2013, 1329, 402, 6107, 9825, 14, 339, 982, 2797, 1928, 376, 1423, 12, 652, 17561, 314, 8402, 2376, 1329, 543, 272, 1373, 6107, 4192, 1553, 1325, 1454, 340, 2337, 1159, 282, 6107, 4192, 370, 506, 9080, 26, 339, 627, 1967, 17, 275, 8177, 14, 8001, 1082, 272, 627, 1967, 18, 275, 8177, 14, 5345, 272, 627, 1967, 19, 275, 8177, 14, 1479, 1493, 272, 627, 8448, 1967, 17, 92, 31471, 3586, 17561, 298, 1082, 14, 18, 2, 272, 627, 8448, 1967, 18, 92, 31471, 3586, 17561, 298, 1082, 2, 272, 627, 8448, 1967, 19, 92, 31471, 3586, 17561, 298, 1082, 14, 19, 2, 339, 982, 1680, 365, 7317, 12, 652, 911, 3544, 2929, 8840, 1680, 1329, 402, 6107, 272, 9825, 26, 339, 627, 8448, 1967, 17, 92, 31471, 26, 19, 3586, 17561, 298, 1082, 14, 8001, 2, 272, 627, 8448, 1967, 18, 92, 31471, 26, 19, 3586, 17561, 298, 1082, 14, 1493 ]
[ 2698, 1750, 4766, 1041, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2196, 465, 2196, 63, 578, 199, 646, 295, 199, 504, 6107, 492, 9769, 6131, 63, 30323, 63, 2160, 12, 9470, 12, 6345, 12, 6378, 6044, 199, 504, 9143, 492, 14018, 199, 504, 10933, 492, 30843, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 6752, 12, 3816, 199, 504, 1639, 14, 1208, 14, 602, 908, 492, 1475, 12, 900, 63, 908, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 1360, 492, 334, 272, 5126, 63, 87, 15521, 12, 12303, 63, 3765, 12, 4772, 12, 4772, 3596, 12, 1004, 18566, 12, 272, 6202, 63, 2969, 12, 7629, 13559, 465, 485, 300, 13559, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1166, 3513, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1451, 12, 2216, 63, 509, 63, 26306, 12, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 505, 492, 334, 272, 25594, 67, 707, 12, 7666, 63, 13839, 12, 14617, 18, 6677, 12, 29864, 465, 485, 5464, 2021, 12, 4816, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 32524, 492, 5431, 2855, 12, 900, 8111, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 12, 26843, 199, 199, 504, 1275, 1095, 492, 4905, 12, 4905, 7400, 199, 504, 1275, 4342, 492, 11243, 199, 199, 2683, 275, 11243, 342, 421, 199, 749, 14776, 199, 3, 18661, 3265, 18650, 6467, 259, 327, 199, 749, 14776, 199, 199, 318, 1059, 1541, 8, 1532, 304, 272, 408, 272, 30684, 367, 4766, 1314, 1077, 1454, 9128, 2649, 2251, 14, 710, 909, 272, 3032, 465, 314, 1642, 11333, 1423, 911, 506, 6702, 370, 282, 2649, 272, 909, 14, 272, 408, 272, 347, 485, 7778, 2031, 589, 12, 1011, 958, 304, 267, 340, 1249, 26, 288, 1249, 275, 769, 8, 589, 9, 288, 1249, 59, 16, 61, 275, 3542, 63, 505, 8, 589, 59, 16, 566, 288, 340, 334, 6074, 8, 589, 59, 16, 467, 14969, 1451, 9, 436, 490, 2519, 1547, 7778, 423, 29299, 63, 1593, 12, 283, 374, 63, 3489, 297, 756, 2298, 355, 372, 2216, 63, 3489, 8, 1532, 2031, 589, 12, 1011, 958, 430, 267, 372, 2562, 2031, 589, 12, 1011, 958, 9, 339, 327, 15783, 282, 3659, 370, 314, 3363, 805, 334, 2972, 370, 1104, 3379, 272, 327, 2368, 701, 314, 1978, 1798, 12, 436, 370, 506, 285, 314, 283, 374, 63, 3489, 7, 2225, 272, 327, 1380, 3663, 20419, 787, 6781, 680, 272, 485, 7778, 423, 29299, 63, 1593, 275, 2519, 8, 1532, 12, 2513, 29299, 63, 1593, 297, 2562, 9, 339, 372, 14018, 8, 1532, 9, 1547, 7778, 9, 421, 199, 749, 5680, 199, 3, 7553, 3881, 260, 327, 199, 749, 5680, 199, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 32, 875, 1541, 199, 318, 1050, 24032, 8, 585, 304, 272, 408, 272, 15747, 20275, 2544, 9344, 14, 18491, 367, 21375, 3326, 315, 14689, 12, 367, 272, 2893, 14, 7005, 385, 2997, 367, 21375, 15250, 27, 675, 314, 1124, 3765, 3596, 1040, 272, 2457, 3140, 14, 272, 408, 272, 372, 574, 14, 1814, 20786, 31375, 1959, 1814, 20630, 6468, 2, 1959, 1814, 27769, 9926, 9859, 421, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 32, 875, 1541, 199, 318, 4021, 2246, 8, 585, 304, 272, 408, 9155, 6910, 6491, 314, 1642, 4528, 402, 314, 574, 1041, 272, 372, 574, 436, 574, 59, 16, 1055, 4142, 342, 435, 574, 59, 17, 2938, 421, 199, 32, 2683, 14, 1541, 480, 3765, 3596, 531, 199, 32, 875, 1541, 199, 318, 4772, 3596, 63, 1541, 8, 585, 304, 272, 408, 10373, 3752, 83, 4110, 367, 675, 315, 15250, 3326, 1041, 272, 372, 4772, 3596, 8, 585, 9, 421, 199, 3, 13468, 367, 5343, 2069, 908, 1324, 6169, 23573, 436, 16046, 30580, 12, 199, 3, 1314, 14460, 9371, 10677, 436, 2018, 5459, 14, 221, 6601, 334, 73, 14, 69, 14, 2269, 5417, 199, 3, 7869, 9, 787, 440, 18054, 701, 6345, 1325, 781, 2934, 370, 372, 3062, 14874, 8118, 14, 199, 3, 8152, 376, 2701, 1059, 465, 781, 886, 367, 14793, 3866, 1324, 14, 221, 3390, 3520, 199, 3, 1929, 370, 506, 6137, 1536, 687, 1338, 626, 787, 440, 10739, 15, 4304, 12, 3967, 10739, 15, 4304, 1338, 886, 199, 3, 440, 13101, 7684, 687, 1275, 11357, 1584, 641, 5417, 6791, 370, 2005, 2166, 402, 2018, 499, 14, 21, 199, 3, 334, 3239, 2018, 13383, 23, 14992, 1046, 436, 13383, 8079, 16113, 680, 199, 1712, 63, 4904, 275, 413, 69, 1840, 627, 413, 69, 1840, 199, 8705, 63, 4904, 275, 446, 17, 69, 1840, 627, 413, 69, 1840, 199, 4304, 275, 334, 17, 69, 1840, 627, 413, 69, 1840, 9, 5001, 334, 17, 69, 1840, 627, 413, 69, 1840, 9, 199, 6664, 63, 1609, 83, 275, 359, 495, 8, 1712, 63, 4904, 395, 620, 8, 8705, 63, 4904, 395, 620, 8, 4304, 1874, 421, 199, 32, 2683, 14, 1541, 8, 374, 63, 3489, 29, 549, 9, 199, 318, 2069, 908, 8, 505, 12, 1680, 4022, 17, 304, 272, 408, 272, 28750, 282, 2069, 370, 282, 2013, 1329, 402, 6107, 9825, 14, 339, 982, 2797, 1928, 376, 1423, 12, 652, 17561, 314, 8402, 2376, 1329, 543, 272, 1373, 6107, 4192, 1553, 1325, 1454, 340, 2337, 1159, 282, 6107, 4192, 370, 506, 9080, 26, 339, 627, 1967, 17, 275, 8177, 14, 8001, 1082, 272, 627, 1967, 18, 275, 8177, 14, 5345, 272, 627, 1967, 19, 275, 8177, 14, 1479, 1493, 272, 627, 8448, 1967, 17, 92, 31471, 3586, 17561, 298, 1082, 14, 18, 2, 272, 627, 8448, 1967, 18, 92, 31471, 3586, 17561, 298, 1082, 2, 272, 627, 8448, 1967, 19, 92, 31471, 3586, 17561, 298, 1082, 14, 19, 2, 339, 982, 1680, 365, 7317, 12, 652, 911, 3544, 2929, 8840, 1680, 1329, 402, 6107, 272, 9825, 26, 339, 627, 8448, 1967, 17, 92, 31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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 ]
geminateCoder/Character-Archive-Website
Lib/site-packages/pip/_vendor/distlib/markers.py
1261
6282
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2013 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # """Parser for the environment markers micro-language defined in PEP 345.""" import ast import os import sys import platform from .compat import python_implementation, string_types from .util import in_venv __all__ = ['interpret'] class Evaluator(object): """ A limited evaluator for Python expressions. """ operators = { 'eq': lambda x, y: x == y, 'gt': lambda x, y: x > y, 'gte': lambda x, y: x >= y, 'in': lambda x, y: x in y, 'lt': lambda x, y: x < y, 'lte': lambda x, y: x <= y, 'not': lambda x: not x, 'noteq': lambda x, y: x != y, 'notin': lambda x, y: x not in y, } allowed_values = { 'sys_platform': sys.platform, 'python_version': '%s.%s' % sys.version_info[:2], # parsing sys.platform is not reliable, but there is no other # way to get e.g. 2.7.2+, and the PEP is defined with sys.version 'python_full_version': sys.version.split(' ', 1)[0], 'os_name': os.name, 'platform_in_venv': str(in_venv()), 'platform_release': platform.release(), 'platform_version': platform.version(), 'platform_machine': platform.machine(), 'platform_python_implementation': python_implementation(), } def __init__(self, context=None): """ Initialise an instance. :param context: If specified, names are looked up in this mapping. """ self.context = context or {} self.source = None def get_fragment(self, offset): """ Get the part of the source which is causing a problem. """ fragment_len = 10 s = '%r' % (self.source[offset:offset + fragment_len]) if offset + fragment_len < len(self.source): s += '...' return s def get_handler(self, node_type): """ Get a handler for the specified AST node type. """ return getattr(self, 'do_%s' % node_type, None) def evaluate(self, node, filename=None): """ Evaluate a source string or node, using ``filename`` when displaying errors. """ if isinstance(node, string_types): self.source = node kwargs = {'mode': 'eval'} if filename: kwargs['filename'] = filename try: node = ast.parse(node, **kwargs) except SyntaxError as e: s = self.get_fragment(e.offset) raise SyntaxError('syntax error %s' % s) node_type = node.__class__.__name__.lower() handler = self.get_handler(node_type) if handler is None: if self.source is None: s = '(source not available)' else: s = self.get_fragment(node.col_offset) raise SyntaxError("don't know how to evaluate %r %s" % ( node_type, s)) return handler(node) def get_attr_key(self, node): assert isinstance(node, ast.Attribute), 'attribute node expected' return '%s.%s' % (node.value.id, node.attr) def do_attribute(self, node): if not isinstance(node.value, ast.Name): valid = False else: key = self.get_attr_key(node) valid = key in self.context or key in self.allowed_values if not valid: raise SyntaxError('invalid expression: %s' % key) if key in self.context: result = self.context[key] else: result = self.allowed_values[key] return result def do_boolop(self, node): result = self.evaluate(node.values[0]) is_or = node.op.__class__ is ast.Or is_and = node.op.__class__ is ast.And assert is_or or is_and if (is_and and result) or (is_or and not result): for n in node.values[1:]: result = self.evaluate(n) if (is_or and result) or (is_and and not result): break return result def do_compare(self, node): def sanity_check(lhsnode, rhsnode): valid = True if isinstance(lhsnode, ast.Str) and isinstance(rhsnode, ast.Str): valid = False #elif (isinstance(lhsnode, ast.Attribute) # and isinstance(rhsnode, ast.Attribute)): # klhs = self.get_attr_key(lhsnode) # krhs = self.get_attr_key(rhsnode) # valid = klhs != krhs if not valid: s = self.get_fragment(node.col_offset) raise SyntaxError('Invalid comparison: %s' % s) lhsnode = node.left lhs = self.evaluate(lhsnode) result = True for op, rhsnode in zip(node.ops, node.comparators): sanity_check(lhsnode, rhsnode) op = op.__class__.__name__.lower() if op not in self.operators: raise SyntaxError('unsupported operation: %r' % op) rhs = self.evaluate(rhsnode) result = self.operators[op](lhs, rhs) if not result: break lhs = rhs lhsnode = rhsnode return result def do_expression(self, node): return self.evaluate(node.body) def do_name(self, node): valid = False if node.id in self.context: valid = True result = self.context[node.id] elif node.id in self.allowed_values: valid = True result = self.allowed_values[node.id] if not valid: raise SyntaxError('invalid expression: %s' % node.id) return result def do_str(self, node): return node.s def interpret(marker, execution_context=None): """ Interpret a marker and return a result depending on environment. :param marker: The marker to interpret. :type marker: str :param execution_context: The context used for name lookup. :type execution_context: mapping """ return Evaluator(execution_context).evaluate(marker.strip())
cc0-1.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 28882, 1187, 428, 9091, 711, 14, 199, 3, 3909, 370, 314, 2018, 2290, 2752, 1334, 282, 11615, 25025, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 2842, 367, 314, 3734, 14327, 9967, 13, 3671, 3247, 315, 13663, 30044, 1041, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 984, 199, 646, 4298, 199, 199, 504, 1275, 5819, 492, 2366, 63, 12236, 12, 1059, 63, 1313, 199, 504, 1275, 1974, 492, 315, 63, 23195, 199, 199, 363, 452, 363, 275, 788, 21533, 418, 421, 199, 533, 16494, 16530, 8, 785, 304, 272, 408, 272, 437, 13988, 29207, 367, 2018, 8455, 14, 272, 408, 339, 10211, 275, 469, 267, 283, 4077, 356, 2400, 671, 12, 612, 26, 671, 508, 612, 12, 267, 283, 3308, 356, 2400, 671, 12, 612, 26, 671, 690, 612, 12, 267, 283, 19586, 356, 2400, 671, 12, 612, 26, 671, 2356, 612, 12, 267, 283, 262, 356, 2400, 671, 12, 612, 26, 671, 315, 612, 12, 267, 283, 4116, 356, 2400, 671, 12, 612, 26, 671, 665, 612, 12, 267, 283, 20740, 356, 2400, 671, 12, 612, 26, 671, 2695, 612, 12, 267, 283, 1397, 356, 2400, 671, 26, 440, 671, 12, 267, 283, 4610, 81, 356, 2400, 671, 12, 612, 26, 671, 1137, 612, 12, 267, 283, 1397, 262, 356, 2400, 671, 12, 612, 26, 671, 440, 315, 612, 12, 272, 789, 339, 4370, 63, 1459, 275, 469, 267, 283, 1274, 63, 3246, 356, 984, 14, 3246, 12, 267, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 267, 327, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 267, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 267, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 267, 283, 736, 63, 354, 356, 747, 14, 354, 12, 267, 283, 3246, 63, 262, 63, 23195, 356, 620, 8, 262, 63, 23195, 4000, 267, 283, 3246, 63, 3221, 356, 4298, 14, 3221, 1062, 267, 283, 3246, 63, 1023, 356, 4298, 14, 1023, 1062, 267, 283, 3246, 63, 6744, 356, 4298, 14, 6744, 1062, 267, 283, 3246, 63, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1067, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1067, 26, 982, 2013, 12, 1561, 787, 21182, 1536, 315, 642, 4412, 14, 267, 408, 267, 291, 14, 1100, 275, 1067, 503, 1052, 267, 291, 14, 1365, 275, 488, 339, 347, 664, 63, 7677, 8, 277, 12, 3268, 304, 267, 408, 267, 2372, 314, 1777, 402, 314, 1350, 1314, 365, 25498, 282, 5160, 14, 267, 408, 267, 7956, 63, 552, 275, 1616, 267, 308, 275, 1543, 82, 7, 450, 334, 277, 14, 1365, 59, 2743, 26, 2743, 435, 7956, 63, 552, 566, 267, 340, 3268, 435, 7956, 63, 552, 665, 822, 8, 277, 14, 1365, 304, 288, 308, 847, 28044, 267, 372, 308, 339, 347, 664, 63, 2232, 8, 277, 12, 1031, 63, 466, 304, 267, 408, 267, 2372, 282, 3016, 367, 314, 2013, 20788, 1031, 730, 14, 267, 408, 267, 372, 2519, 8, 277, 12, 283, 1117, 4970, 83, 7, 450, 1031, 63, 466, 12, 488, 9, 339, 347, 9352, 8, 277, 12, 1031, 12, 1788, 29, 403, 304, 267, 408, 267, 27450, 282, 1350, 1059, 503, 1031, 12, 1808, 1124, 1501, 1040, 1380, 267, 20589, 2552, 14, 267, 408, 267, 340, 1228, 8, 932, 12, 1059, 63, 1313, 304, 288, 291, 14, 1365, 275, 1031, 288, 2074, 275, 791, 632, 356, 283, 2579, 936, 288, 340, 1788, 26, 355, 2074, 459, 1501, 418, 275, 1788, 288, 862, 26, 355, 1031, 275, 6073, 14, 1122, 8, 932, 12, 1011, 958, 9, 288, 871, 12053, 465, 325, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 69, 14, 2743, 9, 355, 746, 12053, 360, 7093, 1125, 450, 83, 7, 450, 308, 9, 267, 1031, 63, 466, 275, 1031, 855, 533, 4914, 354, 4343, 2325, 342, 267, 3016, 275, 291, 14, 362, 63, 2232, 8, 932, 63, 466, 9, 267, 340, 3016, 365, 488, 26, 288, 340, 291, 14, 1365, 365, 488, 26, 355, 308, 275, 8189, 1365, 440, 2808, 3171, 288, 587, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 932, 14, 761, 63, 2743, 9, 288, 746, 12053, 480, 13196, 1133, 5715, 4212, 370, 9352, 450, 82, 450, 83, 2, 450, 334, 355, 1031, 63, 466, 12, 308, 430, 267, 372, 3016, 8, 932, 9, 339, 347, 664, 63, 962, 63, 498, 8, 277, 12, 1031, 304, 267, 702, 1228, 8, 932, 12, 6073, 14, 1646, 395, 283, 3215, 1031, 1420, 7, 267, 372, 1543, 83, 4111, 83, 7, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 9, 339, 347, 886, 63, 3215, 8, 277, 12, 1031, 304, 267, 340, 440, 1228, 8, 932, 14, 585, 12, 6073, 14, 985, 304, 288, 1686, 275, 756, 267, 587, 26, 288, 790, 275, 291, 14, 362, 63, 962, 63, 498, 8, 932, 9, 288, 1686, 275, 790, 315, 291, 14, 1100, 503, 790, 315, 291, 14, 6541, 63, 1459, 267, 340, 440, 1686, 26, 288, 746, 12053, 360, 3197, 3965, 26, 450, 83, 7, 450, 790, 9, 267, 340, 790, 315, 291, 14, 1100, 26, 288, 754, 275, 291, 14, 1100, 59, 498, 61, 267, 587, 26, 288, 754, 275, 291, 14, 6541, 63, 1459, 59, 498, 61, 267, 372, 754, 339, 347, 886, 63, 15056, 18630, 8, 277, 12, 1031, 304, 267, 754, 275, 291, 14, 7383, 8, 932, 14, 1459, 59, 16, 566, 267, 365, 63, 269, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 2844, 267, 365, 63, 460, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 3325, 267, 702, 365, 63, 269, 503, 365, 63, 460, 267, 340, 334, 374, 63, 460, 436, 754, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 28882, 1187, 428, 9091, 711, 14, 199, 3, 3909, 370, 314, 2018, 2290, 2752, 1334, 282, 11615, 25025, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 2842, 367, 314, 3734, 14327, 9967, 13, 3671, 3247, 315, 13663, 30044, 1041, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 984, 199, 646, 4298, 199, 199, 504, 1275, 5819, 492, 2366, 63, 12236, 12, 1059, 63, 1313, 199, 504, 1275, 1974, 492, 315, 63, 23195, 199, 199, 363, 452, 363, 275, 788, 21533, 418, 421, 199, 533, 16494, 16530, 8, 785, 304, 272, 408, 272, 437, 13988, 29207, 367, 2018, 8455, 14, 272, 408, 339, 10211, 275, 469, 267, 283, 4077, 356, 2400, 671, 12, 612, 26, 671, 508, 612, 12, 267, 283, 3308, 356, 2400, 671, 12, 612, 26, 671, 690, 612, 12, 267, 283, 19586, 356, 2400, 671, 12, 612, 26, 671, 2356, 612, 12, 267, 283, 262, 356, 2400, 671, 12, 612, 26, 671, 315, 612, 12, 267, 283, 4116, 356, 2400, 671, 12, 612, 26, 671, 665, 612, 12, 267, 283, 20740, 356, 2400, 671, 12, 612, 26, 671, 2695, 612, 12, 267, 283, 1397, 356, 2400, 671, 26, 440, 671, 12, 267, 283, 4610, 81, 356, 2400, 671, 12, 612, 26, 671, 1137, 612, 12, 267, 283, 1397, 262, 356, 2400, 671, 12, 612, 26, 671, 440, 315, 612, 12, 272, 789, 339, 4370, 63, 1459, 275, 469, 267, 283, 1274, 63, 3246, 356, 984, 14, 3246, 12, 267, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 267, 327, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 267, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 267, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 267, 283, 736, 63, 354, 356, 747, 14, 354, 12, 267, 283, 3246, 63, 262, 63, 23195, 356, 620, 8, 262, 63, 23195, 4000, 267, 283, 3246, 63, 3221, 356, 4298, 14, 3221, 1062, 267, 283, 3246, 63, 1023, 356, 4298, 14, 1023, 1062, 267, 283, 3246, 63, 6744, 356, 4298, 14, 6744, 1062, 267, 283, 3246, 63, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1067, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1067, 26, 982, 2013, 12, 1561, 787, 21182, 1536, 315, 642, 4412, 14, 267, 408, 267, 291, 14, 1100, 275, 1067, 503, 1052, 267, 291, 14, 1365, 275, 488, 339, 347, 664, 63, 7677, 8, 277, 12, 3268, 304, 267, 408, 267, 2372, 314, 1777, 402, 314, 1350, 1314, 365, 25498, 282, 5160, 14, 267, 408, 267, 7956, 63, 552, 275, 1616, 267, 308, 275, 1543, 82, 7, 450, 334, 277, 14, 1365, 59, 2743, 26, 2743, 435, 7956, 63, 552, 566, 267, 340, 3268, 435, 7956, 63, 552, 665, 822, 8, 277, 14, 1365, 304, 288, 308, 847, 28044, 267, 372, 308, 339, 347, 664, 63, 2232, 8, 277, 12, 1031, 63, 466, 304, 267, 408, 267, 2372, 282, 3016, 367, 314, 2013, 20788, 1031, 730, 14, 267, 408, 267, 372, 2519, 8, 277, 12, 283, 1117, 4970, 83, 7, 450, 1031, 63, 466, 12, 488, 9, 339, 347, 9352, 8, 277, 12, 1031, 12, 1788, 29, 403, 304, 267, 408, 267, 27450, 282, 1350, 1059, 503, 1031, 12, 1808, 1124, 1501, 1040, 1380, 267, 20589, 2552, 14, 267, 408, 267, 340, 1228, 8, 932, 12, 1059, 63, 1313, 304, 288, 291, 14, 1365, 275, 1031, 288, 2074, 275, 791, 632, 356, 283, 2579, 936, 288, 340, 1788, 26, 355, 2074, 459, 1501, 418, 275, 1788, 288, 862, 26, 355, 1031, 275, 6073, 14, 1122, 8, 932, 12, 1011, 958, 9, 288, 871, 12053, 465, 325, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 69, 14, 2743, 9, 355, 746, 12053, 360, 7093, 1125, 450, 83, 7, 450, 308, 9, 267, 1031, 63, 466, 275, 1031, 855, 533, 4914, 354, 4343, 2325, 342, 267, 3016, 275, 291, 14, 362, 63, 2232, 8, 932, 63, 466, 9, 267, 340, 3016, 365, 488, 26, 288, 340, 291, 14, 1365, 365, 488, 26, 355, 308, 275, 8189, 1365, 440, 2808, 3171, 288, 587, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 932, 14, 761, 63, 2743, 9, 288, 746, 12053, 480, 13196, 1133, 5715, 4212, 370, 9352, 450, 82, 450, 83, 2, 450, 334, 355, 1031, 63, 466, 12, 308, 430, 267, 372, 3016, 8, 932, 9, 339, 347, 664, 63, 962, 63, 498, 8, 277, 12, 1031, 304, 267, 702, 1228, 8, 932, 12, 6073, 14, 1646, 395, 283, 3215, 1031, 1420, 7, 267, 372, 1543, 83, 4111, 83, 7, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 9, 339, 347, 886, 63, 3215, 8, 277, 12, 1031, 304, 267, 340, 440, 1228, 8, 932, 14, 585, 12, 6073, 14, 985, 304, 288, 1686, 275, 756, 267, 587, 26, 288, 790, 275, 291, 14, 362, 63, 962, 63, 498, 8, 932, 9, 288, 1686, 275, 790, 315, 291, 14, 1100, 503, 790, 315, 291, 14, 6541, 63, 1459, 267, 340, 440, 1686, 26, 288, 746, 12053, 360, 3197, 3965, 26, 450, 83, 7, 450, 790, 9, 267, 340, 790, 315, 291, 14, 1100, 26, 288, 754, 275, 291, 14, 1100, 59, 498, 61, 267, 587, 26, 288, 754, 275, 291, 14, 6541, 63, 1459, 59, 498, 61, 267, 372, 754, 339, 347, 886, 63, 15056, 18630, 8, 277, 12, 1031, 304, 267, 754, 275, 291, 14, 7383, 8, 932, 14, 1459, 59, 16, 566, 267, 365, 63, 269, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 2844, 267, 365, 63, 460, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 3325, 267, 702, 365, 63, 269, 503, 365, 63, 460, 267, 340, 334, 374, 63, 460, 436, 754, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
kkusch/HoneyPy
loggers/twitter/honeypy_twitter.py
1
1837
# HoneyPy Copyright (C) 2013-2017 foospidy # https://github.com/foospidy/HoneyPy # See LICENSE for details # HoneyPy twitter module from twitter import Twitter from twitter.oauth import OAuth from twisted.python import log def process(config, section, parts, time_parts): # TCP # parts[0]: date # parts[1]: time_parts # parts[2]: plugin # parts[3]: session # parts[4]: protocol # parts[5]: event # parts[6]: local_host # parts[7]: local_port # parts[8]: service # parts[9]: remote_host # parts[10]: remote_port # parts[11]: data # UDP # parts[0]: date # parts[1]: time_parts # parts[2]: plugin string part # parts[3]: plugin string part # parts[4]: session # parts[5]: protocol # parts[6]: event # parts[7]: local_host # parts[8]: local_port # parts[9]: service # parts[10]: remote_host # parts[11]: remote_port # parts[12]: data if parts[4] == 'TCP': post(config, parts[8], parts[9]) else: # UDP splits differently (see comment section above) post(config, parts[9], parts[10]) def post(honeypycfg, service, clientip): ck = honeypycfg.get('twitter', 'consumerkey') cs = honeypycfg.get('twitter', 'consumersecret') ot = honeypycfg.get('twitter', 'oauthtoken') os = honeypycfg.get('twitter', 'oauthsecret') t = Twitter(auth=OAuth(ot, os, ck, cs)) nodename = honeypycfg.get('honeypy', 'nodename') try: t.statuses.update(status=nodename + ': #' + service + ' Possible ' + service + ' attack from ' + clientip + ' https://riskdiscovery.com/honeydb/#host/' + clientip) except Exception, err: log.msg('Error posting to Twitter: %s' % err)
gpl-2.0
[ 3, 869, 13234, 2713, 1898, 334, 35, 9, 6171, 13, 10680, 3925, 681, 344, 89, 199, 3, 4178, 921, 5031, 14, 957, 15, 1421, 681, 344, 89, 15, 40, 13234, 2713, 199, 3, 1666, 5113, 367, 2436, 199, 3, 869, 13234, 2713, 15811, 859, 199, 199, 504, 15811, 492, 19259, 199, 504, 15811, 14, 6126, 492, 11715, 199, 504, 7390, 14, 1548, 492, 943, 199, 199, 318, 2112, 8, 888, 12, 3420, 12, 4184, 12, 900, 63, 4181, 304, 267, 327, 13488, 267, 327, 198, 4181, 59, 16, 2189, 1434, 267, 327, 198, 4181, 59, 17, 2189, 900, 63, 4181, 267, 327, 198, 4181, 59, 18, 2189, 3589, 267, 327, 198, 4181, 59, 19, 2189, 2351, 267, 327, 198, 4181, 59, 20, 2189, 4113, 267, 327, 198, 4181, 59, 21, 2189, 1566, 267, 327, 198, 4181, 59, 22, 2189, 2257, 63, 1102, 267, 327, 198, 4181, 59, 23, 2189, 2257, 63, 719, 267, 327, 198, 4181, 59, 24, 2189, 2435, 267, 327, 198, 4181, 59, 25, 2189, 3982, 63, 1102, 267, 327, 198, 4181, 59, 709, 2189, 3982, 63, 719, 267, 327, 198, 4181, 59, 845, 2189, 666, 267, 327, 21802, 267, 327, 198, 4181, 59, 16, 2189, 1434, 267, 327, 198, 4181, 59, 17, 2189, 900, 63, 4181, 267, 327, 198, 4181, 59, 18, 2189, 3589, 1059, 1777, 267, 327, 198, 4181, 59, 19, 2189, 3589, 1059, 1777, 267, 327, 198, 4181, 59, 20, 2189, 2351, 267, 327, 198, 4181, 59, 21, 2189, 4113, 267, 327, 198, 4181, 59, 22, 2189, 1566, 267, 327, 198, 4181, 59, 23, 2189, 2257, 63, 1102, 267, 327, 198, 4181, 59, 24, 2189, 2257, 63, 719, 267, 327, 198, 4181, 59, 25, 2189, 2435, 267, 327, 198, 4181, 59, 709, 2189, 3982, 63, 1102, 267, 327, 198, 4181, 59, 845, 2189, 3982, 63, 719, 267, 327, 198, 4181, 59, 713, 2189, 666, 339, 340, 4184, 59, 20, 61, 508, 283, 9735, 356, 267, 2963, 8, 888, 12, 4184, 59, 24, 467, 4184, 59, 25, 566, 272, 587, 26, 267, 327, 21802, 19115, 23142, 334, 3239, 3721, 3420, 3432, 9, 267, 2963, 8, 888, 12, 4184, 59, 25, 467, 4184, 59, 709, 566, 421, 199, 318, 2963, 8, 72, 13234, 647, 4128, 12, 2435, 12, 5053, 287, 8996, 304, 339, 22030, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 8542, 498, 358, 272, 7117, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 8542, 4731, 358, 272, 312, 84, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 6126, 1418, 358, 272, 747, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 6126, 4731, 358, 339, 307, 275, 19259, 8, 1178, 29, 12906, 8, 357, 12, 747, 12, 22030, 12, 7117, 430, 272, 1031, 354, 275, 394, 13234, 647, 4128, 14, 362, 360, 72, 13234, 647, 297, 283, 932, 354, 358, 339, 862, 26, 267, 307, 14, 17084, 14, 873, 8, 1205, 29, 932, 354, 435, 7596, 17384, 435, 2435, 435, 283, 18558, 283, 221, 435, 2435, 435, 283, 23326, 687, 283, 435, 5053, 287, 8996, 435, 283, 4178, 921, 27473, 14859, 14, 957, 15, 72, 13234, 697, 12645, 1102, 4805, 435, 5053, 287, 8996, 9, 272, 871, 2186, 12, 2329, 26, 267, 943, 14, 1328, 360, 547, 25386, 370, 19259, 26, 450, 83, 7, 450, 2329, 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 ]
[ 869, 13234, 2713, 1898, 334, 35, 9, 6171, 13, 10680, 3925, 681, 344, 89, 199, 3, 4178, 921, 5031, 14, 957, 15, 1421, 681, 344, 89, 15, 40, 13234, 2713, 199, 3, 1666, 5113, 367, 2436, 199, 3, 869, 13234, 2713, 15811, 859, 199, 199, 504, 15811, 492, 19259, 199, 504, 15811, 14, 6126, 492, 11715, 199, 504, 7390, 14, 1548, 492, 943, 199, 199, 318, 2112, 8, 888, 12, 3420, 12, 4184, 12, 900, 63, 4181, 304, 267, 327, 13488, 267, 327, 198, 4181, 59, 16, 2189, 1434, 267, 327, 198, 4181, 59, 17, 2189, 900, 63, 4181, 267, 327, 198, 4181, 59, 18, 2189, 3589, 267, 327, 198, 4181, 59, 19, 2189, 2351, 267, 327, 198, 4181, 59, 20, 2189, 4113, 267, 327, 198, 4181, 59, 21, 2189, 1566, 267, 327, 198, 4181, 59, 22, 2189, 2257, 63, 1102, 267, 327, 198, 4181, 59, 23, 2189, 2257, 63, 719, 267, 327, 198, 4181, 59, 24, 2189, 2435, 267, 327, 198, 4181, 59, 25, 2189, 3982, 63, 1102, 267, 327, 198, 4181, 59, 709, 2189, 3982, 63, 719, 267, 327, 198, 4181, 59, 845, 2189, 666, 267, 327, 21802, 267, 327, 198, 4181, 59, 16, 2189, 1434, 267, 327, 198, 4181, 59, 17, 2189, 900, 63, 4181, 267, 327, 198, 4181, 59, 18, 2189, 3589, 1059, 1777, 267, 327, 198, 4181, 59, 19, 2189, 3589, 1059, 1777, 267, 327, 198, 4181, 59, 20, 2189, 2351, 267, 327, 198, 4181, 59, 21, 2189, 4113, 267, 327, 198, 4181, 59, 22, 2189, 1566, 267, 327, 198, 4181, 59, 23, 2189, 2257, 63, 1102, 267, 327, 198, 4181, 59, 24, 2189, 2257, 63, 719, 267, 327, 198, 4181, 59, 25, 2189, 2435, 267, 327, 198, 4181, 59, 709, 2189, 3982, 63, 1102, 267, 327, 198, 4181, 59, 845, 2189, 3982, 63, 719, 267, 327, 198, 4181, 59, 713, 2189, 666, 339, 340, 4184, 59, 20, 61, 508, 283, 9735, 356, 267, 2963, 8, 888, 12, 4184, 59, 24, 467, 4184, 59, 25, 566, 272, 587, 26, 267, 327, 21802, 19115, 23142, 334, 3239, 3721, 3420, 3432, 9, 267, 2963, 8, 888, 12, 4184, 59, 25, 467, 4184, 59, 709, 566, 421, 199, 318, 2963, 8, 72, 13234, 647, 4128, 12, 2435, 12, 5053, 287, 8996, 304, 339, 22030, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 8542, 498, 358, 272, 7117, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 8542, 4731, 358, 272, 312, 84, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 6126, 1418, 358, 272, 747, 275, 394, 13234, 647, 4128, 14, 362, 360, 13746, 297, 283, 6126, 4731, 358, 339, 307, 275, 19259, 8, 1178, 29, 12906, 8, 357, 12, 747, 12, 22030, 12, 7117, 430, 272, 1031, 354, 275, 394, 13234, 647, 4128, 14, 362, 360, 72, 13234, 647, 297, 283, 932, 354, 358, 339, 862, 26, 267, 307, 14, 17084, 14, 873, 8, 1205, 29, 932, 354, 435, 7596, 17384, 435, 2435, 435, 283, 18558, 283, 221, 435, 2435, 435, 283, 23326, 687, 283, 435, 5053, 287, 8996, 435, 283, 4178, 921, 27473, 14859, 14, 957, 15, 72, 13234, 697, 12645, 1102, 4805, 435, 5053, 287, 8996, 9, 272, 871, 2186, 12, 2329, 26, 267, 943, 14, 1328, 360, 547, 25386, 370, 19259, 26, 450, 83, 7, 450, 2329, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wartman4404/servo
tests/wpt/css-tests/tools/pywebsocket/src/test/test_handshake_hybi.py
413
22552
#!/usr/bin/env python # # Copyright 2011, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Tests for handshake module.""" import unittest import set_sys_path # Update sys.path to locate mod_pywebsocket module. from mod_pywebsocket import common from mod_pywebsocket.handshake._base import AbortedByUserException from mod_pywebsocket.handshake._base import HandshakeException from mod_pywebsocket.handshake._base import VersionException from mod_pywebsocket.handshake.hybi import Handshaker import mock class RequestDefinition(object): """A class for holding data for constructing opening handshake strings for testing the opening handshake processor. """ def __init__(self, method, uri, headers): self.method = method self.uri = uri self.headers = headers def _create_good_request_def(): return RequestDefinition( 'GET', '/demo', {'Host': 'server.example.com', 'Upgrade': 'websocket', 'Connection': 'Upgrade', 'Sec-WebSocket-Key': 'dGhlIHNhbXBsZSBub25jZQ==', 'Sec-WebSocket-Version': '13', 'Origin': 'http://example.com'}) def _create_request(request_def): conn = mock.MockConn('') return mock.MockRequest( method=request_def.method, uri=request_def.uri, headers_in=request_def.headers, connection=conn) def _create_handshaker(request): handshaker = Handshaker(request, mock.MockDispatcher()) return handshaker class SubprotocolChoosingDispatcher(object): """A dispatcher for testing. This dispatcher sets the i-th subprotocol of requested ones to ws_protocol where i is given on construction as index argument. If index is negative, default_value will be set to ws_protocol. """ def __init__(self, index, default_value=None): self.index = index self.default_value = default_value def do_extra_handshake(self, conn_context): if self.index >= 0: conn_context.ws_protocol = conn_context.ws_requested_protocols[ self.index] else: conn_context.ws_protocol = self.default_value def transfer_data(self, conn_context): pass class HandshakeAbortedException(Exception): pass class AbortingDispatcher(object): """A dispatcher for testing. This dispatcher raises an exception in do_extra_handshake to reject the request. """ def do_extra_handshake(self, conn_context): raise HandshakeAbortedException('An exception to reject the request') def transfer_data(self, conn_context): pass class AbortedByUserDispatcher(object): """A dispatcher for testing. This dispatcher raises an AbortedByUserException in do_extra_handshake to reject the request. """ def do_extra_handshake(self, conn_context): raise AbortedByUserException('An AbortedByUserException to reject the ' 'request') def transfer_data(self, conn_context): pass _EXPECTED_RESPONSE = ( 'HTTP/1.1 101 Switching Protocols\r\n' 'Upgrade: websocket\r\n' 'Connection: Upgrade\r\n' 'Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n') class HandshakerTest(unittest.TestCase): """A unittest for draft-ietf-hybi-thewebsocketprotocol-06 and later handshake processor. """ def test_do_handshake(self): request = _create_request(_create_good_request_def()) dispatcher = mock.MockDispatcher() handshaker = Handshaker(request, dispatcher) handshaker.do_handshake() self.assertTrue(dispatcher.do_extra_handshake_called) self.assertEqual( _EXPECTED_RESPONSE, request.connection.written_data()) self.assertEqual('/demo', request.ws_resource) self.assertEqual('http://example.com', request.ws_origin) self.assertEqual(None, request.ws_protocol) self.assertEqual(None, request.ws_extensions) self.assertEqual(common.VERSION_HYBI_LATEST, request.ws_version) def test_do_handshake_with_extra_headers(self): request_def = _create_good_request_def() # Add headers not related to WebSocket opening handshake. request_def.headers['FooKey'] = 'BarValue' request_def.headers['EmptyKey'] = '' request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual( _EXPECTED_RESPONSE, request.connection.written_data()) def test_do_handshake_with_capitalized_value(self): request_def = _create_good_request_def() request_def.headers['upgrade'] = 'WEBSOCKET' request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual( _EXPECTED_RESPONSE, request.connection.written_data()) request_def = _create_good_request_def() request_def.headers['Connection'] = 'UPGRADE' request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual( _EXPECTED_RESPONSE, request.connection.written_data()) def test_do_handshake_with_multiple_connection_values(self): request_def = _create_good_request_def() request_def.headers['Connection'] = 'Upgrade, keep-alive, , ' request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual( _EXPECTED_RESPONSE, request.connection.written_data()) def test_aborting_handshake(self): handshaker = Handshaker( _create_request(_create_good_request_def()), AbortingDispatcher()) # do_extra_handshake raises an exception. Check that it's not caught by # do_handshake. self.assertRaises(HandshakeAbortedException, handshaker.do_handshake) def test_do_handshake_with_protocol(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Protocol'] = 'chat, superchat' request = _create_request(request_def) handshaker = Handshaker(request, SubprotocolChoosingDispatcher(0)) handshaker.do_handshake() EXPECTED_RESPONSE = ( 'HTTP/1.1 101 Switching Protocols\r\n' 'Upgrade: websocket\r\n' 'Connection: Upgrade\r\n' 'Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n' 'Sec-WebSocket-Protocol: chat\r\n\r\n') self.assertEqual(EXPECTED_RESPONSE, request.connection.written_data()) self.assertEqual('chat', request.ws_protocol) def test_do_handshake_protocol_not_in_request_but_in_response(self): request_def = _create_good_request_def() request = _create_request(request_def) handshaker = Handshaker( request, SubprotocolChoosingDispatcher(-1, 'foobar')) # No request has been made but ws_protocol is set. HandshakeException # must be raised. self.assertRaises(HandshakeException, handshaker.do_handshake) def test_do_handshake_with_protocol_no_protocol_selection(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Protocol'] = 'chat, superchat' request = _create_request(request_def) handshaker = _create_handshaker(request) # ws_protocol is not set. HandshakeException must be raised. self.assertRaises(HandshakeException, handshaker.do_handshake) def test_do_handshake_with_extensions(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ( 'permessage-compress; method=deflate, unknown') EXPECTED_RESPONSE = ( 'HTTP/1.1 101 Switching Protocols\r\n' 'Upgrade: websocket\r\n' 'Connection: Upgrade\r\n' 'Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n' 'Sec-WebSocket-Extensions: permessage-compress; method=deflate\r\n' '\r\n') request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual(EXPECTED_RESPONSE, request.connection.written_data()) self.assertEqual(1, len(request.ws_extensions)) extension = request.ws_extensions[0] self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, extension.name()) self.assertEqual(['method'], extension.get_parameter_names()) self.assertEqual('deflate', extension.get_parameter_value('method')) self.assertEqual(1, len(request.ws_extension_processors)) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, request.ws_extension_processors[0].name()) def test_do_handshake_with_permessage_compress(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ( 'permessage-compress; method=deflate') request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual(1, len(request.ws_extensions)) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, request.ws_extensions[0].name()) self.assertEqual(1, len(request.ws_extension_processors)) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, request.ws_extension_processors[0].name()) def test_do_handshake_with_quoted_extensions(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ( 'permessage-compress; method=deflate, , ' 'unknown; e = "mc^2"; ma="\r\n \\\rf "; pv=nrt') request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual(2, len(request.ws_requested_extensions)) first_extension = request.ws_requested_extensions[0] self.assertEqual('permessage-compress', first_extension.name()) self.assertEqual(['method'], first_extension.get_parameter_names()) self.assertEqual('deflate', first_extension.get_parameter_value('method')) second_extension = request.ws_requested_extensions[1] self.assertEqual('unknown', second_extension.name()) self.assertEqual( ['e', 'ma', 'pv'], second_extension.get_parameter_names()) self.assertEqual('mc^2', second_extension.get_parameter_value('e')) self.assertEqual(' \rf ', second_extension.get_parameter_value('ma')) self.assertEqual('nrt', second_extension.get_parameter_value('pv')) def test_do_handshake_with_optional_headers(self): request_def = _create_good_request_def() request_def.headers['EmptyValue'] = '' request_def.headers['AKey'] = 'AValue' request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual( 'AValue', request.headers_in['AKey']) self.assertEqual( '', request.headers_in['EmptyValue']) def test_abort_extra_handshake(self): handshaker = Handshaker( _create_request(_create_good_request_def()), AbortedByUserDispatcher()) # do_extra_handshake raises an AbortedByUserException. Check that it's # not caught by do_handshake. self.assertRaises(AbortedByUserException, handshaker.do_handshake) def test_do_handshake_with_mux_and_deflate_frame(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ('%s, %s' % ( common.MUX_EXTENSION, common.DEFLATE_FRAME_EXTENSION)) request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() # mux should be rejected. self.assertEqual(1, len(request.ws_extensions)) self.assertEqual(common.DEFLATE_FRAME_EXTENSION, request.ws_extensions[0].name()) self.assertEqual(2, len(request.ws_extension_processors)) self.assertEqual(common.MUX_EXTENSION, request.ws_extension_processors[0].name()) self.assertEqual(common.DEFLATE_FRAME_EXTENSION, request.ws_extension_processors[1].name()) self.assertFalse(hasattr(request, 'mux_processor')) def test_do_handshake_with_deflate_frame_and_mux(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ('%s, %s' % ( common.DEFLATE_FRAME_EXTENSION, common.MUX_EXTENSION)) request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() # mux should be rejected. self.assertEqual(1, len(request.ws_extensions)) first_extension = request.ws_extensions[0] self.assertEqual(common.DEFLATE_FRAME_EXTENSION, first_extension.name()) self.assertEqual(2, len(request.ws_extension_processors)) self.assertEqual(common.DEFLATE_FRAME_EXTENSION, request.ws_extension_processors[0].name()) self.assertEqual(common.MUX_EXTENSION, request.ws_extension_processors[1].name()) self.assertFalse(hasattr(request, 'mux')) def test_do_handshake_with_permessage_compress_and_mux(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ( '%s; method=deflate, %s' % ( common.PERMESSAGE_COMPRESSION_EXTENSION, common.MUX_EXTENSION)) request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() self.assertEqual(1, len(request.ws_extensions)) self.assertEqual(common.MUX_EXTENSION, request.ws_extensions[0].name()) self.assertEqual(2, len(request.ws_extension_processors)) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, request.ws_extension_processors[0].name()) self.assertEqual(common.MUX_EXTENSION, request.ws_extension_processors[1].name()) self.assertTrue(hasattr(request, 'mux_processor')) self.assertTrue(request.mux_processor.is_active()) mux_extensions = request.mux_processor.extensions() self.assertEqual(1, len(mux_extensions)) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, mux_extensions[0].name()) def test_do_handshake_with_mux_and_permessage_compress(self): request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Extensions'] = ( '%s, %s; method=deflate' % ( common.MUX_EXTENSION, common.PERMESSAGE_COMPRESSION_EXTENSION)) request = _create_request(request_def) handshaker = _create_handshaker(request) handshaker.do_handshake() # mux should be rejected. self.assertEqual(1, len(request.ws_extensions)) first_extension = request.ws_extensions[0] self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, first_extension.name()) self.assertEqual(2, len(request.ws_extension_processors)) self.assertEqual(common.MUX_EXTENSION, request.ws_extension_processors[0].name()) self.assertEqual(common.PERMESSAGE_COMPRESSION_EXTENSION, request.ws_extension_processors[1].name()) self.assertFalse(hasattr(request, 'mux_processor')) def test_bad_requests(self): bad_cases = [ ('HTTP request', RequestDefinition( 'GET', '/demo', {'Host': 'www.google.com', 'User-Agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5;' ' en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3' ' GTB6 GTBA', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,' '*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Accept-Encoding': 'gzip,deflate', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Keep-Alive': '300', 'Connection': 'keep-alive'}), None, True)] request_def = _create_good_request_def() request_def.method = 'POST' bad_cases.append(('Wrong method', request_def, None, True)) request_def = _create_good_request_def() del request_def.headers['Host'] bad_cases.append(('Missing Host', request_def, None, True)) request_def = _create_good_request_def() del request_def.headers['Upgrade'] bad_cases.append(('Missing Upgrade', request_def, None, True)) request_def = _create_good_request_def() request_def.headers['Upgrade'] = 'nonwebsocket' bad_cases.append(('Wrong Upgrade', request_def, None, True)) request_def = _create_good_request_def() del request_def.headers['Connection'] bad_cases.append(('Missing Connection', request_def, None, True)) request_def = _create_good_request_def() request_def.headers['Connection'] = 'Downgrade' bad_cases.append(('Wrong Connection', request_def, None, True)) request_def = _create_good_request_def() del request_def.headers['Sec-WebSocket-Key'] bad_cases.append(('Missing Sec-WebSocket-Key', request_def, 400, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Key'] = ( 'dGhlIHNhbXBsZSBub25jZQ==garbage') bad_cases.append(('Wrong Sec-WebSocket-Key (with garbage on the tail)', request_def, 400, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Key'] = 'YQ==' # BASE64 of 'a' bad_cases.append( ('Wrong Sec-WebSocket-Key (decoded value is not 16 octets long)', request_def, 400, True)) request_def = _create_good_request_def() # The last character right before == must be any of A, Q, w and g. request_def.headers['Sec-WebSocket-Key'] = ( 'AQIDBAUGBwgJCgsMDQ4PEC==') bad_cases.append( ('Wrong Sec-WebSocket-Key (padding bits are not zero)', request_def, 400, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Key'] = ( 'dGhlIHNhbXBsZSBub25jZQ==,dGhlIHNhbXBsZSBub25jZQ==') bad_cases.append( ('Wrong Sec-WebSocket-Key (multiple values)', request_def, 400, True)) request_def = _create_good_request_def() del request_def.headers['Sec-WebSocket-Version'] bad_cases.append(('Missing Sec-WebSocket-Version', request_def, None, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Version'] = '3' bad_cases.append(('Wrong Sec-WebSocket-Version', request_def, None, False)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Version'] = '13, 13' bad_cases.append(('Wrong Sec-WebSocket-Version (multiple values)', request_def, 400, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Protocol'] = 'illegal\x09protocol' bad_cases.append(('Illegal Sec-WebSocket-Protocol', request_def, 400, True)) request_def = _create_good_request_def() request_def.headers['Sec-WebSocket-Protocol'] = '' bad_cases.append(('Empty Sec-WebSocket-Protocol', request_def, 400, True)) for (case_name, request_def, expected_status, expect_handshake_exception) in bad_cases: request = _create_request(request_def) handshaker = Handshaker(request, mock.MockDispatcher()) try: handshaker.do_handshake() self.fail('No exception thrown for \'%s\' case' % case_name) except HandshakeException, e: self.assertTrue(expect_handshake_exception) self.assertEqual(expected_status, e.status) except VersionException, e: self.assertFalse(expect_handshake_exception) if __name__ == '__main__': unittest.main() # vi:sts=4 sw=4 et
mpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7760, 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, 421, 199, 624, 2925, 367, 14305, 859, 1041, 421, 199, 646, 2882, 199, 199, 646, 663, 63, 1274, 63, 515, 221, 327, 6162, 984, 14, 515, 370, 16592, 3413, 63, 21387, 859, 14, 199, 504, 3413, 63, 21387, 492, 2863, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 8351, 1376, 2175, 1899, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 27451, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 3394, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 14, 3577, 4492, 492, 18405, 25880, 199, 199, 646, 1683, 421, 199, 533, 4784, 10701, 8, 785, 304, 272, 408, 33, 1021, 367, 17573, 666, 367, 22048, 13618, 14305, 3326, 367, 272, 5343, 314, 13618, 14305, 12495, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1083, 12, 5108, 12, 2323, 304, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 2302, 275, 5108, 267, 291, 14, 2139, 275, 2323, 421, 199, 318, 485, 981, 63, 8302, 63, 1069, 63, 318, 837, 272, 372, 4784, 10701, 8, 267, 283, 2970, 297, 1994, 8768, 297, 267, 791, 4965, 356, 283, 1000, 14, 2694, 14, 957, 297, 268, 283, 19217, 356, 283, 13508, 297, 268, 283, 3225, 356, 283, 19217, 297, 268, 283, 4933, 13, 18477, 13, 1197, 356, 283, 28929, 15544, 19824, 46, 16168, 20806, 30587, 12463, 456, 821, 74, 58, 49, 389, 297, 268, 283, 4933, 13, 18477, 13, 3353, 356, 283, 969, 297, 268, 283, 12834, 356, 283, 1014, 921, 2694, 14, 957, 3071, 421, 199, 318, 485, 981, 63, 1069, 8, 1069, 63, 318, 304, 272, 2557, 275, 1683, 14, 3346, 6805, 8355, 272, 372, 1683, 14, 3346, 2017, 8, 267, 1083, 29, 1069, 63, 318, 14, 765, 12, 267, 5108, 29, 1069, 63, 318, 14, 2302, 12, 267, 2323, 63, 262, 29, 1069, 63, 318, 14, 2139, 12, 267, 1950, 29, 1631, 9, 421, 199, 318, 485, 981, 63, 6868, 25880, 8, 1069, 304, 272, 4926, 25880, 275, 18405, 25880, 8, 1069, 12, 1683, 14, 3346, 15461, 1012, 272, 372, 4926, 25880, 421, 199, 533, 4804, 3922, 6209, 26056, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 5951, 314, 284, 13, 273, 1007, 3922, 272, 402, 5839, 7869, 370, 10900, 63, 3922, 2382, 284, 365, 1627, 641, 14538, 465, 1478, 272, 1423, 14, 982, 1478, 365, 6946, 12, 849, 63, 585, 911, 506, 663, 370, 10900, 63, 3922, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1478, 12, 849, 63, 585, 29, 403, 304, 267, 291, 14, 1080, 275, 1478, 267, 291, 14, 885, 63, 585, 275, 849, 63, 585, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 340, 291, 14, 1080, 2356, 378, 26, 288, 2557, 63, 1100, 14, 3569, 63, 3922, 275, 2557, 63, 1100, 14, 3569, 63, 11151, 63, 16541, 59, 355, 291, 14, 1080, 61, 267, 587, 26, 288, 2557, 63, 1100, 14, 3569, 63, 3922, 275, 291, 14, 885, 63, 585, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986, 421, 199, 533, 27451, 5583, 1376, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 31455, 316, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 6534, 376, 1919, 315, 272, 886, 63, 2911, 63, 11913, 370, 17100, 314, 1056, 14, 272, 408, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 746, 27451, 5583, 1376, 1726, 360, 2493, 1919, 370, 17100, 314, 1056, 358, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986, 421, 199, 533, 8351, 1376, 2175, 1899, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 6534, 376, 272, 8351, 1376, 2175, 1899, 1726, 315, 886, 63, 2911, 63, 11913, 370, 17100, 314, 1056, 14, 272, 408, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 746, 8351, 1376, 2175, 1899, 1726, 360, 2493, 8351, 1376, 2175, 1899, 1726, 370, 17100, 314, 283, 3660, 283, 1069, 358, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7760, 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, 421, 199, 624, 2925, 367, 14305, 859, 1041, 421, 199, 646, 2882, 199, 199, 646, 663, 63, 1274, 63, 515, 221, 327, 6162, 984, 14, 515, 370, 16592, 3413, 63, 21387, 859, 14, 199, 504, 3413, 63, 21387, 492, 2863, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 8351, 1376, 2175, 1899, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 27451, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 423, 1095, 492, 3394, 1726, 199, 504, 3413, 63, 21387, 14, 11913, 14, 3577, 4492, 492, 18405, 25880, 199, 199, 646, 1683, 421, 199, 533, 4784, 10701, 8, 785, 304, 272, 408, 33, 1021, 367, 17573, 666, 367, 22048, 13618, 14305, 3326, 367, 272, 5343, 314, 13618, 14305, 12495, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1083, 12, 5108, 12, 2323, 304, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 2302, 275, 5108, 267, 291, 14, 2139, 275, 2323, 421, 199, 318, 485, 981, 63, 8302, 63, 1069, 63, 318, 837, 272, 372, 4784, 10701, 8, 267, 283, 2970, 297, 1994, 8768, 297, 267, 791, 4965, 356, 283, 1000, 14, 2694, 14, 957, 297, 268, 283, 19217, 356, 283, 13508, 297, 268, 283, 3225, 356, 283, 19217, 297, 268, 283, 4933, 13, 18477, 13, 1197, 356, 283, 28929, 15544, 19824, 46, 16168, 20806, 30587, 12463, 456, 821, 74, 58, 49, 389, 297, 268, 283, 4933, 13, 18477, 13, 3353, 356, 283, 969, 297, 268, 283, 12834, 356, 283, 1014, 921, 2694, 14, 957, 3071, 421, 199, 318, 485, 981, 63, 1069, 8, 1069, 63, 318, 304, 272, 2557, 275, 1683, 14, 3346, 6805, 8355, 272, 372, 1683, 14, 3346, 2017, 8, 267, 1083, 29, 1069, 63, 318, 14, 765, 12, 267, 5108, 29, 1069, 63, 318, 14, 2302, 12, 267, 2323, 63, 262, 29, 1069, 63, 318, 14, 2139, 12, 267, 1950, 29, 1631, 9, 421, 199, 318, 485, 981, 63, 6868, 25880, 8, 1069, 304, 272, 4926, 25880, 275, 18405, 25880, 8, 1069, 12, 1683, 14, 3346, 15461, 1012, 272, 372, 4926, 25880, 421, 199, 533, 4804, 3922, 6209, 26056, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 5951, 314, 284, 13, 273, 1007, 3922, 272, 402, 5839, 7869, 370, 10900, 63, 3922, 2382, 284, 365, 1627, 641, 14538, 465, 1478, 272, 1423, 14, 982, 1478, 365, 6946, 12, 849, 63, 585, 911, 506, 663, 370, 10900, 63, 3922, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1478, 12, 849, 63, 585, 29, 403, 304, 267, 291, 14, 1080, 275, 1478, 267, 291, 14, 885, 63, 585, 275, 849, 63, 585, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 340, 291, 14, 1080, 2356, 378, 26, 288, 2557, 63, 1100, 14, 3569, 63, 3922, 275, 2557, 63, 1100, 14, 3569, 63, 11151, 63, 16541, 59, 355, 291, 14, 1080, 61, 267, 587, 26, 288, 2557, 63, 1100, 14, 3569, 63, 3922, 275, 291, 14, 885, 63, 585, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986, 421, 199, 533, 27451, 5583, 1376, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 31455, 316, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 6534, 376, 1919, 315, 272, 886, 63, 2911, 63, 11913, 370, 17100, 314, 1056, 14, 272, 408, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 746, 27451, 5583, 1376, 1726, 360, 2493, 1919, 370, 17100, 314, 1056, 358, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986, 421, 199, 533, 8351, 1376, 2175, 1899, 15461, 8, 785, 304, 272, 408, 33, 17475, 367, 5343, 14, 961, 17475, 6534, 376, 272, 8351, 1376, 2175, 1899, 1726, 315, 886, 63, 2911, 63, 11913, 370, 17100, 314, 1056, 14, 272, 408, 339, 347, 886, 63, 2911, 63, 11913, 8, 277, 12, 2557, 63, 1100, 304, 267, 746, 8351, 1376, 2175, 1899, 1726, 360, 2493, 8351, 1376, 2175, 1899, 1726, 370, 17100, 314, 283, 3660, 283, 1069, 358, 339, 347, 9307, 63, 576, 8, 277, 12, 2557, 63, 1100, 304, 267, 986, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
schuylermartin45/mood_switch
musicservice.py
1
1849
#/usr/bin/python from __future__ import print_function ''' musicservice.py Parent class for all music services. "Enforces" a strict interface. These classes are used by the Playback class. @author: Schuyler Martin <schuylermartin45@gmail.com> ''' __author__ = "Schuyler Martin" class MusicService: ''' Music Service class "enforces" a common interface for all music services ''' def __init__(self, strType, plTypeTTS): ''' Constructor :param: strType String version of the service type's name :param: plTypeTTS String indicating what the playlist is over TTS (For example, radio stations may report "Playing station x" over "Playing playlist x") ''' self.strType = strType self.plTypeTTS = plTypeTTS def __str__(self): ''' __str__() :return: Return the service's string-name equivalent ''' return self.strType def getPlaylists(self): ''' Returns a dictionary of playlists from this service :return: Dictionary of playlists ([playlist_id] -> playlist) ''' # "Enforce" interface raise Exception("getPlaylists() not implemented for service " + self.strType) def getStream(self, playlist): ''' Retrieves the location of the (current) song to play :param: playlist Reference to Playlist object to use :return: Music stream location ''' # "Enforce" interface raise Exception("getStream() not implemented for service " + self.strType) class ServiceException(Exception): ''' Custom exception to throw if there is an issue with a music service ''' pass def main(): ''' Main execution point for testing ''' if __name__ == '__main__': main()
mit
[ 3, 15, 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 2344, 199, 20544, 1364, 14, 647, 199, 6652, 1021, 367, 1006, 30891, 8500, 14, 298, 1327, 509, 823, 2, 282, 7478, 3217, 14, 199, 20676, 3992, 787, 1202, 701, 314, 16527, 894, 1021, 14, 199, 32, 2502, 26, 22985, 29514, 1435, 603, 26788, 665, 15820, 29514, 1435, 77, 26788, 2322, 32, 6799, 14, 957, 30, 199, 2344, 199, 363, 2502, 363, 275, 298, 31936, 29514, 1435, 603, 26788, 2, 199, 199, 533, 28919, 9916, 3167, 26, 272, 1449, 272, 28919, 9916, 7591, 1021, 298, 287, 509, 823, 2, 282, 2863, 3217, 367, 1006, 30891, 8500, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 620, 804, 12, 1620, 804, 1481, 51, 304, 267, 1449, 267, 20297, 267, 520, 635, 26, 620, 804, 2624, 1015, 402, 314, 2435, 730, 1159, 536, 267, 520, 635, 26, 1620, 804, 1481, 51, 2624, 9297, 4052, 314, 13210, 365, 1806, 377, 9730, 288, 334, 1858, 2893, 12, 22008, 410, 1298, 1443, 3622, 298, 29975, 16518, 671, 2, 1806, 288, 298, 29975, 13210, 671, 531, 267, 1449, 267, 291, 14, 495, 804, 275, 620, 804, 267, 291, 14, 1168, 804, 1481, 51, 275, 1620, 804, 1481, 51, 339, 347, 636, 495, 721, 277, 304, 267, 1449, 267, 636, 495, 4533, 267, 520, 1107, 26, 1432, 314, 2435, 1159, 1059, 13, 354, 7353, 267, 1449, 267, 372, 291, 14, 495, 804, 339, 347, 664, 9651, 6717, 8, 277, 304, 267, 1449, 267, 1803, 282, 2600, 402, 5232, 6717, 687, 642, 2435, 267, 520, 1107, 26, 11932, 402, 5232, 6717, 7287, 10411, 63, 344, 61, 1035, 13210, 9, 267, 1449, 267, 327, 298, 1327, 3990, 2, 3217, 267, 746, 2186, 480, 362, 9651, 6717, 342, 440, 6366, 367, 2435, 298, 7205, 435, 291, 14, 495, 804, 9, 339, 347, 664, 3296, 8, 277, 12, 13210, 304, 267, 1449, 267, 27940, 314, 2909, 402, 314, 334, 1818, 9, 20178, 370, 5232, 267, 520, 635, 26, 13210, 10944, 370, 16527, 513, 909, 370, 675, 267, 520, 1107, 26, 28919, 9916, 2547, 2909, 267, 1449, 267, 327, 298, 1327, 3990, 2, 3217, 267, 746, 2186, 480, 362, 3296, 342, 440, 6366, 367, 2435, 298, 7205, 435, 291, 14, 495, 804, 9, 199, 199, 533, 7591, 1726, 8, 1726, 304, 272, 1449, 272, 8388, 1919, 370, 7978, 340, 2337, 365, 376, 4976, 543, 282, 30891, 2435, 272, 1449, 272, 986, 199, 199, 318, 2446, 837, 272, 1449, 272, 11298, 6451, 2376, 367, 5343, 272, 1449, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 15, 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 2344, 199, 20544, 1364, 14, 647, 199, 6652, 1021, 367, 1006, 30891, 8500, 14, 298, 1327, 509, 823, 2, 282, 7478, 3217, 14, 199, 20676, 3992, 787, 1202, 701, 314, 16527, 894, 1021, 14, 199, 32, 2502, 26, 22985, 29514, 1435, 603, 26788, 665, 15820, 29514, 1435, 77, 26788, 2322, 32, 6799, 14, 957, 30, 199, 2344, 199, 363, 2502, 363, 275, 298, 31936, 29514, 1435, 603, 26788, 2, 199, 199, 533, 28919, 9916, 3167, 26, 272, 1449, 272, 28919, 9916, 7591, 1021, 298, 287, 509, 823, 2, 282, 2863, 3217, 367, 1006, 30891, 8500, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 620, 804, 12, 1620, 804, 1481, 51, 304, 267, 1449, 267, 20297, 267, 520, 635, 26, 620, 804, 2624, 1015, 402, 314, 2435, 730, 1159, 536, 267, 520, 635, 26, 1620, 804, 1481, 51, 2624, 9297, 4052, 314, 13210, 365, 1806, 377, 9730, 288, 334, 1858, 2893, 12, 22008, 410, 1298, 1443, 3622, 298, 29975, 16518, 671, 2, 1806, 288, 298, 29975, 13210, 671, 531, 267, 1449, 267, 291, 14, 495, 804, 275, 620, 804, 267, 291, 14, 1168, 804, 1481, 51, 275, 1620, 804, 1481, 51, 339, 347, 636, 495, 721, 277, 304, 267, 1449, 267, 636, 495, 4533, 267, 520, 1107, 26, 1432, 314, 2435, 1159, 1059, 13, 354, 7353, 267, 1449, 267, 372, 291, 14, 495, 804, 339, 347, 664, 9651, 6717, 8, 277, 304, 267, 1449, 267, 1803, 282, 2600, 402, 5232, 6717, 687, 642, 2435, 267, 520, 1107, 26, 11932, 402, 5232, 6717, 7287, 10411, 63, 344, 61, 1035, 13210, 9, 267, 1449, 267, 327, 298, 1327, 3990, 2, 3217, 267, 746, 2186, 480, 362, 9651, 6717, 342, 440, 6366, 367, 2435, 298, 7205, 435, 291, 14, 495, 804, 9, 339, 347, 664, 3296, 8, 277, 12, 13210, 304, 267, 1449, 267, 27940, 314, 2909, 402, 314, 334, 1818, 9, 20178, 370, 5232, 267, 520, 635, 26, 13210, 10944, 370, 16527, 513, 909, 370, 675, 267, 520, 1107, 26, 28919, 9916, 2547, 2909, 267, 1449, 267, 327, 298, 1327, 3990, 2, 3217, 267, 746, 2186, 480, 362, 3296, 342, 440, 6366, 367, 2435, 298, 7205, 435, 291, 14, 495, 804, 9, 199, 199, 533, 7591, 1726, 8, 1726, 304, 272, 1449, 272, 8388, 1919, 370, 7978, 340, 2337, 365, 376, 4976, 543, 282, 30891, 2435, 272, 1449, 272, 986, 199, 199, 318, 2446, 837, 272, 1449, 272, 11298, 6451, 2376, 367, 5343, 272, 1449, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
khertan/KhtBMA
khtbma/bna.py
1
5890
""" python-bna Battle.net Authenticator routines in Python. Specification can be found here: <http://bnetauth.freeportal.us/specification.html> Python implementation by Jerome Leclanche <jerome.leclanche@gmail.com> """ __version__ = "3.1" import hmac from binascii import hexlify from hashlib import sha1 try: from http.client import HTTPConnection except ImportError: from httplib import HTTPConnection from time import time RSA_MOD = 104890018807986556874007710914205443157030159668034197186125678960287470894290830530618284943118405110896322835449099433232093151168250152146023319326491587651685252774820340995950744075665455681760652136576493028733914892166700899109836291180881063097461175643998356321993663868233366705340758102567742483097 RSA_KEY = 257 ENROLL_HOSTS = { "EU": "m.eu.mobileservice.blizzard.com", "US": "m.us.mobileservice.blizzard.com", #"EU": "eu.mobile-service.blizzard.com", #"US": "us.mobile-service.blizzard.com", "default": "mobile-service.blizzard.com", } class HTTPError(Exception): def __init__(self, msg, response): self.response = response super(HTTPError, self).__init__(msg) def getOneTimePad(length): def timedigest(): return sha1(str(time()).encode()).digest() return (timedigest() + timedigest())[:length] def getServerResponse(data, host, path): """ Send computed data to Blizzard servers Return the answer from the server """ conn = HTTPConnection(host) conn.request("POST", path, data) response = conn.getresponse() if response.status != 200: raise HTTPError("%s returned status %i" % (host, response.status), response) ret = response.read() conn.close() return ret def enroll(data, host=ENROLL_HOSTS["default"], path="/enrollment/enroll.htm"): return getServerResponse(data, host, path) def encrypt(data): data = int(hexlify(data), 16) n = data ** RSA_KEY % RSA_MOD ret = "" while n > 0: n, m = divmod(n, 256) ret = chr(m) + ret return ret def decrypt(response, otp): ret = bytearray() for c, e in zip(response, otp): # python2 compatibility if isinstance(c, str): c = ord(c) e = ord(e) ret.append(c ^ e) return ret def requestNewSerial(region="US", model="Motorola RAZR v3"): """ Requests a new authenticator This will connect to the Blizzard servers """ def baseMsg(otp, region, model): ret = (otp + b"\0" * 37)[:37] ret += region.encode() or b"\0\0" ret += (model.encode() + b"\0" * 16)[:16] return b"\1" + ret otp = getOneTimePad(37) data = baseMsg(otp, region, model) e = encrypt(data) host = ENROLL_HOSTS.get(region, ENROLL_HOSTS["default"]) # get the host, or fallback to default response = decrypt(enroll(e, host)[8:], otp) secret = bytes(response[:20]) serial = response[20:].decode() region = serial[:2] if region not in ("EU", "US"): raise ValueError("Unexpected region: %r" % (region)) return serial, secret def bytesToRestoreCode(digest): ret = [] for i in digest: # Python2 compat if isinstance(i, str): i = ord(i) c = i & 0x1f if c < 10: c += 48 else: c += 55 if c > 72: # I c += 1 if c > 75: # L c += 1 if c > 78: # O c += 1 if c > 82: # S c += 1 ret.append(chr(c)) return "".join(ret) def getRestoreCode(serial, secret): data = (serial.encode() + secret) digest = sha1(data).digest()[-10:] return bytesToRestoreCode(digest) def getToken(secret, digits=8, seconds=30): """ Computes the token for a given secret Returns the token, and the seconds remaining for that token """ from struct import pack, unpack t = int(time()) msg = pack(">Q", int(t / seconds)) r = hmac.new(secret, msg, sha1).digest() k = r[19] # Python2 compat if isinstance(k, str): k = ord(k) idx = k & 0x0f h = unpack(">L", r[idx:idx+4])[0] & 0x7fffffff return h % (10 ** digits), -(t % seconds - seconds) def normalizeSerial(serial): """ Normalizes a serial Will uppercase it, remove its dashes and strip any whitespace """ return serial.upper().replace("-", "").strip() def prettifySerial(serial): """ Returns the prettified version of a serial It should look like XX-AAAA-BBBB-CCCC-DDDD """ serial = normalizeSerial(serial) if len(serial) != 14: raise ValueError("serial %r should be 14 characters long" % (serial)) def digits(chars): if not chars.isdigit(): raise ValueError("bad serial %r" % (serial)) return "%04i" % int((chars)) return "%s-%s-%s-%s" % (serial[0:2].upper(), digits(serial[2:6]), digits(serial[6:10]), digits(serial[10:14])) # restore functions, as reverse-engineered from the android implementation def restore(serial, code): serial = normalizeSerial(serial) if len(code) != 10: raise ValueError("invalid restore code (should be 10 bytes): %r" % (code)) challenge = initiatePaperRestore(serial) if len(challenge) != 32: raise HTTPError("Invalid challenge length (expected 32, got %i)" % (len(challenge))) code = restoreCodeToBytes(code) hash = hmac.new(code, serial.encode() + challenge, digestmod=sha1).digest() otp = getOneTimePad(20) e = encrypt(hash + otp) response = validatePaperRestore(serial + e) secret = decrypt(response, otp) return secret def restoreCodeToBytes(code): ret = bytearray() for c in code: c = ord(c) if 58 > c > 47: c -= 48 else: mod = c - 55 if c > 72: mod -= 1 if c > 75: mod -= 1 if c > 78: mod -= 1 if c > 82: mod -= 1 c = mod ret.append(c) return bytes(ret) def initiatePaperRestore(serial, host=ENROLL_HOSTS["default"], path="/enrollment/initiatePaperRestore.htm"): return getServerResponse(serial, host, path) def validatePaperRestore(data, host=ENROLL_HOSTS["default"], path="/enrollment/validatePaperRestore.htm"): try: response = getServerResponse(data, host, path) except HTTPError as e: if e.response.status == 600: raise HTTPError("Invalid serial or restore key", e.response) else: raise return response
gpl-3.0
[ 624, 199, 1548, 13, 66, 3540, 199, 34, 29274, 14, 846, 3590, 21345, 14975, 315, 2018, 14, 199, 199, 26235, 883, 506, 1911, 2348, 26, 523, 665, 1014, 921, 66, 846, 1178, 14, 4624, 8707, 14, 527, 15, 22271, 14, 1360, 30, 199, 4718, 4514, 701, 1603, 281, 1377, 7005, 429, 290, 595, 665, 74, 281, 1377, 14, 274, 429, 290, 595, 32, 6799, 14, 957, 30, 199, 624, 199, 199, 363, 1023, 363, 275, 298, 19, 14, 17, 2, 199, 199, 646, 20330, 199, 504, 14755, 492, 6318, 8209, 199, 504, 8337, 492, 7793, 17, 199, 893, 26, 199, 198, 504, 1455, 14, 1258, 492, 3101, 3225, 199, 2590, 3545, 26, 199, 198, 504, 8809, 492, 3101, 3225, 199, 504, 900, 492, 900, 199, 199, 12115, 63, 8816, 275, 21083, 1407, 23148, 1257, 1965, 1184, 1229, 2333, 1342, 31610, 6996, 1079, 1165, 1477, 2824, 10823, 1644, 614, 1427, 1272, 1257, 1082, 11165, 11656, 713, 6690, 22, 15501, 1342, 2760, 12128, 1398, 2036, 11565, 11363, 1085, 10681, 2635, 17539, 1349, 1717, 6019, 12031, 708, 1651, 1276, 1602, 2710, 1020, 2824, 24356, 1643, 9927, 845, 2333, 821, 614, 2528, 11432, 996, 1153, 1167, 708, 11228, 1046, 1555, 2182, 975, 2426, 6390, 1138, 2006, 1165, 13424, 1020, 1427, 1400, 1342, 12641, 29982, 1477, 1229, 2333, 10216, 1690, 2528, 8138, 1641, 772, 3129, 996, 1555, 11870, 1079, 1407, 9669, 1822, 8662, 1020, 709, 2905, 1344, 1398, 845, 1257, 1299, 7357, 10556, 17718, 845, 2194, 772, 10936, 24, 13251, 708, 7155, 11065, 8040, 2564, 1153, 11065, 23, 1717, 1082, 1780, 2010, 709, 3912, 15464, 11242, 1216, 2576, 199, 12115, 63, 3078, 275, 499, 1641, 199, 199, 742, 14881, 63, 23775, 275, 469, 199, 198, 2, 23539, 582, 298, 77, 14, 16913, 14, 11375, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 2, 1668, 582, 298, 77, 14, 527, 14, 11375, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 23662, 23539, 582, 298, 16913, 14, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 23662, 1668, 582, 298, 527, 14, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 2, 885, 582, 298, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 93, 199, 199, 533, 15050, 8, 1726, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1499, 12, 1177, 304, 507, 198, 277, 14, 1310, 275, 1177, 507, 198, 4792, 8, 12815, 12, 291, 2843, 826, 721, 1328, 9, 199, 199, 318, 664, 4395, 1366, 18584, 8, 1267, 304, 199, 198, 318, 900, 5671, 837, 507, 198, 1107, 7793, 17, 8, 495, 8, 521, 8801, 2143, 8801, 5671, 342, 421, 198, 1107, 334, 521, 5671, 342, 435, 900, 5671, 1012, 1491, 1267, 61, 199, 199, 318, 664, 3120, 2364, 8, 576, 12, 1591, 12, 931, 304, 199, 198, 624, 199, 198, 6795, 9235, 666, 370, 699, 317, 4348, 1005, 8037, 199, 198, 1767, 314, 6385, 687, 314, 1654, 199, 198, 624, 199, 198, 1631, 275, 3101, 3225, 8, 1102, 9, 199, 198, 1631, 14, 1069, 480, 4030, 401, 931, 12, 666, 9, 199, 198, 1310, 275, 2557, 14, 25006, 342, 421, 198, 692, 1177, 14, 1205, 1137, 1926, 26, 507, 198, 3730, 15050, 3647, 83, 2138, 2004, 450, 73, 2, 450, 334, 1102, 12, 1177, 14, 1205, 395, 1177, 9, 421, 198, 3292, 275, 1177, 14, 739, 342, 199, 198, 1631, 14, 1600, 342, 199, 198, 1107, 2203, 199, 199, 318, 26361, 8, 576, 12, 1591, 29, 742, 14881, 63, 23775, 905, 885, 2255, 931, 9555, 12214, 15, 14695, 14, 15575, 2349, 199, 198, 1107, 664, 3120, 2364, 8, 576, 12, 1591, 12, 931, 9, 199, 199, 318, 14645, 8, 576, 304, 199, 198, 576, 275, 1109, 8, 20677, 8, 576, 395, 3193, 9, 199, 198, 78, 275, 666, 1011, 18471, 63, 3078, 450, 18471, 63, 8816, 199, 198, 3292, 275, 3087, 199, 198, 6710, 302, 690, 378, 26, 507, 198, 78, 12, 333, 275, 16438, 8, 78, 12, 7633, 9, 507, 198, 3292, 275, 8678, 8, 77, 9, 435, 2203, 199, 198, 1107, 2203, 199, 199, 318, 20090, 8, 1310, 12, 312, 683, 304, 199, 198, 3292, 275, 11640, 342, 199, 198, 509, 286, 12, 325, 315, 3482, 8, 1310, 12, 312, 683, 304, 507, 198, 3, 2366, 18, 7163, 507, 198, 692, 1228, 8, 67, 12, 620, 304, 686, 198, 67, 275, 6206, 8, 67, 9, 686, 198, 69, 275, 6206, 8, 69, 9, 2742, 198, 3292, 14, 740, 8, 67, 7167, 325, 9, 199, 198, 1107, 2203, 199, 199, 318, 1056, 4665, 3571, 8, 4551, 628, 1668, 401, 1402, 628, 31642, 22205, 820, 17613, 50, 373, 19, 2349, 199, 198, 624, 199, 198, 16272, 282, 892, 1790, 21345, 199, 198, 2765, 911, 4907, 370, 314, 699, 317, 4348, 1005, 8037, 199, 198, 624, 199, 198, 318, 1300, 6173, 8, 357, 80, 12, 4897, 12, 1402, 304, 507, 198, 3292, 275, 334, 357, 80, 435, 330, 3212, 16, 2, 627, 6877, 18562, 1401, 61, 507, 198, 3292, 847, 4897, 14, 2143, 342, 503, 330, 3212, 16, 60, 16, 2, 507, 198, 3292, 847, 334, 1238, 14, 2143, 342, 435, 330, 3212, 16, 2, 627, 3193, 18562, 975, 61, 507, 198, 1107, 330, 3212, 17, 2, 435, 2203, 421, 198, 357, 80, 275, 664, 4395, 1366, 18584, 8, 1401, 9, 199, 198, 576, 275, 1300, 6173, 8, 357, 80, 12, 4897, 12, 1402, 9, 421, 198, 69, 275, 14645, 8, 576, 9, 199, 198, 1102, 275, 5070, 14881, 63, 23775, 14, 362, 8, 4551, 12, 5070, 14881, 63, 23775, 905, 885, 3135, 327, 664, 314, 1591, 12, 503, 9567, 370, 849, 199, 198, 1310, 275, 20090, 8, 14695, 8, 69, 12, 1591, 2788, 24, 8429, 312, 683, 9, 421, 198, 4731, 275, 2783, 8, 1310, 1491, 1165, 566, 199, 198, 2171, 275, 1177, 59, 1165, 11455, 2708, 342, 421, 198, 4551, 275, 3012, 1491, 18, 61, 199, 198, 692, 4897, 440, 315, 1689, 23539, 401, 298, 1668, 2349, 507, 198, 3730, 1722, 480, 8708, 4897, 26, 450, 82, 2, 450, 334, 4551, 430, 421, 198, 1107, 3012, 12, 7565, 199, 199, 318, 2783, 1378, 21012, 3034, 8, 5671, 304 ]
[ 199, 1548, 13, 66, 3540, 199, 34, 29274, 14, 846, 3590, 21345, 14975, 315, 2018, 14, 199, 199, 26235, 883, 506, 1911, 2348, 26, 523, 665, 1014, 921, 66, 846, 1178, 14, 4624, 8707, 14, 527, 15, 22271, 14, 1360, 30, 199, 4718, 4514, 701, 1603, 281, 1377, 7005, 429, 290, 595, 665, 74, 281, 1377, 14, 274, 429, 290, 595, 32, 6799, 14, 957, 30, 199, 624, 199, 199, 363, 1023, 363, 275, 298, 19, 14, 17, 2, 199, 199, 646, 20330, 199, 504, 14755, 492, 6318, 8209, 199, 504, 8337, 492, 7793, 17, 199, 893, 26, 199, 198, 504, 1455, 14, 1258, 492, 3101, 3225, 199, 2590, 3545, 26, 199, 198, 504, 8809, 492, 3101, 3225, 199, 504, 900, 492, 900, 199, 199, 12115, 63, 8816, 275, 21083, 1407, 23148, 1257, 1965, 1184, 1229, 2333, 1342, 31610, 6996, 1079, 1165, 1477, 2824, 10823, 1644, 614, 1427, 1272, 1257, 1082, 11165, 11656, 713, 6690, 22, 15501, 1342, 2760, 12128, 1398, 2036, 11565, 11363, 1085, 10681, 2635, 17539, 1349, 1717, 6019, 12031, 708, 1651, 1276, 1602, 2710, 1020, 2824, 24356, 1643, 9927, 845, 2333, 821, 614, 2528, 11432, 996, 1153, 1167, 708, 11228, 1046, 1555, 2182, 975, 2426, 6390, 1138, 2006, 1165, 13424, 1020, 1427, 1400, 1342, 12641, 29982, 1477, 1229, 2333, 10216, 1690, 2528, 8138, 1641, 772, 3129, 996, 1555, 11870, 1079, 1407, 9669, 1822, 8662, 1020, 709, 2905, 1344, 1398, 845, 1257, 1299, 7357, 10556, 17718, 845, 2194, 772, 10936, 24, 13251, 708, 7155, 11065, 8040, 2564, 1153, 11065, 23, 1717, 1082, 1780, 2010, 709, 3912, 15464, 11242, 1216, 2576, 199, 12115, 63, 3078, 275, 499, 1641, 199, 199, 742, 14881, 63, 23775, 275, 469, 199, 198, 2, 23539, 582, 298, 77, 14, 16913, 14, 11375, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 2, 1668, 582, 298, 77, 14, 527, 14, 11375, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 23662, 23539, 582, 298, 16913, 14, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 23662, 1668, 582, 298, 527, 14, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 198, 2, 885, 582, 298, 11375, 13, 1364, 14, 66, 317, 4348, 1005, 14, 957, 401, 199, 93, 199, 199, 533, 15050, 8, 1726, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1499, 12, 1177, 304, 507, 198, 277, 14, 1310, 275, 1177, 507, 198, 4792, 8, 12815, 12, 291, 2843, 826, 721, 1328, 9, 199, 199, 318, 664, 4395, 1366, 18584, 8, 1267, 304, 199, 198, 318, 900, 5671, 837, 507, 198, 1107, 7793, 17, 8, 495, 8, 521, 8801, 2143, 8801, 5671, 342, 421, 198, 1107, 334, 521, 5671, 342, 435, 900, 5671, 1012, 1491, 1267, 61, 199, 199, 318, 664, 3120, 2364, 8, 576, 12, 1591, 12, 931, 304, 199, 198, 624, 199, 198, 6795, 9235, 666, 370, 699, 317, 4348, 1005, 8037, 199, 198, 1767, 314, 6385, 687, 314, 1654, 199, 198, 624, 199, 198, 1631, 275, 3101, 3225, 8, 1102, 9, 199, 198, 1631, 14, 1069, 480, 4030, 401, 931, 12, 666, 9, 199, 198, 1310, 275, 2557, 14, 25006, 342, 421, 198, 692, 1177, 14, 1205, 1137, 1926, 26, 507, 198, 3730, 15050, 3647, 83, 2138, 2004, 450, 73, 2, 450, 334, 1102, 12, 1177, 14, 1205, 395, 1177, 9, 421, 198, 3292, 275, 1177, 14, 739, 342, 199, 198, 1631, 14, 1600, 342, 199, 198, 1107, 2203, 199, 199, 318, 26361, 8, 576, 12, 1591, 29, 742, 14881, 63, 23775, 905, 885, 2255, 931, 9555, 12214, 15, 14695, 14, 15575, 2349, 199, 198, 1107, 664, 3120, 2364, 8, 576, 12, 1591, 12, 931, 9, 199, 199, 318, 14645, 8, 576, 304, 199, 198, 576, 275, 1109, 8, 20677, 8, 576, 395, 3193, 9, 199, 198, 78, 275, 666, 1011, 18471, 63, 3078, 450, 18471, 63, 8816, 199, 198, 3292, 275, 3087, 199, 198, 6710, 302, 690, 378, 26, 507, 198, 78, 12, 333, 275, 16438, 8, 78, 12, 7633, 9, 507, 198, 3292, 275, 8678, 8, 77, 9, 435, 2203, 199, 198, 1107, 2203, 199, 199, 318, 20090, 8, 1310, 12, 312, 683, 304, 199, 198, 3292, 275, 11640, 342, 199, 198, 509, 286, 12, 325, 315, 3482, 8, 1310, 12, 312, 683, 304, 507, 198, 3, 2366, 18, 7163, 507, 198, 692, 1228, 8, 67, 12, 620, 304, 686, 198, 67, 275, 6206, 8, 67, 9, 686, 198, 69, 275, 6206, 8, 69, 9, 2742, 198, 3292, 14, 740, 8, 67, 7167, 325, 9, 199, 198, 1107, 2203, 199, 199, 318, 1056, 4665, 3571, 8, 4551, 628, 1668, 401, 1402, 628, 31642, 22205, 820, 17613, 50, 373, 19, 2349, 199, 198, 624, 199, 198, 16272, 282, 892, 1790, 21345, 199, 198, 2765, 911, 4907, 370, 314, 699, 317, 4348, 1005, 8037, 199, 198, 624, 199, 198, 318, 1300, 6173, 8, 357, 80, 12, 4897, 12, 1402, 304, 507, 198, 3292, 275, 334, 357, 80, 435, 330, 3212, 16, 2, 627, 6877, 18562, 1401, 61, 507, 198, 3292, 847, 4897, 14, 2143, 342, 503, 330, 3212, 16, 60, 16, 2, 507, 198, 3292, 847, 334, 1238, 14, 2143, 342, 435, 330, 3212, 16, 2, 627, 3193, 18562, 975, 61, 507, 198, 1107, 330, 3212, 17, 2, 435, 2203, 421, 198, 357, 80, 275, 664, 4395, 1366, 18584, 8, 1401, 9, 199, 198, 576, 275, 1300, 6173, 8, 357, 80, 12, 4897, 12, 1402, 9, 421, 198, 69, 275, 14645, 8, 576, 9, 199, 198, 1102, 275, 5070, 14881, 63, 23775, 14, 362, 8, 4551, 12, 5070, 14881, 63, 23775, 905, 885, 3135, 327, 664, 314, 1591, 12, 503, 9567, 370, 849, 199, 198, 1310, 275, 20090, 8, 14695, 8, 69, 12, 1591, 2788, 24, 8429, 312, 683, 9, 421, 198, 4731, 275, 2783, 8, 1310, 1491, 1165, 566, 199, 198, 2171, 275, 1177, 59, 1165, 11455, 2708, 342, 421, 198, 4551, 275, 3012, 1491, 18, 61, 199, 198, 692, 4897, 440, 315, 1689, 23539, 401, 298, 1668, 2349, 507, 198, 3730, 1722, 480, 8708, 4897, 26, 450, 82, 2, 450, 334, 4551, 430, 421, 198, 1107, 3012, 12, 7565, 199, 199, 318, 2783, 1378, 21012, 3034, 8, 5671, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Bloodyaugust/pongsugarlabcpp
lib/boost/tools/build/src/util/order.py
9
4322
# Copyright (C) 2003 Vladimir Prus # Use, modification, and distribution is subject to the Boost Software # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy # at http://www.boost.org/LICENSE_1_0.txt) class Order: """Allows ordering arbitrary objects with regard to arbitrary binary relation. The primary use case is the gcc toolset, which is sensitive to library order: if library 'a' uses symbols from library 'b', then 'a' must be present before 'b' on the linker's command line. This requirement can be lifted for gcc with GNU ld, but for gcc with Solaris LD (and for Solaris toolset as well), the order always matters. So, we need to store order requirements and then order libraries according to them. It it not possible to use dependency graph as order requirements. What we need is "use symbols" relationship while dependency graph provides "needs to be updated" relationship. For example:: lib a : a.cpp b; lib b ; For static linking, the 'a' library need not depend on 'b'. However, it still should come before 'b' on the command line. """ def __init__ (self): self.constraints_ = [] def add_pair (self, first, second): """ Adds the constraint that 'first' should precede 'second'. """ self.constraints_.append ((first, second)) def order (self, objects): """ Given a list of objects, reorder them so that the constains specified by 'add_pair' are satisfied. The algorithm was adopted from an awk script by Nikita Youshchenko (yoush at cs dot msu dot su) """ # The algorithm used is the same is standard transitive closure, # except that we're not keeping in-degree for all vertices, but # rather removing edges. result = [] if not objects: return result constraints = self.__eliminate_unused_constraits (objects) # Find some library that nobody depends upon and add it to # the 'result' array. obj = None while objects: new_objects = [] while objects: obj = objects [0] if self.__has_no_dependents (obj, constraints): # Emulate break ; new_objects.extend (objects [1:]) objects = [] else: new_objects.append (obj) obj = None objects = objects [1:] if not obj: raise BaseException ("Circular order dependencies") # No problem with placing first. result.append (obj) # Remove all containts where 'obj' comes first, # since they are already satisfied. constraints = self.__remove_satisfied (constraints, obj) # Add the remaining objects for further processing # on the next iteration objects = new_objects return result def __eliminate_unused_constraits (self, objects): """ Eliminate constraints which mention objects not in 'objects'. In graph-theory terms, this is finding subgraph induced by ordered vertices. """ result = [] for c in self.constraints_: if c [0] in objects and c [1] in objects: result.append (c) return result def __has_no_dependents (self, obj, constraints): """ Returns true if there's no constraint in 'constraints' where 'obj' comes second. """ failed = False while constraints and not failed: c = constraints [0] if c [1] == obj: failed = True constraints = constraints [1:] return not failed def __remove_satisfied (self, constraints, obj): result = [] for c in constraints: if c [0] != obj: result.append (c) return result
gpl-2.0
[ 3, 221, 1898, 334, 35, 9, 13004, 812, 416, 3572, 723, 510, 20791, 202, 199, 3, 221, 3645, 12, 7100, 12, 436, 4084, 365, 5420, 370, 314, 30470, 2290, 202, 199, 3, 221, 844, 12, 3394, 413, 14, 16, 14, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 202, 199, 3, 221, 737, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 2999, 199, 533, 9240, 26, 1128, 408, 19780, 7794, 9697, 2251, 543, 8794, 370, 9697, 3366, 5850, 14, 4341, 710, 5062, 675, 1930, 365, 314, 19443, 20070, 12, 1314, 365, 18423, 370, 1039, 3555, 1865, 26, 340, 3555, 283, 65, 7, 4440, 6698, 687, 3555, 283, 66, 297, 1039, 2066, 283, 65, 7, 1471, 506, 3451, 2544, 283, 66, 7, 641, 314, 17261, 1159, 1414, 1004, 14, 13594, 961, 10685, 883, 506, 221, 853, 471, 367, 19443, 543, 1664, 8827, 12, 1325, 367, 19443, 543, 1039, 17991, 4663, 16978, 334, 460, 367, 17991, 4663, 20070, 465, 5521, 395, 314, 1865, 3544, 2530, 878, 14, 13594, 2002, 12, 781, 1929, 370, 3877, 1865, 9760, 436, 2066, 1865, 8363, 1039, 7182, 370, 3062, 14, 2779, 652, 440, 3962, 370, 675, 5936, 3343, 465, 1039, 1865, 9760, 14, 14791, 781, 1929, 365, 298, 1180, 6698, 2, 8931, 1039, 1830, 5936, 3343, 6571, 298, 10065, 370, 506, 4588, 2, 8931, 14, 13594, 2104, 2893, 447, 16765, 1973, 282, 520, 282, 14, 5910, 330, 27, 16765, 1973, 330, 8700, 13594, 2104, 2955, 25833, 12, 314, 283, 65, 7, 3555, 1929, 440, 11687, 641, 283, 66, 1370, 9738, 12, 652, 1039, 5139, 1077, 11492, 2544, 283, 66, 7, 641, 314, 1414, 1004, 14, 1128, 408, 2958, 347, 636, 826, 363, 334, 277, 304, 1039, 291, 14, 9882, 63, 275, 942, 26016, 347, 1050, 63, 3852, 334, 277, 12, 1642, 12, 3499, 304, 1039, 408, 15747, 314, 5828, 626, 283, 2246, 7, 1077, 9222, 271, 283, 4375, 1370, 1039, 408, 1039, 291, 14, 9882, 3754, 740, 3666, 2246, 12, 3499, 430, 2958, 347, 1865, 334, 277, 12, 2251, 304, 1039, 408, 9138, 282, 769, 402, 2251, 12, 32179, 3062, 880, 626, 314, 950, 1581, 83, 2013, 1675, 701, 283, 525, 63, 3852, 7, 787, 23233, 14, 17554, 1675, 710, 5563, 1990, 1503, 411, 471, 687, 376, 282, 14947, 2884, 701, 653, 3258, 21492, 1488, 1785, 72, 24604, 7697, 1675, 334, 89, 1785, 72, 737, 7117, 6308, 6605, 85, 6308, 18741, 9, 1039, 408, 1039, 327, 710, 5563, 1202, 365, 314, 2011, 365, 4465, 7115, 3013, 17903, 12, 1039, 327, 871, 626, 781, 3984, 440, 22181, 315, 13, 10956, 367, 1006, 14971, 12, 1325, 1039, 327, 7830, 12881, 8207, 14, 1039, 754, 275, 942, 4341, 340, 440, 2251, 26, 221, 1675, 372, 754, 4341, 9565, 275, 291, 855, 69, 13769, 323, 63, 8618, 63, 1297, 345, 1405, 334, 1462, 9, 13594, 327, 6668, 2005, 3555, 626, 949, 2030, 8350, 12188, 436, 1050, 652, 370, 1039, 327, 314, 283, 1099, 7, 1625, 14, 1039, 1559, 275, 488, 1039, 1830, 2251, 26, 1675, 892, 63, 1462, 275, 942, 1675, 1830, 2251, 26, 2628, 1559, 275, 2251, 359, 16, 61, 24216, 340, 291, 855, 1989, 63, 889, 63, 32333, 334, 1113, 12, 9565, 304, 4906, 327, 662, 3703, 323, 2059, 8700, 4906, 892, 63, 1462, 14, 2880, 334, 1462, 359, 17, 5728, 4906, 2251, 275, 942, 24216, 587, 26, 4906, 892, 63, 1462, 14, 740, 334, 1113, 9, 4906, 1559, 275, 488, 4906, 2251, 275, 2251, 359, 17, 2938, 17554, 1675, 340, 440, 1559, 26, 2628, 746, 25416, 1689, 35, 24998, 1865, 5124, 531, 11556, 327, 3091, 5160, 543, 299, 13121, 1642, 14, 1675, 754, 14, 740, 334, 1113, 9, 11556, 327, 5852, 1006, 406, 502, 13141, 2382, 283, 1113, 7, 12477, 1642, 12, 1675, 327, 3967, 2985, 787, 2575, 23233, 14, 1675, 9565, 275, 291, 855, 2168, 63, 22878, 334, 9882, 12, 1559, 9, 11556, 327, 2654, 314, 7971, 2251, 367, 9848, 6661, 1675, 327, 641, 314, 2163, 8494, 1675, 2251, 275, 892, 63, 1462, 17554, 1039, 372, 754, 2958, 347, 636, 69, 13769, 323, 63, 8618, 63, 1297, 345, 1405, 334, 277, 12, 2251, 304, 1039, 408, 662, 13769, 323, 9565, 1314, 20811, 2251, 440, 315, 283, 1462, 1370, 1675, 1010, 3343, 13, 1589, 1089, 2895, 12, 642, 365, 17196, 23649, 315, 16584, 701, 1675, 7741, 14971, 14, 1039, 408, 1039, 754, 275, 942, 1039, 367, 286, 315, 291, 14, 9882, 10388, 1675, 340, 286, 359, 16, 61, 315, 2251, 436, 286, 359, 17, 61, 315, 2251, 26, 2628, 754, 14, 740, 334, 67, 9, 4341, 372, 754, 11787, 347, 636, 1989, 63, 889, 63, 32333, 334, 277, 12, 1559, 12, 9565, 304, 1039, 408, 1803, 2549, 340, 2337, 1159, 949, 5828, 315, 283, 9882, 7, 2382, 221, 1675, 283, 1113, 7, 12477, 3499, 14, 1039, 408, 1039, 3405, 275, 756, 1039, 1830, 9565, 436, 440, 3405, 26, 1675, 286, 275, 9565, 359, 16, 61, 11556, 340, 286, 359, 17, 61, 508, 1559, 26, 2628, 3405, 275, 715, 11556, 9565, 275, 9565, 359, 17, 2938, 4341, 372, 440, 3405, 11787, 347, 636, 2168, 63, 22878, 334, 277, 12, 9565, 12, 1559, 304, 1039, 754, 275, 942, 1039, 367, 286, 315, 9565, 26, 1675, 340, 286, 359, 16, 61, 1137, 1559, 26, 2628, 754, 14, 740, 334, 67, 9, 4341, 372, 754, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 221, 1898, 334, 35, 9, 13004, 812, 416, 3572, 723, 510, 20791, 202, 199, 3, 221, 3645, 12, 7100, 12, 436, 4084, 365, 5420, 370, 314, 30470, 2290, 202, 199, 3, 221, 844, 12, 3394, 413, 14, 16, 14, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 202, 199, 3, 221, 737, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 2999, 199, 533, 9240, 26, 1128, 408, 19780, 7794, 9697, 2251, 543, 8794, 370, 9697, 3366, 5850, 14, 4341, 710, 5062, 675, 1930, 365, 314, 19443, 20070, 12, 1314, 365, 18423, 370, 1039, 3555, 1865, 26, 340, 3555, 283, 65, 7, 4440, 6698, 687, 3555, 283, 66, 297, 1039, 2066, 283, 65, 7, 1471, 506, 3451, 2544, 283, 66, 7, 641, 314, 17261, 1159, 1414, 1004, 14, 13594, 961, 10685, 883, 506, 221, 853, 471, 367, 19443, 543, 1664, 8827, 12, 1325, 367, 19443, 543, 1039, 17991, 4663, 16978, 334, 460, 367, 17991, 4663, 20070, 465, 5521, 395, 314, 1865, 3544, 2530, 878, 14, 13594, 2002, 12, 781, 1929, 370, 3877, 1865, 9760, 436, 2066, 1865, 8363, 1039, 7182, 370, 3062, 14, 2779, 652, 440, 3962, 370, 675, 5936, 3343, 465, 1039, 1865, 9760, 14, 14791, 781, 1929, 365, 298, 1180, 6698, 2, 8931, 1039, 1830, 5936, 3343, 6571, 298, 10065, 370, 506, 4588, 2, 8931, 14, 13594, 2104, 2893, 447, 16765, 1973, 282, 520, 282, 14, 5910, 330, 27, 16765, 1973, 330, 8700, 13594, 2104, 2955, 25833, 12, 314, 283, 65, 7, 3555, 1929, 440, 11687, 641, 283, 66, 1370, 9738, 12, 652, 1039, 5139, 1077, 11492, 2544, 283, 66, 7, 641, 314, 1414, 1004, 14, 1128, 408, 2958, 347, 636, 826, 363, 334, 277, 304, 1039, 291, 14, 9882, 63, 275, 942, 26016, 347, 1050, 63, 3852, 334, 277, 12, 1642, 12, 3499, 304, 1039, 408, 15747, 314, 5828, 626, 283, 2246, 7, 1077, 9222, 271, 283, 4375, 1370, 1039, 408, 1039, 291, 14, 9882, 3754, 740, 3666, 2246, 12, 3499, 430, 2958, 347, 1865, 334, 277, 12, 2251, 304, 1039, 408, 9138, 282, 769, 402, 2251, 12, 32179, 3062, 880, 626, 314, 950, 1581, 83, 2013, 1675, 701, 283, 525, 63, 3852, 7, 787, 23233, 14, 17554, 1675, 710, 5563, 1990, 1503, 411, 471, 687, 376, 282, 14947, 2884, 701, 653, 3258, 21492, 1488, 1785, 72, 24604, 7697, 1675, 334, 89, 1785, 72, 737, 7117, 6308, 6605, 85, 6308, 18741, 9, 1039, 408, 1039, 327, 710, 5563, 1202, 365, 314, 2011, 365, 4465, 7115, 3013, 17903, 12, 1039, 327, 871, 626, 781, 3984, 440, 22181, 315, 13, 10956, 367, 1006, 14971, 12, 1325, 1039, 327, 7830, 12881, 8207, 14, 1039, 754, 275, 942, 4341, 340, 440, 2251, 26, 221, 1675, 372, 754, 4341, 9565, 275, 291, 855, 69, 13769, 323, 63, 8618, 63, 1297, 345, 1405, 334, 1462, 9, 13594, 327, 6668, 2005, 3555, 626, 949, 2030, 8350, 12188, 436, 1050, 652, 370, 1039, 327, 314, 283, 1099, 7, 1625, 14, 1039, 1559, 275, 488, 1039, 1830, 2251, 26, 1675, 892, 63, 1462, 275, 942, 1675, 1830, 2251, 26, 2628, 1559, 275, 2251, 359, 16, 61, 24216, 340, 291, 855, 1989, 63, 889, 63, 32333, 334, 1113, 12, 9565, 304, 4906, 327, 662, 3703, 323, 2059, 8700, 4906, 892, 63, 1462, 14, 2880, 334, 1462, 359, 17, 5728, 4906, 2251, 275, 942, 24216, 587, 26, 4906, 892, 63, 1462, 14, 740, 334, 1113, 9, 4906, 1559, 275, 488, 4906, 2251, 275, 2251, 359, 17, 2938, 17554, 1675, 340, 440, 1559, 26, 2628, 746, 25416, 1689, 35, 24998, 1865, 5124, 531, 11556, 327, 3091, 5160, 543, 299, 13121, 1642, 14, 1675, 754, 14, 740, 334, 1113, 9, 11556, 327, 5852, 1006, 406, 502, 13141, 2382, 283, 1113, 7, 12477, 1642, 12, 1675, 327, 3967, 2985, 787, 2575, 23233, 14, 1675, 9565, 275, 291, 855, 2168, 63, 22878, 334, 9882, 12, 1559, 9, 11556, 327, 2654, 314, 7971, 2251, 367, 9848, 6661, 1675, 327, 641, 314, 2163, 8494, 1675, 2251, 275, 892, 63, 1462, 17554, 1039, 372, 754, 2958, 347, 636, 69, 13769, 323, 63, 8618, 63, 1297, 345, 1405, 334, 277, 12, 2251, 304, 1039, 408, 662, 13769, 323, 9565, 1314, 20811, 2251, 440, 315, 283, 1462, 1370, 1675, 1010, 3343, 13, 1589, 1089, 2895, 12, 642, 365, 17196, 23649, 315, 16584, 701, 1675, 7741, 14971, 14, 1039, 408, 1039, 754, 275, 942, 1039, 367, 286, 315, 291, 14, 9882, 10388, 1675, 340, 286, 359, 16, 61, 315, 2251, 436, 286, 359, 17, 61, 315, 2251, 26, 2628, 754, 14, 740, 334, 67, 9, 4341, 372, 754, 11787, 347, 636, 1989, 63, 889, 63, 32333, 334, 277, 12, 1559, 12, 9565, 304, 1039, 408, 1803, 2549, 340, 2337, 1159, 949, 5828, 315, 283, 9882, 7, 2382, 221, 1675, 283, 1113, 7, 12477, 3499, 14, 1039, 408, 1039, 3405, 275, 756, 1039, 1830, 9565, 436, 440, 3405, 26, 1675, 286, 275, 9565, 359, 16, 61, 11556, 340, 286, 359, 17, 61, 508, 1559, 26, 2628, 3405, 275, 715, 11556, 9565, 275, 9565, 359, 17, 2938, 4341, 372, 440, 3405, 11787, 347, 636, 2168, 63, 22878, 334, 277, 12, 9565, 12, 1559, 304, 1039, 754, 275, 942, 1039, 367, 286, 315, 9565, 26, 1675, 340, 286, 359, 16, 61, 1137, 1559, 26, 2628, 754, 14, 740, 334, 67, 9, 4341, 372, 754, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
msegado/edx-platform
lms/djangoapps/course_api/blocks/views.py
25
9338
""" CourseBlocks API views """ from django.core.exceptions import ValidationError from django.http import Http404 from rest_framework.generics import ListAPIView from rest_framework.response import Response from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from openedx.core.lib.api.view_utils import view_auth_classes, DeveloperErrorViewMixin from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError from .api import get_blocks from .forms import BlockListGetForm @view_auth_classes() class BlocksView(DeveloperErrorViewMixin, ListAPIView): """ **Use Case** Returns the blocks within the requested block tree according to the requesting user's access level. **Example requests**: GET /api/courses/v1/blocks/<root_block_usage_id>/?depth=all GET /api/courses/v1/blocks/<usage_id>/? username=anjali &depth=all &requested_fields=graded,format,student_view_multi_device &block_counts=video &student_view_data=video **Parameters**: * username: (string) The name of the user on whose behalf we want to see the data. Example: username=anjali * student_view_data: (list) Indicates for which block types to return student_view_data. Example: student_view_data=video * block_counts: (list) Indicates for which block types to return the aggregate count of the blocks. Example: block_counts=video,problem * requested_fields: (list) Indicates which additional fields to return for each block. For a list of available fields see under `Response Values -> blocks`, below. The following fields are always returned: id, type, display_name Example: requested_fields=graded,format,student_view_multi_device * depth: (integer or all) Indicates how deep to traverse into the blocks hierarchy. A value of all means the entire hierarchy. Default is 0 Example: depth=all * nav_depth: (integer) WARNING: nav_depth is not supported, and may be removed at any time. Indicates how far deep to traverse into the course hierarchy before bundling all the descendants. Default is 3 since typical navigational views of the course show a maximum of chapter->sequential->vertical. Example: nav_depth=3 * return_type (string) Indicates in what data type to return the blocks. Default is dict. Supported values are: dict, list Example: return_type=dict **Response Values** The following fields are returned with a successful response. * root: The ID of the root node of the course blocks. * blocks: A dictionary that maps block usage IDs to a collection of information about each block. Each block contains the following fields. * id: (string) The usage ID of the block. * type: (string) The type of block. Possible values include course, chapter, sequential, vertical, html, problem, video, and discussion. The type can also be the name of a custom type of block used for the course. * display_name: (string) The display name of the block. * children: (list) If the block has child blocks, a list of IDs of the child blocks. Returned only if "children" is included in the "requested_fields" parameter. * block_counts: (dict) For each block type specified in the block_counts parameter to the endpoint, the aggregate number of blocks of that type for this block and all of its descendants. Returned only if the "block_counts" input parameter contains this block's type. * graded (boolean) Whether or not the block or any of its descendants is graded. Returned only if "graded" is included in the "requested_fields" parameter. * format: (string) The assignment type of the block. Possible values can be "Homework", "Lab", "Midterm Exam", and "Final Exam". Returned only if "format" is included in the "requested_fields" parameter. * student_view_data: (dict) The JSON data for this block. Returned only if the "student_view_data" input parameter contains this block's type. * student_view_url: (string) The URL to retrieve the HTML rendering of this block's student view. The HTML could include CSS and Javascript code. This field can be used in combination with the student_view_multi_device field to decide whether to display this content to the user. This URL can be used as a fallback if the student_view_data for this block type is not supported by the client or the block. * student_view_multi_device: (boolean) Whether or not the block's rendering obtained via block_url has support for multiple devices. Returned only if "student_view_multi_device" is included in the "requested_fields" parameter. * lms_web_url: (string) The URL to the navigational container of the xBlock on the web LMS. This URL can be used as a further fallback if the student_view_url and the student_view_data fields are not supported. """ def list(self, request, usage_key_string): # pylint: disable=arguments-differ """ REST API endpoint for listing all the blocks information in the course, while regarding user access and roles. Arguments: request - Django request object usage_key_string - The usage key for a block. """ # validate request parameters requested_params = request.query_params.copy() requested_params.update({'usage_key': usage_key_string}) params = BlockListGetForm(requested_params, initial={'requesting_user': request.user}) if not params.is_valid(): raise ValidationError(params.errors) try: return Response( get_blocks( request, params.cleaned_data['usage_key'], params.cleaned_data['user'], params.cleaned_data['depth'], params.cleaned_data.get('nav_depth'), params.cleaned_data['requested_fields'], params.cleaned_data.get('block_counts', []), params.cleaned_data.get('student_view_data', []), params.cleaned_data['return_type'] ) ) except ItemNotFoundError as exception: raise Http404("Block not found: {}".format(exception.message)) @view_auth_classes() class BlocksInCourseView(BlocksView): """ **Use Case** Returns the blocks in the course according to the requesting user's access level. **Example requests**: GET /api/courses/v1/blocks/?course_id=<course_id> GET /api/courses/v1/blocks/?course_id=<course_id> &username=anjali &depth=all &requested_fields=graded,format,student_view_multi_device &block_counts=video &student_view_data=video **Parameters**: This view redirects to /api/courses/v1/blocks/<root_usage_key>/ for the root usage key of the course specified by course_id. The view accepts all parameters accepted by :class:`BlocksView`, plus the following required parameter * course_id: (string, required) The ID of the course whose block data we want to return **Response Values** Responses are identical to those returned by :class:`BlocksView` when passed the root_usage_key of the requested course. If the course_id is not supplied, a 400: Bad Request is returned, with a message indicating that course_id is required. If an invalid course_id is supplied, a 400: Bad Request is returned, with a message indicating that the course_id is not valid. """ def list(self, request): # pylint: disable=arguments-differ """ Retrieves the usage_key for the requested course, and then returns the same information that would be returned by BlocksView.list, called with that usage key Arguments: request - Django request object """ # convert the requested course_key to the course's root block's usage_key course_key_string = request.query_params.get('course_id', None) if not course_key_string: raise ValidationError('course_id is required.') try: course_key = CourseKey.from_string(course_key_string) course_usage_key = modulestore().make_course_usage_key(course_key) except InvalidKeyError: raise ValidationError("'{}' is not a valid course key.".format(unicode(course_key_string))) return super(BlocksInCourseView, self).list(request, course_usage_key)
agpl-3.0
[ 624, 199, 6979, 24996, 3261, 6858, 199, 624, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 4618, 63, 4857, 14, 2038, 2932, 492, 3820, 25778, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 199, 504, 15058, 63, 1612, 492, 6378, 10230, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 22709, 14, 1018, 14, 773, 14, 1246, 14, 1345, 63, 1208, 492, 2455, 63, 1178, 63, 2888, 12, 9607, 547, 2768, 4256, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 14, 3924, 492, 7020, 10870, 199, 199, 504, 1275, 1246, 492, 664, 63, 4166, 199, 504, 1275, 3351, 492, 8651, 1296, 1002, 2821, 421, 199, 32, 1345, 63, 1178, 63, 2888, 342, 199, 533, 8651, 83, 2768, 8, 31032, 547, 2768, 4256, 12, 3820, 25778, 304, 272, 408, 272, 1011, 6119, 12425, 538, 398, 1803, 314, 5664, 4453, 314, 5839, 1853, 3123, 7182, 370, 314, 267, 23502, 922, 1159, 2879, 2166, 14, 339, 1011, 9846, 4145, 26742, 398, 9576, 1182, 1246, 15, 11653, 15, 86, 17, 15, 4166, 8316, 1231, 63, 1457, 63, 3807, 63, 344, 30, 10197, 4631, 29, 452, 267, 9576, 1182, 1246, 15, 11653, 15, 86, 17, 15, 4166, 8316, 3807, 63, 344, 30, 10197, 288, 3434, 29, 290, 74, 10874, 288, 1253, 4631, 29, 452, 288, 1253, 11151, 63, 955, 29, 13688, 12, 908, 12, 5500, 63, 1345, 63, 3029, 63, 1782, 288, 1253, 1457, 63, 6851, 29, 3722, 288, 1253, 5500, 63, 1345, 63, 576, 29, 3722, 339, 1011, 5976, 26742, 398, 627, 3434, 26, 334, 875, 9, 710, 536, 402, 314, 922, 641, 7447, 506, 10220, 781, 2934, 370, 881, 1937, 314, 666, 14, 8592, 5679, 26, 3434, 29, 290, 74, 10874, 398, 627, 6474, 63, 1345, 63, 576, 26, 334, 513, 9, 19334, 367, 1314, 1853, 2943, 370, 372, 881, 6474, 63, 1345, 63, 576, 14, 8592, 5679, 26, 6474, 63, 1345, 63, 576, 29, 3722, 398, 627, 1853, 63, 6851, 26, 334, 513, 9, 19334, 367, 1314, 1853, 2943, 370, 372, 314, 881, 9531, 2338, 402, 314, 5664, 14, 8592, 5679, 26, 1853, 63, 6851, 29, 3722, 12, 6462, 398, 627, 5839, 63, 955, 26, 334, 513, 9, 19334, 1314, 4722, 1504, 370, 372, 881, 367, 1924, 1853, 14, 221, 2104, 282, 769, 402, 2808, 1504, 1937, 1334, 658, 2364, 881, 13468, 1035, 5664, 3559, 5084, 14, 8592, 710, 2569, 1504, 787, 3544, 2138, 26, 1305, 12, 730, 12, 2929, 63, 354, 8592, 5679, 26, 5839, 63, 955, 29, 13688, 12, 908, 12, 5500, 63, 1345, 63, 3029, 63, 1782, 398, 627, 5818, 26, 334, 4115, 503, 1006, 9, 19334, 4212, 13217, 370, 24749, 1901, 314, 5664, 881, 14446, 14, 221, 437, 574, 402, 1006, 4910, 314, 8039, 14446, 14, 8592, 3758, 365, 378, 8592, 5679, 26, 5818, 29, 452, 398, 627, 16681, 63, 4631, 26, 334, 4115, 9, 8592, 14750, 26, 16681, 63, 4631, 365, 440, 3748, 12, 436, 1443, 506, 4829, 737, 1263, 900, 14, 8592, 19334, 4212, 12474, 13217, 370, 24749, 1901, 314, 881, 2518, 14446, 2544, 330, 725, 2983, 1006, 314, 26061, 14, 8592, 3758, 365, 650, 3967, 25780, 19191, 279, 6858, 402, 314, 2518, 2498, 282, 881, 5696, 402, 17044, 5118, 16211, 5118, 7870, 14, 8592, 5679, 26, 16681, 63, 4631, 29, 19, 398, 627, 372, 63, 466, 334, 875, 9, 19334, 315, 4052, 666, 730, 370, 372, 314, 881, 5664, 14, 8592, 3758, 365, 1211, 14, 26167, 1338, 787, 26, 1211, 12, 769, 8592, 5679, 26, 372, 63, 466, 29, 807, 339, 1011, 2364, 13468, 538, 398, 710, 2569, 1504, 787, 2138, 543, 282, 9512, 1177, 14, 398, 627, 1738, 26, 710, 2870, 402, 314, 1738, 1031, 402, 314, 2518, 5664, 14, 398, 627, 5664, 26, 437, 2600, 626, 9033, 1853, 4503, 11449, 370, 282, 3245, 402, 881, 2556, 3595, 1924, 1853, 14, 221, 7048, 1853, 3509, 314, 2569, 881, 1504, 14, 8592, 627, 1305, 26, 334, 875, 9, 710, 4503, 2870, 402, 314, 1853, 14, 8592, 627, 730, 26, 334, 875, 9, 710, 730, 402, 1853, 14, 18558, 1338, 2387, 2518, 12, 288, 17044, 12, 23381, 12, 13763, 12, 3517, 12, 5160, 12, 3991, 12, 436, 288, 16582, 14, 710, 730, 883, 2597, 506, 314, 536, 402, 282, 3537, 730, 402, 1853, 288, 1202, 367, 314, 2518, 14, 8592, 627, 2929, 63, 354, 26, 334, 875, 9, 710, 2929, 536, 402, 314, 1853, 14, 8592, 627, 4978, 26, 334, 513, 9, 982, 314, 1853, 965, 1982, 5664, 12, 282, 769, 402, 11449, 402, 288, 314, 1982, 5664, 14, 221, 19907, 1454, 340, 298, 3223, 2, 365, 5120, 315, 314, 288, 298, 11151, 63, 955, 2, 2725, 14, 8592, 627, 1853, 63, 6851, 26, 334, 807, 9, 2104, 1924, 1853, 730, 2013, 315, 314, 288, 1853, 63, 6851, 2725, 370, 314, 6037, 12, 314, 9531, 1329, 402, 288, 5664, 402, 626, 730, 367, 642, 1853, 436, 1006, 402, 2399, 26061, 14, 288, 19907, 1454, 340, 314, 298, 1457, 63, 6851, 2, 1324, 2725, 3509, 642, 288, 1853, 1159, 730, 14, 8592, 627, 1999, 770, 334, 4871, 9, 7480, 503, 440, 314, 1853, 503, 1263, 402, 2399, 26061, 288, 365, 1999, 770, 14, 221, 19907, 1454, 340, 298, 13688, 2, 365, 5120, 315, 314, 288, 298, 11151, 63, 955, 2, 2725, 14, 8592, 627, 1475, 26, 334, 875, 9, 710, 9801, 730, 402, 314, 1853, 14, 221, 18558, 1338, 288, 883, 506, 298, 12054, 800, 401, 298, 22511, 401, 298, 28735, 5125, 1316, 455, 401, 436, 298, 12776, 1316, 455, 1674, 288, 19907, 1454, 340, 298, 908, 2, 365, 5120, 315, 314, 298, 11151, 63, 955, 2, 288, 2725, 14, 8592, 627, 6474, 63, 1345, 63, 576, 26, 334, 807, 9, 710, 4840, 666, 367, 642, 1853, 14, 288, 19907, 1454, 340, 314, 298, 5500, 63, 1345, 63, 576, 2, 1324, 2725, 3509, 288, 642, 1853, 1159, 730, 14, 8592, 627, 6474, 63, 1345, 63, 633, 26, 334, 875, 9, 710, 2851, 370, 8044, 314, 4163, 14066, 288, 402, 642, 1853, 1159, 6474, 2455, 14, 221, 710, 4163, 4293, 2387, 15750, 436, 288, 31861, 1233, 14, 961, 901 ]
[ 199, 6979, 24996, 3261, 6858, 199, 624, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 4618, 63, 4857, 14, 2038, 2932, 492, 3820, 25778, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 199, 504, 15058, 63, 1612, 492, 6378, 10230, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 22709, 14, 1018, 14, 773, 14, 1246, 14, 1345, 63, 1208, 492, 2455, 63, 1178, 63, 2888, 12, 9607, 547, 2768, 4256, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 14, 3924, 492, 7020, 10870, 199, 199, 504, 1275, 1246, 492, 664, 63, 4166, 199, 504, 1275, 3351, 492, 8651, 1296, 1002, 2821, 421, 199, 32, 1345, 63, 1178, 63, 2888, 342, 199, 533, 8651, 83, 2768, 8, 31032, 547, 2768, 4256, 12, 3820, 25778, 304, 272, 408, 272, 1011, 6119, 12425, 538, 398, 1803, 314, 5664, 4453, 314, 5839, 1853, 3123, 7182, 370, 314, 267, 23502, 922, 1159, 2879, 2166, 14, 339, 1011, 9846, 4145, 26742, 398, 9576, 1182, 1246, 15, 11653, 15, 86, 17, 15, 4166, 8316, 1231, 63, 1457, 63, 3807, 63, 344, 30, 10197, 4631, 29, 452, 267, 9576, 1182, 1246, 15, 11653, 15, 86, 17, 15, 4166, 8316, 3807, 63, 344, 30, 10197, 288, 3434, 29, 290, 74, 10874, 288, 1253, 4631, 29, 452, 288, 1253, 11151, 63, 955, 29, 13688, 12, 908, 12, 5500, 63, 1345, 63, 3029, 63, 1782, 288, 1253, 1457, 63, 6851, 29, 3722, 288, 1253, 5500, 63, 1345, 63, 576, 29, 3722, 339, 1011, 5976, 26742, 398, 627, 3434, 26, 334, 875, 9, 710, 536, 402, 314, 922, 641, 7447, 506, 10220, 781, 2934, 370, 881, 1937, 314, 666, 14, 8592, 5679, 26, 3434, 29, 290, 74, 10874, 398, 627, 6474, 63, 1345, 63, 576, 26, 334, 513, 9, 19334, 367, 1314, 1853, 2943, 370, 372, 881, 6474, 63, 1345, 63, 576, 14, 8592, 5679, 26, 6474, 63, 1345, 63, 576, 29, 3722, 398, 627, 1853, 63, 6851, 26, 334, 513, 9, 19334, 367, 1314, 1853, 2943, 370, 372, 314, 881, 9531, 2338, 402, 314, 5664, 14, 8592, 5679, 26, 1853, 63, 6851, 29, 3722, 12, 6462, 398, 627, 5839, 63, 955, 26, 334, 513, 9, 19334, 1314, 4722, 1504, 370, 372, 881, 367, 1924, 1853, 14, 221, 2104, 282, 769, 402, 2808, 1504, 1937, 1334, 658, 2364, 881, 13468, 1035, 5664, 3559, 5084, 14, 8592, 710, 2569, 1504, 787, 3544, 2138, 26, 1305, 12, 730, 12, 2929, 63, 354, 8592, 5679, 26, 5839, 63, 955, 29, 13688, 12, 908, 12, 5500, 63, 1345, 63, 3029, 63, 1782, 398, 627, 5818, 26, 334, 4115, 503, 1006, 9, 19334, 4212, 13217, 370, 24749, 1901, 314, 5664, 881, 14446, 14, 221, 437, 574, 402, 1006, 4910, 314, 8039, 14446, 14, 8592, 3758, 365, 378, 8592, 5679, 26, 5818, 29, 452, 398, 627, 16681, 63, 4631, 26, 334, 4115, 9, 8592, 14750, 26, 16681, 63, 4631, 365, 440, 3748, 12, 436, 1443, 506, 4829, 737, 1263, 900, 14, 8592, 19334, 4212, 12474, 13217, 370, 24749, 1901, 314, 881, 2518, 14446, 2544, 330, 725, 2983, 1006, 314, 26061, 14, 8592, 3758, 365, 650, 3967, 25780, 19191, 279, 6858, 402, 314, 2518, 2498, 282, 881, 5696, 402, 17044, 5118, 16211, 5118, 7870, 14, 8592, 5679, 26, 16681, 63, 4631, 29, 19, 398, 627, 372, 63, 466, 334, 875, 9, 19334, 315, 4052, 666, 730, 370, 372, 314, 881, 5664, 14, 8592, 3758, 365, 1211, 14, 26167, 1338, 787, 26, 1211, 12, 769, 8592, 5679, 26, 372, 63, 466, 29, 807, 339, 1011, 2364, 13468, 538, 398, 710, 2569, 1504, 787, 2138, 543, 282, 9512, 1177, 14, 398, 627, 1738, 26, 710, 2870, 402, 314, 1738, 1031, 402, 314, 2518, 5664, 14, 398, 627, 5664, 26, 437, 2600, 626, 9033, 1853, 4503, 11449, 370, 282, 3245, 402, 881, 2556, 3595, 1924, 1853, 14, 221, 7048, 1853, 3509, 314, 2569, 881, 1504, 14, 8592, 627, 1305, 26, 334, 875, 9, 710, 4503, 2870, 402, 314, 1853, 14, 8592, 627, 730, 26, 334, 875, 9, 710, 730, 402, 1853, 14, 18558, 1338, 2387, 2518, 12, 288, 17044, 12, 23381, 12, 13763, 12, 3517, 12, 5160, 12, 3991, 12, 436, 288, 16582, 14, 710, 730, 883, 2597, 506, 314, 536, 402, 282, 3537, 730, 402, 1853, 288, 1202, 367, 314, 2518, 14, 8592, 627, 2929, 63, 354, 26, 334, 875, 9, 710, 2929, 536, 402, 314, 1853, 14, 8592, 627, 4978, 26, 334, 513, 9, 982, 314, 1853, 965, 1982, 5664, 12, 282, 769, 402, 11449, 402, 288, 314, 1982, 5664, 14, 221, 19907, 1454, 340, 298, 3223, 2, 365, 5120, 315, 314, 288, 298, 11151, 63, 955, 2, 2725, 14, 8592, 627, 1853, 63, 6851, 26, 334, 807, 9, 2104, 1924, 1853, 730, 2013, 315, 314, 288, 1853, 63, 6851, 2725, 370, 314, 6037, 12, 314, 9531, 1329, 402, 288, 5664, 402, 626, 730, 367, 642, 1853, 436, 1006, 402, 2399, 26061, 14, 288, 19907, 1454, 340, 314, 298, 1457, 63, 6851, 2, 1324, 2725, 3509, 642, 288, 1853, 1159, 730, 14, 8592, 627, 1999, 770, 334, 4871, 9, 7480, 503, 440, 314, 1853, 503, 1263, 402, 2399, 26061, 288, 365, 1999, 770, 14, 221, 19907, 1454, 340, 298, 13688, 2, 365, 5120, 315, 314, 288, 298, 11151, 63, 955, 2, 2725, 14, 8592, 627, 1475, 26, 334, 875, 9, 710, 9801, 730, 402, 314, 1853, 14, 221, 18558, 1338, 288, 883, 506, 298, 12054, 800, 401, 298, 22511, 401, 298, 28735, 5125, 1316, 455, 401, 436, 298, 12776, 1316, 455, 1674, 288, 19907, 1454, 340, 298, 908, 2, 365, 5120, 315, 314, 298, 11151, 63, 955, 2, 288, 2725, 14, 8592, 627, 6474, 63, 1345, 63, 576, 26, 334, 807, 9, 710, 4840, 666, 367, 642, 1853, 14, 288, 19907, 1454, 340, 314, 298, 5500, 63, 1345, 63, 576, 2, 1324, 2725, 3509, 288, 642, 1853, 1159, 730, 14, 8592, 627, 6474, 63, 1345, 63, 633, 26, 334, 875, 9, 710, 2851, 370, 8044, 314, 4163, 14066, 288, 402, 642, 1853, 1159, 6474, 2455, 14, 221, 710, 4163, 4293, 2387, 15750, 436, 288, 31861, 1233, 14, 961, 901, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jgcaaprom/android_external_chromium_org
third_party/closure_linter/closure_linter/scopeutil.py
84
5414
#!/usr/bin/env python # # Copyright 2012 The Closure Linter Authors. All Rights Reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tools to match goog.scope alias statements.""" # Allow non-Google copyright # pylint: disable=g-bad-file-header __author__ = ('nnaze@google.com (Nathan Naze)') import itertools from closure_linter import ecmametadatapass from closure_linter import tokenutil from closure_linter.javascripttokens import JavaScriptTokenType def IsGoogScopeBlock(context): """Whether the given context is a goog.scope block. This function only checks that the block is a function block inside a goog.scope() call. TODO(nnaze): Implement goog.scope checks that verify the call is in the root context and contains only a single function literal. Args: context: An EcmaContext of type block. Returns: Whether the context is a goog.scope block. """ if context.type != ecmametadatapass.EcmaContext.BLOCK: return False if not _IsFunctionLiteralBlock(context): return False # Check that this function is contained by a group # of form "goog.scope(...)". parent = context.parent if parent and parent.type is ecmametadatapass.EcmaContext.GROUP: last_code_token = parent.start_token.metadata.last_code if (last_code_token and last_code_token.type is JavaScriptTokenType.IDENTIFIER and last_code_token.string == 'goog.scope'): return True return False def _IsFunctionLiteralBlock(block_context): """Check if a context is a function literal block (without parameters). Example function literal block: 'function() {}' Args: block_context: An EcmaContext of type block. Returns: Whether this context is a function literal block. """ previous_code_tokens_iter = itertools.ifilter( lambda token: token not in JavaScriptTokenType.NON_CODE_TYPES, reversed(block_context.start_token)) # Ignore the current token next(previous_code_tokens_iter, None) # Grab the previous three tokens and put them in correct order. previous_code_tokens = list(itertools.islice(previous_code_tokens_iter, 3)) previous_code_tokens.reverse() # There aren't three previous tokens. if len(previous_code_tokens) is not 3: return False # Check that the previous three code tokens are "function ()" previous_code_token_types = [token.type for token in previous_code_tokens] if (previous_code_token_types == [ JavaScriptTokenType.FUNCTION_DECLARATION, JavaScriptTokenType.START_PARAMETERS, JavaScriptTokenType.END_PARAMETERS]): return True return False def IsInClosurizedNamespace(symbol, closurized_namespaces): """Match a goog.scope alias. Args: symbol: An identifier like 'goog.events.Event'. closurized_namespaces: Iterable of valid Closurized namespaces (strings). Returns: True if symbol is an identifier in a Closurized namespace, otherwise False. """ for ns in closurized_namespaces: if symbol.startswith(ns + '.'): return True return False def MatchAlias(context): """Match an alias statement (some identifier assigned to a variable). Example alias: var MyClass = proj.longNamespace.MyClass. Args: context: An EcmaContext of type EcmaContext.VAR. Returns: If a valid alias, returns a tuple of alias and symbol, otherwise None. """ if context.type != ecmametadatapass.EcmaContext.VAR: return # The var's parent is a STATEMENT, which should be directly below goog.scope. if not IsGoogScopeBlock(context.parent.parent): return # Get the tokens in this statement. if context.start_token and context.end_token: statement_tokens = tokenutil.GetTokenRange(context.start_token, context.end_token) else: return # And now just those tokens that are actually code. is_non_code_type = lambda t: t.type not in JavaScriptTokenType.NON_CODE_TYPES code_tokens = filter(is_non_code_type, statement_tokens) # This section identifies statements of the alias form "var alias = symbol". # Pop off the semicolon if present. if code_tokens and code_tokens[-1].IsType(JavaScriptTokenType.SEMICOLON): code_tokens.pop() if len(code_tokens) < 4: return # Verify that this is of the form "var lvalue = identifier;". # The identifier may span multiple lines and could be multiple tokens. if (code_tokens[0].IsKeyword('var') and code_tokens[1].IsType(JavaScriptTokenType.SIMPLE_LVALUE) and code_tokens[2].IsOperator('=') and all(t.IsType(JavaScriptTokenType.IDENTIFIER) for t in code_tokens[3:])): alias, symbol = code_tokens[1], code_tokens[3] # Mark both tokens as an alias definition to avoid counting them as usages. alias.metadata.is_alias_definition = True symbol.metadata.is_alias_definition = True return alias.string, tokenutil.GetIdentifierForToken(symbol)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 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, 13, 1311, 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, 11654, 370, 1336, 2621, 974, 14, 2645, 5162, 9834, 1041, 199, 199, 3, 9812, 2222, 13, 13266, 4248, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 493, 13, 1291, 199, 199, 363, 2502, 363, 275, 661, 78, 3540, 806, 32, 3098, 14, 957, 334, 46, 1619, 290, 11290, 806, 5942, 199, 199, 646, 7975, 199, 199, 504, 17903, 63, 25240, 492, 325, 4400, 313, 1732, 1529, 199, 504, 17903, 63, 25240, 492, 1526, 1974, 199, 504, 17903, 63, 25240, 14, 9554, 4504, 492, 15250, 3264, 804, 4388, 199, 318, 6596, 7250, 974, 7812, 3142, 8, 1100, 304, 523, 408, 26625, 314, 1627, 1067, 365, 282, 2621, 974, 14, 2645, 1853, 14, 819, 961, 805, 1454, 5920, 626, 314, 1853, 365, 282, 805, 1853, 6272, 523, 282, 2621, 974, 14, 2645, 342, 1240, 14, 819, 3254, 8, 78, 3540, 806, 304, 22467, 2621, 974, 14, 2645, 5920, 626, 4911, 314, 1240, 365, 523, 315, 314, 1738, 1067, 436, 3509, 1454, 282, 2849, 805, 8785, 14, 819, 3033, 26, 272, 1067, 26, 1626, 662, 67, 391, 2998, 402, 730, 1853, 14, 819, 1803, 26, 272, 7480, 314, 1067, 365, 282, 2621, 974, 14, 2645, 1853, 14, 523, 408, 819, 340, 1067, 14, 466, 1137, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 8475, 26, 272, 372, 756, 819, 340, 440, 485, 1831, 3481, 7621, 3142, 8, 1100, 304, 272, 372, 756, 819, 327, 2670, 626, 642, 805, 365, 10470, 701, 282, 1572, 523, 327, 402, 1824, 298, 28069, 14, 2645, 20186, 1674, 523, 1676, 275, 1067, 14, 1708, 523, 340, 1676, 436, 1676, 14, 466, 365, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 7823, 26, 339, 2061, 63, 600, 63, 1418, 275, 1676, 14, 928, 63, 1418, 14, 2343, 14, 2019, 63, 600, 339, 340, 334, 2019, 63, 600, 63, 1418, 436, 267, 2061, 63, 600, 63, 1418, 14, 466, 365, 15250, 3264, 804, 14, 22698, 436, 267, 2061, 63, 600, 63, 1418, 14, 875, 508, 283, 28069, 14, 2645, 735, 489, 372, 715, 819, 372, 756, 421, 199, 318, 485, 1831, 3481, 7621, 3142, 8, 1457, 63, 1100, 304, 523, 408, 1799, 340, 282, 1067, 365, 282, 805, 8785, 1853, 334, 7395, 2633, 680, 819, 5679, 805, 8785, 1853, 26, 283, 1593, 342, 1052, 7, 819, 3033, 26, 272, 1853, 63, 1100, 26, 1626, 662, 67, 391, 2998, 402, 730, 1853, 14, 819, 1803, 26, 272, 7480, 642, 1067, 365, 282, 805, 8785, 1853, 14, 523, 408, 819, 4136, 63, 600, 63, 4504, 63, 1661, 275, 7975, 14, 73, 1541, 8, 489, 2400, 1526, 26, 1526, 440, 315, 15250, 3264, 804, 14, 13887, 63, 6012, 63, 7893, 12, 489, 10822, 8, 1457, 63, 1100, 14, 928, 63, 1418, 430, 819, 327, 14092, 314, 1453, 1526, 523, 2163, 8, 6352, 63, 600, 63, 4504, 63, 1661, 12, 488, 9, 819, 327, 29225, 314, 4136, 7795, 4645, 436, 5324, 3062, 315, 3211, 1865, 14, 523, 4136, 63, 600, 63, 4504, 275, 769, 8, 17691, 14, 374, 3037, 8, 6352, 63, 600, 63, 4504, 63, 1661, 12, 650, 430, 523, 4136, 63, 600, 63, 4504, 14, 4471, 342, 819, 327, 6006, 10621, 1133, 7795, 4136, 4645, 14, 523, 340, 822, 8, 6352, 63, 600, 63, 4504, 9, 365, 440, 650, 26, 272, 372, 756, 819, 327, 2670, 626, 314, 4136, 7795, 1233, 4645, 787, 298, 1593, 334, 2924, 523, 4136, 63, 600, 63, 1418, 63, 1313, 275, 359, 1418, 14, 466, 367, 1526, 315, 4136, 63, 600, 63, 4504, 61, 523, 340, 334, 6352, 63, 600, 63, 1418, 63, 1313, 508, 359, 489, 15250, 3264, 804, 14, 15476, 63, 27402, 689, 2594, 12, 489, 15250, 3264, 804, 14, 7363, 63, 24014, 12, 489, 15250, 3264, 804, 14, 3902, 63, 24014, 4682, 272, 372, 715, 819, 372, 756, 421, 199, 318, 6596, 607, 3337, 5105, 1759, 8814, 8, 5155, 12, 2463, 5105, 1759, 63, 9247, 304, 523, 408, 4486, 282, 2621, 974, 14, 2645, 5162, 14, 819, 3033, 26, 272, 5272, 26, 1626, 5148, 2839, 283, 28069, 14, 4368, 14, 2390, 1370, 272, 2463, 5105, 1759, 63, 9247, 26, 19937, 402, 1686, 5980, 5105, 1759, 10747, 334, 5465, 680, 819, 1803, 26, 272, 715, 340, 5272, 365, 376, 5148, 315, 282, 5980, 5105, 1759, 3231, 12, 4257, 756, 14, 523, 408, 523, 367, 700, 315, 2463, 5105, 1759, 63, 9247, 26, 272, 340, 5272, 14, 2460, 8, 561, 435, 1987, 735, 489, 372, 715, 819, 372, 756, 421, 199, 318, 9814, 14149, 8, 1100, 304, 523, 408, 4486, 376, 5162, 5164, 334, 3972, 5148, 7943, 370, 282, 1750, 680, 819, 5679, 5162, 26, 2729, 4932, 2543, 275, 13523, 14, 2809, 8814, 14, 5713, 2543, 14, 819, 3033, 26, 272, 1067, 26, 1626, 662, 67, 391, 2998, 402, 730, 662, 67, 391, 2998, 14, 5568, 14, 819, 1803, 26, 272, 982, 282, 1686, 5162, 12, 2529, 282, 2008, 402, 5162, 436, 5272, 12, 4257, 488, 14, 523, 408, 523, 340, 1067, 14, 466, 1137, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 5568, 26, 272, 372, 819, 327, 710, 2729, 1159, 1676, 365, 282, 11377, 4479, 12, 1314, 1077, 506, 5370, 5084, 2621, 974, 14, 2645, 14, 523, 340, 440, 6596, 7250, 974, 7812 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 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, 13, 1311, 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, 11654, 370, 1336, 2621, 974, 14, 2645, 5162, 9834, 1041, 199, 199, 3, 9812, 2222, 13, 13266, 4248, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 493, 13, 1291, 199, 199, 363, 2502, 363, 275, 661, 78, 3540, 806, 32, 3098, 14, 957, 334, 46, 1619, 290, 11290, 806, 5942, 199, 199, 646, 7975, 199, 199, 504, 17903, 63, 25240, 492, 325, 4400, 313, 1732, 1529, 199, 504, 17903, 63, 25240, 492, 1526, 1974, 199, 504, 17903, 63, 25240, 14, 9554, 4504, 492, 15250, 3264, 804, 4388, 199, 318, 6596, 7250, 974, 7812, 3142, 8, 1100, 304, 523, 408, 26625, 314, 1627, 1067, 365, 282, 2621, 974, 14, 2645, 1853, 14, 819, 961, 805, 1454, 5920, 626, 314, 1853, 365, 282, 805, 1853, 6272, 523, 282, 2621, 974, 14, 2645, 342, 1240, 14, 819, 3254, 8, 78, 3540, 806, 304, 22467, 2621, 974, 14, 2645, 5920, 626, 4911, 314, 1240, 365, 523, 315, 314, 1738, 1067, 436, 3509, 1454, 282, 2849, 805, 8785, 14, 819, 3033, 26, 272, 1067, 26, 1626, 662, 67, 391, 2998, 402, 730, 1853, 14, 819, 1803, 26, 272, 7480, 314, 1067, 365, 282, 2621, 974, 14, 2645, 1853, 14, 523, 408, 819, 340, 1067, 14, 466, 1137, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 8475, 26, 272, 372, 756, 819, 340, 440, 485, 1831, 3481, 7621, 3142, 8, 1100, 304, 272, 372, 756, 819, 327, 2670, 626, 642, 805, 365, 10470, 701, 282, 1572, 523, 327, 402, 1824, 298, 28069, 14, 2645, 20186, 1674, 523, 1676, 275, 1067, 14, 1708, 523, 340, 1676, 436, 1676, 14, 466, 365, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 7823, 26, 339, 2061, 63, 600, 63, 1418, 275, 1676, 14, 928, 63, 1418, 14, 2343, 14, 2019, 63, 600, 339, 340, 334, 2019, 63, 600, 63, 1418, 436, 267, 2061, 63, 600, 63, 1418, 14, 466, 365, 15250, 3264, 804, 14, 22698, 436, 267, 2061, 63, 600, 63, 1418, 14, 875, 508, 283, 28069, 14, 2645, 735, 489, 372, 715, 819, 372, 756, 421, 199, 318, 485, 1831, 3481, 7621, 3142, 8, 1457, 63, 1100, 304, 523, 408, 1799, 340, 282, 1067, 365, 282, 805, 8785, 1853, 334, 7395, 2633, 680, 819, 5679, 805, 8785, 1853, 26, 283, 1593, 342, 1052, 7, 819, 3033, 26, 272, 1853, 63, 1100, 26, 1626, 662, 67, 391, 2998, 402, 730, 1853, 14, 819, 1803, 26, 272, 7480, 642, 1067, 365, 282, 805, 8785, 1853, 14, 523, 408, 819, 4136, 63, 600, 63, 4504, 63, 1661, 275, 7975, 14, 73, 1541, 8, 489, 2400, 1526, 26, 1526, 440, 315, 15250, 3264, 804, 14, 13887, 63, 6012, 63, 7893, 12, 489, 10822, 8, 1457, 63, 1100, 14, 928, 63, 1418, 430, 819, 327, 14092, 314, 1453, 1526, 523, 2163, 8, 6352, 63, 600, 63, 4504, 63, 1661, 12, 488, 9, 819, 327, 29225, 314, 4136, 7795, 4645, 436, 5324, 3062, 315, 3211, 1865, 14, 523, 4136, 63, 600, 63, 4504, 275, 769, 8, 17691, 14, 374, 3037, 8, 6352, 63, 600, 63, 4504, 63, 1661, 12, 650, 430, 523, 4136, 63, 600, 63, 4504, 14, 4471, 342, 819, 327, 6006, 10621, 1133, 7795, 4136, 4645, 14, 523, 340, 822, 8, 6352, 63, 600, 63, 4504, 9, 365, 440, 650, 26, 272, 372, 756, 819, 327, 2670, 626, 314, 4136, 7795, 1233, 4645, 787, 298, 1593, 334, 2924, 523, 4136, 63, 600, 63, 1418, 63, 1313, 275, 359, 1418, 14, 466, 367, 1526, 315, 4136, 63, 600, 63, 4504, 61, 523, 340, 334, 6352, 63, 600, 63, 1418, 63, 1313, 508, 359, 489, 15250, 3264, 804, 14, 15476, 63, 27402, 689, 2594, 12, 489, 15250, 3264, 804, 14, 7363, 63, 24014, 12, 489, 15250, 3264, 804, 14, 3902, 63, 24014, 4682, 272, 372, 715, 819, 372, 756, 421, 199, 318, 6596, 607, 3337, 5105, 1759, 8814, 8, 5155, 12, 2463, 5105, 1759, 63, 9247, 304, 523, 408, 4486, 282, 2621, 974, 14, 2645, 5162, 14, 819, 3033, 26, 272, 5272, 26, 1626, 5148, 2839, 283, 28069, 14, 4368, 14, 2390, 1370, 272, 2463, 5105, 1759, 63, 9247, 26, 19937, 402, 1686, 5980, 5105, 1759, 10747, 334, 5465, 680, 819, 1803, 26, 272, 715, 340, 5272, 365, 376, 5148, 315, 282, 5980, 5105, 1759, 3231, 12, 4257, 756, 14, 523, 408, 523, 367, 700, 315, 2463, 5105, 1759, 63, 9247, 26, 272, 340, 5272, 14, 2460, 8, 561, 435, 1987, 735, 489, 372, 715, 819, 372, 756, 421, 199, 318, 9814, 14149, 8, 1100, 304, 523, 408, 4486, 376, 5162, 5164, 334, 3972, 5148, 7943, 370, 282, 1750, 680, 819, 5679, 5162, 26, 2729, 4932, 2543, 275, 13523, 14, 2809, 8814, 14, 5713, 2543, 14, 819, 3033, 26, 272, 1067, 26, 1626, 662, 67, 391, 2998, 402, 730, 662, 67, 391, 2998, 14, 5568, 14, 819, 1803, 26, 272, 982, 282, 1686, 5162, 12, 2529, 282, 2008, 402, 5162, 436, 5272, 12, 4257, 488, 14, 523, 408, 523, 340, 1067, 14, 466, 1137, 325, 4400, 313, 1732, 1529, 14, 30478, 391, 2998, 14, 5568, 26, 272, 372, 819, 327, 710, 2729, 1159, 1676, 365, 282, 11377, 4479, 12, 1314, 1077, 506, 5370, 5084, 2621, 974, 14, 2645, 14, 523, 340, 440, 6596, 7250, 974, 7812, 0 ]
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1 ]
myfluxi/xxICSKernel
scripts/tracing/draw_functrace.py
14676
3560
#!/usr/bin/python """ Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com> Licensed under the terms of the GNU GPL License version 2 This script parses a trace provided by the function tracer in kernel/trace/trace_functions.c The resulted trace is processed into a tree to produce a more human view of the call stack by drawing textual but hierarchical tree of calls. Only the functions's names and the the call time are provided. Usage: Be sure that you have CONFIG_FUNCTION_TRACER # mount -t debugfs nodev /sys/kernel/debug # echo function > /sys/kernel/debug/tracing/current_tracer $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func Wait some times but not too much, the script is a bit slow. Break the pipe (Ctrl + Z) $ scripts/draw_functrace.py < raw_trace_func > draw_functrace Then you have your drawn trace in draw_functrace """ import sys, re class CallTree: """ This class provides a tree representation of the functions call stack. If a function has no parent in the kernel (interrupt, syscall, kernel thread...) then it is attached to a virtual parent called ROOT. """ ROOT = None def __init__(self, func, time = None, parent = None): self._func = func self._time = time if parent is None: self._parent = CallTree.ROOT else: self._parent = parent self._children = [] def calls(self, func, calltime): """ If a function calls another one, call this method to insert it into the tree at the appropriate place. @return: A reference to the newly created child node. """ child = CallTree(func, calltime, self) self._children.append(child) return child def getParent(self, func): """ Retrieve the last parent of the current node that has the name given by func. If this function is not on a parent, then create it as new child of root @return: A reference to the parent. """ tree = self while tree != CallTree.ROOT and tree._func != func: tree = tree._parent if tree == CallTree.ROOT: child = CallTree.ROOT.calls(func, None) return child return tree def __repr__(self): return self.__toString("", True) def __toString(self, branch, lastChild): if self._time is not None: s = "%s----%s (%s)\n" % (branch, self._func, self._time) else: s = "%s----%s\n" % (branch, self._func) i = 0 if lastChild: branch = branch[:-1] + " " while i < len(self._children): if i != len(self._children) - 1: s += "%s" % self._children[i].__toString(branch +\ " |", False) else: s += "%s" % self._children[i].__toString(branch +\ " |", True) i += 1 return s class BrokenLineException(Exception): """If the last line is not complete because of the pipe breakage, we want to stop the processing and ignore this line. """ pass class CommentLineException(Exception): """ If the line is a comment (as in the beginning of the trace file), just ignore it. """ pass def parseLine(line): line = line.strip() if line.startswith("#"): raise CommentLineException m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line) if m is None: raise BrokenLineException return (m.group(1), m.group(2), m.group(3)) def main(): CallTree.ROOT = CallTree("Root (Nowhere)", None, None) tree = CallTree.ROOT for line in sys.stdin: try: calltime, callee, caller = parseLine(line) except BrokenLineException: break except CommentLineException: continue tree = tree.getParent(caller) tree = tree.calls(callee, calltime) print CallTree.ROOT if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1,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35
71412
from __future__ import division, absolute_import, print_function import sys import os import re import itertools import warnings import weakref from operator import itemgetter import numpy as np from . import format from ._datasource import DataSource from numpy.core.multiarray import packbits, unpackbits from ._iotools import ( LineSplitter, NameValidator, StringConverter, ConverterError, ConverterLockError, ConversionWarning, _is_string_like, has_nested_fields, flatten_dtype, easy_dtype, _bytes_to_name ) from numpy.compat import ( asbytes, asstr, asbytes_nested, bytes, basestring, unicode ) if sys.version_info[0] >= 3: import pickle else: import cPickle as pickle from future_builtins import map loads = pickle.loads __all__ = [ 'savetxt', 'loadtxt', 'genfromtxt', 'ndfromtxt', 'mafromtxt', 'recfromtxt', 'recfromcsv', 'load', 'loads', 'save', 'savez', 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource' ] class BagObj(object): """ BagObj(obj) Convert attribute look-ups to getitems on the object passed in. Parameters ---------- obj : class instance Object on which attribute look-up is performed. Examples -------- >>> from numpy.lib.npyio import BagObj as BO >>> class BagDemo(object): ... def __getitem__(self, key): # An instance of BagObj(BagDemo) ... # will call this method when any ... # attribute look-up is required ... result = "Doesn't matter what you want, " ... return result + "you're gonna get this" ... >>> demo_obj = BagDemo() >>> bagobj = BO(demo_obj) >>> bagobj.hello_there "Doesn't matter what you want, you're gonna get this" >>> bagobj.I_can_be_anything "Doesn't matter what you want, you're gonna get this" """ def __init__(self, obj): # Use weakref to make NpzFile objects collectable by refcount self._obj = weakref.proxy(obj) def __getattribute__(self, key): try: return object.__getattribute__(self, '_obj')[key] except KeyError: raise AttributeError(key) def __dir__(self): """ Enables dir(bagobj) to list the files in an NpzFile. This also enables tab-completion in an interpreter or IPython. """ return object.__getattribute__(self, '_obj').keys() def zipfile_factory(*args, **kwargs): import zipfile kwargs['allowZip64'] = True return zipfile.ZipFile(*args, **kwargs) class NpzFile(object): """ NpzFile(fid) A dictionary-like object with lazy-loading of files in the zipped archive provided on construction. `NpzFile` is used to load files in the NumPy ``.npz`` data archive format. It assumes that files in the archive have a ``.npy`` extension, other files are ignored. The arrays and file strings are lazily loaded on either getitem access using ``obj['key']`` or attribute lookup using ``obj.f.key``. A list of all files (without ``.npy`` extensions) can be obtained with ``obj.files`` and the ZipFile object itself using ``obj.zip``. Attributes ---------- files : list of str List of all files in the archive with a ``.npy`` extension. zip : ZipFile instance The ZipFile object initialized with the zipped archive. f : BagObj instance An object on which attribute can be performed as an alternative to getitem access on the `NpzFile` instance itself. allow_pickle : bool, optional Allow loading pickled data. Default: True pickle_kwargs : dict, optional Additional keyword arguments to pass on to pickle.load. These are only useful when loading object arrays saved on Python 2 when using Python 3. Parameters ---------- fid : file or str The zipped archive to open. This is either a file-like object or a string containing the path to the archive. own_fid : bool, optional Whether NpzFile should close the file handle. Requires that `fid` is a file-like object. Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> y = np.sin(x) >>> np.savez(outfile, x=x, y=y) >>> outfile.seek(0) >>> npz = np.load(outfile) >>> isinstance(npz, np.lib.io.NpzFile) True >>> npz.files ['y', 'x'] >>> npz['x'] # getitem access array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> npz.f.x # attribute lookup array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) """ def __init__(self, fid, own_fid=False, allow_pickle=True, pickle_kwargs=None): # Import is postponed to here since zipfile depends on gzip, an # optional component of the so-called standard library. _zip = zipfile_factory(fid) self._files = _zip.namelist() self.files = [] self.allow_pickle = allow_pickle self.pickle_kwargs = pickle_kwargs for x in self._files: if x.endswith('.npy'): self.files.append(x[:-4]) else: self.files.append(x) self.zip = _zip self.f = BagObj(self) if own_fid: self.fid = fid else: self.fid = None def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() def close(self): """ Close the file. """ if self.zip is not None: self.zip.close() self.zip = None if self.fid is not None: self.fid.close() self.fid = None self.f = None # break reference cycle def __del__(self): self.close() def __getitem__(self, key): # FIXME: This seems like it will copy strings around # more than is strictly necessary. The zipfile # will read the string and then # the format.read_array will copy the string # to another place in memory. # It would be better if the zipfile could read # (or at least uncompress) the data # directly into the array memory. member = 0 if key in self._files: member = 1 elif key in self.files: member = 1 key += '.npy' if member: bytes = self.zip.open(key) magic = bytes.read(len(format.MAGIC_PREFIX)) bytes.close() if magic == format.MAGIC_PREFIX: bytes = self.zip.open(key) return format.read_array(bytes, allow_pickle=self.allow_pickle, pickle_kwargs=self.pickle_kwargs) else: return self.zip.read(key) else: raise KeyError("%s is not a file in the archive" % key) def __iter__(self): return iter(self.files) def items(self): """ Return a list of tuples, with each tuple (filename, array in file). """ return [(f, self[f]) for f in self.files] def iteritems(self): """Generator that returns tuples (filename, array in file).""" for f in self.files: yield (f, self[f]) def keys(self): """Return files in the archive with a ``.npy`` extension.""" return self.files def iterkeys(self): """Return an iterator over the files in the archive.""" return self.__iter__() def __contains__(self, key): return self.files.__contains__(key) def load(file, mmap_mode=None, allow_pickle=True, fix_imports=True, encoding='ASCII'): """ Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files. Parameters ---------- file : file-like object or string The file to read. File-like objects must support the ``seek()`` and ``read()`` methods. Pickled files require that the file-like object support the ``readline()`` method as well. mmap_mode : {None, 'r+', 'r', 'w+', 'c'}, optional If not None, then memory-map the file, using the given mode (see `numpy.memmap` for a detailed description of the modes). A memory-mapped array is kept on disk. However, it can be accessed and sliced like any ndarray. Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory. allow_pickle : bool, optional Allow loading pickled object arrays stored in npy files. Reasons for disallowing pickles include security, as loading pickled data can execute arbitrary code. If pickles are disallowed, loading object arrays will fail. Default: True fix_imports : bool, optional Only useful when loading Python 2 generated pickled files on Python 3, which includes npy/npz files containing object arrays. If `fix_imports` is True, pickle will try to map the old Python 2 names to the new names used in Python 3. encoding : str, optional What encoding to use when reading Python 2 strings. Only useful when loading Python 2 generated pickled files on Python 3, which includes npy/npz files containing object arrays. Values other than 'latin1', 'ASCII', and 'bytes' are not allowed, as they can corrupt numerical data. Default: 'ASCII' Returns ------- result : array, tuple, dict, etc. Data stored in the file. For ``.npz`` files, the returned instance of NpzFile class must be closed to avoid leaking file descriptors. Raises ------ IOError If the input file does not exist or cannot be read. ValueError The file contains an object array, but allow_pickle=False given. See Also -------- save, savez, savez_compressed, loadtxt memmap : Create a memory-map to an array stored in a file on disk. Notes ----- - If the file contains pickle data, then whatever object is stored in the pickle is returned. - If the file is a ``.npy`` file, then a single array is returned. - If the file is a ``.npz`` file, then a dictionary-like object is returned, containing ``{filename: array}`` key-value pairs, one for each file in the archive. - If the file is a ``.npz`` file, the returned value supports the context manager protocol in a similar fashion to the open function:: with load('foo.npz') as data: a = data['a'] The underlying file descriptor is closed when exiting the 'with' block. Examples -------- Store data to disk, and load it again: >>> np.save('/tmp/123', np.array([[1, 2, 3], [4, 5, 6]])) >>> np.load('/tmp/123.npy') array([[1, 2, 3], [4, 5, 6]]) Store compressed data to disk, and load it again: >>> a=np.array([[1, 2, 3], [4, 5, 6]]) >>> b=np.array([1, 2]) >>> np.savez('/tmp/123.npz', a=a, b=b) >>> data = np.load('/tmp/123.npz') >>> data['a'] array([[1, 2, 3], [4, 5, 6]]) >>> data['b'] array([1, 2]) >>> data.close() Mem-map the stored array, and then access the second row directly from disk: >>> X = np.load('/tmp/123.npy', mmap_mode='r') >>> X[1, :] memmap([4, 5, 6]) """ import gzip own_fid = False if isinstance(file, basestring): fid = open(file, "rb") own_fid = True else: fid = file if encoding not in ('ASCII', 'latin1', 'bytes'): # The 'encoding' value for pickle also affects what encoding # the serialized binary data of Numpy arrays is loaded # in. Pickle does not pass on the encoding information to # Numpy. The unpickling code in numpy.core.multiarray is # written to assume that unicode data appearing where binary # should be is in 'latin1'. 'bytes' is also safe, as is 'ASCII'. # # Other encoding values can corrupt binary data, and we # purposefully disallow them. For the same reason, the errors= # argument is not exposed, as values other than 'strict' # result can similarly silently corrupt numerical data. raise ValueError("encoding must be 'ASCII', 'latin1', or 'bytes'") if sys.version_info[0] >= 3: pickle_kwargs = dict(encoding=encoding, fix_imports=fix_imports) else: # Nothing to do on Python 2 pickle_kwargs = {} try: # Code to distinguish from NumPy binary files and pickles. _ZIP_PREFIX = asbytes('PK\x03\x04') N = len(format.MAGIC_PREFIX) magic = fid.read(N) fid.seek(-N, 1) # back-up if magic.startswith(_ZIP_PREFIX): # zip-file (assume .npz) # Transfer file ownership to NpzFile tmp = own_fid own_fid = False return NpzFile(fid, own_fid=tmp, allow_pickle=allow_pickle, pickle_kwargs=pickle_kwargs) elif magic == format.MAGIC_PREFIX: # .npy file if mmap_mode: return format.open_memmap(file, mode=mmap_mode) else: return format.read_array(fid, allow_pickle=allow_pickle, pickle_kwargs=pickle_kwargs) else: # Try a pickle if not allow_pickle: raise ValueError("allow_pickle=False, but file does not contain " "non-pickled data") try: return pickle.load(fid, **pickle_kwargs) except: raise IOError( "Failed to interpret file %s as a pickle" % repr(file)) finally: if own_fid: fid.close() def save(file, arr, allow_pickle=True, fix_imports=True): """ Save an array to a binary file in NumPy ``.npy`` format. Parameters ---------- file : file or str File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string, a ``.npy`` extension will be appended to the file name if it does not already have one. allow_pickle : bool, optional Allow saving object arrays using Python pickles. Reasons for disallowing pickles include security (loading pickled data can execute arbitrary code) and portability (pickled objects may not be loadable on different Python installations, for example if the stored objects require libraries that are not available, and not all pickled data is compatible between Python 2 and Python 3). Default: True fix_imports : bool, optional Only useful in forcing objects in object arrays on Python 3 to be pickled in a Python 2 compatible way. If `fix_imports` is True, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. arr : array_like Array data to be saved. See Also -------- savez : Save several arrays into a ``.npz`` archive savetxt, load Notes ----- For a description of the ``.npy`` format, see the module docstring of `numpy.lib.format` or the Numpy Enhancement Proposal http://docs.scipy.org/doc/numpy/neps/npy-format.html Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> np.save(outfile, x) >>> outfile.seek(0) # Only needed here to simulate closing & reopening file >>> np.load(outfile) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) """ own_fid = False if isinstance(file, basestring): if not file.endswith('.npy'): file = file + '.npy' fid = open(file, "wb") own_fid = True else: fid = file if sys.version_info[0] >= 3: pickle_kwargs = dict(fix_imports=fix_imports) else: # Nothing to do on Python 2 pickle_kwargs = None try: arr = np.asanyarray(arr) format.write_array(fid, arr, allow_pickle=allow_pickle, pickle_kwargs=pickle_kwargs) finally: if own_fid: fid.close() def savez(file, *args, **kwds): """ Save several arrays into a single file in uncompressed ``.npz`` format. If arguments are passed in with no keywords, the corresponding variable names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword arguments are given, the corresponding variable names, in the ``.npz`` file will match the keyword names. Parameters ---------- file : str or file Either the file name (string) or an open file (file-like object) where the data will be saved. If file is a string, the ``.npz`` extension will be appended to the file name if it is not already there. args : Arguments, optional Arrays to save to the file. Since it is not possible for Python to know the names of the arrays outside `savez`, the arrays will be saved with names "arr_0", "arr_1", and so on. These arguments can be any expression. kwds : Keyword arguments, optional Arrays to save to the file. Arrays will be saved in the file with the keyword names. Returns ------- None See Also -------- save : Save a single array to a binary file in NumPy format. savetxt : Save an array to a file as plain text. savez_compressed : Save several arrays into a compressed ``.npz`` archive Notes ----- The ``.npz`` file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in ``.npy`` format. For a description of the ``.npy`` format, see `numpy.lib.format` or the Numpy Enhancement Proposal http://docs.scipy.org/doc/numpy/neps/npy-format.html When opening the saved ``.npz`` file with `load` a `NpzFile` object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the ``.files`` attribute), and for the arrays themselves. Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> y = np.sin(x) Using `savez` with \\*args, the arrays are saved with default names. >>> np.savez(outfile, x, y) >>> outfile.seek(0) # Only needed here to simulate closing & reopening file >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_1', 'arr_0'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Using `savez` with \\**kwds, the arrays are saved with the keyword names. >>> outfile = TemporaryFile() >>> np.savez(outfile, x=x, y=y) >>> outfile.seek(0) >>> npzfile = np.load(outfile) >>> npzfile.files ['y', 'x'] >>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) """ _savez(file, args, kwds, False) def savez_compressed(file, *args, **kwds): """ Save several arrays into a single file in compressed ``.npz`` format. If keyword arguments are given, then filenames are taken from the keywords. If arguments are passed in with no keywords, then stored file names are arr_0, arr_1, etc. Parameters ---------- file : str File name of ``.npz`` file. args : Arguments Function arguments. kwds : Keyword arguments Keywords. See Also -------- numpy.savez : Save several arrays into an uncompressed ``.npz`` file format numpy.load : Load the files created by savez_compressed. """ _savez(file, args, kwds, True) def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None): # Import is postponed to here since zipfile depends on gzip, an optional # component of the so-called standard library. import zipfile # Import deferred for startup time improvement import tempfile if isinstance(file, basestring): if not file.endswith('.npz'): file = file + '.npz' namedict = kwds for i, val in enumerate(args): key = 'arr_%d' % i if key in namedict.keys(): raise ValueError( "Cannot use un-named variables and keyword %s" % key) namedict[key] = val if compress: compression = zipfile.ZIP_DEFLATED else: compression = zipfile.ZIP_STORED zipf = zipfile_factory(file, mode="w", compression=compression) # Stage arrays in a temporary file on disk, before writing to zip. fd, tmpfile = tempfile.mkstemp(suffix='-numpy.npy') os.close(fd) try: for key, val in namedict.items(): fname = key + '.npy' fid = open(tmpfile, 'wb') try: format.write_array(fid, np.asanyarray(val), allow_pickle=allow_pickle, pickle_kwargs=pickle_kwargs) fid.close() fid = None zipf.write(tmpfile, arcname=fname) finally: if fid: fid.close() finally: os.remove(tmpfile) zipf.close() def _getconv(dtype): """ Find the correct dtype converter. Adapted from matplotlib """ def floatconv(x): x.lower() if b'0x' in x: return float.fromhex(asstr(x)) return float(x) typ = dtype.type if issubclass(typ, np.bool_): return lambda x: bool(int(x)) if issubclass(typ, np.uint64): return np.uint64 if issubclass(typ, np.int64): return np.int64 if issubclass(typ, np.integer): return lambda x: int(float(x)) elif issubclass(typ, np.longdouble): return np.longdouble elif issubclass(typ, np.floating): return floatconv elif issubclass(typ, np.complex): return lambda x: complex(asstr(x)) elif issubclass(typ, np.bytes_): return bytes else: return str def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0): """ Load data from a text file. Each row in the text file must have the same number of values. Parameters ---------- fname : file or str File, filename, or generator to read. If the filename extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note that generators should return byte strings for Python 3k. dtype : data-type, optional Data-type of the resulting array; default: float. If this is a structured data-type, the resulting array will be 1-dimensional, and each row will be interpreted as an element of the array. In this case, the number of columns used must match the number of fields in the data-type. comments : str or sequence, optional The characters or list of characters used to indicate the start of a comment; default: '#'. delimiter : str, optional The string used to separate values. By default, this is any whitespace. converters : dict, optional A dictionary mapping column number to a function that will convert that column to a float. E.g., if column 0 is a date string: ``converters = {0: datestr2num}``. Converters can also be used to provide a default value for missing data (but see also `genfromtxt`): ``converters = {3: lambda s: float(s.strip() or 0)}``. Default: None. skiprows : int, optional Skip the first `skiprows` lines; default: 0. usecols : sequence, optional Which columns to read, with 0 being the first. For example, ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns. The default, None, results in all columns being read. unpack : bool, optional If True, the returned array is transposed, so that arguments may be unpacked using ``x, y, z = loadtxt(...)``. When used with a structured data-type, arrays are returned for each field. Default is False. ndmin : int, optional The returned array will have at least `ndmin` dimensions. Otherwise mono-dimensional axes will be squeezed. Legal values: 0 (default), 1 or 2. .. versionadded:: 1.6.0 Returns ------- out : ndarray Data read from the text file. See Also -------- load, fromstring, fromregex genfromtxt : Load data with missing values handled as specified. scipy.io.loadmat : reads MATLAB data files Notes ----- This function aims to be a fast reader for simply formatted files. The `genfromtxt` function provides more sophisticated handling of, e.g., lines with missing values. .. versionadded:: 1.10.0 The strings produced by the Python float.hex method can be used as input for floats. Examples -------- >>> from io import StringIO # StringIO behaves like a file object >>> c = StringIO("0 1\\n2 3") >>> np.loadtxt(c) array([[ 0., 1.], [ 2., 3.]]) >>> d = StringIO("M 21 72\\nF 35 58") >>> np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'), ... 'formats': ('S1', 'i4', 'f4')}) array([('M', 21, 72.0), ('F', 35, 58.0)], dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')]) >>> c = StringIO("1,0,2\\n3,0,4") >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True) >>> x array([ 1., 3.]) >>> y array([ 2., 4.]) """ # Type conversions for Py3 convenience if comments is not None: if isinstance(comments, (basestring, bytes)): comments = [asbytes(comments)] else: comments = [asbytes(comment) for comment in comments] # Compile regex for comments beforehand comments = (re.escape(comment) for comment in comments) regex_comments = re.compile(asbytes('|').join(comments)) user_converters = converters if delimiter is not None: delimiter = asbytes(delimiter) if usecols is not None: usecols = list(usecols) fown = False try: if _is_string_like(fname): fown = True if fname.endswith('.gz'): import gzip fh = iter(gzip.GzipFile(fname)) elif fname.endswith('.bz2'): import bz2 fh = iter(bz2.BZ2File(fname)) elif sys.version_info[0] == 2: fh = iter(open(fname, 'U')) else: fh = iter(open(fname)) else: fh = iter(fname) except TypeError: raise ValueError('fname must be a string, file handle, or generator') X = [] def flatten_dtype(dt): """Unpack a structured data-type, and produce re-packing info.""" if dt.names is None: # If the dtype is flattened, return. # If the dtype has a shape, the dtype occurs # in the list more than once. shape = dt.shape if len(shape) == 0: return ([dt.base], None) else: packing = [(shape[-1], list)] if len(shape) > 1: for dim in dt.shape[-2::-1]: packing = [(dim*packing[0][0], packing*dim)] return ([dt.base] * int(np.prod(dt.shape)), packing) else: types = [] packing = [] for field in dt.names: tp, bytes = dt.fields[field] flat_dt, flat_packing = flatten_dtype(tp) types.extend(flat_dt) # Avoid extra nesting for subarrays if len(tp.shape) > 0: packing.extend(flat_packing) else: packing.append((len(flat_dt), flat_packing)) return (types, packing) def pack_items(items, packing): """Pack items into nested lists based on re-packing info.""" if packing is None: return items[0] elif packing is tuple: return tuple(items) elif packing is list: return list(items) else: start = 0 ret = [] for length, subpacking in packing: ret.append(pack_items(items[start:start+length], subpacking)) start += length return tuple(ret) def split_line(line): """Chop off comments, strip, and split at delimiter. Note that although the file is opened as text, this function returns bytes. """ line = asbytes(line) if comments is not None: line = regex_comments.split(asbytes(line), maxsplit=1)[0] line = line.strip(asbytes('\r\n')) if line: return line.split(delimiter) else: return [] try: # Make sure we're dealing with a proper dtype dtype = np.dtype(dtype) defconv = _getconv(dtype) # Skip the first `skiprows` lines for i in range(skiprows): next(fh) # Read until we find a line with some values, and use # it to estimate the number of columns, N. first_vals = None try: while not first_vals: first_line = next(fh) first_vals = split_line(first_line) except StopIteration: # End of lines reached first_line = '' first_vals = [] warnings.warn('loadtxt: Empty input file: "%s"' % fname) N = len(usecols or first_vals) dtype_types, packing = flatten_dtype(dtype) if len(dtype_types) > 1: # We're dealing with a structured array, each field of # the dtype matches a column converters = [_getconv(dt) for dt in dtype_types] else: # All fields have the same dtype converters = [defconv for i in range(N)] if N > 1: packing = [(N, tuple)] # By preference, use the converters specified by the user for i, conv in (user_converters or {}).items(): if usecols: try: i = usecols.index(i) except ValueError: # Unused converter specified continue converters[i] = conv # Parse each line, including the first for i, line in enumerate(itertools.chain([first_line], fh)): vals = split_line(line) if len(vals) == 0: continue if usecols: vals = [vals[i] for i in usecols] if len(vals) != N: line_num = i + skiprows + 1 raise ValueError("Wrong number of columns at line %d" % line_num) # Convert each value according to its column and store items = [conv(val) for (conv, val) in zip(converters, vals)] # Then pack it according to the dtype's nesting items = pack_items(items, packing) X.append(items) finally: if fown: fh.close() X = np.array(X, dtype) # Multicolumn data are returned with shape (1, N, M), i.e. # (1, 1, M) for a single row - remove the singleton dimension there if X.ndim == 3 and X.shape[:2] == (1, 1): X.shape = (1, -1) # Verify that the array has at least dimensions `ndmin`. # Check correctness of the values of `ndmin` if ndmin not in [0, 1, 2]: raise ValueError('Illegal value of ndmin keyword: %s' % ndmin) # Tweak the size and shape of the arrays - remove extraneous dimensions if X.ndim > ndmin: X = np.squeeze(X) # and ensure we have the minimum number of dimensions asked for # - has to be in this order for the odd case ndmin=1, X.squeeze().ndim=0 if X.ndim < ndmin: if ndmin == 1: X = np.atleast_1d(X) elif ndmin == 2: X = np.atleast_2d(X).T if unpack: if len(dtype_types) > 1: # For structured arrays, return an array for each field. return [X[field] for field in dtype.names] else: return X.T else: return X def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# '): """ Save an array to a text file. Parameters ---------- fname : filename or file handle If the filename ends in ``.gz``, the file is automatically saved in compressed gzip format. `loadtxt` understands gzipped files transparently. X : array_like Data to be saved to a text file. fmt : str or sequence of strs, optional A single format (%10.5f), a sequence of formats, or a multi-format string, e.g. 'Iteration %d -- %10.5f', in which case `delimiter` is ignored. For complex `X`, the legal options for `fmt` are: a) a single specifier, `fmt='%.4e'`, resulting in numbers formatted like `' (%s+%sj)' % (fmt, fmt)` b) a full string specifying every real and imaginary part, e.g. `' %.4e %+.4j %.4e %+.4j %.4e %+.4j'` for 3 columns c) a list of specifiers, one per column - in this case, the real and imaginary part must have separate specifiers, e.g. `['%.3e + %.3ej', '(%.15e%+.15ej)']` for 2 columns delimiter : str, optional String or character separating columns. newline : str, optional String or character separating lines. .. versionadded:: 1.5.0 header : str, optional String that will be written at the beginning of the file. .. versionadded:: 1.7.0 footer : str, optional String that will be written at the end of the file. .. versionadded:: 1.7.0 comments : str, optional String that will be prepended to the ``header`` and ``footer`` strings, to mark them as comments. Default: '# ', as expected by e.g. ``numpy.loadtxt``. .. versionadded:: 1.7.0 See Also -------- save : Save an array to a binary file in NumPy ``.npy`` format savez : Save several arrays into an uncompressed ``.npz`` archive savez_compressed : Save several arrays into a compressed ``.npz`` archive Notes ----- Further explanation of the `fmt` parameter (``%[flag]width[.precision]specifier``): flags: ``-`` : left justify ``+`` : Forces to precede result with + or -. ``0`` : Left pad the number with zeros instead of space (see width). width: Minimum number of characters to be printed. The value is not truncated if it has more characters. precision: - For integer specifiers (eg. ``d,i,o,x``), the minimum number of digits. - For ``e, E`` and ``f`` specifiers, the number of digits to print after the decimal point. - For ``g`` and ``G``, the maximum number of significant digits. - For ``s``, the maximum number of characters. specifiers: ``c`` : character ``d`` or ``i`` : signed decimal integer ``e`` or ``E`` : scientific notation with ``e`` or ``E``. ``f`` : decimal floating point ``g,G`` : use the shorter of ``e,E`` or ``f`` ``o`` : signed octal ``s`` : string of characters ``u`` : unsigned decimal integer ``x,X`` : unsigned hexadecimal integer This explanation of ``fmt`` is not complete, for an exhaustive specification see [1]_. References ---------- .. [1] `Format Specification Mini-Language <http://docs.python.org/library/string.html# format-specification-mini-language>`_, Python Documentation. Examples -------- >>> x = y = z = np.arange(0.0,5.0,1.0) >>> np.savetxt('test.out', x, delimiter=',') # X is an array >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation """ # Py3 conversions first if isinstance(fmt, bytes): fmt = asstr(fmt) delimiter = asstr(delimiter) own_fh = False if _is_string_like(fname): own_fh = True if fname.endswith('.gz'): import gzip fh = gzip.open(fname, 'wb') else: if sys.version_info[0] >= 3: fh = open(fname, 'wb') else: fh = open(fname, 'w') elif hasattr(fname, 'write'): fh = fname else: raise ValueError('fname must be a string or file handle') try: X = np.asarray(X) # Handle 1-dimensional arrays if X.ndim == 1: # Common case -- 1d array of numbers if X.dtype.names is None: X = np.atleast_2d(X).T ncol = 1 # Complex dtype -- each field indicates a separate column else: ncol = len(X.dtype.descr) else: ncol = X.shape[1] iscomplex_X = np.iscomplexobj(X) # `fmt` can be a string with multiple insertion points or a # list of formats. E.g. '%10.5f\t%10d' or ('%10.5f', '$10d') if type(fmt) in (list, tuple): if len(fmt) != ncol: raise AttributeError('fmt has wrong shape. %s' % str(fmt)) format = asstr(delimiter).join(map(asstr, fmt)) elif isinstance(fmt, str): n_fmt_chars = fmt.count('%') error = ValueError('fmt has wrong number of %% formats: %s' % fmt) if n_fmt_chars == 1: if iscomplex_X: fmt = [' (%s+%sj)' % (fmt, fmt), ] * ncol else: fmt = [fmt, ] * ncol format = delimiter.join(fmt) elif iscomplex_X and n_fmt_chars != (2 * ncol): raise error elif ((not iscomplex_X) and n_fmt_chars != ncol): raise error else: format = fmt else: raise ValueError('invalid fmt: %r' % (fmt,)) if len(header) > 0: header = header.replace('\n', '\n' + comments) fh.write(asbytes(comments + header + newline)) if iscomplex_X: for row in X: row2 = [] for number in row: row2.append(number.real) row2.append(number.imag) fh.write(asbytes(format % tuple(row2) + newline)) else: for row in X: try: fh.write(asbytes(format % tuple(row) + newline)) except TypeError: raise TypeError("Mismatch between array dtype ('%s') and " "format specifier ('%s')" % (str(X.dtype), format)) if len(footer) > 0: footer = footer.replace('\n', '\n' + comments) fh.write(asbytes(comments + footer + newline)) finally: if own_fh: fh.close() def fromregex(file, regexp, dtype): """ Construct an array from a text file, using regular expression parsing. The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to fields of the structured array. Parameters ---------- file : str or file File name or file object to read. regexp : str or regexp Regular expression used to parse the file. Groups in the regular expression correspond to fields in the dtype. dtype : dtype or list of dtypes Dtype for the structured array. Returns ------- output : ndarray The output array, containing the part of the content of `file` that was matched by `regexp`. `output` is always a structured array. Raises ------ TypeError When `dtype` is not a valid dtype for a structured array. See Also -------- fromstring, loadtxt Notes ----- Dtypes for structured arrays can be specified in several forms, but all forms specify at least the data type and field name. For details see `doc.structured_arrays`. Examples -------- >>> f = open('test.dat', 'w') >>> f.write("1312 foo\\n1534 bar\\n444 qux") >>> f.close() >>> regexp = r"(\\d+)\\s+(...)" # match [digits, whitespace, anything] >>> output = np.fromregex('test.dat', regexp, ... [('num', np.int64), ('key', 'S3')]) >>> output array([(1312L, 'foo'), (1534L, 'bar'), (444L, 'qux')], dtype=[('num', '<i8'), ('key', '|S3')]) >>> output['num'] array([1312, 1534, 444], dtype=int64) """ own_fh = False if not hasattr(file, "read"): file = open(file, 'rb') own_fh = True try: if not hasattr(regexp, 'match'): regexp = re.compile(asbytes(regexp)) if not isinstance(dtype, np.dtype): dtype = np.dtype(dtype) seq = regexp.findall(file.read()) if seq and not isinstance(seq[0], tuple): # Only one group is in the regexp. # Create the new array as a single data-type and then # re-interpret as a single-field structured array. newdtype = np.dtype(dtype[dtype.names[0]]) output = np.array(seq, dtype=newdtype) output.dtype = dtype else: output = np.array(seq, dtype=dtype) return output finally: if own_fh: file.close() #####-------------------------------------------------------------------------- #---- --- ASCII functions --- #####-------------------------------------------------------------------------- def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=None, replace_space='_', autostrip=False, case_sensitive=True, defaultfmt="f%i", unpack=None, usemask=False, loose=True, invalid_raise=True, max_rows=None): """ Load data from a text file, with missing values handled as specified. Each line past the first `skip_header` lines is split at the `delimiter` character, and characters following the `comments` character are discarded. Parameters ---------- fname : file, str, list of str, generator File, filename, list, or generator to read. If the filename extension is `.gz` or `.bz2`, the file is first decompressed. Mote that generators must return byte strings in Python 3k. The strings in a list or produced by a generator are treated as lines. dtype : dtype, optional Data type of the resulting array. If None, the dtypes will be determined by the contents of each column, individually. comments : str, optional The character used to indicate the start of a comment. All the characters occurring on a line after a comment are discarded delimiter : str, int, or sequence, optional The string used to separate values. By default, any consecutive whitespaces act as delimiter. An integer or sequence of integers can also be provided as width(s) of each field. skiprows : int, optional `skiprows` was removed in numpy 1.10. Please use `skip_header` instead. skip_header : int, optional The number of lines to skip at the beginning of the file. skip_footer : int, optional The number of lines to skip at the end of the file. converters : variable, optional The set of functions that convert the data of a column to a value. The converters can also be used to provide a default value for missing data: ``converters = {3: lambda s: float(s or 0)}``. missing : variable, optional `missing` was removed in numpy 1.10. Please use `missing_values` instead. missing_values : variable, optional The set of strings corresponding to missing data. filling_values : variable, optional The set of values to be used as default when the data are missing. usecols : sequence, optional Which columns to read, with 0 being the first. For example, ``usecols = (1, 4, 5)`` will extract the 2nd, 5th and 6th columns. names : {None, True, str, sequence}, optional If `names` is True, the field names are read from the first valid line after the first `skip_header` lines. If `names` is a sequence or a single-string of comma-separated names, the names will be used to define the field names in a structured dtype. If `names` is None, the names of the dtype fields will be used, if any. excludelist : sequence, optional A list of names to exclude. This list is appended to the default list ['return','file','print']. Excluded names are appended an underscore: for example, `file` would become `file_`. deletechars : str, optional A string combining invalid characters that must be deleted from the names. defaultfmt : str, optional A format used to define default field names, such as "f%i" or "f_%02i". autostrip : bool, optional Whether to automatically strip white spaces from the variables. replace_space : char, optional Character(s) used in replacement of white spaces in the variables names. By default, use a '_'. case_sensitive : {True, False, 'upper', 'lower'}, optional If True, field names are case sensitive. If False or 'upper', field names are converted to upper case. If 'lower', field names are converted to lower case. unpack : bool, optional If True, the returned array is transposed, so that arguments may be unpacked using ``x, y, z = loadtxt(...)`` usemask : bool, optional If True, return a masked array. If False, return a regular array. loose : bool, optional If True, do not raise errors for invalid values. invalid_raise : bool, optional If True, an exception is raised if an inconsistency is detected in the number of columns. If False, a warning is emitted and the offending lines are skipped. max_rows : int, optional The maximum number of rows to read. Must not be used with skip_footer at the same time. If given, the value must be at least 1. Default is to read the entire file. .. versionadded:: 1.10.0 Returns ------- out : ndarray Data read from the text file. If `usemask` is True, this is a masked array. See Also -------- numpy.loadtxt : equivalent function when no data is missing. Notes ----- * When spaces are used as delimiters, or when no delimiter has been given as input, there should not be any missing data between two fields. * When the variables are named (either by a flexible dtype or with `names`, there must not be any header in the file (else a ValueError exception is raised). * Individual values are not stripped of spaces by default. When using a custom converter, make sure the function does remove spaces. References ---------- .. [1] Numpy User Guide, section `I/O with Numpy <http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html>`_. Examples --------- >>> from io import StringIO >>> import numpy as np Comma delimited file with mixed dtype >>> s = StringIO("1,1.3,abcde") >>> data = np.genfromtxt(s, dtype=[('myint','i8'),('myfloat','f8'), ... ('mystring','S5')], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', '|S5')]) Using dtype = None >>> s.seek(0) # needed for StringIO example only >>> data = np.genfromtxt(s, dtype=None, ... names = ['myint','myfloat','mystring'], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', '|S5')]) Specifying dtype and names >>> s.seek(0) >>> data = np.genfromtxt(s, dtype="i8,f8,S5", ... names=['myint','myfloat','mystring'], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', '|S5')]) An example with fixed-width columns >>> s = StringIO("11.3abcde") >>> data = np.genfromtxt(s, dtype=None, names=['intvar','fltvar','strvar'], ... delimiter=[1,3,5]) >>> data array((1, 1.3, 'abcde'), dtype=[('intvar', '<i8'), ('fltvar', '<f8'), ('strvar', '|S5')]) """ if max_rows is not None: if skip_footer: raise ValueError( "The keywords 'skip_footer' and 'max_rows' can not be " "specified at the same time.") if max_rows < 1: raise ValueError("'max_rows' must be at least 1.") # Py3 data conversions to bytes, for convenience if comments is not None: comments = asbytes(comments) if isinstance(delimiter, unicode): delimiter = asbytes(delimiter) if isinstance(missing_values, (unicode, list, tuple)): missing_values = asbytes_nested(missing_values) # if usemask: from numpy.ma import MaskedArray, make_mask_descr # Check the input dictionary of converters user_converters = converters or {} if not isinstance(user_converters, dict): raise TypeError( "The input argument 'converter' should be a valid dictionary " "(got '%s' instead)" % type(user_converters)) # Initialize the filehandle, the LineSplitter and the NameValidator own_fhd = False try: if isinstance(fname, basestring): if sys.version_info[0] == 2: fhd = iter(np.lib._datasource.open(fname, 'rbU')) else: fhd = iter(np.lib._datasource.open(fname, 'rb')) own_fhd = True else: fhd = iter(fname) except TypeError: raise TypeError( "fname must be a string, filehandle, list of strings, " "or generator. Got %s instead." % type(fname)) split_line = LineSplitter(delimiter=delimiter, comments=comments, autostrip=autostrip)._handyman validate_names = NameValidator(excludelist=excludelist, deletechars=deletechars, case_sensitive=case_sensitive, replace_space=replace_space) # Skip the first `skip_header` rows for i in range(skip_header): next(fhd) # Keep on until we find the first valid values first_values = None try: while not first_values: first_line = next(fhd) if names is True: if comments in first_line: first_line = ( asbytes('').join(first_line.split(comments)[1:])) first_values = split_line(first_line) except StopIteration: # return an empty array if the datafile is empty first_line = asbytes('') first_values = [] warnings.warn('genfromtxt: Empty input file: "%s"' % fname) # Should we take the first values as names ? if names is True: fval = first_values[0].strip() if fval in comments: del first_values[0] # Check the columns to use: make sure `usecols` is a list if usecols is not None: try: usecols = [_.strip() for _ in usecols.split(",")] except AttributeError: try: usecols = list(usecols) except TypeError: usecols = [usecols, ] nbcols = len(usecols or first_values) # Check the names and overwrite the dtype.names if needed if names is True: names = validate_names([_bytes_to_name(_.strip()) for _ in first_values]) first_line = asbytes('') elif _is_string_like(names): names = validate_names([_.strip() for _ in names.split(',')]) elif names: names = validate_names(names) # Get the dtype if dtype is not None: dtype = easy_dtype(dtype, defaultfmt=defaultfmt, names=names, excludelist=excludelist, deletechars=deletechars, case_sensitive=case_sensitive, replace_space=replace_space) # Make sure the names is a list (for 2.5) if names is not None: names = list(names) if usecols: for (i, current) in enumerate(usecols): # if usecols is a list of names, convert to a list of indices if _is_string_like(current): usecols[i] = names.index(current) elif current < 0: usecols[i] = current + len(first_values) # If the dtype is not None, make sure we update it if (dtype is not None) and (len(dtype) > nbcols): descr = dtype.descr dtype = np.dtype([descr[_] for _ in usecols]) names = list(dtype.names) # If `names` is not None, update the names elif (names is not None) and (len(names) > nbcols): names = [names[_] for _ in usecols] elif (names is not None) and (dtype is not None): names = list(dtype.names) # Process the missing values ............................... # Rename missing_values for convenience user_missing_values = missing_values or () # Define the list of missing_values (one column: one list) missing_values = [list([asbytes('')]) for _ in range(nbcols)] # We have a dictionary: process it field by field if isinstance(user_missing_values, dict): # Loop on the items for (key, val) in user_missing_values.items(): # Is the key a string ? if _is_string_like(key): try: # Transform it into an integer key = names.index(key) except ValueError: # We couldn't find it: the name must have been dropped continue # Redefine the key as needed if it's a column number if usecols: try: key = usecols.index(key) except ValueError: pass # Transform the value as a list of string if isinstance(val, (list, tuple)): val = [str(_) for _ in val] else: val = [str(val), ] # Add the value(s) to the current list of missing if key is None: # None acts as default for miss in missing_values: miss.extend(val) else: missing_values[key].extend(val) # We have a sequence : each item matches a column elif isinstance(user_missing_values, (list, tuple)): for (value, entry) in zip(user_missing_values, missing_values): value = str(value) if value not in entry: entry.append(value) # We have a string : apply it to all entries elif isinstance(user_missing_values, bytes): user_value = user_missing_values.split(asbytes(",")) for entry in missing_values: entry.extend(user_value) # We have something else: apply it to all entries else: for entry in missing_values: entry.extend([str(user_missing_values)]) # Process the filling_values ............................... # Rename the input for convenience user_filling_values = filling_values if user_filling_values is None: user_filling_values = [] # Define the default filling_values = [None] * nbcols # We have a dictionary : update each entry individually if isinstance(user_filling_values, dict): for (key, val) in user_filling_values.items(): if _is_string_like(key): try: # Transform it into an integer key = names.index(key) except ValueError: # We couldn't find it: the name must have been dropped, continue # Redefine the key if it's a column number and usecols is defined if usecols: try: key = usecols.index(key) except ValueError: pass # Add the value to the list filling_values[key] = val # We have a sequence : update on a one-to-one basis elif isinstance(user_filling_values, (list, tuple)): n = len(user_filling_values) if (n <= nbcols): filling_values[:n] = user_filling_values else: filling_values = user_filling_values[:nbcols] # We have something else : use it for all entries else: filling_values = [user_filling_values] * nbcols # Initialize the converters ................................ if dtype is None: # Note: we can't use a [...]*nbcols, as we would have 3 times the same # ... converter, instead of 3 different converters. converters = [StringConverter(None, missing_values=miss, default=fill) for (miss, fill) in zip(missing_values, filling_values)] else: dtype_flat = flatten_dtype(dtype, flatten_base=True) # Initialize the converters if len(dtype_flat) > 1: # Flexible type : get a converter from each dtype zipit = zip(dtype_flat, missing_values, filling_values) converters = [StringConverter(dt, locked=True, missing_values=miss, default=fill) for (dt, miss, fill) in zipit] else: # Set to a default converter (but w/ different missing values) zipit = zip(missing_values, filling_values) converters = [StringConverter(dtype, locked=True, missing_values=miss, default=fill) for (miss, fill) in zipit] # Update the converters to use the user-defined ones uc_update = [] for (j, conv) in user_converters.items(): # If the converter is specified by column names, use the index instead if _is_string_like(j): try: j = names.index(j) i = j except ValueError: continue elif usecols: try: i = usecols.index(j) except ValueError: # Unused converter specified continue else: i = j # Find the value to test - first_line is not filtered by usecols: if len(first_line): testing_value = first_values[j] else: testing_value = None converters[i].update(conv, locked=True, testing_value=testing_value, default=filling_values[i], missing_values=missing_values[i],) uc_update.append((i, conv)) # Make sure we have the corrected keys in user_converters... user_converters.update(uc_update) # Fixme: possible error as following variable never used. #miss_chars = [_.missing_values for _ in converters] # Initialize the output lists ... # ... rows rows = [] append_to_rows = rows.append # ... masks if usemask: masks = [] append_to_masks = masks.append # ... invalid invalid = [] append_to_invalid = invalid.append # Parse each line for (i, line) in enumerate(itertools.chain([first_line, ], fhd)): values = split_line(line) nbvalues = len(values) # Skip an empty line if nbvalues == 0: continue if usecols: # Select only the columns we need try: values = [values[_] for _ in usecols] except IndexError: append_to_invalid((i + skip_header + 1, nbvalues)) continue elif nbvalues != nbcols: append_to_invalid((i + skip_header + 1, nbvalues)) continue # Store the values append_to_rows(tuple(values)) if usemask: append_to_masks(tuple([v.strip() in m for (v, m) in zip(values, missing_values)])) if len(rows) == max_rows: break if own_fhd: fhd.close() # Upgrade the converters (if needed) if dtype is None: for (i, converter) in enumerate(converters): current_column = [itemgetter(i)(_m) for _m in rows] try: converter.iterupgrade(current_column) except ConverterLockError: errmsg = "Converter #%i is locked and cannot be upgraded: " % i current_column = map(itemgetter(i), rows) for (j, value) in enumerate(current_column): try: converter.upgrade(value) except (ConverterError, ValueError): errmsg += "(occurred line #%i for value '%s')" errmsg %= (j + 1 + skip_header, value) raise ConverterError(errmsg) # Check that we don't have invalid values nbinvalid = len(invalid) if nbinvalid > 0: nbrows = len(rows) + nbinvalid - skip_footer # Construct the error message template = " Line #%%i (got %%i columns instead of %i)" % nbcols if skip_footer > 0: nbinvalid_skipped = len([_ for _ in invalid if _[0] > nbrows + skip_header]) invalid = invalid[:nbinvalid - nbinvalid_skipped] skip_footer -= nbinvalid_skipped # # nbrows -= skip_footer # errmsg = [template % (i, nb) # for (i, nb) in invalid if i < nbrows] # else: errmsg = [template % (i, nb) for (i, nb) in invalid] if len(errmsg): errmsg.insert(0, "Some errors were detected !") errmsg = "\n".join(errmsg) # Raise an exception ? if invalid_raise: raise ValueError(errmsg) # Issue a warning ? else: warnings.warn(errmsg, ConversionWarning) # Strip the last skip_footer data if skip_footer > 0: rows = rows[:-skip_footer] if usemask: masks = masks[:-skip_footer] # Convert each value according to the converter: # We want to modify the list in place to avoid creating a new one... if loose: rows = list( zip(*[[conv._loose_call(_r) for _r in map(itemgetter(i), rows)] for (i, conv) in enumerate(converters)])) else: rows = list( zip(*[[conv._strict_call(_r) for _r in map(itemgetter(i), rows)] for (i, conv) in enumerate(converters)])) # Reset the dtype data = rows if dtype is None: # Get the dtypes from the types of the converters column_types = [conv.type for conv in converters] # Find the columns with strings... strcolidx = [i for (i, v) in enumerate(column_types) if v in (type('S'), np.string_)] # ... and take the largest number of chars. for i in strcolidx: column_types[i] = "|S%i" % max(len(row[i]) for row in data) # if names is None: # If the dtype is uniform, don't define names, else use '' base = set([c.type for c in converters if c._checked]) if len(base) == 1: (ddtype, mdtype) = (list(base)[0], np.bool) else: ddtype = [(defaultfmt % i, dt) for (i, dt) in enumerate(column_types)] if usemask: mdtype = [(defaultfmt % i, np.bool) for (i, dt) in enumerate(column_types)] else: ddtype = list(zip(names, column_types)) mdtype = list(zip(names, [np.bool] * len(column_types))) output = np.array(data, dtype=ddtype) if usemask: outputmask = np.array(masks, dtype=mdtype) else: # Overwrite the initial dtype names if needed if names and dtype.names: dtype.names = names # Case 1. We have a structured type if len(dtype_flat) > 1: # Nested dtype, eg [('a', int), ('b', [('b0', int), ('b1', 'f4')])] # First, create the array using a flattened dtype: # [('a', int), ('b1', int), ('b2', float)] # Then, view the array using the specified dtype. if 'O' in (_.char for _ in dtype_flat): if has_nested_fields(dtype): raise NotImplementedError( "Nested fields involving objects are not supported...") else: output = np.array(data, dtype=dtype) else: rows = np.array(data, dtype=[('', _) for _ in dtype_flat]) output = rows.view(dtype) # Now, process the rowmasks the same way if usemask: rowmasks = np.array( masks, dtype=np.dtype([('', np.bool) for t in dtype_flat])) # Construct the new dtype mdtype = make_mask_descr(dtype) outputmask = rowmasks.view(mdtype) # Case #2. We have a basic dtype else: # We used some user-defined converters if user_converters: ishomogeneous = True descr = [] for i, ttype in enumerate([conv.type for conv in converters]): # Keep the dtype of the current converter if i in user_converters: ishomogeneous &= (ttype == dtype.type) if ttype == np.string_: ttype = "|S%i" % max(len(row[i]) for row in data) descr.append(('', ttype)) else: descr.append(('', dtype)) # So we changed the dtype ? if not ishomogeneous: # We have more than one field if len(descr) > 1: dtype = np.dtype(descr) # We have only one field: drop the name if not needed. else: dtype = np.dtype(ttype) # output = np.array(data, dtype) if usemask: if dtype.names: mdtype = [(_, np.bool) for _ in dtype.names] else: mdtype = np.bool outputmask = np.array(masks, dtype=mdtype) # Try to take care of the missing data we missed names = output.dtype.names if usemask and names: for (name, conv) in zip(names or (), converters): missing_values = [conv(_) for _ in conv.missing_values if _ != asbytes('')] for mval in missing_values: outputmask[name] |= (output[name] == mval) # Construct the final array if usemask: output = output.view(MaskedArray) output._mask = outputmask if unpack: return output.squeeze().T return output.squeeze() def ndfromtxt(fname, **kwargs): """ Load ASCII data stored in a file and return it as a single array. Parameters ---------- fname, kwargs : For a description of input parameters, see `genfromtxt`. See Also -------- numpy.genfromtxt : generic function. """ kwargs['usemask'] = False return genfromtxt(fname, **kwargs) def mafromtxt(fname, **kwargs): """ Load ASCII data stored in a text file and return a masked array. Parameters ---------- fname, kwargs : For a description of input parameters, see `genfromtxt`. See Also -------- numpy.genfromtxt : generic function to load ASCII data. """ kwargs['usemask'] = True return genfromtxt(fname, **kwargs) def recfromtxt(fname, **kwargs): """ Load ASCII data from a file and return it in a record array. If ``usemask=False`` a standard `recarray` is returned, if ``usemask=True`` a MaskedRecords array is returned. Parameters ---------- fname, kwargs : For a description of input parameters, see `genfromtxt`. See Also -------- numpy.genfromtxt : generic function Notes ----- By default, `dtype` is None, which means that the data-type of the output array will be determined from the data. """ kwargs.setdefault("dtype", None) usemask = kwargs.get('usemask', False) output = genfromtxt(fname, **kwargs) if usemask: from numpy.ma.mrecords import MaskedRecords output = output.view(MaskedRecords) else: output = output.view(np.recarray) return output def recfromcsv(fname, **kwargs): """ Load ASCII data stored in a comma-separated file. The returned array is a record array (if ``usemask=False``, see `recarray`) or a masked record array (if ``usemask=True``, see `ma.mrecords.MaskedRecords`). Parameters ---------- fname, kwargs : For a description of input parameters, see `genfromtxt`. See Also -------- numpy.genfromtxt : generic function to load ASCII data. Notes ----- By default, `dtype` is None, which means that the data-type of the output array will be determined from the data. """ # Set default kwargs for genfromtxt as relevant to csv import. kwargs.setdefault("case_sensitive", "lower") kwargs.setdefault("names", True) kwargs.setdefault("delimiter", ",") kwargs.setdefault("dtype", None) output = genfromtxt(fname, **kwargs) usemask = kwargs.get("usemask", False) if usemask: from numpy.ma.mrecords import MaskedRecords output = output.view(MaskedRecords) else: output = output.view(np.recarray) return output
bsd-3-clause
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 646, 7975, 199, 646, 3598, 199, 646, 13852, 199, 504, 4182, 492, 1242, 7416, 199, 199, 646, 2680, 465, 980, 199, 504, 1275, 492, 1475, 199, 504, 13653, 21208, 492, 24300, 199, 504, 2680, 14, 1018, 14, 23698, 492, 1706, 5609, 12, 7787, 5609, 199, 504, 13653, 73, 3459, 1446, 492, 334, 272, 7030, 26407, 12, 2812, 8640, 12, 2624, 11907, 12, 11801, 351, 547, 12, 272, 11801, 351, 6432, 547, 12, 1448, 1023, 3849, 12, 485, 374, 63, 875, 63, 2930, 12, 965, 63, 6376, 63, 955, 12, 272, 9378, 63, 2271, 12, 8837, 63, 2271, 12, 485, 2394, 63, 475, 63, 354, 272, 776, 199, 199, 504, 2680, 14, 5819, 492, 334, 272, 28217, 12, 465, 495, 12, 28217, 63, 6376, 12, 2783, 12, 7116, 12, 2649, 272, 776, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 492, 5927, 199, 2836, 26, 272, 492, 17572, 465, 5927, 272, 687, 6466, 63, 10372, 492, 2341, 199, 199, 3640, 275, 5927, 14, 3640, 199, 199, 363, 452, 363, 275, 359, 272, 283, 23374, 386, 400, 297, 283, 27992, 297, 283, 2268, 30439, 297, 283, 977, 30439, 297, 283, 391, 30439, 297, 272, 283, 2761, 30439, 297, 283, 2761, 504, 4737, 297, 283, 912, 297, 283, 3640, 297, 283, 2117, 297, 283, 2117, 90, 297, 272, 283, 2117, 90, 63, 10895, 297, 283, 1389, 5609, 297, 283, 5301, 5609, 297, 283, 504, 3821, 297, 283, 16693, 7, 272, 1622, 421, 199, 533, 699, 643, 5665, 8, 785, 304, 272, 408, 272, 699, 643, 5665, 8, 1113, 9, 339, 7905, 2225, 3648, 13, 15203, 370, 2312, 280, 3733, 641, 314, 909, 3032, 315, 14, 339, 3897, 272, 4143, 272, 1559, 520, 1021, 1256, 267, 6935, 641, 1314, 2225, 3648, 13, 384, 365, 10585, 14, 339, 6058, 272, 3001, 272, 1306, 687, 2680, 14, 773, 14, 20245, 2308, 492, 699, 643, 5665, 465, 4367, 272, 1306, 1021, 699, 643, 21493, 8, 785, 304, 272, 2263, 258, 347, 636, 6095, 721, 277, 12, 790, 304, 327, 1626, 1256, 402, 699, 643, 5665, 8, 31641, 21493, 9, 272, 2263, 2476, 327, 911, 1240, 642, 1083, 1380, 1263, 272, 2263, 2476, 327, 2225, 3648, 13, 384, 365, 1415, 272, 2263, 260, 754, 275, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 298, 272, 2263, 260, 372, 754, 435, 298, 13297, 3984, 486, 265, 3540, 664, 642, 2, 272, 2263, 272, 1306, 14779, 63, 1113, 275, 699, 643, 21493, 342, 272, 1306, 330, 643, 1113, 275, 4367, 8, 8768, 63, 1113, 9, 272, 1306, 330, 643, 1113, 14, 5006, 63, 16990, 272, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 1265, 3984, 486, 265, 3540, 664, 642, 2, 272, 1306, 330, 643, 1113, 14, 41, 63, 2425, 63, 1235, 63, 25058, 272, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 1265, 3984, 486, 265, 3540, 664, 642, 2, 339, 408, 339, 347, 636, 826, 721, 277, 12, 1559, 304, 267, 327, 3645, 13852, 370, 1852, 653, 80, 90, 1173, 2251, 8775, 461, 701, 2984, 835, 267, 291, 423, 1113, 275, 13852, 14, 3280, 8, 1113, 9, 339, 347, 636, 18480, 721, 277, 12, 790, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 2513, 1113, 5832, 498, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 498, 9, 339, 347, 636, 694, 721, 277, 304, 267, 408, 267, 3447, 5921, 2935, 8, 19430, 1113, 9, 370, 769, 314, 1584, 315, 376, 653, 80, 90, 1173, 14, 398, 961, 2597, 22741, 5174, 13, 13207, 315, 376, 12693, 503, 16243, 14, 267, 408, 267, 372, 909, 855, 18480, 721, 277, 12, 2513, 1113, 1959, 1612, 342, 421, 199, 318, 10392, 63, 3702, 2031, 589, 12, 1011, 958, 304, 272, 492, 10392, 272, 2074, 459, 3306, 8674, 772, 418, 275, 715, 272, 372, 10392, 14, 15016, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 653, 80, 90, 1173, 8, 785, 304, 272, 408, 272, 653, 80, 90, 1173, 8, 9430, 9, 339, 437, 2600, 13, 2930, 909, 543, 9617, 13, 8786, 402, 1584, 315, 314, 3482, 1915, 272, 6359, 2741, 641, 14538, 14, 339, 658, 46, 80, 90, 1173, 64, 365, 1202, 370, 2248, 1584, 315, 314, 20602, 21502, 1590, 90, 1040, 666, 6359, 272, 1475, 14, 2779, 15194, 626, 1584, 315, 314, 6359, 1172, 282, 21502, 20245, 1040, 3329, 12, 272, 1163, 1584, 787, 5525, 14, 339, 710, 6572, 436, 570, 3326, 787, 29667, 3444, 6511, 641, 1902, 272, 2312, 4484, 2879, 1808, 1124, 1113, 459, 498, 418, 1040, 503, 2225, 4237, 1808, 272, 1124, 1113, 14, 70, 14, 498, 4345, 437, 769, 402, 1006, 1584, 334, 7395, 21502, 20245, 1040, 5478, 9, 883, 272, 506, 15884, 543, 1124, 1113, 14, 1725, 1040, 436, 314, 26755, 909, 6337, 1808, 272, 1124, 1113, 14, 3065, 4345, 339, 9382, 272, 4143, 272, 1584, 520, 769, 402, 620, 267, 3820, 402, 1006, 1584, 315, 314, 6359, 543, 282, 21502, 20245, 1040, 3329, 14, 272, 3482, 520, 26755, 1256, 267, 710, 26755, 909, 10038, 543, 314, 3482, 1915, 6359, 14, 272, 289, 520, 699, 643, 5665, 1256, 267, 1626, 909, 641, 1314, 2225, 883, 506, 10585, 465, 376, 13943, 267, 370, 2312, 4484, 2879, 641, 314, 658, 46, 80, 90, 1173, 64, 1256, 6337, 14, 272, 2040, 63, 8092, 520, 2155, 12, 2716, 267, 9812, 8697, 18731, 666, 14, 3758, 26, 715, 272, 5927, 63, 958, 520, 1211, 12, 2716, 267, 10961, 4252, 2368, 370, 986, 641, 370, 5927, 14, 912, 14, 267, 5723, 787, 1454, 2997, 1380, 8697, 909, 6572, 6290, 641, 267, 2018, 499, 1380, 1808, 2018, 650, 14, 339, 3897, 272, 4143, 272, 8289, 520, 570, 503, 620, 267, 710, 3482, 1915, 6359, 370, 1551, 14, 961, 365, 1902, 282, 570, 13, 2930, 909, 267, 503, 282, 1059, 3035, 314, 931, 370, 314, 6359, 14, 272, 5705, 63, 9430, 520, 2155, 12, 2716, 267, 7480, 653, 80, 90, 1173, 1077, 4002, 314, 570, 2429, 14, 267, 15127, 626, 658, 9430, 64, 365, 282, 570, 13 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 646, 7975, 199, 646, 3598, 199, 646, 13852, 199, 504, 4182, 492, 1242, 7416, 199, 199, 646, 2680, 465, 980, 199, 504, 1275, 492, 1475, 199, 504, 13653, 21208, 492, 24300, 199, 504, 2680, 14, 1018, 14, 23698, 492, 1706, 5609, 12, 7787, 5609, 199, 504, 13653, 73, 3459, 1446, 492, 334, 272, 7030, 26407, 12, 2812, 8640, 12, 2624, 11907, 12, 11801, 351, 547, 12, 272, 11801, 351, 6432, 547, 12, 1448, 1023, 3849, 12, 485, 374, 63, 875, 63, 2930, 12, 965, 63, 6376, 63, 955, 12, 272, 9378, 63, 2271, 12, 8837, 63, 2271, 12, 485, 2394, 63, 475, 63, 354, 272, 776, 199, 199, 504, 2680, 14, 5819, 492, 334, 272, 28217, 12, 465, 495, 12, 28217, 63, 6376, 12, 2783, 12, 7116, 12, 2649, 272, 776, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 492, 5927, 199, 2836, 26, 272, 492, 17572, 465, 5927, 272, 687, 6466, 63, 10372, 492, 2341, 199, 199, 3640, 275, 5927, 14, 3640, 199, 199, 363, 452, 363, 275, 359, 272, 283, 23374, 386, 400, 297, 283, 27992, 297, 283, 2268, 30439, 297, 283, 977, 30439, 297, 283, 391, 30439, 297, 272, 283, 2761, 30439, 297, 283, 2761, 504, 4737, 297, 283, 912, 297, 283, 3640, 297, 283, 2117, 297, 283, 2117, 90, 297, 272, 283, 2117, 90, 63, 10895, 297, 283, 1389, 5609, 297, 283, 5301, 5609, 297, 283, 504, 3821, 297, 283, 16693, 7, 272, 1622, 421, 199, 533, 699, 643, 5665, 8, 785, 304, 272, 408, 272, 699, 643, 5665, 8, 1113, 9, 339, 7905, 2225, 3648, 13, 15203, 370, 2312, 280, 3733, 641, 314, 909, 3032, 315, 14, 339, 3897, 272, 4143, 272, 1559, 520, 1021, 1256, 267, 6935, 641, 1314, 2225, 3648, 13, 384, 365, 10585, 14, 339, 6058, 272, 3001, 272, 1306, 687, 2680, 14, 773, 14, 20245, 2308, 492, 699, 643, 5665, 465, 4367, 272, 1306, 1021, 699, 643, 21493, 8, 785, 304, 272, 2263, 258, 347, 636, 6095, 721, 277, 12, 790, 304, 327, 1626, 1256, 402, 699, 643, 5665, 8, 31641, 21493, 9, 272, 2263, 2476, 327, 911, 1240, 642, 1083, 1380, 1263, 272, 2263, 2476, 327, 2225, 3648, 13, 384, 365, 1415, 272, 2263, 260, 754, 275, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 298, 272, 2263, 260, 372, 754, 435, 298, 13297, 3984, 486, 265, 3540, 664, 642, 2, 272, 2263, 272, 1306, 14779, 63, 1113, 275, 699, 643, 21493, 342, 272, 1306, 330, 643, 1113, 275, 4367, 8, 8768, 63, 1113, 9, 272, 1306, 330, 643, 1113, 14, 5006, 63, 16990, 272, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 1265, 3984, 486, 265, 3540, 664, 642, 2, 272, 1306, 330, 643, 1113, 14, 41, 63, 2425, 63, 1235, 63, 25058, 272, 298, 6586, 78, 1133, 17247, 4052, 1265, 2934, 12, 1265, 3984, 486, 265, 3540, 664, 642, 2, 339, 408, 339, 347, 636, 826, 721, 277, 12, 1559, 304, 267, 327, 3645, 13852, 370, 1852, 653, 80, 90, 1173, 2251, 8775, 461, 701, 2984, 835, 267, 291, 423, 1113, 275, 13852, 14, 3280, 8, 1113, 9, 339, 347, 636, 18480, 721, 277, 12, 790, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 2513, 1113, 5832, 498, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 498, 9, 339, 347, 636, 694, 721, 277, 304, 267, 408, 267, 3447, 5921, 2935, 8, 19430, 1113, 9, 370, 769, 314, 1584, 315, 376, 653, 80, 90, 1173, 14, 398, 961, 2597, 22741, 5174, 13, 13207, 315, 376, 12693, 503, 16243, 14, 267, 408, 267, 372, 909, 855, 18480, 721, 277, 12, 2513, 1113, 1959, 1612, 342, 421, 199, 318, 10392, 63, 3702, 2031, 589, 12, 1011, 958, 304, 272, 492, 10392, 272, 2074, 459, 3306, 8674, 772, 418, 275, 715, 272, 372, 10392, 14, 15016, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 653, 80, 90, 1173, 8, 785, 304, 272, 408, 272, 653, 80, 90, 1173, 8, 9430, 9, 339, 437, 2600, 13, 2930, 909, 543, 9617, 13, 8786, 402, 1584, 315, 314, 3482, 1915, 272, 6359, 2741, 641, 14538, 14, 339, 658, 46, 80, 90, 1173, 64, 365, 1202, 370, 2248, 1584, 315, 314, 20602, 21502, 1590, 90, 1040, 666, 6359, 272, 1475, 14, 2779, 15194, 626, 1584, 315, 314, 6359, 1172, 282, 21502, 20245, 1040, 3329, 12, 272, 1163, 1584, 787, 5525, 14, 339, 710, 6572, 436, 570, 3326, 787, 29667, 3444, 6511, 641, 1902, 272, 2312, 4484, 2879, 1808, 1124, 1113, 459, 498, 418, 1040, 503, 2225, 4237, 1808, 272, 1124, 1113, 14, 70, 14, 498, 4345, 437, 769, 402, 1006, 1584, 334, 7395, 21502, 20245, 1040, 5478, 9, 883, 272, 506, 15884, 543, 1124, 1113, 14, 1725, 1040, 436, 314, 26755, 909, 6337, 1808, 272, 1124, 1113, 14, 3065, 4345, 339, 9382, 272, 4143, 272, 1584, 520, 769, 402, 620, 267, 3820, 402, 1006, 1584, 315, 314, 6359, 543, 282, 21502, 20245, 1040, 3329, 14, 272, 3482, 520, 26755, 1256, 267, 710, 26755, 909, 10038, 543, 314, 3482, 1915, 6359, 14, 272, 289, 520, 699, 643, 5665, 1256, 267, 1626, 909, 641, 1314, 2225, 883, 506, 10585, 465, 376, 13943, 267, 370, 2312, 4484, 2879, 641, 314, 658, 46, 80, 90, 1173, 64, 1256, 6337, 14, 272, 2040, 63, 8092, 520, 2155, 12, 2716, 267, 9812, 8697, 18731, 666, 14, 3758, 26, 715, 272, 5927, 63, 958, 520, 1211, 12, 2716, 267, 10961, 4252, 2368, 370, 986, 641, 370, 5927, 14, 912, 14, 267, 5723, 787, 1454, 2997, 1380, 8697, 909, 6572, 6290, 641, 267, 2018, 499, 1380, 1808, 2018, 650, 14, 339, 3897, 272, 4143, 272, 8289, 520, 570, 503, 620, 267, 710, 3482, 1915, 6359, 370, 1551, 14, 961, 365, 1902, 282, 570, 13, 2930, 909, 267, 503, 282, 1059, 3035, 314, 931, 370, 314, 6359, 14, 272, 5705, 63, 9430, 520, 2155, 12, 2716, 267, 7480, 653, 80, 90, 1173, 1077, 4002, 314, 570, 2429, 14, 267, 15127, 626, 658, 9430, 64, 365, 282, 570, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
qusp/orange3
Orange/widgets/utils/scaling.py
1
25636
from datetime import time import sys import random import numpy as np import Orange from Orange.data import Table, ContinuousVariable, DiscreteVariable from Orange.statistics.basic_stats import DomainBasicStats from Orange.widgets.settings import Setting from Orange.widgets.utils.datacaching import getCached, setCached # noinspection PyBroadException def checksum(x): if x is None: return None try: return x.checksum() except: return float('nan') def get_variable_values_sorted(variable): """ Return a list of sorted values for given attribute, if all its values can be cast to int's. """ if isinstance(variable, ContinuousVariable): return [] try: return sorted(variable.values, key=int) except ValueError: return variable.values def get_variable_value_indices(variable, sort_values=True): """ Create a dictionary with given variable. Keys are variable values, values are indices (transformed from string to int); in case all values are integers, we also sort them. """ if isinstance(variable, ContinuousVariable): return {} if sort_values: values = get_variable_values_sorted(variable) else: values = variable.values return {value: i for i, value in enumerate(values)} class ScaleData: jitter_size = Setting(10) jitter_continuous = Setting(False) def __init__(self): self.raw_data = None # input data self.attribute_names = [] # list of attribute names from self.raw_data self.attribute_name_index = {} # dict with indices to attributes self.attribute_flip_info = {} # dictionary with attrName: 0/1 attribute is flipped or not self.data_has_class = False self.data_has_continuous_class = False self.data_has_discrete_class = False self.data_class_name = None self.data_domain = None self.data_class_index = None self.have_data = False self.jitter_seed = 0 self.attr_values = {} self.domain_data_stat = [] self.original_data = None # input (nonscaled) data in a numpy array self.scaled_data = None # scaled data to the interval 0-1 self.no_jittering_scaled_data = None self.valid_data_array = None def rescale_data(self): """ Force the existing data to be rescaled due to changes like jitter_continuous, jitter_size, ... """ self.set_data(self.raw_data, skipIfSame=0) def set_data(self, data, **args): if args.get("skipIfSame", 1): if checksum(data) == checksum(self.raw_data): return self.domain_data_stat = [] self.attr_values = {} self.original_data = None self.scaled_data = None self.no_jittering_scaled_data = None self.valid_data_array = None self.raw_data = None self.have_data = False self.data_has_class = False self.data_has_continuous_class = False self.data_has_discrete_class = False self.data_class_name = None self.data_domain = None self.data_class_index = None if data is None: return full_data = data self.raw_data = data len_data = data and len(data) or 0 self.attribute_names = [attr.name for attr in full_data.domain] self.attribute_name_index = dict([(full_data.domain[i].name, i) for i in range(len(full_data.domain))]) self.attribute_flip_info = {} self.data_domain = full_data.domain self.data_has_class = bool(full_data.domain.class_var) self.data_has_continuous_class = \ isinstance(full_data.domain.class_var, ContinuousVariable) self.data_has_discrete_class = \ isinstance(full_data.domain.class_var, DiscreteVariable) self.data_class_name = self.data_has_class and full_data.domain.class_var.name if self.data_has_class: self.data_class_index = self.attribute_name_index[self.data_class_name] self.have_data = bool(self.raw_data and len(self.raw_data) > 0) self.domain_data_stat = getCached(full_data, DomainBasicStats, (full_data,)) sort_values_for_discrete_attrs = args.get("sort_values_for_discrete_attrs", 1) for index in range(len(full_data.domain)): attr = full_data.domain[index] if isinstance(attr, DiscreteVariable): self.attr_values[attr.name] = [0, len(attr.values)] elif isinstance(attr, ContinuousVariable): self.attr_values[attr.name] = [self.domain_data_stat[index].min, self.domain_data_stat[index].max] if 'no_data' in args: return # the original_data, no_jittering_scaled_data and validArray are arrays # that we can cache so that other visualization widgets don't need to # compute it. The scaled_data on the other hand has to be computed for # each widget separately because of different # jitter_continuous and jitter_size values if getCached(data, "visualizationData"): self.original_data, self.no_jittering_scaled_data, self.valid_data_array = getCached(data, "visualizationData") else: no_jittering_data = np.c_[full_data.X, full_data.Y].T valid_data_array = no_jittering_data != np.NaN original_data = no_jittering_data.copy() for index in range(len(data.domain)): attr = data.domain[index] if isinstance(attr, DiscreteVariable): # see if the values for discrete attributes have to be resorted variable_value_indices = get_variable_value_indices(data.domain[index], sort_values_for_discrete_attrs) if 0 in [i == variable_value_indices[attr.values[i]] for i in range(len(attr.values))]: # make the array a contiguous, otherwise the putmask # function does not work line = no_jittering_data[index].copy() indices = [np.where(line == val, 1, 0) for val in range(len(attr.values))] for i in range(len(attr.values)): np.putmask(line, indices[i], variable_value_indices[attr.values[i]]) no_jittering_data[index] = line # save the changed array original_data[index] = line # reorder also the values in the original data no_jittering_data[index] = ((no_jittering_data[index] * 2.0 + 1.0) / float(2 * len(attr.values))) elif isinstance(attr, ContinuousVariable): diff = self.domain_data_stat[index].max - self.domain_data_stat[ index].min or 1 # if all values are the same then prevent division by zero no_jittering_data[index] = (no_jittering_data[index] - self.domain_data_stat[index].min) / diff self.original_data = original_data self.no_jittering_scaled_data = no_jittering_data self.valid_data_array = valid_data_array if data: setCached(data, "visualizationData", (self.original_data, self.no_jittering_scaled_data, self.valid_data_array)) # compute the scaled_data arrays scaled_data = self.no_jittering_scaled_data # Random generators for jittering random = np.random.RandomState(seed=self.jitter_seed) rand_seeds = random.random_integers(0, 2 ** 30 - 1, size=len(data.domain)) for index, rseed in zip(list(range(len(data.domain))), rand_seeds): # Need to use a different seed for each feature random = np.random.RandomState(seed=rseed) attr = data.domain[index] if isinstance(attr, DiscreteVariable): scaled_data[index] += (self.jitter_size / (50.0 * max(1, len(attr.values)))) * \ (random.rand(len(full_data)) - 0.5) elif isinstance(attr, ContinuousVariable) and self.jitter_continuous: scaled_data[index] += self.jitter_size / 50.0 * (0.5 - random.rand(len(full_data))) scaled_data[index] = np.absolute(scaled_data[index]) # fix values below zero ind = np.where(scaled_data[index] > 1.0, 1, 0) # fix values above 1 np.putmask(scaled_data[index], ind, 2.0 - np.compress(ind, scaled_data[index])) self.scaled_data = scaled_data[:, :len_data] def scale_example_value(self, instance, index): """ Scale instance's value at index index to a range between 0 and 1 with respect to self.raw_data. """ if instance[index].isSpecial(): print("Warning: scaling instance with missing value") return 0.5 if isinstance(instance.domain[index], DiscreteVariable): d = get_variable_value_indices(instance.domain[index]) return (d[instance[index].value] * 2 + 1) / float(2 * len(d)) elif isinstance(instance.domain[index], ContinuousVariable): diff = self.domain_data_stat[index].max - self.domain_data_stat[index].min if diff == 0: diff = 1 # if all values are the same then prevent division by zero return (instance[index] - self.domain_data_stat[index].min) / diff def get_attribute_label(self, attr_name): if self.attribute_flip_info.get(attr_name, 0) and \ isinstance(self.data_domain[attr_name], ContinuousVariable): return "-" + attr_name return attr_name def flip_attribute(self, attr_name): if attr_name not in self.attribute_names: return 0 if isinstance(self.data_domain[attr_name], DiscreteVariable): return 0 index = self.attribute_name_index[attr_name] self.attribute_flip_info[attr_name] = 1 - self.attribute_flip_info.get(attr_name, 0) if isinstance(self.data_domain[attr_name], ContinuousVariable): self.attr_values[attr_name] = [-self.attr_values[attr_name][1], -self.attr_values[attr_name][0]] self.scaled_data[index] = 1 - self.scaled_data[index] self.no_jittering_scaled_data[index] = 1 - self.no_jittering_scaled_data[index] return 1 def get_min_max_val(self, attr): if type(attr) == int: attr = self.attribute_names[attr] diff = self.attr_values[attr][1] - self.attr_values[attr][0] return diff or 1.0 def get_valid_list(self, indices, also_class_if_exists=1): """ Get array of 0 and 1 of len = len(self.raw_data). If there is a missing value at any attribute in indices return 0 for that instance. """ if self.valid_data_array is None or len(self.valid_data_array) == 0: return np.array([], np.bool) inds = indices[:] if also_class_if_exists and self.data_has_class: inds.append(self.data_class_index) selected_array = self.valid_data_array.take(inds, axis=0) arr = np.add.reduce(selected_array) return np.equal(arr, len(inds)) def get_valid_indices(self, indices): """ Get array with numbers that represent the instance indices that have a valid data value. """ valid_list = self.get_valid_list(indices) return np.nonzero(valid_list)[0] def rnd_correction(self, max): """ Return a number from -max to max. """ return (random.random() - 0.5) * 2 * max class ScaleScatterPlotData(ScaleData): def get_original_data(self, indices): data = self.original_data.take(indices, axis = 0) for i, ind in enumerate(indices): [minVal, maxVal] = self.attr_values[self.data_domain[ind].name] if isinstance(self.data_domain[ind], DiscreteVariable): data[i] += (self.jitter_size/50.0)*(np.random.random(len(self.raw_data)) - 0.5) elif isinstance(self.data_domain[ind], ContinuousVariable) and self.jitter_continuous: data[i] += (self.jitter_size/(50.0*(maxVal-minVal or 1)))*(np.random.random(len(self.raw_data)) - 0.5) return data getOriginalData = get_original_data # @deprecated_keywords({"xAttr": "xattr", "yAttr": "yattr"}) def get_xy_data_positions(self, xattr, yattr, filter_valid=False, copy=True): """ Create x-y projection of attributes in attrlist. """ xattr_index = self.attribute_name_index[xattr] yattr_index = self.attribute_name_index[yattr] xattr_index = self.attribute_name_index[xattr] yattr_index = self.attribute_name_index[yattr] if filter_valid is True: filter_valid = self.get_valid_list([xattr_index, yattr_index]) if isinstance(filter_valid, np.ndarray): xdata = self.scaled_data[xattr_index, filter_valid] ydata = self.scaled_data[yattr_index, filter_valid] elif copy: xdata = self.scaled_data[xattr_index].copy() ydata = self.scaled_data[yattr_index].copy() else: xdata = self.scaled_data[xattr_index] ydata = self.scaled_data[yattr_index] if isinstance(self.data_domain[xattr_index], DiscreteVariable): xdata *= len(self.data_domain[xattr_index].values) xdata -= 0.5 else: xdata *= self.attr_values[xattr][1] - self.attr_values[xattr][0] xdata += float(self.attr_values[xattr][0]) if isinstance(self.data_domain[yattr_index], DiscreteVariable): ydata *= len(self.data_domain[yattr_index].values) ydata -= 0.5 else: ydata *= self.attr_values[yattr][1] - self.attr_values[yattr][0] ydata += float(self.attr_values[yattr][0]) return xdata, ydata getXYDataPositions = get_xy_data_positions # @deprecated_keywords({"attrIndices": "attr_indices", # "settingsDict": "settings_dict"}) def get_projected_point_position(self, attr_indices, values, **settings_dict): """ For attributes in attr_indices and values of these attributes in values compute point positions this function has more sense in radviz and polyviz methods. settings_dict has to be because radviz and polyviz have this parameter. """ return values getProjectedPointPosition = get_projected_point_position # @deprecated_keywords({"attrIndices": "attr_indices", # "settingsDict": "settings_dict"}) def create_projection_as_example_table(self, attr_indices, **settings_dict): """ Create the projection of attribute indices given in attr_indices and create an example table with it. """ if self.data_has_class: domain = settings_dict.get("domain") or \ Orange.data.Domain([Orange.feature.Continuous(self.data_domain[attr_indices[0]].name), Orange.feature.Continuous(self.data_domain[attr_indices[1]].name), Orange.feature.Discrete(self.data_domain.class_var.name, values = get_variable_values_sorted(self.data_domain.class_var))]) else: domain = settings_dict.get("domain") or \ Orange.data.Domain([Orange.feature.Continuous(self.data_domain[attr_indices[0]].name), Orange.feature.Continuous(self.data_domain[attr_indices[1]].name)]) data = self.create_projection_as_numeric_array(attr_indices, **settings_dict) if data != None: return Orange.data.Table(domain, data) else: return Orange.data.Table(domain) createProjectionAsExampleTable = create_projection_as_example_table # @deprecated_keywords({"attrIndices": "attr_indices", # "settingsDict": "settings_dict"}) def create_projection_as_example_table_3D(self, attr_indices, **settings_dict): """ Create the projection of attribute indices given in attr_indices and create an example table with it. """ if self.data_has_class: domain = settings_dict.get("domain") or \ Orange.data.Domain([Orange.feature.Continuous(self.data_domain[attr_indices[0]].name), Orange.feature.Continuous(self.data_domain[attr_indices[1]].name), Orange.feature.Continuous(self.data_domain[attr_indices[2]].name), Orange.feature.Discrete(self.data_domain.class_var.name, values = get_variable_values_sorted(self.data_domain.class_var))]) else: domain = settings_dict.get("domain") or \ Orange.data.Domain([Orange.feature.Continuous(self.data_domain[attr_indices[0]].name), Orange.feature.Continuous(self.data_domain[attr_indices[1]].name), Orange.feature.Continuous(self.data_domain[attr_indices[2]].name)]) data = self.create_projection_as_numeric_array_3D(attr_indices, **settings_dict) if data != None: return Orange.data.Table(domain, data) else: return Orange.data.Table(domain) createProjectionAsExampleTable3D = create_projection_as_example_table_3D # @deprecated_keywords({"attrIndices": "attr_indices", # "settingsDict": "settings_dict", # "validData": "valid_data", # "classList": "class_list", # "jutterSize": "jitter_size"}) def create_projection_as_numeric_array(self, attr_indices, **settings_dict): valid_data = settings_dict.get("valid_data") class_list = settings_dict.get("class_list") jitter_size = settings_dict.get("jitter_size", 0.0) if valid_data == None: valid_data = self.get_valid_list(attr_indices) if sum(valid_data) == 0: return None if class_list == None and self.data_has_class: class_list = self.original_data[self.data_class_index] xarray = self.no_jittering_scaled_data[attr_indices[0]] yarray = self.no_jittering_scaled_data[attr_indices[1]] if jitter_size > 0.0: xarray += (np.random.random(len(xarray))-0.5)*jitter_size yarray += (np.random.random(len(yarray))-0.5)*jitter_size if class_list != None: data = np.compress(valid_data, np.array((xarray, yarray, class_list)), axis = 1) else: data = np.compress(valid_data, np.array((xarray, yarray)), axis = 1) data = np.transpose(data) return data createProjectionAsNumericArray = create_projection_as_numeric_array # @deprecated_keywords({"attrIndices": "attr_indices", # "settingsDict": "settings_dict", # "validData": "valid_data", # "classList": "class_list", # "jutterSize": "jitter_size"}) def create_projection_as_numeric_array_3D(self, attr_indices, **settings_dict): valid_data = settings_dict.get("valid_data") class_list = settings_dict.get("class_list") jitter_size = settings_dict.get("jitter_size", 0.0) if valid_data == None: valid_data = self.get_valid_list(attr_indices) if sum(valid_data) == 0: return None if class_list == None and self.data_has_class: class_list = self.original_data[self.data_class_index] xarray = self.no_jittering_scaled_data[attr_indices[0]] yarray = self.no_jittering_scaled_data[attr_indices[1]] zarray = self.no_jittering_scaled_data[attr_indices[2]] if jitter_size > 0.0: xarray += (np.random.random(len(xarray))-0.5)*jitter_size yarray += (np.random.random(len(yarray))-0.5)*jitter_size zarray += (np.random.random(len(zarray))-0.5)*jitter_size if class_list != None: data = np.compress(valid_data, np.array((xarray, yarray, zarray, class_list)), axis = 1) else: data = np.compress(valid_data, np.array((xarray, yarray, zarray)), axis = 1) data = np.transpose(data) return data createProjectionAsNumericArray3D = create_projection_as_numeric_array_3D # @deprecated_keywords({"attributeNameOrder": "attribute_name_order", # "addResultFunct": "add_result_funct"}) def get_optimal_clusters(self, attribute_name_order, add_result_funct): if not self.data_has_class or self.data_has_continuous_class: return jitter_size = 0.001 * self.clusterOptimization.jitterDataBeforeTriangulation domain = Orange.data.Domain([Orange.feature.Continuous("xVar"), Orange.feature.Continuous("yVar"), self.data_domain.class_var]) # init again, in case that the attribute ordering took too much time self.scatterWidget.progressBarInit() start_time = time.time() count = len(attribute_name_order)*(len(attribute_name_order)-1)/2 test_index = 0 for i in range(len(attribute_name_order)): for j in range(i): try: attr1 = self.attribute_name_index[attribute_name_order[j]] attr2 = self.attribute_name_index[attribute_name_order[i]] test_index += 1 if self.clusterOptimization.isOptimizationCanceled(): secs = time.time() - start_time self.clusterOptimization.setStatusBarText("Evaluation stopped (evaluated %d projections in %d min, %d sec)" % (test_index, secs/60, secs%60)) self.scatterWidget.progressBarFinished() return data = self.create_projection_as_example_table([attr1, attr2], domain = domain, jitter_size = jitter_size) graph, valuedict, closuredict, polygon_vertices_dict, enlarged_closure_dict, other_dict = self.clusterOptimization.evaluateClusters(data) all_value = 0.0 classes_dict = {} for key in valuedict.keys(): add_result_funct(valuedict[key], closuredict[key], polygon_vertices_dict[key], [attribute_name_order[i], attribute_name_order[j]], int(graph.objects[polygon_vertices_dict[key][0]].getclass()), enlarged_closure_dict[key], other_dict[key]) classes_dict[key] = int(graph.objects[polygon_vertices_dict[key][0]].getclass()) all_value += valuedict[key] add_result_funct(all_value, closuredict, polygon_vertices_dict, [attribute_name_order[i], attribute_name_order[j]], classes_dict, enlarged_closure_dict, other_dict) # add all the clusters self.clusterOptimization.setStatusBarText("Evaluated %d projections..." % (test_index)) self.scatterWidget.progressBarSet(100.0*test_index/float(count)) del data, graph, valuedict, closuredict, polygon_vertices_dict, enlarged_closure_dict, other_dict, classes_dict except: type, val, traceback = sys.exc_info() sys.excepthook(type, val, traceback) # print the exception secs = time.time() - start_time self.clusterOptimization.setStatusBarText("Finished evaluation (evaluated %d projections in %d min, %d sec)" % (test_index, secs/60, secs%60)) self.scatterWidget.progressBarFinished() getOptimalClusters = get_optimal_clusters
bsd-2-clause
[ 504, 2197, 492, 900, 199, 646, 984, 199, 646, 2196, 199, 646, 2680, 465, 980, 199, 646, 593, 1842, 199, 199, 504, 593, 1842, 14, 576, 492, 6957, 12, 1448, 1346, 7514, 2773, 12, 5289, 7564, 2773, 199, 504, 593, 1842, 14, 13724, 14, 4316, 63, 3200, 492, 14061, 6845, 8257, 199, 504, 593, 1842, 14, 8583, 14, 1751, 492, 13510, 199, 504, 593, 1842, 14, 8583, 14, 1208, 14, 576, 22738, 492, 664, 16138, 12, 663, 16138, 421, 199, 3, 30870, 1611, 34, 5063, 1726, 199, 318, 9040, 8, 88, 304, 272, 340, 671, 365, 488, 26, 267, 372, 488, 272, 862, 26, 267, 372, 671, 14, 8928, 342, 272, 871, 26, 267, 372, 2069, 360, 4304, 358, 421, 199, 318, 664, 63, 1975, 63, 1459, 63, 5917, 8, 1975, 304, 272, 408, 272, 1432, 282, 769, 402, 3355, 1338, 367, 1627, 2225, 12, 340, 1006, 2399, 1338, 883, 506, 272, 9106, 370, 1109, 1159, 14, 272, 408, 272, 340, 1228, 8, 1975, 12, 1448, 1346, 7514, 2773, 304, 267, 372, 942, 272, 862, 26, 267, 372, 3355, 8, 1975, 14, 1459, 12, 790, 29, 442, 9, 272, 871, 1722, 26, 267, 372, 1750, 14, 1459, 421, 199, 318, 664, 63, 1975, 63, 585, 63, 4108, 8, 1975, 12, 4069, 63, 1459, 29, 549, 304, 272, 408, 272, 2790, 282, 2600, 543, 1627, 1750, 14, 17276, 787, 1750, 1338, 12, 1338, 272, 787, 4918, 334, 20209, 687, 1059, 370, 1109, 2736, 315, 1930, 1006, 1338, 787, 272, 9446, 12, 781, 2597, 4069, 3062, 14, 272, 408, 272, 340, 1228, 8, 1975, 12, 1448, 1346, 7514, 2773, 304, 267, 372, 1052, 272, 340, 4069, 63, 1459, 26, 267, 1338, 275, 664, 63, 1975, 63, 1459, 63, 5917, 8, 1975, 9, 272, 587, 26, 267, 1338, 275, 1750, 14, 1459, 272, 372, 469, 585, 26, 284, 367, 284, 12, 574, 315, 3874, 8, 1459, 6769, 421, 199, 533, 22869, 1451, 26, 272, 31292, 351, 63, 890, 275, 13510, 8, 709, 9, 272, 31292, 351, 63, 23458, 275, 13510, 8, 797, 9, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1773, 63, 576, 275, 488, 3698, 327, 1324, 666, 267, 291, 14, 3215, 63, 1247, 275, 942, 259, 327, 769, 402, 2225, 1561, 687, 291, 14, 1773, 63, 576, 267, 291, 14, 3215, 63, 354, 63, 1080, 275, 1052, 221, 327, 1211, 543, 4918, 370, 3004, 267, 291, 14, 3215, 63, 16114, 63, 815, 275, 1052, 257, 327, 2600, 543, 1921, 985, 26, 378, 15, 17, 2225, 365, 18761, 1915, 503, 440, 398, 291, 14, 576, 63, 1989, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 756, 267, 291, 14, 576, 63, 533, 63, 354, 275, 488, 267, 291, 14, 576, 63, 2261, 275, 488, 267, 291, 14, 576, 63, 533, 63, 1080, 275, 488, 267, 291, 14, 7804, 63, 576, 275, 756, 398, 291, 14, 17676, 351, 63, 5176, 275, 378, 398, 291, 14, 962, 63, 1459, 275, 1052, 267, 291, 14, 2261, 63, 576, 63, 3736, 275, 942, 267, 291, 14, 5043, 63, 576, 275, 488, 259, 327, 1324, 334, 2865, 15120, 9, 666, 315, 282, 2680, 1625, 267, 291, 14, 15120, 63, 576, 275, 488, 263, 327, 17923, 666, 370, 314, 6252, 378, 13, 17, 267, 291, 14, 889, 63, 17676, 351, 316, 63, 15120, 63, 576, 275, 488, 267, 291, 14, 1078, 63, 576, 63, 1144, 275, 488, 339, 347, 522, 2357, 63, 576, 8, 277, 304, 267, 408, 267, 18771, 314, 3411, 666, 370, 506, 522, 696, 1146, 7037, 370, 4493, 2839, 267, 31292, 351, 63, 23458, 12, 31292, 351, 63, 890, 12, 2263, 267, 408, 267, 291, 14, 409, 63, 576, 8, 277, 14, 1773, 63, 576, 12, 3372, 3917, 8479, 29, 16, 9, 339, 347, 663, 63, 576, 8, 277, 12, 666, 12, 1011, 589, 304, 267, 340, 1249, 14, 362, 480, 15118, 8479, 401, 413, 304, 288, 340, 9040, 8, 576, 9, 508, 9040, 8, 277, 14, 1773, 63, 576, 304, 355, 372, 398, 291, 14, 2261, 63, 576, 63, 3736, 275, 942, 267, 291, 14, 962, 63, 1459, 275, 1052, 267, 291, 14, 5043, 63, 576, 275, 488, 267, 291, 14, 15120, 63, 576, 275, 488, 267, 291, 14, 889, 63, 17676, 351, 316, 63, 15120, 63, 576, 275, 488, 267, 291, 14, 1078, 63, 576, 63, 1144, 275, 488, 398, 291, 14, 1773, 63, 576, 275, 488, 267, 291, 14, 7804, 63, 576, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 756, 267, 291, 14, 576, 63, 533, 63, 354, 275, 488, 267, 291, 14, 576, 63, 2261, 275, 488, 267, 291, 14, 576, 63, 533, 63, 1080, 275, 488, 398, 340, 666, 365, 488, 26, 288, 372, 267, 2615, 63, 576, 275, 666, 267, 291, 14, 1773, 63, 576, 275, 666, 398, 822, 63, 576, 275, 666, 436, 822, 8, 576, 9, 503, 378, 398, 291, 14, 3215, 63, 1247, 275, 359, 962, 14, 354, 367, 1921, 315, 2615, 63, 576, 14, 2261, 61, 267, 291, 14, 3215, 63, 354, 63, 1080, 275, 1211, 7694, 2861, 63, 576, 14, 2261, 59, 73, 1055, 354, 12, 284, 9, 5101, 367, 284, 315, 1425, 8, 552, 8, 2861, 63, 576, 14, 2261, 18229, 267, 291, 14, 3215, 63, 16114, 63, 815, 275, 1052, 398, 291, 14, 576, 63, 2261, 275, 2615, 63, 576, 14, 2261, 267, 291, 14, 576, 63, 1989, 63, 533, 275, 2155, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 9, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 971, 288, 1228, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 12, 1448, 1346, 7514, 2773, 9, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 971, 288, 1228, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 12, 5289, 7564, 2773, 9, 398, 291, 14, 576, 63, 533, 63, 354, 275, 291, 14, 576, 63, 1989 ]
[ 2197, 492, 900, 199, 646, 984, 199, 646, 2196, 199, 646, 2680, 465, 980, 199, 646, 593, 1842, 199, 199, 504, 593, 1842, 14, 576, 492, 6957, 12, 1448, 1346, 7514, 2773, 12, 5289, 7564, 2773, 199, 504, 593, 1842, 14, 13724, 14, 4316, 63, 3200, 492, 14061, 6845, 8257, 199, 504, 593, 1842, 14, 8583, 14, 1751, 492, 13510, 199, 504, 593, 1842, 14, 8583, 14, 1208, 14, 576, 22738, 492, 664, 16138, 12, 663, 16138, 421, 199, 3, 30870, 1611, 34, 5063, 1726, 199, 318, 9040, 8, 88, 304, 272, 340, 671, 365, 488, 26, 267, 372, 488, 272, 862, 26, 267, 372, 671, 14, 8928, 342, 272, 871, 26, 267, 372, 2069, 360, 4304, 358, 421, 199, 318, 664, 63, 1975, 63, 1459, 63, 5917, 8, 1975, 304, 272, 408, 272, 1432, 282, 769, 402, 3355, 1338, 367, 1627, 2225, 12, 340, 1006, 2399, 1338, 883, 506, 272, 9106, 370, 1109, 1159, 14, 272, 408, 272, 340, 1228, 8, 1975, 12, 1448, 1346, 7514, 2773, 304, 267, 372, 942, 272, 862, 26, 267, 372, 3355, 8, 1975, 14, 1459, 12, 790, 29, 442, 9, 272, 871, 1722, 26, 267, 372, 1750, 14, 1459, 421, 199, 318, 664, 63, 1975, 63, 585, 63, 4108, 8, 1975, 12, 4069, 63, 1459, 29, 549, 304, 272, 408, 272, 2790, 282, 2600, 543, 1627, 1750, 14, 17276, 787, 1750, 1338, 12, 1338, 272, 787, 4918, 334, 20209, 687, 1059, 370, 1109, 2736, 315, 1930, 1006, 1338, 787, 272, 9446, 12, 781, 2597, 4069, 3062, 14, 272, 408, 272, 340, 1228, 8, 1975, 12, 1448, 1346, 7514, 2773, 304, 267, 372, 1052, 272, 340, 4069, 63, 1459, 26, 267, 1338, 275, 664, 63, 1975, 63, 1459, 63, 5917, 8, 1975, 9, 272, 587, 26, 267, 1338, 275, 1750, 14, 1459, 272, 372, 469, 585, 26, 284, 367, 284, 12, 574, 315, 3874, 8, 1459, 6769, 421, 199, 533, 22869, 1451, 26, 272, 31292, 351, 63, 890, 275, 13510, 8, 709, 9, 272, 31292, 351, 63, 23458, 275, 13510, 8, 797, 9, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1773, 63, 576, 275, 488, 3698, 327, 1324, 666, 267, 291, 14, 3215, 63, 1247, 275, 942, 259, 327, 769, 402, 2225, 1561, 687, 291, 14, 1773, 63, 576, 267, 291, 14, 3215, 63, 354, 63, 1080, 275, 1052, 221, 327, 1211, 543, 4918, 370, 3004, 267, 291, 14, 3215, 63, 16114, 63, 815, 275, 1052, 257, 327, 2600, 543, 1921, 985, 26, 378, 15, 17, 2225, 365, 18761, 1915, 503, 440, 398, 291, 14, 576, 63, 1989, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 756, 267, 291, 14, 576, 63, 533, 63, 354, 275, 488, 267, 291, 14, 576, 63, 2261, 275, 488, 267, 291, 14, 576, 63, 533, 63, 1080, 275, 488, 267, 291, 14, 7804, 63, 576, 275, 756, 398, 291, 14, 17676, 351, 63, 5176, 275, 378, 398, 291, 14, 962, 63, 1459, 275, 1052, 267, 291, 14, 2261, 63, 576, 63, 3736, 275, 942, 267, 291, 14, 5043, 63, 576, 275, 488, 259, 327, 1324, 334, 2865, 15120, 9, 666, 315, 282, 2680, 1625, 267, 291, 14, 15120, 63, 576, 275, 488, 263, 327, 17923, 666, 370, 314, 6252, 378, 13, 17, 267, 291, 14, 889, 63, 17676, 351, 316, 63, 15120, 63, 576, 275, 488, 267, 291, 14, 1078, 63, 576, 63, 1144, 275, 488, 339, 347, 522, 2357, 63, 576, 8, 277, 304, 267, 408, 267, 18771, 314, 3411, 666, 370, 506, 522, 696, 1146, 7037, 370, 4493, 2839, 267, 31292, 351, 63, 23458, 12, 31292, 351, 63, 890, 12, 2263, 267, 408, 267, 291, 14, 409, 63, 576, 8, 277, 14, 1773, 63, 576, 12, 3372, 3917, 8479, 29, 16, 9, 339, 347, 663, 63, 576, 8, 277, 12, 666, 12, 1011, 589, 304, 267, 340, 1249, 14, 362, 480, 15118, 8479, 401, 413, 304, 288, 340, 9040, 8, 576, 9, 508, 9040, 8, 277, 14, 1773, 63, 576, 304, 355, 372, 398, 291, 14, 2261, 63, 576, 63, 3736, 275, 942, 267, 291, 14, 962, 63, 1459, 275, 1052, 267, 291, 14, 5043, 63, 576, 275, 488, 267, 291, 14, 15120, 63, 576, 275, 488, 267, 291, 14, 889, 63, 17676, 351, 316, 63, 15120, 63, 576, 275, 488, 267, 291, 14, 1078, 63, 576, 63, 1144, 275, 488, 398, 291, 14, 1773, 63, 576, 275, 488, 267, 291, 14, 7804, 63, 576, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 756, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 756, 267, 291, 14, 576, 63, 533, 63, 354, 275, 488, 267, 291, 14, 576, 63, 2261, 275, 488, 267, 291, 14, 576, 63, 533, 63, 1080, 275, 488, 398, 340, 666, 365, 488, 26, 288, 372, 267, 2615, 63, 576, 275, 666, 267, 291, 14, 1773, 63, 576, 275, 666, 398, 822, 63, 576, 275, 666, 436, 822, 8, 576, 9, 503, 378, 398, 291, 14, 3215, 63, 1247, 275, 359, 962, 14, 354, 367, 1921, 315, 2615, 63, 576, 14, 2261, 61, 267, 291, 14, 3215, 63, 354, 63, 1080, 275, 1211, 7694, 2861, 63, 576, 14, 2261, 59, 73, 1055, 354, 12, 284, 9, 5101, 367, 284, 315, 1425, 8, 552, 8, 2861, 63, 576, 14, 2261, 18229, 267, 291, 14, 3215, 63, 16114, 63, 815, 275, 1052, 398, 291, 14, 576, 63, 2261, 275, 2615, 63, 576, 14, 2261, 267, 291, 14, 576, 63, 1989, 63, 533, 275, 2155, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 9, 267, 291, 14, 576, 63, 1989, 63, 23458, 63, 533, 275, 971, 288, 1228, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 12, 1448, 1346, 7514, 2773, 9, 267, 291, 14, 576, 63, 1989, 63, 23591, 63, 533, 275, 971, 288, 1228, 8, 2861, 63, 576, 14, 2261, 14, 533, 63, 1391, 12, 5289, 7564, 2773, 9, 398, 291, 14, 576, 63, 533, 63, 354, 275, 291, 14, 576, 63, 1989, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Jasoning/namebench
nb_third_party/dns/rdtypes/ANY/RP.py
248
3275
# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, 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 dns.exception import dns.rdata import dns.name class RP(dns.rdata.Rdata): """RP record @ivar mbox: The responsible person's mailbox @type mbox: dns.name.Name object @ivar txt: The owner name of a node with TXT records, or the root name if no TXT records are associated with this RP. @type txt: dns.name.Name object @see: RFC 1183""" __slots__ = ['mbox', 'txt'] def __init__(self, rdclass, rdtype, mbox, txt): super(RP, self).__init__(rdclass, rdtype) self.mbox = mbox self.txt = txt def to_text(self, origin=None, relativize=True, **kw): mbox = self.mbox.choose_relativity(origin, relativize) txt = self.txt.choose_relativity(origin, relativize) return "%s %s" % (str(mbox), str(txt)) def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): mbox = tok.get_name() txt = tok.get_name() mbox = mbox.choose_relativity(origin, relativize) txt = txt.choose_relativity(origin, relativize) tok.get_eol() return cls(rdclass, rdtype, mbox, txt) from_text = classmethod(from_text) def to_wire(self, file, compress = None, origin = None): self.mbox.to_wire(file, None, origin) self.txt.to_wire(file, None, origin) def to_digestable(self, origin = None): return self.mbox.to_digestable(origin) + \ self.txt.to_digestable(origin) def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None): (mbox, cused) = dns.name.from_wire(wire[: current + rdlen], current) current += cused rdlen -= cused if rdlen <= 0: raise dns.exception.FormError (txt, cused) = dns.name.from_wire(wire[: current + rdlen], current) if cused != rdlen: raise dns.exception.FormError if not origin is None: mbox = mbox.relativize(origin) txt = txt.relativize(origin) return cls(rdclass, rdtype, mbox, txt) from_wire = classmethod(from_wire) def choose_relativity(self, origin = None, relativize = True): self.mbox = self.mbox.choose_relativity(origin, relativize) self.txt = self.txt.choose_relativity(origin, relativize) def _cmp(self, other): v = cmp(self.mbox, other.mbox) if v == 0: v = cmp(self.txt, other.txt) return v
apache-2.0
[ 3, 1898, 334, 35, 9, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 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, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 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, 646, 6715, 14, 1971, 199, 646, 6715, 14, 23203, 199, 646, 6715, 14, 354, 199, 199, 533, 820, 48, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 18612, 2777, 339, 768, 7725, 333, 1977, 26, 710, 17845, 4954, 1159, 17470, 272, 768, 466, 333, 1977, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 7725, 9444, 26, 710, 5771, 536, 402, 282, 1031, 543, 377, 18926, 5767, 12, 503, 314, 1738, 536, 272, 340, 949, 377, 18926, 5767, 787, 4568, 543, 642, 820, 48, 14, 272, 768, 466, 9444, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 3239, 26, 7329, 413, 12363, 624, 339, 636, 7257, 363, 275, 788, 27201, 297, 283, 2424, 418, 339, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 333, 1977, 12, 9444, 304, 267, 1613, 8, 18612, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 27201, 275, 333, 1977, 267, 291, 14, 2424, 275, 9444, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 333, 1977, 275, 291, 14, 27201, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 9444, 275, 291, 14, 2424, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 2071, 83, 450, 83, 2, 450, 334, 495, 8, 27201, 395, 620, 8, 2424, 430, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 333, 1977, 275, 8431, 14, 362, 63, 354, 342, 267, 9444, 275, 8431, 14, 362, 63, 354, 342, 267, 333, 1977, 275, 333, 1977, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 9444, 275, 9444, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 333, 1977, 12, 9444, 9, 339, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 291, 14, 27201, 14, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 267, 291, 14, 2424, 14, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 372, 291, 14, 27201, 14, 475, 63, 5671, 461, 8, 6493, 9, 435, 971, 288, 291, 14, 2424, 14, 475, 63, 5671, 461, 8, 6493, 9, 339, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 27201, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 5644, 1453, 9, 267, 1453, 847, 286, 2972, 267, 11517, 552, 4862, 286, 2972, 267, 340, 11517, 552, 2695, 378, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 334, 2424, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 5101, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 333, 1977, 275, 333, 1977, 14, 17060, 29282, 8, 6493, 9, 288, 9444, 275, 9444, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 333, 1977, 12, 9444, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63, 17060, 4191, 8, 277, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 291, 14, 27201, 275, 291, 14, 27201, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 291, 14, 2424, 275, 291, 14, 2424, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 339, 347, 485, 5730, 8, 277, 12, 1163, 304, 267, 373, 275, 10467, 8, 277, 14, 27201, 12, 1163, 14, 27201, 9, 267, 340, 373, 508, 378, 26, 288, 373, 275, 10467, 8, 277, 14, 2424, 12, 1163, 14, 2424, 9, 267, 372, 373, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 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, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 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, 646, 6715, 14, 1971, 199, 646, 6715, 14, 23203, 199, 646, 6715, 14, 354, 199, 199, 533, 820, 48, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 18612, 2777, 339, 768, 7725, 333, 1977, 26, 710, 17845, 4954, 1159, 17470, 272, 768, 466, 333, 1977, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 7725, 9444, 26, 710, 5771, 536, 402, 282, 1031, 543, 377, 18926, 5767, 12, 503, 314, 1738, 536, 272, 340, 949, 377, 18926, 5767, 787, 4568, 543, 642, 820, 48, 14, 272, 768, 466, 9444, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 3239, 26, 7329, 413, 12363, 624, 339, 636, 7257, 363, 275, 788, 27201, 297, 283, 2424, 418, 339, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 333, 1977, 12, 9444, 304, 267, 1613, 8, 18612, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 27201, 275, 333, 1977, 267, 291, 14, 2424, 275, 9444, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 333, 1977, 275, 291, 14, 27201, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 9444, 275, 291, 14, 2424, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 2071, 83, 450, 83, 2, 450, 334, 495, 8, 27201, 395, 620, 8, 2424, 430, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 333, 1977, 275, 8431, 14, 362, 63, 354, 342, 267, 9444, 275, 8431, 14, 362, 63, 354, 342, 267, 333, 1977, 275, 333, 1977, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 9444, 275, 9444, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 333, 1977, 12, 9444, 9, 339, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 291, 14, 27201, 14, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 267, 291, 14, 2424, 14, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 372, 291, 14, 27201, 14, 475, 63, 5671, 461, 8, 6493, 9, 435, 971, 288, 291, 14, 2424, 14, 475, 63, 5671, 461, 8, 6493, 9, 339, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 27201, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 5644, 1453, 9, 267, 1453, 847, 286, 2972, 267, 11517, 552, 4862, 286, 2972, 267, 340, 11517, 552, 2695, 378, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 334, 2424, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 5101, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 333, 1977, 275, 333, 1977, 14, 17060, 29282, 8, 6493, 9, 288, 9444, 275, 9444, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 333, 1977, 12, 9444, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63, 17060, 4191, 8, 277, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 291, 14, 27201, 275, 291, 14, 27201, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 291, 14, 2424, 275, 291, 14, 2424, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 339, 347, 485, 5730, 8, 277, 12, 1163, 304, 267, 373, 275, 10467, 8, 277, 14, 27201, 12, 1163, 14, 27201, 9, 267, 340, 373, 508, 378, 26, 288, 373, 275, 10467, 8, 277, 14, 2424, 12, 1163, 14, 2424, 9, 267, 372, 373, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
openstack/networking-bagpipe-l2
networking_bagpipe/db/sfc_db.py
3
5828
# Copyright (c) 2017 Orange. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import sqlalchemy as sa from oslo_config import cfg from oslo_log import helpers as log_helpers from oslo_log import log as logging from neutron_lib import context as n_context from neutron_lib.db import model_base LOG = logging.getLogger(__name__) sfc_bagpipe_opts = [ cfg.IntOpt('as_number', default=64512, help=_("Autonomous System number used to generate BGP Route " "Targets that will be used for Port Chain allocations")), cfg.ListOpt('rtnn', default=[5000, 5999], help=_("List containing <rtnn_min>, <rtnn_max> " "defining a range of BGP Route Targets that will " "be used for Port Chain allocations. This range MUST " "not intersect the one used for network segmentation " "identifiers")), ] cfg.CONF.register_opts(sfc_bagpipe_opts, "sfc_bagpipe") class BaGPipePpgRTAssoc(model_base.BASEV2, model_base.HasId): '''Mapping from Port Pair Group to the NN part of an AS:NN route target''' __tablename__ = 'sfc_bagpipe_ppg_rtnn_associations' ppg_id = sa.Column(sa.String(36), primary_key=True) rtnn = sa.Column(sa.Integer, unique=True, nullable=False) is_redirect = sa.Column(sa.Boolean(), nullable=False) reverse = sa.Column(sa.Boolean(), nullable=False) def singleton(class_): instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance @singleton class RTAllocator(object): def __init__(self): self.config = cfg.CONF.sfc_bagpipe self.session = n_context.get_admin_context().session def _get_rt_from_rtnn(self, rtnn): return ':'.join([str(self.config.as_number), str(rtnn)]) @log_helpers.log_method_call def allocate_rt(self, ppg_id, is_redirect=False, reverse=False): query = self.session.query( BaGPipePpgRTAssoc).order_by( BaGPipePpgRTAssoc.rtnn) allocated_rtnns = {obj.rtnn for obj in query.all()} # Find first one available in range start, end = int(self.config.rtnn[0]), int(self.config.rtnn[1]) + 1 for rtnn in range(start, end): if rtnn not in allocated_rtnns: with self.session.begin(subtransactions=True): ppg_rtnn = BaGPipePpgRTAssoc(ppg_id=ppg_id, rtnn=rtnn, is_redirect=is_redirect, reverse=reverse) self.session.add(ppg_rtnn) return self._get_rt_from_rtnn(rtnn) LOG.error("Can't allocate route target, all range in use") return None @log_helpers.log_method_call def get_rts_by_ppg(self, ppg_id): ppg_rts = self.session.query( BaGPipePpgRTAssoc).filter_by(ppg_id=ppg_id).all() if not ppg_rts: return None return [ppg_rt.rtnn for ppg_rt in ppg_rts] @log_helpers.log_method_call def get_redirect_rt_by_ppg(self, ppg_id, reverse=False): ppg_redirect_rt = self.session.query( BaGPipePpgRTAssoc).filter_by(ppg_id=ppg_id, is_redirect=True, reverse=reverse).one() return self._get_rt_from_rtnn(ppg_redirect_rt.rtnn) @log_helpers.log_method_call def release_rt(self, rtnn): with self.session.begin(subtransactions=True): ppg_rtnn = self.session.query( BaGPipePpgRTAssoc).filter_by(rtnn=rtnn).first() if ppg_rtnn: self.session.delete(ppg_rtnn) else: LOG.warning("Can't release route target %s, not used", rtnn) class BaGPipeChainHop(model_base.BASEV2, model_base.HasId, model_base.HasProject): __tablename__ = 'sfc_bagpipe_chain_hops' ingress_ppg = sa.Column(sa.String(36), nullable=True) egress_ppg = sa.Column(sa.String(36), nullable=True) ingress_network = sa.Column(sa.String(36), sa.ForeignKey('networks.id'), nullable=True) egress_network = sa.Column(sa.String(36), sa.ForeignKey('networks.id'), nullable=True) rts = sa.Column(sa.String(255)) ingress_gw = sa.Column(sa.String(64)) egress_gw = sa.Column(sa.String(64)) readv_from_rts = sa.Column(sa.String(255)) readv_to_rt = sa.Column(sa.String(255)) attract_to_rt = sa.Column(sa.String(255)) redirect_rts = sa.Column(sa.String(255)) classifiers = sa.Column(sa.String(255)) reverse_hop = sa.Column(sa.Boolean(), nullable=False) portchain_id = sa.Column(sa.String(36), nullable=False, primary_key=True) class BaGPipeSfcDriverDB(object): def initialize(self): self.admin_context = n_context.get_admin_context()
apache-2.0
[ 3, 1898, 334, 67, 9, 9708, 593, 1842, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 8335, 465, 2937, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 10897, 465, 943, 63, 7546, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 504, 8224, 63, 773, 492, 1067, 465, 302, 63, 1100, 199, 504, 8224, 63, 773, 14, 697, 492, 1402, 63, 1095, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 83, 3003, 63, 19430, 4990, 63, 3291, 275, 359, 272, 4810, 14, 3241, 9985, 360, 305, 63, 1955, 297, 849, 29, 772, 7736, 12, 2049, 1720, 9384, 23570, 30671, 7376, 6187, 1329, 1202, 370, 3550, 27893, 24244, 298, 1993, 298, 14126, 626, 911, 506, 1202, 367, 10977, 25384, 741, 8022, 8150, 272, 4810, 14, 1296, 9985, 360, 2591, 4411, 297, 355, 849, 1524, 13128, 12, 959, 5637, 467, 355, 1720, 9384, 1296, 3035, 665, 2591, 4411, 63, 827, 6244, 665, 2591, 4411, 63, 988, 30, 298, 2432, 298, 318, 7969, 282, 1425, 402, 27893, 24244, 10256, 83, 626, 911, 298, 2432, 298, 1235, 1202, 367, 10977, 25384, 741, 8022, 14, 961, 1425, 18095, 298, 2432, 298, 1397, 26066, 314, 1373, 1202, 367, 2784, 27315, 298, 2432, 298, 14227, 8150, 199, 61, 199, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 83, 3003, 63, 19430, 4990, 63, 3291, 12, 298, 83, 3003, 63, 19430, 4990, 531, 421, 199, 533, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 8, 1238, 63, 1095, 14, 5825, 54, 18, 12, 1402, 63, 1095, 14, 6362, 1304, 304, 272, 1449, 7674, 687, 10977, 510, 8387, 5611, 370, 314, 31242, 1777, 402, 376, 4319, 26, 7178, 7475, 1347, 2344, 339, 636, 10983, 363, 275, 283, 83, 3003, 63, 19430, 4990, 63, 802, 71, 63, 2591, 4411, 63, 32600, 7, 272, 299, 4198, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 1344, 395, 5062, 63, 498, 29, 549, 9, 272, 14059, 4411, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 3747, 29, 549, 12, 7854, 29, 797, 9, 272, 365, 63, 4876, 275, 2937, 14, 4547, 8, 2231, 14, 4082, 1062, 7854, 29, 797, 9, 272, 3837, 275, 2937, 14, 4547, 8, 2231, 14, 4082, 1062, 7854, 29, 797, 9, 421, 199, 318, 19768, 8, 533, 7822, 272, 4454, 275, 1052, 339, 347, 664, 842, 2031, 589, 12, 1011, 958, 304, 267, 340, 1021, 63, 440, 315, 4454, 26, 288, 4454, 59, 533, 24601, 275, 1021, 63, 2031, 589, 12, 1011, 958, 9, 267, 372, 4454, 59, 533, 24601, 272, 372, 664, 842, 421, 199, 32, 24675, 199, 533, 24090, 20191, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 888, 275, 4810, 14, 3103, 14, 83, 3003, 63, 19430, 4990, 267, 291, 14, 1730, 275, 302, 63, 1100, 14, 362, 63, 2113, 63, 1100, 1252, 1730, 339, 347, 485, 362, 63, 2591, 63, 504, 63, 2591, 4411, 8, 277, 12, 14059, 4411, 304, 267, 372, 29010, 904, 779, 495, 8, 277, 14, 888, 14, 305, 63, 1955, 395, 620, 8, 2591, 4411, 3948, 339, 768, 793, 63, 7546, 14, 793, 63, 765, 63, 1250, 272, 347, 18310, 63, 2591, 8, 277, 12, 299, 4198, 63, 344, 12, 365, 63, 4876, 29, 797, 12, 3837, 29, 797, 304, 267, 1827, 275, 291, 14, 1730, 14, 1131, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 680, 1648, 63, 991, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 14, 2591, 4411, 9, 398, 17659, 63, 2591, 78, 561, 275, 469, 1113, 14, 2591, 4411, 367, 1559, 315, 1827, 14, 452, 12737, 398, 327, 6668, 1642, 1373, 2808, 315, 1425, 267, 1343, 12, 1284, 275, 1109, 8, 277, 14, 888, 14, 2591, 4411, 59, 16, 2522, 1109, 8, 277, 14, 888, 14, 2591, 4411, 59, 17, 566, 435, 413, 267, 367, 14059, 4411, 315, 1425, 8, 928, 12, 1284, 304, 288, 340, 14059, 4411, 440, 315, 17659, 63, 2591, 78, 561, 26, 355, 543, 291, 14, 1730, 14, 5037, 8, 954, 13754, 29, 549, 304, 490, 299, 4198, 63, 2591, 4411, 275, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 8, 802, 71, 63, 344, 29, 802, 71, 63, 344, 12, 1740, 14059, 4411, 29, 2591, 4411, 12, 1740, 365, 63, 4876, 29, 374, 63, 4876, 12, 1740, 3837, 29, 4471, 9, 490, 291, 14, 1730, 14, 525, 8, 802, 71, 63, 2591, 4411, 9, 355, 372, 291, 423, 362, 63, 2591, 63, 504, 63, 2591, 4411, 8, 2591, 4411, 9, 398, 5051, 14, 705, 480, 6049, 1133, 18310, 7475, 1347, 12, 1006, 1425, 315, 675, 531, 267, 372, 488, 339, 768, 793, 63, 7546, 14, 793, 63, 765, 63, 1250, 272, 347, 664, 63, 31210, 63, 991, 63, 802, 71, 8, 277, 12, 299, 4198, 63, 344, 304, 398, 299, 4198, 63, 31210, 275, 291, 14, 1730, 14, 1131, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 680, 1541, 63, 991, 8, 802, 71, 63, 344, 29, 802, 71, 63, 344, 680, 452, 342, 267, 340, 440, 299, 4198, 63, 31210, 26, 288, 372, 488, 398, 372, 359, 802, 71, 63, 2591, 14, 2591, 4411, 367, 299, 4198, 63, 2591, 315, 299, 4198, 63, 31210, 61 ]
[ 1898, 334, 67, 9, 9708, 593, 1842, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 8335, 465, 2937, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 10897, 465, 943, 63, 7546, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 504, 8224, 63, 773, 492, 1067, 465, 302, 63, 1100, 199, 504, 8224, 63, 773, 14, 697, 492, 1402, 63, 1095, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 83, 3003, 63, 19430, 4990, 63, 3291, 275, 359, 272, 4810, 14, 3241, 9985, 360, 305, 63, 1955, 297, 849, 29, 772, 7736, 12, 2049, 1720, 9384, 23570, 30671, 7376, 6187, 1329, 1202, 370, 3550, 27893, 24244, 298, 1993, 298, 14126, 626, 911, 506, 1202, 367, 10977, 25384, 741, 8022, 8150, 272, 4810, 14, 1296, 9985, 360, 2591, 4411, 297, 355, 849, 1524, 13128, 12, 959, 5637, 467, 355, 1720, 9384, 1296, 3035, 665, 2591, 4411, 63, 827, 6244, 665, 2591, 4411, 63, 988, 30, 298, 2432, 298, 318, 7969, 282, 1425, 402, 27893, 24244, 10256, 83, 626, 911, 298, 2432, 298, 1235, 1202, 367, 10977, 25384, 741, 8022, 14, 961, 1425, 18095, 298, 2432, 298, 1397, 26066, 314, 1373, 1202, 367, 2784, 27315, 298, 2432, 298, 14227, 8150, 199, 61, 199, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 83, 3003, 63, 19430, 4990, 63, 3291, 12, 298, 83, 3003, 63, 19430, 4990, 531, 421, 199, 533, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 8, 1238, 63, 1095, 14, 5825, 54, 18, 12, 1402, 63, 1095, 14, 6362, 1304, 304, 272, 1449, 7674, 687, 10977, 510, 8387, 5611, 370, 314, 31242, 1777, 402, 376, 4319, 26, 7178, 7475, 1347, 2344, 339, 636, 10983, 363, 275, 283, 83, 3003, 63, 19430, 4990, 63, 802, 71, 63, 2591, 4411, 63, 32600, 7, 272, 299, 4198, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 1344, 395, 5062, 63, 498, 29, 549, 9, 272, 14059, 4411, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 3747, 29, 549, 12, 7854, 29, 797, 9, 272, 365, 63, 4876, 275, 2937, 14, 4547, 8, 2231, 14, 4082, 1062, 7854, 29, 797, 9, 272, 3837, 275, 2937, 14, 4547, 8, 2231, 14, 4082, 1062, 7854, 29, 797, 9, 421, 199, 318, 19768, 8, 533, 7822, 272, 4454, 275, 1052, 339, 347, 664, 842, 2031, 589, 12, 1011, 958, 304, 267, 340, 1021, 63, 440, 315, 4454, 26, 288, 4454, 59, 533, 24601, 275, 1021, 63, 2031, 589, 12, 1011, 958, 9, 267, 372, 4454, 59, 533, 24601, 272, 372, 664, 842, 421, 199, 32, 24675, 199, 533, 24090, 20191, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 888, 275, 4810, 14, 3103, 14, 83, 3003, 63, 19430, 4990, 267, 291, 14, 1730, 275, 302, 63, 1100, 14, 362, 63, 2113, 63, 1100, 1252, 1730, 339, 347, 485, 362, 63, 2591, 63, 504, 63, 2591, 4411, 8, 277, 12, 14059, 4411, 304, 267, 372, 29010, 904, 779, 495, 8, 277, 14, 888, 14, 305, 63, 1955, 395, 620, 8, 2591, 4411, 3948, 339, 768, 793, 63, 7546, 14, 793, 63, 765, 63, 1250, 272, 347, 18310, 63, 2591, 8, 277, 12, 299, 4198, 63, 344, 12, 365, 63, 4876, 29, 797, 12, 3837, 29, 797, 304, 267, 1827, 275, 291, 14, 1730, 14, 1131, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 680, 1648, 63, 991, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 14, 2591, 4411, 9, 398, 17659, 63, 2591, 78, 561, 275, 469, 1113, 14, 2591, 4411, 367, 1559, 315, 1827, 14, 452, 12737, 398, 327, 6668, 1642, 1373, 2808, 315, 1425, 267, 1343, 12, 1284, 275, 1109, 8, 277, 14, 888, 14, 2591, 4411, 59, 16, 2522, 1109, 8, 277, 14, 888, 14, 2591, 4411, 59, 17, 566, 435, 413, 267, 367, 14059, 4411, 315, 1425, 8, 928, 12, 1284, 304, 288, 340, 14059, 4411, 440, 315, 17659, 63, 2591, 78, 561, 26, 355, 543, 291, 14, 1730, 14, 5037, 8, 954, 13754, 29, 549, 304, 490, 299, 4198, 63, 2591, 4411, 275, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 8, 802, 71, 63, 344, 29, 802, 71, 63, 344, 12, 1740, 14059, 4411, 29, 2591, 4411, 12, 1740, 365, 63, 4876, 29, 374, 63, 4876, 12, 1740, 3837, 29, 4471, 9, 490, 291, 14, 1730, 14, 525, 8, 802, 71, 63, 2591, 4411, 9, 355, 372, 291, 423, 362, 63, 2591, 63, 504, 63, 2591, 4411, 8, 2591, 4411, 9, 398, 5051, 14, 705, 480, 6049, 1133, 18310, 7475, 1347, 12, 1006, 1425, 315, 675, 531, 267, 372, 488, 339, 768, 793, 63, 7546, 14, 793, 63, 765, 63, 1250, 272, 347, 664, 63, 31210, 63, 991, 63, 802, 71, 8, 277, 12, 299, 4198, 63, 344, 304, 398, 299, 4198, 63, 31210, 275, 291, 14, 1730, 14, 1131, 8, 288, 699, 65, 8225, 3662, 48, 4198, 50, 6166, 385, 679, 680, 1541, 63, 991, 8, 802, 71, 63, 344, 29, 802, 71, 63, 344, 680, 452, 342, 267, 340, 440, 299, 4198, 63, 31210, 26, 288, 372, 488, 398, 372, 359, 802, 71, 63, 2591, 14, 2591, 4411, 367, 299, 4198, 63, 2591, 315, 299, 4198, 63, 31210, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
Widiot/simpleblog
venv/lib/python3.5/site-packages/flask_admin/babel.py
12
1945
try: from flask_babelex import Domain except ImportError: def gettext(string, **variables): return string % variables def ngettext(singular, plural, num, **variables): variables.setdefault('num', num) return (singular if num == 1 else plural) % variables def lazy_gettext(string, **variables): return gettext(string, **variables) class Translations(object): ''' dummy Translations class for WTForms, no translation support ''' def gettext(self, string): return string def ngettext(self, singular, plural, n): return singular if n == 1 else plural else: from flask_admin import translations class CustomDomain(Domain): def __init__(self): super(CustomDomain, self).__init__(translations.__path__[0], domain='admin') def get_translations_path(self, ctx): view = get_current_view() if view is not None: dirname = view.admin.translations_path if dirname is not None: return dirname return super(CustomDomain, self).get_translations_path(ctx) domain = CustomDomain() gettext = domain.gettext ngettext = domain.ngettext lazy_gettext = domain.lazy_gettext try: from wtforms.i18n import messages_path except ImportError: from wtforms.ext.i18n.utils import messages_path wtforms_domain = Domain(messages_path(), domain='wtforms') class Translations(object): ''' Fixes WTForms translation support and uses wtforms translations ''' def gettext(self, string): t = wtforms_domain.get_translations() return t.ugettext(string) def ngettext(self, singular, plural, n): t = wtforms_domain.get_translations() return t.ungettext(singular, plural, n) # lazy imports from .helpers import get_current_view
mit
[ 893, 26, 272, 687, 7209, 63, 66, 7570, 3113, 492, 14061, 199, 199, 2590, 3545, 26, 272, 347, 9796, 8, 875, 12, 1011, 3669, 304, 267, 372, 1059, 450, 2860, 339, 347, 29793, 8, 17045, 12, 11718, 12, 1967, 12, 1011, 3669, 304, 267, 2860, 14, 5486, 360, 1507, 297, 1967, 9, 267, 372, 334, 17045, 340, 1967, 508, 413, 587, 11718, 9, 450, 2860, 339, 347, 9617, 63, 5152, 8, 875, 12, 1011, 3669, 304, 267, 372, 9796, 8, 875, 12, 1011, 3669, 9, 339, 1021, 6266, 6011, 8, 785, 304, 267, 1449, 7283, 6266, 6011, 1021, 367, 644, 52, 26028, 12, 949, 7761, 2291, 1449, 267, 347, 9796, 8, 277, 12, 1059, 304, 288, 372, 1059, 398, 347, 29793, 8, 277, 12, 15823, 12, 11718, 12, 302, 304, 288, 372, 15823, 340, 302, 508, 413, 587, 11718, 199, 2836, 26, 272, 687, 7209, 63, 2113, 492, 15547, 339, 1021, 8388, 7705, 8, 7705, 304, 267, 347, 636, 826, 721, 277, 304, 288, 1613, 8, 7223, 7705, 12, 291, 2843, 826, 721, 13982, 855, 515, 12298, 16, 467, 2881, 534, 2113, 358, 398, 347, 664, 63, 13982, 63, 515, 8, 277, 12, 4027, 304, 288, 2455, 275, 664, 63, 1818, 63, 1345, 342, 953, 340, 2455, 365, 440, 488, 26, 355, 9017, 275, 2455, 14, 2113, 14, 13982, 63, 515, 355, 340, 9017, 365, 440, 488, 26, 490, 372, 9017, 953, 372, 1613, 8, 7223, 7705, 12, 291, 680, 362, 63, 13982, 63, 515, 8, 3799, 9, 339, 2881, 275, 8388, 7705, 342, 339, 9796, 275, 2881, 14, 5152, 272, 29793, 275, 2881, 14, 28234, 272, 9617, 63, 5152, 275, 2881, 14, 6395, 63, 5152, 339, 862, 26, 267, 687, 24756, 3351, 14, 73, 1085, 78, 492, 3788, 63, 515, 272, 871, 3545, 26, 267, 687, 24756, 3351, 14, 832, 14, 73, 1085, 78, 14, 1208, 492, 3788, 63, 515, 339, 24756, 3351, 63, 2261, 275, 14061, 8, 3431, 63, 515, 1062, 2881, 534, 9115, 3351, 358, 339, 1021, 6266, 6011, 8, 785, 304, 267, 1449, 14811, 397, 644, 52, 26028, 7761, 2291, 436, 4440, 24756, 3351, 15547, 1449, 267, 347, 9796, 8, 277, 12, 1059, 304, 288, 307, 275, 24756, 3351, 63, 2261, 14, 362, 63, 13982, 342, 288, 372, 307, 14, 23499, 8, 875, 9, 398, 347, 29793, 8, 277, 12, 15823, 12, 11718, 12, 302, 304, 288, 307, 275, 24756, 3351, 63, 2261, 14, 362, 63, 13982, 342, 288, 372, 307, 14, 324, 5152, 8, 17045, 12, 11718, 12, 302, 9, 421, 199, 3, 9617, 8925, 199, 504, 1275, 7546, 492, 664, 63, 1818, 63, 1345, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 26, 272, 687, 7209, 63, 66, 7570, 3113, 492, 14061, 199, 199, 2590, 3545, 26, 272, 347, 9796, 8, 875, 12, 1011, 3669, 304, 267, 372, 1059, 450, 2860, 339, 347, 29793, 8, 17045, 12, 11718, 12, 1967, 12, 1011, 3669, 304, 267, 2860, 14, 5486, 360, 1507, 297, 1967, 9, 267, 372, 334, 17045, 340, 1967, 508, 413, 587, 11718, 9, 450, 2860, 339, 347, 9617, 63, 5152, 8, 875, 12, 1011, 3669, 304, 267, 372, 9796, 8, 875, 12, 1011, 3669, 9, 339, 1021, 6266, 6011, 8, 785, 304, 267, 1449, 7283, 6266, 6011, 1021, 367, 644, 52, 26028, 12, 949, 7761, 2291, 1449, 267, 347, 9796, 8, 277, 12, 1059, 304, 288, 372, 1059, 398, 347, 29793, 8, 277, 12, 15823, 12, 11718, 12, 302, 304, 288, 372, 15823, 340, 302, 508, 413, 587, 11718, 199, 2836, 26, 272, 687, 7209, 63, 2113, 492, 15547, 339, 1021, 8388, 7705, 8, 7705, 304, 267, 347, 636, 826, 721, 277, 304, 288, 1613, 8, 7223, 7705, 12, 291, 2843, 826, 721, 13982, 855, 515, 12298, 16, 467, 2881, 534, 2113, 358, 398, 347, 664, 63, 13982, 63, 515, 8, 277, 12, 4027, 304, 288, 2455, 275, 664, 63, 1818, 63, 1345, 342, 953, 340, 2455, 365, 440, 488, 26, 355, 9017, 275, 2455, 14, 2113, 14, 13982, 63, 515, 355, 340, 9017, 365, 440, 488, 26, 490, 372, 9017, 953, 372, 1613, 8, 7223, 7705, 12, 291, 680, 362, 63, 13982, 63, 515, 8, 3799, 9, 339, 2881, 275, 8388, 7705, 342, 339, 9796, 275, 2881, 14, 5152, 272, 29793, 275, 2881, 14, 28234, 272, 9617, 63, 5152, 275, 2881, 14, 6395, 63, 5152, 339, 862, 26, 267, 687, 24756, 3351, 14, 73, 1085, 78, 492, 3788, 63, 515, 272, 871, 3545, 26, 267, 687, 24756, 3351, 14, 832, 14, 73, 1085, 78, 14, 1208, 492, 3788, 63, 515, 339, 24756, 3351, 63, 2261, 275, 14061, 8, 3431, 63, 515, 1062, 2881, 534, 9115, 3351, 358, 339, 1021, 6266, 6011, 8, 785, 304, 267, 1449, 14811, 397, 644, 52, 26028, 7761, 2291, 436, 4440, 24756, 3351, 15547, 1449, 267, 347, 9796, 8, 277, 12, 1059, 304, 288, 307, 275, 24756, 3351, 63, 2261, 14, 362, 63, 13982, 342, 288, 372, 307, 14, 23499, 8, 875, 9, 398, 347, 29793, 8, 277, 12, 15823, 12, 11718, 12, 302, 304, 288, 307, 275, 24756, 3351, 63, 2261, 14, 362, 63, 13982, 342, 288, 372, 307, 14, 324, 5152, 8, 17045, 12, 11718, 12, 302, 9, 421, 199, 3, 9617, 8925, 199, 504, 1275, 7546, 492, 664, 63, 1818, 63, 1345, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
xxshutong/openerp-7.0
openerp/addons/base/module/wizard/base_module_configuration.py
447
2274
# -*- 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/>. # ############################################################################## from openerp.osv import osv from openerp.tools.translate import _ class base_module_configuration(osv.osv_memory): _name = "base.module.configuration" def start(self, cr, uid, ids, context=None): todo_ids = self.pool.get('ir.actions.todo').search(cr, uid, ['|', ('type','=','recurring'), ('state', '=', 'open')]) if not todo_ids: # When there is no wizard todo it will display message data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'base', 'view_base_module_configuration_form') view_id = data_obj.browse(cr, uid, result).res_id value = { 'name': _('System Configuration done'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'base.module.configuration', 'view_id': [view_id], 'type': 'ir.actions.act_window', 'target': 'new' } return value # Run the config wizards config_pool = self.pool.get('res.config') return config_pool.start(cr, uid, ids, context=context) base_module_configuration() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 1300, 63, 578, 63, 4758, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 298, 1095, 14, 578, 14, 4758, 2, 339, 347, 1343, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 11386, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 11396, 1959, 1733, 8, 1556, 12, 1747, 12, 288, 788, 26320, 661, 466, 1673, 29511, 6794, 5985, 659, 661, 929, 297, 6291, 283, 1490, 2023, 267, 340, 440, 11386, 63, 1580, 26, 288, 327, 3979, 2337, 365, 949, 12262, 11386, 652, 911, 2929, 1245, 288, 666, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 288, 754, 275, 666, 63, 1113, 423, 362, 63, 344, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1345, 63, 1095, 63, 578, 63, 4758, 63, 964, 358, 288, 2455, 63, 344, 275, 666, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 754, 680, 470, 63, 344, 288, 574, 275, 469, 490, 283, 354, 356, 4018, 3989, 11595, 4224, 659, 15324, 283, 1345, 63, 466, 356, 283, 964, 297, 15324, 283, 1345, 63, 632, 356, 283, 964, 297, 15324, 283, 470, 63, 1238, 356, 283, 1095, 14, 578, 14, 4758, 297, 15324, 283, 1345, 63, 344, 356, 359, 1345, 63, 344, 467, 15324, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 15324, 283, 1375, 356, 283, 1222, 7, 355, 789, 288, 372, 574, 267, 327, 3378, 314, 1101, 31067, 5596, 267, 1101, 63, 2293, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 888, 358, 267, 372, 1101, 63, 2293, 14, 928, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 199, 199, 1095, 63, 578, 63, 4758, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 1300, 63, 578, 63, 4758, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 298, 1095, 14, 578, 14, 4758, 2, 339, 347, 1343, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 11386, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 11396, 1959, 1733, 8, 1556, 12, 1747, 12, 288, 788, 26320, 661, 466, 1673, 29511, 6794, 5985, 659, 661, 929, 297, 6291, 283, 1490, 2023, 267, 340, 440, 11386, 63, 1580, 26, 288, 327, 3979, 2337, 365, 949, 12262, 11386, 652, 911, 2929, 1245, 288, 666, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 288, 754, 275, 666, 63, 1113, 423, 362, 63, 344, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1345, 63, 1095, 63, 578, 63, 4758, 63, 964, 358, 288, 2455, 63, 344, 275, 666, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 754, 680, 470, 63, 344, 288, 574, 275, 469, 490, 283, 354, 356, 4018, 3989, 11595, 4224, 659, 15324, 283, 1345, 63, 466, 356, 283, 964, 297, 15324, 283, 1345, 63, 632, 356, 283, 964, 297, 15324, 283, 470, 63, 1238, 356, 283, 1095, 14, 578, 14, 4758, 297, 15324, 283, 1345, 63, 344, 356, 359, 1345, 63, 344, 467, 15324, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 15324, 283, 1375, 356, 283, 1222, 7, 355, 789, 288, 372, 574, 267, 327, 3378, 314, 1101, 31067, 5596, 267, 1101, 63, 2293, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 888, 358, 267, 372, 1101, 63, 2293, 14, 928, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 199, 199, 1095, 63, 578, 63, 4758, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mythsmith/veusz
veusz/dialogs/preferences.py
4
9670
# Copyright (C) 2006 Jeremy S. Sanders # Email: Jeremy Sanders <jeremy@jeremysanders.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ############################################################################## from __future__ import division from .. import qtall as qt4 from .. import setting from .. import utils from .veuszdialog import VeuszDialog def _(text, disambiguation=None, context="PrefsDialog"): """Translate text.""" return qt4.QCoreApplication.translate(context, text, disambiguation) # names for display of colors and a longer description color_names = { 'page': (_('Page'), _('Page background color')), 'error': (_('Error'), _('Color for errors')), 'command': (_('Console command'), _('Commands in the console window color')), 'cntrlline': (_('Control line'), _('Color of lines controlling widgets')), 'cntrlcorner': (_('Control corner'), _('Color of corners controlling widgets')), } class PreferencesDialog(VeuszDialog): """Preferences dialog.""" def __init__(self, mainwindow): """Setup dialog.""" VeuszDialog.__init__(self, mainwindow, 'preferences.ui', modal=True) self.plotwindow = mainwindow.plot # for ease of use setdb = setting.settingdb # view settings self.antialiasCheck.setChecked( setdb['plot_antialias'] ) self.englishCheck.setChecked( setdb['ui_english'] ) for intv in self.plotwindow.updateintervals: self.intervalCombo.addItem(intv[1]) index = [i[0] for i in self.plotwindow.updateintervals].index( setdb['plot_updatepolicy']) self.intervalCombo.setCurrentIndex(index) self.threadSpinBox.setValue( setdb['plot_numthreads'] ) # disable thread option if not supported if not qt4.QFontDatabase.supportsThreadedFontRendering(): self.threadSpinBox.setEnabled(False) self.threadSpinBox.setToolTip(_("Disabled because of lack of " "threaded drawing support")) # use cwd for file dialogs (self.dirDocCWDRadio if setdb['dirname_usecwd'] else self.dirDocPrevRadio).click() # exporting documents { 'doc': self.dirExportDocRadio, 'cwd': self.dirExportCWDRadio, 'prev': self.dirExportPrevRadio, }[setdb.get('dirname_export_location')].click() # set icon size self.iconSizeCombo.setCurrentIndex( self.iconSizeCombo.findText( str(setdb['toolbar_size']))) # default stylesheet self.styleLineEdit.setText(setdb['stylesheet_default']) self.styleBrowseButton.clicked.connect(self.styleBrowseClicked) # default custom settings self.customLineEdit.setText(setdb['custom_default']) self.customBrowseButton.clicked.connect(self.customBrowseClicked) # for plugins plugins = list( setdb.get('plugins', []) ) self.pluginmodel = qt4.QStringListModel(plugins) self.pluginList.setModel(self.pluginmodel) self.pluginAddButton.clicked.connect(self.pluginAddClicked) self.pluginRemoveButton.clicked.connect(self.pluginRemoveClicked) # specifics for color tab self.setupColorTab() # for point picker self.pickerToConsoleCheck.setChecked( setdb['picker_to_console'] ) self.pickerToClipboardCheck.setChecked( setdb['picker_to_clipboard'] ) # python path self.externalPythonPath.setText(setdb['external_pythonpath']) def setupColorTab(self): """Initialise color tab this makes a grid of controls for each color consisting of label, isdefault check and change color button.""" self.chosencolors = {} self.colorbutton = {} self.colordefaultcheck = {} layout = qt4.QGridLayout() setdb = setting.settingdb for row, colname in enumerate(setdb.colors): isdefault, colval = setting.settingdb['color_%s' % colname] self.chosencolors[colname] = qt4.QColor(colval) # label name, tooltip = color_names[colname] label = qt4.QLabel(name) label.setToolTip(tooltip) layout.addWidget(label, row, 0) # is default check defcheck = qt4.QCheckBox(_("Default")) defcheck.setToolTip( _("Use the default color instead of the one chosen here")) layout.addWidget(defcheck, row, 1) self.colordefaultcheck[colname] = defcheck defcheck.setChecked(isdefault) # connect button to method to change color button = self.colorbutton[colname] = qt4.QPushButton() def getcolclick(cname): # double function to get around colname changing return lambda: self.colorButtonClicked(cname) button.clicked.connect(getcolclick(colname)) layout.addWidget(button, row, 2) self.colorGroup.setLayout(layout) self.updateButtonColors() def colorButtonClicked(self, cname): """Open color dialog if color button clicked.""" retcolor = qt4.QColorDialog.getColor( self.chosencolors[cname], self ) if retcolor.isValid(): self.chosencolors[cname] = retcolor self.updateButtonColors() def updateButtonColors(self): """Update color icons on color buttons.""" for name, val in self.chosencolors.items(): pixmap = qt4.QPixmap(16, 16) pixmap.fill(val) self.colorbutton[name].setIcon( qt4.QIcon(pixmap) ) def accept(self): """Keep settings if okay pressed.""" qt4.QDialog.accept(self) # view settings setdb = setting.settingdb setdb['plot_updatepolicy'] = ( self.plotwindow.updateintervals[self.intervalCombo.currentIndex()][0] ) setdb['plot_antialias'] = self.antialiasCheck.isChecked() setdb['ui_english'] = self.englishCheck.isChecked() setdb['plot_numthreads'] = self.threadSpinBox.value() # use cwd setdb['dirname_usecwd'] = self.dirDocCWDRadio.isChecked() for radio, val in ( (self.dirExportDocRadio, 'doc'), (self.dirExportCWDRadio, 'cwd'), (self.dirExportPrevRadio, 'prev'), ): if radio.isChecked(): setdb['dirname_export_location'] = val # update icon size if necessary iconsize = int( self.iconSizeCombo.currentText() ) if iconsize != setdb['toolbar_size']: setdb['toolbar_size'] = iconsize for widget in self.parent().children(): # find toolbars if isinstance(widget, qt4.QToolBar): widget.setIconSize( qt4.QSize(iconsize, iconsize) ) # new document settings setdb['stylesheet_default'] = self.styleLineEdit.text() setdb['custom_default'] = self.customLineEdit.text() # colors for name, color in self.chosencolors.items(): isdefault = self.colordefaultcheck[name].isChecked() colorname = color.name() setdb['color_' + name] = (isdefault, colorname) # plugins plugins = self.pluginmodel.stringList() setdb['plugins'] = plugins # picker setdb['picker_to_clipboard'] = self.pickerToClipboardCheck.isChecked() setdb['picker_to_console'] = self.pickerToConsoleCheck.isChecked() # python path setdb['external_pythonpath'] = self.externalPythonPath.text() self.plotwindow.updatePlotSettings() # write settings out now, rather than wait until the end setdb.writeSettings() def styleBrowseClicked(self): """Browse for a stylesheet.""" filename = self.parent().fileOpenDialog( [_('Veusz stylesheet (*.vst)')], _('Choose stylesheet')) if filename: self.styleLineEdit.setText(filename) def customBrowseClicked(self): """Browse for a custom definitons.""" filename = self.parent().fileOpenDialog( [_('Veusz document (*.vsz)')], _('Choose custom definitons')) if filename: self.customLineEdit.setText(filename) def pluginAddClicked(self): """Add a new plugin.""" filename = self.parent().fileOpenDialog( [_('Python scripts (*.py)')], _('Choose plugin')) if filename: self.pluginmodel.insertRows(0, 1) self.pluginmodel.setData( self.pluginmodel.index(0), filename ) def pluginRemoveClicked(self): """Remove selected plugin.""" sel = self.pluginList.selectionModel().currentIndex() if sel.isValid(): self.pluginmodel.removeRow( sel.row() )
gpl-2.0
[ 3, 259, 1898, 334, 35, 9, 8315, 1603, 69, 264, 1662, 428, 14, 29359, 7735, 199, 3, 259, 11426, 26, 1603, 69, 264, 1662, 29359, 7735, 665, 6532, 264, 1662, 32, 6532, 13179, 588, 290, 7735, 14, 846, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 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, 3180, 199, 3, 259, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 259, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 4605, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 2508, 492, 19227, 452, 465, 19227, 20, 199, 504, 2508, 492, 4260, 199, 504, 2508, 492, 3778, 199, 504, 1275, 432, 527, 90, 7196, 492, 25777, 527, 90, 5619, 199, 199, 318, 12561, 505, 12, 2153, 16902, 4086, 29, 403, 12, 1067, 628, 48, 7655, 5619, 2349, 272, 408, 18355, 1318, 1041, 272, 372, 19227, 20, 14, 49, 29263, 14, 5275, 8, 1100, 12, 1318, 12, 2153, 16902, 4086, 9, 199, 199, 3, 1561, 367, 2929, 402, 9229, 436, 282, 8088, 1369, 199, 2326, 63, 1247, 275, 469, 272, 283, 1606, 356, 21790, 3276, 659, 1467, 4018, 3276, 8020, 3164, 3855, 272, 283, 705, 356, 21790, 547, 659, 1598, 4018, 4117, 367, 2552, 3855, 272, 283, 1531, 356, 21790, 9270, 1414, 659, 355, 4018, 14680, 315, 314, 8559, 4353, 3164, 3855, 272, 283, 6507, 4308, 604, 356, 21790, 3717, 1004, 659, 2116, 4018, 4117, 402, 2385, 30350, 11114, 3855, 272, 283, 6507, 4308, 22605, 356, 21790, 3717, 17703, 659, 490, 4018, 4117, 402, 31657, 30350, 11114, 3855, 272, 789, 199, 199, 533, 5543, 4023, 5619, 8, 15169, 527, 90, 5619, 304, 272, 408, 30772, 9592, 1041, 339, 347, 636, 826, 721, 277, 12, 2446, 3806, 304, 267, 408, 8555, 9592, 1041, 267, 25777, 527, 90, 5619, 855, 826, 721, 277, 12, 2446, 3806, 12, 283, 18063, 14, 1907, 297, 21698, 29, 549, 9, 398, 291, 14, 2798, 3806, 275, 2446, 3806, 14, 2798, 398, 327, 367, 325, 482, 402, 675, 267, 663, 697, 275, 4260, 14, 6031, 697, 398, 327, 2455, 2202, 267, 291, 14, 290, 1009, 2241, 1799, 14, 26657, 8, 663, 697, 459, 2798, 63, 290, 1009, 2241, 418, 776, 267, 291, 14, 17872, 1799, 14, 26657, 8, 663, 697, 459, 1907, 63, 17872, 418, 776, 267, 367, 1109, 86, 315, 291, 14, 2798, 3806, 14, 873, 18574, 26, 288, 291, 14, 4284, 12413, 14, 19798, 8, 442, 86, 59, 17, 566, 267, 1478, 275, 359, 73, 59, 16, 61, 367, 284, 315, 291, 14, 2798, 3806, 14, 873, 18574, 1055, 1080, 8, 288, 663, 697, 459, 2798, 63, 873, 3185, 1105, 267, 291, 14, 4284, 12413, 14, 31549, 8, 1080, 9, 267, 291, 14, 2671, 27806, 14, 14733, 8, 663, 697, 459, 2798, 63, 1507, 6962, 418, 776, 398, 327, 3507, 2462, 945, 340, 440, 3748, 267, 340, 440, 19227, 20, 14, 49, 6986, 7243, 14, 9823, 31699, 6986, 9216, 316, 837, 288, 291, 14, 2671, 27806, 14, 14329, 8, 797, 9, 288, 291, 14, 2671, 27806, 14, 29892, 6115, 15049, 2952, 402, 29098, 402, 298, 4490, 298, 19710, 17455, 2291, 2237, 398, 327, 675, 8288, 367, 570, 487, 18238, 267, 334, 277, 14, 694, 3768, 35, 16698, 16065, 340, 663, 697, 459, 3475, 63, 1180, 6525, 418, 587, 291, 14, 694, 3768, 18873, 16065, 680, 4891, 342, 398, 327, 4843, 316, 8247, 267, 469, 288, 283, 1301, 356, 291, 14, 694, 11399, 3768, 16065, 12, 288, 283, 6525, 356, 291, 14, 694, 11399, 35, 16698, 16065, 12, 288, 283, 5701, 356, 291, 14, 694, 11399, 18873, 16065, 12, 267, 28439, 409, 697, 14, 362, 360, 3475, 63, 3790, 63, 1985, 358, 1055, 4891, 342, 398, 327, 663, 7016, 1568, 267, 291, 14, 4677, 2320, 12413, 14, 31549, 8, 288, 291, 14, 4677, 2320, 12413, 14, 1623, 1872, 8, 355, 620, 8, 409, 697, 459, 13951, 63, 890, 26991, 398, 327, 849, 3449, 5069, 267, 291, 14, 2487, 21708, 14, 8341, 8, 409, 697, 459, 15479, 63, 885, 1105, 267, 291, 14, 2487, 24149, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2487, 24149, 31483, 9, 398, 327, 849, 3537, 2202, 267, 291, 14, 4229, 21708, 14, 8341, 8, 409, 697, 459, 4229, 63, 885, 1105, 267, 291, 14, 4229, 24149, 4259, 14, 11276, 14, 2242, 8, 277, 14, 4229, 24149, 31483, 9, 398, 327, 367, 8963, 267, 8963, 275, 769, 8, 663, 697, 14, 362, 360, 5265, 297, 3073, 776, 267, 291, 14, 2718, 1238, 275, 19227, 20, 14, 49, 32216, 1685, 8, 5265, 9, 267, 291, 14, 2718, 1296, 14, 409, 1685, 8, 277, 14, 2718, 1238, 9, 267, 291, 14, 2718, 1123, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2718, 1123, 31483, 9, 267, 291, 14, 2718, 5587, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2718, 5587, 31483, 9, 398, 327, 1106, 329, 1259, 367, 3164, 5174, 267, 291, 14, 2758, 4117, 7690, 342, 398, 327, 367, 2376, 3732, 281, 267, 291, 14, 4510, 281, 1378, 9270, 1799, 14, 26657, 8, 663, 697, 459, 4510, 281, 63, 475, 63, 6614, 418, 776, 267, 291, 14, 4510, 281, 1378, 28459, 1799, 14, 26657, 8, 663, 697, 459, 4510, 281, 63, 475, 63, 7548, 3576, 418, 776, 398, 327, 2366, 931, 267, 291, 14, 5159, 4718, 2042, 14, 8341, 8, 409, 697, 459, 5159, 63, 1548, 515, 1105, 339, 347, 3272, 4117 ]
[ 259, 1898, 334, 35, 9, 8315, 1603, 69, 264, 1662, 428, 14, 29359, 7735, 199, 3, 259, 11426, 26, 1603, 69, 264, 1662, 29359, 7735, 665, 6532, 264, 1662, 32, 6532, 13179, 588, 290, 7735, 14, 846, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 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, 3180, 199, 3, 259, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 259, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 4605, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 2508, 492, 19227, 452, 465, 19227, 20, 199, 504, 2508, 492, 4260, 199, 504, 2508, 492, 3778, 199, 504, 1275, 432, 527, 90, 7196, 492, 25777, 527, 90, 5619, 199, 199, 318, 12561, 505, 12, 2153, 16902, 4086, 29, 403, 12, 1067, 628, 48, 7655, 5619, 2349, 272, 408, 18355, 1318, 1041, 272, 372, 19227, 20, 14, 49, 29263, 14, 5275, 8, 1100, 12, 1318, 12, 2153, 16902, 4086, 9, 199, 199, 3, 1561, 367, 2929, 402, 9229, 436, 282, 8088, 1369, 199, 2326, 63, 1247, 275, 469, 272, 283, 1606, 356, 21790, 3276, 659, 1467, 4018, 3276, 8020, 3164, 3855, 272, 283, 705, 356, 21790, 547, 659, 1598, 4018, 4117, 367, 2552, 3855, 272, 283, 1531, 356, 21790, 9270, 1414, 659, 355, 4018, 14680, 315, 314, 8559, 4353, 3164, 3855, 272, 283, 6507, 4308, 604, 356, 21790, 3717, 1004, 659, 2116, 4018, 4117, 402, 2385, 30350, 11114, 3855, 272, 283, 6507, 4308, 22605, 356, 21790, 3717, 17703, 659, 490, 4018, 4117, 402, 31657, 30350, 11114, 3855, 272, 789, 199, 199, 533, 5543, 4023, 5619, 8, 15169, 527, 90, 5619, 304, 272, 408, 30772, 9592, 1041, 339, 347, 636, 826, 721, 277, 12, 2446, 3806, 304, 267, 408, 8555, 9592, 1041, 267, 25777, 527, 90, 5619, 855, 826, 721, 277, 12, 2446, 3806, 12, 283, 18063, 14, 1907, 297, 21698, 29, 549, 9, 398, 291, 14, 2798, 3806, 275, 2446, 3806, 14, 2798, 398, 327, 367, 325, 482, 402, 675, 267, 663, 697, 275, 4260, 14, 6031, 697, 398, 327, 2455, 2202, 267, 291, 14, 290, 1009, 2241, 1799, 14, 26657, 8, 663, 697, 459, 2798, 63, 290, 1009, 2241, 418, 776, 267, 291, 14, 17872, 1799, 14, 26657, 8, 663, 697, 459, 1907, 63, 17872, 418, 776, 267, 367, 1109, 86, 315, 291, 14, 2798, 3806, 14, 873, 18574, 26, 288, 291, 14, 4284, 12413, 14, 19798, 8, 442, 86, 59, 17, 566, 267, 1478, 275, 359, 73, 59, 16, 61, 367, 284, 315, 291, 14, 2798, 3806, 14, 873, 18574, 1055, 1080, 8, 288, 663, 697, 459, 2798, 63, 873, 3185, 1105, 267, 291, 14, 4284, 12413, 14, 31549, 8, 1080, 9, 267, 291, 14, 2671, 27806, 14, 14733, 8, 663, 697, 459, 2798, 63, 1507, 6962, 418, 776, 398, 327, 3507, 2462, 945, 340, 440, 3748, 267, 340, 440, 19227, 20, 14, 49, 6986, 7243, 14, 9823, 31699, 6986, 9216, 316, 837, 288, 291, 14, 2671, 27806, 14, 14329, 8, 797, 9, 288, 291, 14, 2671, 27806, 14, 29892, 6115, 15049, 2952, 402, 29098, 402, 298, 4490, 298, 19710, 17455, 2291, 2237, 398, 327, 675, 8288, 367, 570, 487, 18238, 267, 334, 277, 14, 694, 3768, 35, 16698, 16065, 340, 663, 697, 459, 3475, 63, 1180, 6525, 418, 587, 291, 14, 694, 3768, 18873, 16065, 680, 4891, 342, 398, 327, 4843, 316, 8247, 267, 469, 288, 283, 1301, 356, 291, 14, 694, 11399, 3768, 16065, 12, 288, 283, 6525, 356, 291, 14, 694, 11399, 35, 16698, 16065, 12, 288, 283, 5701, 356, 291, 14, 694, 11399, 18873, 16065, 12, 267, 28439, 409, 697, 14, 362, 360, 3475, 63, 3790, 63, 1985, 358, 1055, 4891, 342, 398, 327, 663, 7016, 1568, 267, 291, 14, 4677, 2320, 12413, 14, 31549, 8, 288, 291, 14, 4677, 2320, 12413, 14, 1623, 1872, 8, 355, 620, 8, 409, 697, 459, 13951, 63, 890, 26991, 398, 327, 849, 3449, 5069, 267, 291, 14, 2487, 21708, 14, 8341, 8, 409, 697, 459, 15479, 63, 885, 1105, 267, 291, 14, 2487, 24149, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2487, 24149, 31483, 9, 398, 327, 849, 3537, 2202, 267, 291, 14, 4229, 21708, 14, 8341, 8, 409, 697, 459, 4229, 63, 885, 1105, 267, 291, 14, 4229, 24149, 4259, 14, 11276, 14, 2242, 8, 277, 14, 4229, 24149, 31483, 9, 398, 327, 367, 8963, 267, 8963, 275, 769, 8, 663, 697, 14, 362, 360, 5265, 297, 3073, 776, 267, 291, 14, 2718, 1238, 275, 19227, 20, 14, 49, 32216, 1685, 8, 5265, 9, 267, 291, 14, 2718, 1296, 14, 409, 1685, 8, 277, 14, 2718, 1238, 9, 267, 291, 14, 2718, 1123, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2718, 1123, 31483, 9, 267, 291, 14, 2718, 5587, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2718, 5587, 31483, 9, 398, 327, 1106, 329, 1259, 367, 3164, 5174, 267, 291, 14, 2758, 4117, 7690, 342, 398, 327, 367, 2376, 3732, 281, 267, 291, 14, 4510, 281, 1378, 9270, 1799, 14, 26657, 8, 663, 697, 459, 4510, 281, 63, 475, 63, 6614, 418, 776, 267, 291, 14, 4510, 281, 1378, 28459, 1799, 14, 26657, 8, 663, 697, 459, 4510, 281, 63, 475, 63, 7548, 3576, 418, 776, 398, 327, 2366, 931, 267, 291, 14, 5159, 4718, 2042, 14, 8341, 8, 409, 697, 459, 5159, 63, 1548, 515, 1105, 339, 347, 3272, 4117, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dcroc16/skunk_works
google_appengine/lib/django-1.3/django/template/loader.py
149
8326
# Wrapper for loading templates from storage of some sort (e.g. filesystem, database). # # This uses the TEMPLATE_LOADERS setting, which is a list of loaders to use. # Each loader is expected to have this interface: # # callable(name, dirs=[]) # # name is the template name. # dirs is an optional list of directories to search instead of TEMPLATE_DIRS. # # The loader should return a tuple of (template_source, path). The path returned # might be shown to the user for debugging purposes, so it should identify where # the template was loaded from. # # A loader may return an already-compiled template instead of the actual # template source. In that case the path returned should be None, since the # path information is associated with the template during the compilation, # which has already been done. # # Each loader should have an "is_usable" attribute set. This is a boolean that # specifies whether the loader can be used in this Python installation. Each # loader is responsible for setting this when it's initialized. # # For example, the eggs loader (which is capable of loading templates from # Python eggs) sets is_usable to False if the "pkg_resources" module isn't # installed, because pkg_resources is necessary to read eggs. from django.core.exceptions import ImproperlyConfigured from django.template.base import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins from django.utils.importlib import import_module from django.conf import settings template_source_loaders = None class BaseLoader(object): is_usable = False def __init__(self, *args, **kwargs): pass def __call__(self, template_name, template_dirs=None): return self.load_template(template_name, template_dirs) def load_template(self, template_name, template_dirs=None): source, display_name = self.load_template_source(template_name, template_dirs) origin = make_origin(display_name, self.load_template_source, template_name, template_dirs) try: template = get_template_from_string(source, origin, template_name) return template, None except TemplateDoesNotExist: # If compiling the template we found raises TemplateDoesNotExist, back off to # returning the source and display name for the template we were asked to load. # This allows for correct identification (later) of the actual template that does # not exist. return source, display_name def load_template_source(self, template_name, template_dirs=None): """ Returns a tuple containing the source and origin for the given template name. """ raise NotImplementedError def reset(self): """ Resets any state maintained by the loader instance (e.g., cached templates or cached loader modules). """ pass class LoaderOrigin(Origin): def __init__(self, display_name, loader, name, dirs): super(LoaderOrigin, self).__init__(display_name) self.loader, self.loadname, self.dirs = loader, name, dirs def reload(self): return self.loader(self.loadname, self.dirs)[0] def make_origin(display_name, loader, name, dirs): if settings.TEMPLATE_DEBUG and display_name: return LoaderOrigin(display_name, loader, name, dirs) else: return None def find_template_loader(loader): if isinstance(loader, (tuple, list)): loader, args = loader[0], loader[1:] else: args = [] if isinstance(loader, basestring): module, attr = loader.rsplit('.', 1) try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e)) try: TemplateLoader = getattr(mod, attr) except AttributeError, e: raise ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e)) if hasattr(TemplateLoader, 'load_template_source'): func = TemplateLoader(*args) else: # Try loading module the old way - string is full path to callable if args: raise ImproperlyConfigured("Error importing template source loader %s - can't pass arguments to function-based loader." % loader) func = TemplateLoader if not func.is_usable: import warnings warnings.warn("Your TEMPLATE_LOADERS setting includes %r, but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS." % loader) return None else: return func else: raise ImproperlyConfigured('Loader does not define a "load_template" callable template source loader') def find_template(name, dirs=None): # Calculate template_source_loaders the first time the function is executed # because putting this logic in the module-level namespace may cause # circular import errors. See Django ticket #1292. global template_source_loaders if template_source_loaders is None: loaders = [] for loader_name in settings.TEMPLATE_LOADERS: loader = find_template_loader(loader_name) if loader is not None: loaders.append(loader) template_source_loaders = tuple(loaders) for loader in template_source_loaders: try: source, display_name = loader(name, dirs) return (source, make_origin(display_name, loader, name, dirs)) except TemplateDoesNotExist: pass raise TemplateDoesNotExist(name) def find_template_source(name, dirs=None): # For backward compatibility import warnings warnings.warn( "`django.template.loader.find_template_source` is deprecated; use `django.template.loader.find_template` instead.", DeprecationWarning ) template, origin = find_template(name, dirs) if hasattr(template, 'render'): raise Exception("Found a compiled template that is incompatible with the deprecated `django.template.loader.find_template_source` function.") return template, origin def get_template(template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ template, origin = find_template(template_name) if not hasattr(template, 'render'): # template needs to be compiled template = get_template_from_string(template, origin, template_name) return template def get_template_from_string(source, origin=None, name=None): """ Returns a compiled Template object for the given template code, handling template inheritance recursively. """ return Template(source, origin, name) def render_to_string(template_name, dictionary=None, context_instance=None): """ Loads the given template_name and renders it with the given dictionary as context. The template_name may be a string to load a single template using get_template, or it may be a tuple to use select_template to find one of the templates in the list. Returns a string. """ dictionary = dictionary or {} if isinstance(template_name, (list, tuple)): t = select_template(template_name) else: t = get_template(template_name) if not context_instance: return t.render(Context(dictionary)) # Add the dictionary to the context stack, ensuring it gets removed again # to keep the context_instance in the same state it started in. context_instance.update(dictionary) try: return t.render(context_instance) finally: context_instance.pop() def select_template(template_name_list): "Given a list of template names, returns the first that can be loaded." not_found = [] for template_name in template_name_list: try: return get_template(template_name) except TemplateDoesNotExist, e: if e.args[0] not in not_found: not_found.append(e.args[0]) continue # If we get here, none of the templates could be loaded raise TemplateDoesNotExist(', '.join(not_found)) add_to_builtins('django.template.loader_tags')
mit
[ 3, 21947, 367, 8697, 7009, 687, 4887, 402, 2005, 4069, 334, 69, 14, 71, 14, 10036, 12, 3050, 680, 199, 3, 199, 3, 961, 4440, 314, 24877, 63, 7405, 3960, 4260, 12, 1314, 365, 282, 769, 402, 25520, 370, 675, 14, 199, 3, 7048, 5077, 365, 1420, 370, 1172, 642, 3217, 26, 199, 3, 199, 3, 259, 4550, 8, 354, 12, 7606, 14285, 199, 3, 199, 3, 536, 365, 314, 1978, 536, 14, 199, 3, 7606, 365, 376, 2716, 769, 402, 6602, 370, 2754, 3140, 402, 24877, 63, 14455, 14, 199, 3, 199, 3, 710, 5077, 1077, 372, 282, 2008, 402, 334, 1160, 63, 1365, 12, 931, 680, 710, 931, 2138, 199, 3, 5594, 506, 9164, 370, 314, 922, 367, 10201, 12901, 12, 880, 652, 1077, 10405, 2382, 199, 3, 314, 1978, 1990, 6511, 687, 14, 199, 3, 199, 3, 437, 5077, 1443, 372, 376, 2575, 13, 8427, 1978, 3140, 402, 314, 3503, 199, 3, 1978, 1350, 14, 1010, 626, 1930, 314, 931, 2138, 1077, 506, 488, 12, 3967, 314, 199, 3, 931, 2556, 365, 4568, 543, 314, 1978, 5309, 314, 18653, 12, 199, 3, 1314, 965, 2575, 2757, 4224, 14, 199, 3, 199, 3, 7048, 5077, 1077, 1172, 376, 298, 374, 63, 14418, 2, 2225, 663, 14, 961, 365, 282, 5046, 626, 199, 3, 9314, 3775, 314, 5077, 883, 506, 1202, 315, 642, 2018, 12096, 14, 7048, 199, 3, 5077, 365, 17845, 367, 4260, 642, 1380, 652, 1159, 10038, 14, 199, 3, 199, 3, 2104, 2893, 12, 314, 22151, 5077, 334, 6777, 365, 4021, 461, 402, 8697, 7009, 687, 199, 3, 2018, 22151, 9, 5951, 365, 63, 14418, 370, 756, 340, 314, 298, 4600, 63, 4435, 2, 859, 5712, 1133, 199, 3, 4903, 12, 2952, 5496, 63, 4435, 365, 5784, 370, 1586, 22151, 14, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1160, 14, 1095, 492, 31534, 12, 5458, 12, 9470, 12, 27193, 12, 1050, 63, 475, 63, 10372, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 1160, 63, 1365, 63, 16370, 275, 488, 199, 199, 533, 3523, 5455, 8, 785, 304, 272, 365, 63, 14418, 275, 756, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 986, 339, 347, 636, 1250, 721, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 372, 291, 14, 912, 63, 1160, 8, 1160, 63, 354, 12, 1978, 63, 3220, 9, 339, 347, 2248, 63, 1160, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 1350, 12, 2929, 63, 354, 275, 291, 14, 912, 63, 1160, 63, 1365, 8, 1160, 63, 354, 12, 1978, 63, 3220, 9, 267, 6330, 275, 1852, 63, 6493, 8, 2918, 63, 354, 12, 291, 14, 912, 63, 1160, 63, 1365, 12, 1978, 63, 354, 12, 1978, 63, 3220, 9, 267, 862, 26, 288, 1978, 275, 664, 63, 1160, 63, 504, 63, 875, 8, 1365, 12, 6330, 12, 1978, 63, 354, 9, 288, 372, 1978, 12, 488, 267, 871, 27193, 26, 288, 327, 982, 1013, 5662, 314, 1978, 781, 1911, 6534, 27193, 12, 1771, 2331, 370, 288, 327, 8152, 314, 1350, 436, 2929, 536, 367, 314, 1978, 781, 4898, 20864, 370, 2248, 14, 288, 327, 961, 6127, 367, 3211, 29193, 334, 18103, 9, 402, 314, 3503, 1978, 626, 1630, 288, 327, 440, 2187, 14, 288, 372, 1350, 12, 2929, 63, 354, 339, 347, 2248, 63, 1160, 63, 1365, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 408, 267, 1803, 282, 2008, 3035, 314, 1350, 436, 6330, 367, 314, 1627, 1978, 267, 536, 14, 398, 408, 267, 746, 4279, 339, 347, 5305, 8, 277, 304, 267, 408, 267, 799, 2193, 1263, 1174, 26391, 701, 314, 5077, 1256, 334, 69, 14, 71, 2020, 6328, 267, 7009, 503, 6328, 5077, 4621, 680, 398, 408, 267, 986, 199, 199, 533, 22865, 12834, 8, 12834, 304, 272, 347, 636, 826, 721, 277, 12, 2929, 63, 354, 12, 5077, 12, 536, 12, 7606, 304, 267, 1613, 8, 5455, 12834, 12, 291, 2843, 826, 721, 2918, 63, 354, 9, 267, 291, 14, 3422, 12, 291, 14, 912, 354, 12, 291, 14, 3220, 275, 5077, 12, 536, 12, 7606, 339, 347, 13101, 8, 277, 304, 267, 372, 291, 14, 3422, 8, 277, 14, 912, 354, 12, 291, 14, 3220, 2788, 16, 61, 199, 199, 318, 1852, 63, 6493, 8, 2918, 63, 354, 12, 5077, 12, 536, 12, 7606, 304, 272, 340, 2202, 14, 7433, 63, 5287, 436, 2929, 63, 354, 26, 267, 372, 22865, 12834, 8, 2918, 63, 354, 12, 5077, 12, 536, 12, 7606, 9, 272, 587, 26, 267, 372, 488, 199, 199, 318, 2342, 63, 1160, 63, 3422, 8, 3422, 304, 272, 340, 1228, 8, 3422, 12, 334, 2960, 12, 769, 2298, 267, 5077, 12, 1249, 275, 5077, 59, 16, 467, 5077, 59, 17, 2938, 272, 587, 26, 267, 1249, 275, 942, 272, 340, 1228, 8, 3422, 12, 7116, 304, 267, 859, 12, 1921, 275, 5077, 14, 13490, 14078, 413, 9, 267, 862, 26, 288, 3413, 275, 492, 63, 578, 8, 578, 9, 267, 871, 3545, 12, 325, 26, 288, 746, 11897, 360, 547, 16306, 1978, 1350, 5077, 450, 83, 26, 2071, 83, 4507, 450, 334, 3422, 12, 325, 430, 267, 862, 26, 288, 5458, 5455, 275, 2519, 8, 1494, 12, 1921, 9, 267, 871, 4281, 12, 325, 26, 288, 746, 11897, 360, 547, 16306, 1978, 1350, 5077, 450, 83, 26, 2071, 83, 4507, 450, 334, 3422, 12, 325, 430, 398, 340, 2688, 8, 4231, 5455, 12, 283, 912, 63, 1160, 63, 1365, 735, 288, 2562, 275, 5458, 5455, 2031, 589, 9, 267, 587, 26, 288, 327, 7649, 8697, 859, 314, 2269, 4340, 446, 1059, 365, 2615, 931, 370, 4550, 288, 340, 1249, 26, 355, 746, 11897, 480, 547, 16306, 1978, 1350, 5077, 450, 83, 446, 883, 1133, 986, 2368, 370, 805, 13, 6788, 5077, 2122, 450, 5077, 9, 288, 2562, 275, 5458, 5455, 398, 340, 440, 2562, 14, 374, 63, 14418, 26, 288, 492, 3598, 288, 3598, 14, 4050, 480, 14398, 24877, 63, 7405, 3960, 4260, 6952, 450, 82, 12 ]
[ 21947, 367, 8697, 7009, 687, 4887, 402, 2005, 4069, 334, 69, 14, 71, 14, 10036, 12, 3050, 680, 199, 3, 199, 3, 961, 4440, 314, 24877, 63, 7405, 3960, 4260, 12, 1314, 365, 282, 769, 402, 25520, 370, 675, 14, 199, 3, 7048, 5077, 365, 1420, 370, 1172, 642, 3217, 26, 199, 3, 199, 3, 259, 4550, 8, 354, 12, 7606, 14285, 199, 3, 199, 3, 536, 365, 314, 1978, 536, 14, 199, 3, 7606, 365, 376, 2716, 769, 402, 6602, 370, 2754, 3140, 402, 24877, 63, 14455, 14, 199, 3, 199, 3, 710, 5077, 1077, 372, 282, 2008, 402, 334, 1160, 63, 1365, 12, 931, 680, 710, 931, 2138, 199, 3, 5594, 506, 9164, 370, 314, 922, 367, 10201, 12901, 12, 880, 652, 1077, 10405, 2382, 199, 3, 314, 1978, 1990, 6511, 687, 14, 199, 3, 199, 3, 437, 5077, 1443, 372, 376, 2575, 13, 8427, 1978, 3140, 402, 314, 3503, 199, 3, 1978, 1350, 14, 1010, 626, 1930, 314, 931, 2138, 1077, 506, 488, 12, 3967, 314, 199, 3, 931, 2556, 365, 4568, 543, 314, 1978, 5309, 314, 18653, 12, 199, 3, 1314, 965, 2575, 2757, 4224, 14, 199, 3, 199, 3, 7048, 5077, 1077, 1172, 376, 298, 374, 63, 14418, 2, 2225, 663, 14, 961, 365, 282, 5046, 626, 199, 3, 9314, 3775, 314, 5077, 883, 506, 1202, 315, 642, 2018, 12096, 14, 7048, 199, 3, 5077, 365, 17845, 367, 4260, 642, 1380, 652, 1159, 10038, 14, 199, 3, 199, 3, 2104, 2893, 12, 314, 22151, 5077, 334, 6777, 365, 4021, 461, 402, 8697, 7009, 687, 199, 3, 2018, 22151, 9, 5951, 365, 63, 14418, 370, 756, 340, 314, 298, 4600, 63, 4435, 2, 859, 5712, 1133, 199, 3, 4903, 12, 2952, 5496, 63, 4435, 365, 5784, 370, 1586, 22151, 14, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1160, 14, 1095, 492, 31534, 12, 5458, 12, 9470, 12, 27193, 12, 1050, 63, 475, 63, 10372, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 1160, 63, 1365, 63, 16370, 275, 488, 199, 199, 533, 3523, 5455, 8, 785, 304, 272, 365, 63, 14418, 275, 756, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 986, 339, 347, 636, 1250, 721, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 372, 291, 14, 912, 63, 1160, 8, 1160, 63, 354, 12, 1978, 63, 3220, 9, 339, 347, 2248, 63, 1160, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 1350, 12, 2929, 63, 354, 275, 291, 14, 912, 63, 1160, 63, 1365, 8, 1160, 63, 354, 12, 1978, 63, 3220, 9, 267, 6330, 275, 1852, 63, 6493, 8, 2918, 63, 354, 12, 291, 14, 912, 63, 1160, 63, 1365, 12, 1978, 63, 354, 12, 1978, 63, 3220, 9, 267, 862, 26, 288, 1978, 275, 664, 63, 1160, 63, 504, 63, 875, 8, 1365, 12, 6330, 12, 1978, 63, 354, 9, 288, 372, 1978, 12, 488, 267, 871, 27193, 26, 288, 327, 982, 1013, 5662, 314, 1978, 781, 1911, 6534, 27193, 12, 1771, 2331, 370, 288, 327, 8152, 314, 1350, 436, 2929, 536, 367, 314, 1978, 781, 4898, 20864, 370, 2248, 14, 288, 327, 961, 6127, 367, 3211, 29193, 334, 18103, 9, 402, 314, 3503, 1978, 626, 1630, 288, 327, 440, 2187, 14, 288, 372, 1350, 12, 2929, 63, 354, 339, 347, 2248, 63, 1160, 63, 1365, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 408, 267, 1803, 282, 2008, 3035, 314, 1350, 436, 6330, 367, 314, 1627, 1978, 267, 536, 14, 398, 408, 267, 746, 4279, 339, 347, 5305, 8, 277, 304, 267, 408, 267, 799, 2193, 1263, 1174, 26391, 701, 314, 5077, 1256, 334, 69, 14, 71, 2020, 6328, 267, 7009, 503, 6328, 5077, 4621, 680, 398, 408, 267, 986, 199, 199, 533, 22865, 12834, 8, 12834, 304, 272, 347, 636, 826, 721, 277, 12, 2929, 63, 354, 12, 5077, 12, 536, 12, 7606, 304, 267, 1613, 8, 5455, 12834, 12, 291, 2843, 826, 721, 2918, 63, 354, 9, 267, 291, 14, 3422, 12, 291, 14, 912, 354, 12, 291, 14, 3220, 275, 5077, 12, 536, 12, 7606, 339, 347, 13101, 8, 277, 304, 267, 372, 291, 14, 3422, 8, 277, 14, 912, 354, 12, 291, 14, 3220, 2788, 16, 61, 199, 199, 318, 1852, 63, 6493, 8, 2918, 63, 354, 12, 5077, 12, 536, 12, 7606, 304, 272, 340, 2202, 14, 7433, 63, 5287, 436, 2929, 63, 354, 26, 267, 372, 22865, 12834, 8, 2918, 63, 354, 12, 5077, 12, 536, 12, 7606, 9, 272, 587, 26, 267, 372, 488, 199, 199, 318, 2342, 63, 1160, 63, 3422, 8, 3422, 304, 272, 340, 1228, 8, 3422, 12, 334, 2960, 12, 769, 2298, 267, 5077, 12, 1249, 275, 5077, 59, 16, 467, 5077, 59, 17, 2938, 272, 587, 26, 267, 1249, 275, 942, 272, 340, 1228, 8, 3422, 12, 7116, 304, 267, 859, 12, 1921, 275, 5077, 14, 13490, 14078, 413, 9, 267, 862, 26, 288, 3413, 275, 492, 63, 578, 8, 578, 9, 267, 871, 3545, 12, 325, 26, 288, 746, 11897, 360, 547, 16306, 1978, 1350, 5077, 450, 83, 26, 2071, 83, 4507, 450, 334, 3422, 12, 325, 430, 267, 862, 26, 288, 5458, 5455, 275, 2519, 8, 1494, 12, 1921, 9, 267, 871, 4281, 12, 325, 26, 288, 746, 11897, 360, 547, 16306, 1978, 1350, 5077, 450, 83, 26, 2071, 83, 4507, 450, 334, 3422, 12, 325, 430, 398, 340, 2688, 8, 4231, 5455, 12, 283, 912, 63, 1160, 63, 1365, 735, 288, 2562, 275, 5458, 5455, 2031, 589, 9, 267, 587, 26, 288, 327, 7649, 8697, 859, 314, 2269, 4340, 446, 1059, 365, 2615, 931, 370, 4550, 288, 340, 1249, 26, 355, 746, 11897, 480, 547, 16306, 1978, 1350, 5077, 450, 83, 446, 883, 1133, 986, 2368, 370, 805, 13, 6788, 5077, 2122, 450, 5077, 9, 288, 2562, 275, 5458, 5455, 398, 340, 440, 2562, 14, 374, 63, 14418, 26, 288, 492, 3598, 288, 3598, 14, 4050, 480, 14398, 24877, 63, 7405, 3960, 4260, 6952, 450, 82, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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[1] == '-h': print "\nUsage:" print "\t./tools/classhier.py file1.py file2.py ...\n" print "\n\t".join(textwrap.wrap("\tGenerate a nice graph of the class hierarchy in the files supplied as arguments.")) print sys.exit(0) class ClassInfo(object): def __init__(self, module, name): self.module = module self.name = name class ClassDb(object): def __init__(self): self.db = {} def add_classdef(self, mod, name): """ mod - the module the class is defined in name - the name of the class """ if mod not in self.db: self.db[mod] = {} self.db[mod][name] = [] def add_class_parent(self, mod, name, parent): """ mod - the module the class is defined in name - the name of the class parent - a (mod, name) tuple of one parent """ self.db[mod][name].append(parent) def has_class(self, mod, name): return mod in self.db and name in self.db[mod] def write(self, filename, filetype): def fmt(mod, cls): return cls return r'"%s %s"' % (mod.replace(".", "_"), cls) f = open(filename, 'w') if filetype == 'fdp': joinstr = " -- " print >> f, "graph G {" print >> f, "overlap=false;" print >> f, "splines=true;" elif filetype == 'dot': print >> f, "digraph G {" #print >> f, 'size = "8,10";' print >> f, 'ratio = fill;' print >> f, 'margin = 1;' print >> f, 'center = 1;' print >> f, 'bgcolor=white;' print >> f, 'edge [color=blue,arrowhead=normal,arrowsize=1.5];' print >> f, "rankdir=LR;" joinstr = " -> " for mod in self.db: for cl in self.db[mod]: this_mod = mod.replace(".", "_") #print >> f, fmt(mod, cl) for parent in self.db[mod][cl]: p = r'"%s\n%s"' % (this_mod, parent) print >> f, r'%s%s%s;' % (fmt(mod, cl), joinstr, fmt(*parent)) print >> f, "}" f.close() class_re = re.compile(""" (?P<all>class\s* (?P<classname>[a-zA-Z]\w*) (\( (?P<parentlist> (.*?) # The first parent (,(.*?))* # unknown number of more parents )\))?:)""", re.VERBOSE)#(\(*?\))") db = ClassDb() def mod_split(modulename): """ Split the complete modulename into (package, modulename) tuple """ v = modulename.split(".") return ".".join(modulename.split(".")[:-1]), v[-1] def mod_to_filename(mod): " solfege.abstract => solfege/abstract.py" return mod.replace(".", "/") + ".py" def do_file(fn): modulename = fn[:-3].replace("/", ".") package = mod_split(modulename)[0] s = open(fn).read() for m in class_re.finditer(s): if m: parents = m.group('parentlist') if parents: parents = [p.strip() for p in parents.split(",")] else: parents = [] db.add_classdef(modulename, m.group('classname')) for p in parents: # Continue if this is not a module in this project. if p in ('unicode', 'list', 'dict', 'object'): continue if p.startswith("Gtk."): continue mname = os.path.join(mod_split(modulename)[0], mod_split(p)[0])+".py" if mod_split(p)[0] and not os.path.exists(mname): print "DROPPING", p continue if "." in p: mm = ".".join((package, mod_split(p)[0])) nn = mod_split(p)[1] db.add_class_parent(modulename, m.group('classname'), (mm, nn)) else: db.add_class_parent(modulename, m.group('classname'), (modulename, p)) for fn in sys.argv[1:]: do_file(fn) for mod, d in db.db.items(): for deps in d.values(): for dep in deps: if dep[0] not in db.db.keys(): do_file(mod_to_filename(dep[0])) db.write("classhier.dot", 'dot') os.system("dot -T png -o classhier.png classhier.dot") print "created classhier.png" #os.system("fdp -T png -o classhier.png classhier.dot")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 295, 199, 646, 984, 199, 646, 747, 199, 646, 13390, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 272, 870, 1867, 78, 7692, 5424, 272, 870, 1867, 84, 13186, 2537, 15, 533, 31184, 14, 647, 570, 17, 14, 647, 570, 18, 14, 647, 2263, 60, 78, 2, 272, 870, 1867, 78, 60, 84, 1674, 904, 8, 505, 3823, 14, 3823, 4582, 84, 6864, 282, 14213, 3343, 402, 314, 1021, 14446, 315, 314, 1584, 6841, 465, 2368, 13853, 272, 870, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 533, 8089, 2354, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 536, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 354, 275, 536, 199, 199, 533, 8089, 8882, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 697, 275, 1052, 272, 347, 1050, 63, 533, 318, 8, 277, 12, 3413, 12, 536, 304, 267, 408, 267, 3413, 446, 314, 859, 314, 1021, 365, 3247, 315, 267, 536, 446, 314, 536, 402, 314, 1021, 267, 408, 267, 340, 3413, 440, 315, 291, 14, 697, 26, 288, 291, 14, 697, 59, 1494, 61, 275, 1052, 267, 291, 14, 697, 59, 1494, 1527, 354, 61, 275, 942, 272, 347, 1050, 63, 533, 63, 1708, 8, 277, 12, 3413, 12, 536, 12, 1676, 304, 267, 408, 267, 3413, 446, 314, 859, 314, 1021, 365, 3247, 315, 267, 536, 446, 314, 536, 402, 314, 1021, 267, 1676, 446, 282, 334, 1494, 12, 536, 9, 2008, 402, 1373, 1676, 267, 408, 267, 291, 14, 697, 59, 1494, 1527, 354, 1055, 740, 8, 1708, 9, 272, 347, 965, 63, 533, 8, 277, 12, 3413, 12, 536, 304, 267, 372, 3413, 315, 291, 14, 697, 436, 536, 315, 291, 14, 697, 59, 1494, 61, 272, 347, 2218, 8, 277, 12, 1788, 12, 26245, 304, 267, 347, 7104, 8, 1494, 12, 843, 304, 288, 372, 843, 288, 372, 519, 4065, 5, 83, 450, 83, 4507, 450, 334, 1494, 14, 1814, 30381, 2668, 1288, 843, 9, 267, 289, 275, 1551, 8, 1501, 12, 283, 87, 358, 267, 340, 26245, 508, 283, 2592, 80, 356, 288, 4263, 495, 275, 298, 1553, 298, 288, 870, 4331, 289, 12, 298, 2180, 598, 2420, 288, 870, 4331, 289, 12, 298, 16736, 29, 3910, 9426, 288, 870, 4331, 289, 12, 298, 681, 1278, 29, 2052, 9426, 267, 916, 26245, 508, 283, 3287, 356, 288, 870, 4331, 289, 12, 298, 328, 2180, 598, 2420, 288, 327, 1361, 4331, 289, 12, 283, 890, 275, 298, 24, 12, 709, 2, 8942, 288, 870, 4331, 289, 12, 283, 6884, 275, 5554, 8942, 288, 870, 4331, 289, 12, 283, 9650, 275, 413, 8942, 288, 870, 4331, 289, 12, 283, 4218, 275, 413, 8942, 288, 870, 4331, 289, 12, 283, 28710, 29, 7510, 8942, 288, 870, 4331, 289, 12, 283, 5173, 359, 2326, 29, 6304, 12, 7691, 2993, 29, 3302, 12, 7691, 890, 29, 17, 14, 21, 61, 8942, 288, 870, 4331, 289, 12, 298, 4648, 694, 29, 17665, 9426, 953, 4263, 495, 275, 298, 1035, 298, 267, 367, 3413, 315, 291, 14, 697, 26, 288, 367, 824, 315, 291, 14, 697, 59, 1494, 2189, 355, 642, 63, 1494, 275, 3413, 14, 1814, 30381, 2668, 531, 355, 327, 1361, 4331, 289, 12, 7104, 8, 1494, 12, 824, 9, 355, 367, 1676, 315, 291, 14, 697, 59, 1494, 1527, 429, 2189, 490, 299, 275, 519, 4065, 5, 83, 60, 78, 5, 83, 4507, 450, 334, 3749, 63, 1494, 12, 1676, 9, 490, 870, 4331, 289, 12, 519, 5956, 83, 5, 83, 5, 83, 8942, 450, 334, 5045, 8, 1494, 12, 824, 395, 4263, 495, 12, 7104, 2031, 1708, 430, 267, 870, 4331, 289, 12, 298, 7063, 267, 289, 14, 1600, 342, 199, 199, 533, 63, 264, 275, 295, 14, 2014, 4852, 2043, 7558, 48, 28, 452, 30, 533, 60, 83, 10, 272, 7558, 48, 28, 19851, 9514, 65, 13, 6353, 13, 58, 7272, 87, 13278, 272, 14749, 8, 272, 7558, 48, 28, 1708, 513, 30, 272, 334, 6697, 9, 221, 327, 710, 1642, 1676, 272, 334, 12803, 6697, 19198, 327, 5809, 1329, 402, 1655, 8623, 272, 776, 60, 22119, 26, 9, 7208, 295, 14, 16075, 28017, 2961, 2031, 8995, 430, 531, 199, 199, 697, 275, 8089, 8882, 342, 199, 199, 318, 3413, 63, 1294, 8, 22582, 304, 272, 408, 272, 11740, 314, 4890, 30045, 1901, 334, 2491, 12, 30045, 9, 2008, 272, 408, 272, 373, 275, 30045, 14, 1294, 15857, 272, 372, 32443, 904, 8, 22582, 14, 1294, 15857, 4439, 17, 2522, 373, 1988, 17, 61, 199, 199, 318, 3413, 63, 475, 63, 1501, 8, 1494, 304, 272, 298, 880, 276, 69, 303, 14, 6198, 9265, 880, 276, 69, 303, 15, 6198, 14, 647, 2, 272, 372, 3413, 14, 1814, 30381, 3286, 531, 435, 3680, 647, 2, 199, 318, 886, 63, 493, 8, 2324, 304, 272, 30045, 275, 4325, 4439, 19, 1055, 1814, 27374, 298, 2685, 272, 2559, 275, 3413, 63, 1294, 8, 22582, 2788, 16, 61, 272, 308, 275, 1551, 8, 2324, 680, 739, 342, 272, 367, 333, 315, 1021, 63, 264, 14, 19373, 8, 83, 304, 267, 340, 333, 26, 288, 8623, 275, 333, 14, 923, 360, 1708, 513, 358, 288, 340, 8623, 26, 355, 8623, 275, 359, 80, 14, 1913, 342, 367, 299, 315, 8623, 14, 1294, 11854, 11323, 288, 587, 26, 355, 8623, 275, 942, 288, 1592, 14, 525, 63, 533, 318, 8, 22582, 12, 333, 14, 923, 360, 19851, 1333, 288, 367, 299, 315, 8623, 26, 355, 327, 1448, 1781, 340, 642, 365, 440, 282, 859, 315, 642, 2199, 14, 355, 340, 299, 315, 661, 2975, 297, 283, 513, 297, 283, 807, 297, 283, 785, 735, 490, 1980, 355, 340, 299, 14, 2460, 480, 18891, 30946, 490, 1980, 355, 333, 354, 275, 747, 14, 515, 14, 904, 8, 1494, 63, 1294, 8, 22582, 2788, 16, 467, 3413, 63, 1294, 8, 80, 2788, 16, 566, 24878, 647, 2, 355, 340, 3413, 63, 1294, 8, 80, 2788, 16, 61, 436, 440, 747, 14, 515, 14, 2444, 8, 77, 354, 304, 490, 870 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 295, 199, 646, 984, 199, 646, 747, 199, 646, 13390, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 272, 870, 1867, 78, 7692, 5424, 272, 870, 1867, 84, 13186, 2537, 15, 533, 31184, 14, 647, 570, 17, 14, 647, 570, 18, 14, 647, 2263, 60, 78, 2, 272, 870, 1867, 78, 60, 84, 1674, 904, 8, 505, 3823, 14, 3823, 4582, 84, 6864, 282, 14213, 3343, 402, 314, 1021, 14446, 315, 314, 1584, 6841, 465, 2368, 13853, 272, 870, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 533, 8089, 2354, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 536, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 354, 275, 536, 199, 199, 533, 8089, 8882, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 697, 275, 1052, 272, 347, 1050, 63, 533, 318, 8, 277, 12, 3413, 12, 536, 304, 267, 408, 267, 3413, 446, 314, 859, 314, 1021, 365, 3247, 315, 267, 536, 446, 314, 536, 402, 314, 1021, 267, 408, 267, 340, 3413, 440, 315, 291, 14, 697, 26, 288, 291, 14, 697, 59, 1494, 61, 275, 1052, 267, 291, 14, 697, 59, 1494, 1527, 354, 61, 275, 942, 272, 347, 1050, 63, 533, 63, 1708, 8, 277, 12, 3413, 12, 536, 12, 1676, 304, 267, 408, 267, 3413, 446, 314, 859, 314, 1021, 365, 3247, 315, 267, 536, 446, 314, 536, 402, 314, 1021, 267, 1676, 446, 282, 334, 1494, 12, 536, 9, 2008, 402, 1373, 1676, 267, 408, 267, 291, 14, 697, 59, 1494, 1527, 354, 1055, 740, 8, 1708, 9, 272, 347, 965, 63, 533, 8, 277, 12, 3413, 12, 536, 304, 267, 372, 3413, 315, 291, 14, 697, 436, 536, 315, 291, 14, 697, 59, 1494, 61, 272, 347, 2218, 8, 277, 12, 1788, 12, 26245, 304, 267, 347, 7104, 8, 1494, 12, 843, 304, 288, 372, 843, 288, 372, 519, 4065, 5, 83, 450, 83, 4507, 450, 334, 1494, 14, 1814, 30381, 2668, 1288, 843, 9, 267, 289, 275, 1551, 8, 1501, 12, 283, 87, 358, 267, 340, 26245, 508, 283, 2592, 80, 356, 288, 4263, 495, 275, 298, 1553, 298, 288, 870, 4331, 289, 12, 298, 2180, 598, 2420, 288, 870, 4331, 289, 12, 298, 16736, 29, 3910, 9426, 288, 870, 4331, 289, 12, 298, 681, 1278, 29, 2052, 9426, 267, 916, 26245, 508, 283, 3287, 356, 288, 870, 4331, 289, 12, 298, 328, 2180, 598, 2420, 288, 327, 1361, 4331, 289, 12, 283, 890, 275, 298, 24, 12, 709, 2, 8942, 288, 870, 4331, 289, 12, 283, 6884, 275, 5554, 8942, 288, 870, 4331, 289, 12, 283, 9650, 275, 413, 8942, 288, 870, 4331, 289, 12, 283, 4218, 275, 413, 8942, 288, 870, 4331, 289, 12, 283, 28710, 29, 7510, 8942, 288, 870, 4331, 289, 12, 283, 5173, 359, 2326, 29, 6304, 12, 7691, 2993, 29, 3302, 12, 7691, 890, 29, 17, 14, 21, 61, 8942, 288, 870, 4331, 289, 12, 298, 4648, 694, 29, 17665, 9426, 953, 4263, 495, 275, 298, 1035, 298, 267, 367, 3413, 315, 291, 14, 697, 26, 288, 367, 824, 315, 291, 14, 697, 59, 1494, 2189, 355, 642, 63, 1494, 275, 3413, 14, 1814, 30381, 2668, 531, 355, 327, 1361, 4331, 289, 12, 7104, 8, 1494, 12, 824, 9, 355, 367, 1676, 315, 291, 14, 697, 59, 1494, 1527, 429, 2189, 490, 299, 275, 519, 4065, 5, 83, 60, 78, 5, 83, 4507, 450, 334, 3749, 63, 1494, 12, 1676, 9, 490, 870, 4331, 289, 12, 519, 5956, 83, 5, 83, 5, 83, 8942, 450, 334, 5045, 8, 1494, 12, 824, 395, 4263, 495, 12, 7104, 2031, 1708, 430, 267, 870, 4331, 289, 12, 298, 7063, 267, 289, 14, 1600, 342, 199, 199, 533, 63, 264, 275, 295, 14, 2014, 4852, 2043, 7558, 48, 28, 452, 30, 533, 60, 83, 10, 272, 7558, 48, 28, 19851, 9514, 65, 13, 6353, 13, 58, 7272, 87, 13278, 272, 14749, 8, 272, 7558, 48, 28, 1708, 513, 30, 272, 334, 6697, 9, 221, 327, 710, 1642, 1676, 272, 334, 12803, 6697, 19198, 327, 5809, 1329, 402, 1655, 8623, 272, 776, 60, 22119, 26, 9, 7208, 295, 14, 16075, 28017, 2961, 2031, 8995, 430, 531, 199, 199, 697, 275, 8089, 8882, 342, 199, 199, 318, 3413, 63, 1294, 8, 22582, 304, 272, 408, 272, 11740, 314, 4890, 30045, 1901, 334, 2491, 12, 30045, 9, 2008, 272, 408, 272, 373, 275, 30045, 14, 1294, 15857, 272, 372, 32443, 904, 8, 22582, 14, 1294, 15857, 4439, 17, 2522, 373, 1988, 17, 61, 199, 199, 318, 3413, 63, 475, 63, 1501, 8, 1494, 304, 272, 298, 880, 276, 69, 303, 14, 6198, 9265, 880, 276, 69, 303, 15, 6198, 14, 647, 2, 272, 372, 3413, 14, 1814, 30381, 3286, 531, 435, 3680, 647, 2, 199, 318, 886, 63, 493, 8, 2324, 304, 272, 30045, 275, 4325, 4439, 19, 1055, 1814, 27374, 298, 2685, 272, 2559, 275, 3413, 63, 1294, 8, 22582, 2788, 16, 61, 272, 308, 275, 1551, 8, 2324, 680, 739, 342, 272, 367, 333, 315, 1021, 63, 264, 14, 19373, 8, 83, 304, 267, 340, 333, 26, 288, 8623, 275, 333, 14, 923, 360, 1708, 513, 358, 288, 340, 8623, 26, 355, 8623, 275, 359, 80, 14, 1913, 342, 367, 299, 315, 8623, 14, 1294, 11854, 11323, 288, 587, 26, 355, 8623, 275, 942, 288, 1592, 14, 525, 63, 533, 318, 8, 22582, 12, 333, 14, 923, 360, 19851, 1333, 288, 367, 299, 315, 8623, 26, 355, 327, 1448, 1781, 340, 642, 365, 440, 282, 859, 315, 642, 2199, 14, 355, 340, 299, 315, 661, 2975, 297, 283, 513, 297, 283, 807, 297, 283, 785, 735, 490, 1980, 355, 340, 299, 14, 2460, 480, 18891, 30946, 490, 1980, 355, 333, 354, 275, 747, 14, 515, 14, 904, 8, 1494, 63, 1294, 8, 22582, 2788, 16, 467, 3413, 63, 1294, 8, 80, 2788, 16, 566, 24878, 647, 2, 355, 340, 3413, 63, 1294, 8, 80, 2788, 16, 61, 436, 440, 747, 14, 515, 14, 2444, 8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 1, 1, 1, 1, 1, 1, 1, 1 ]
rfdrake/netbox
netbox/extras/management/commands/run_inventory.py
1
5738
from getpass import getpass from ncclient.transport.errors import AuthenticationError from paramiko import AuthenticationException from django.conf import settings from django.core.management.base import BaseCommand, CommandError from django.db import transaction from dcim.models import Device, Module, Site class Command(BaseCommand): help = "Update inventory information for specified devices" username = settings.NETBOX_USERNAME password = settings.NETBOX_PASSWORD def add_arguments(self, parser): parser.add_argument('-u', '--username', dest='username', help="Specify the username to use") parser.add_argument('-p', '--password', action='store_true', default=False, help="Prompt for password to use") parser.add_argument('-s', '--site', dest='site', action='append', help="Filter devices by site (include argument once per site)") parser.add_argument('-n', '--name', dest='name', help="Filter devices by name (regular expression)") parser.add_argument('--full', action='store_true', default=False, help="For inventory update for all devices") parser.add_argument('--fake', action='store_true', default=False, help="Do not actually update database") def handle(self, *args, **options): def create_modules(modules, parent=None): for module in modules: m = Module(device=device, parent=parent, name=module['name'], part_id=module['part_id'], serial=module['serial'], discovered=True) m.save() create_modules(module.get('modules', []), parent=m) # Credentials if options['username']: self.username = options['username'] if options['password']: self.password = getpass("Password: ") # Attempt to inventory only active devices device_list = Device.objects.filter(status=True) # --site: Include only devices belonging to specified site(s) if options['site']: sites = Site.objects.filter(slug__in=options['site']) if sites: site_names = [s.name for s in sites] self.stdout.write("Running inventory for these sites: {}".format(', '.join(site_names))) else: raise CommandError("One or more sites specified but none found.") device_list = device_list.filter(rack__site__in=sites) # --name: Filter devices by name matching a regex if options['name']: device_list = device_list.filter(name__iregex=options['name']) # --full: Gather inventory data for *all* devices if options['full']: self.stdout.write("WARNING: Running inventory for all devices! Prior data will be overwritten. (--full)") # --fake: Gathering data but not updating the database if options['fake']: self.stdout.write("WARNING: Inventory data will not be saved! (--fake)") device_count = device_list.count() self.stdout.write("** Found {} devices...".format(device_count)) for i, device in enumerate(device_list, start=1): self.stdout.write("[{}/{}] {}: ".format(i, device_count, device.name), ending='') # Skip inactive devices if not device.status: self.stdout.write("Skipped (inactive)") continue # Skip devices without primary_ip set if not device.primary_ip: self.stdout.write("Skipped (no primary IP set)") continue # Skip devices which have already been inventoried if not doing a full update if device.serial and not options['full']: self.stdout.write("Skipped (Serial: {})".format(device.serial)) continue RPC = device.get_rpc_client() if not RPC: self.stdout.write("Skipped (no RPC client available for platform {})".format(device.platform)) continue # Connect to device and retrieve inventory info try: with RPC(device, self.username, self.password) as rpc_client: inventory = rpc_client.get_inventory() except KeyboardInterrupt: raise except (AuthenticationError, AuthenticationException): self.stdout.write("Authentication error!") continue except Exception as e: self.stdout.write("Error: {}".format(e)) continue if options['verbosity'] > 1: self.stdout.write("") self.stdout.write("\tSerial: {}".format(inventory['chassis']['serial'])) self.stdout.write("\tDescription: {}".format(inventory['chassis']['description'])) for module in inventory['modules']: self.stdout.write("\tModule: {} / {} ({})".format(module['name'], module['part_id'], module['serial'])) else: self.stdout.write("{} ({})".format(inventory['chassis']['description'], inventory['chassis']['serial'])) if not options['fake']: with transaction.atomic(): # Update device serial if device.serial != inventory['chassis']['serial']: device.serial = inventory['chassis']['serial'] device.save() Module.objects.filter(device=device, discovered=True).delete() create_modules(inventory.get('modules', [])) self.stdout.write("Finished!")
apache-2.0
[ 504, 18354, 492, 18354, 199, 504, 12698, 1258, 14, 5545, 14, 2550, 492, 15995, 547, 199, 504, 26162, 492, 15995, 1726, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6008, 199, 199, 504, 366, 559, 77, 14, 992, 492, 12272, 12, 5673, 12, 11666, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 4152, 8200, 2556, 367, 2013, 7256, 2, 272, 3434, 275, 2202, 14, 7278, 15694, 63, 11958, 272, 2505, 275, 2202, 14, 7278, 15694, 63, 9032, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 3654, 85, 297, 2850, 2473, 297, 2053, 534, 2473, 297, 1720, 628, 17768, 314, 3434, 370, 675, 531, 267, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 2060, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 20430, 367, 2505, 370, 675, 531, 267, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 2124, 297, 2053, 534, 2124, 297, 1595, 534, 740, 297, 1169, 1720, 628, 4131, 7256, 701, 4770, 334, 2613, 1423, 5403, 1126, 4770, 6320, 267, 1798, 14, 525, 63, 2094, 3654, 78, 297, 2850, 354, 297, 2053, 534, 354, 297, 1720, 628, 4131, 7256, 701, 536, 334, 7898, 3965, 6320, 267, 1798, 14, 525, 63, 2094, 4517, 2861, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 1858, 8200, 1678, 367, 1006, 7256, 531, 267, 1798, 14, 525, 63, 2094, 4517, 3183, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 2585, 440, 5965, 1678, 3050, 531, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 347, 1218, 63, 3112, 8, 3112, 12, 1676, 29, 403, 304, 288, 367, 859, 315, 4621, 26, 355, 333, 275, 5673, 8, 1782, 29, 1782, 12, 1676, 29, 1708, 12, 536, 29, 578, 459, 354, 995, 1777, 63, 344, 29, 578, 459, 2064, 63, 344, 995, 2574, 3012, 29, 578, 459, 2171, 995, 24983, 29, 549, 9, 355, 333, 14, 2117, 342, 355, 1218, 63, 3112, 8, 578, 14, 362, 360, 3112, 297, 14431, 1676, 29, 77, 9, 398, 327, 23934, 267, 340, 1511, 459, 2473, 2565, 288, 291, 14, 2473, 275, 1511, 459, 2473, 418, 267, 340, 1511, 459, 2060, 2565, 288, 291, 14, 2060, 275, 18354, 480, 6139, 26, 6099, 398, 327, 23115, 370, 8200, 1454, 4702, 7256, 267, 2243, 63, 513, 275, 12272, 14, 1462, 14, 1541, 8, 1205, 29, 549, 9, 398, 327, 1553, 2124, 26, 15783, 1454, 7256, 30226, 370, 2013, 4770, 8, 83, 9, 267, 340, 1511, 459, 2124, 2565, 288, 15424, 275, 11666, 14, 1462, 14, 1541, 8, 5464, 363, 262, 29, 1419, 459, 2124, 1105, 288, 340, 15424, 26, 355, 4770, 63, 1247, 275, 359, 83, 14, 354, 367, 308, 315, 15424, 61, 355, 291, 14, 2703, 14, 952, 480, 9602, 8200, 367, 3520, 15424, 26, 8352, 908, 5102, 1987, 904, 8, 2124, 63, 1247, 1724, 288, 587, 26, 355, 746, 14393, 480, 4395, 503, 1655, 15424, 2013, 1325, 7179, 1911, 2685, 288, 2243, 63, 513, 275, 2243, 63, 513, 14, 1541, 8, 8085, 363, 2124, 363, 262, 29, 8619, 9, 398, 327, 1553, 354, 26, 9388, 7256, 701, 536, 4877, 282, 5163, 267, 340, 1511, 459, 354, 2565, 288, 2243, 63, 513, 275, 2243, 63, 513, 14, 1541, 8, 354, 363, 3621, 2145, 29, 1419, 459, 354, 1105, 398, 327, 1553, 2861, 26, 19634, 8200, 666, 367, 627, 452, 10, 7256, 267, 340, 1511, 459, 2861, 2565, 288, 291, 14, 2703, 14, 952, 480, 9171, 26, 26848, 8200, 367, 1006, 7256, 1, 8538, 269, 666, 911, 506, 20200, 14, 334, 306, 2861, 6320, 398, 327, 1553, 3183, 26, 19634, 316, 666, 1325, 440, 12928, 314, 3050, 267, 340, 1511, 459, 3183, 2565, 288, 291, 14, 2703, 14, 952, 480, 9171, 26, 19337, 666, 911, 440, 506, 6290, 1, 334, 306, 3183, 6320, 398, 2243, 63, 835, 275, 2243, 63, 513, 14, 835, 342, 267, 291, 14, 2703, 14, 952, 480, 538, 2643, 1052, 7256, 1396, 1674, 908, 8, 1782, 63, 835, 430, 398, 367, 284, 12, 2243, 315, 3874, 8, 1782, 63, 513, 12, 1343, 29, 17, 304, 953, 291, 14, 2703, 14, 952, 10994, 2440, 14698, 61, 24702, 3680, 908, 8, 73, 12, 2243, 63, 835, 12, 2243, 14, 354, 395, 13401, 13275, 953, 327, 8232, 21325, 7256, 288, 340, 440, 2243, 14, 1205, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 16856, 6320, 355, 1980, 953, 327, 8232, 7256, 1928, 5062, 63, 711, 663, 288, 340, 440, 2243, 14, 3327, 63, 711, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 889, 5062, 3531, 663, 6320, 355, 1980, 953, 327, 8232, 7256, 1314, 1172, 2575, 2757, 315, 782, 269, 5299, 340, 440, 9689, 282, 2615, 1678, 288, 340, 2243, 14, 2171, 436, 440, 1511, 459, 2861, 2565, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 3571, 26, 5009, 1674, 908, 8, 1782, 14, 2171, 430, 355, 1980, 953, 11785, 275, 2243, 14, 362, 63, 4354, 63, 1258, 342, 288, 340, 440, 11785, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 889, 11785, 1890, 2808, 367, 4298, 5009, 1674, 908, 8, 1782, 14, 3246, 430, 355, 1980, 953, 327, 15175, 370, 2243, 436, 8044, 8200, 2256, 288, 862, 26, 355, 543, 11785, 8, 1782, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 465, 8985, 63, 1258, 26, 490, 8200, 275, 8985, 63, 1258, 14, 362, 63, 7212, 342, 288, 871, 13483, 26, 355, 746, 288, 871, 334, 27942, 12, 15995, 1726, 304, 355, 291, 14, 2703, 14, 952, 480, 10348, 1125, 9124, 355, 1980, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 2703, 14, 952, 480, 547, 26, 8352, 908, 8, 69, 430, 355, 1980, 953, 340, 1511, 459, 9833, 418, 690, 413, 26, 355, 291, 14, 2703, 14, 952, 10804, 355, 291, 14, 2703, 14, 952, 4582, 84, 3571, 26, 8352, 908, 8, 7212, 459, 31187, 2545, 2171, 5156, 355, 291, 14, 2703, 14, 952, 4582, 84, 5831, 26, 8352, 908, 8, 7212, 459 ]
[ 18354, 492, 18354, 199, 504, 12698, 1258, 14, 5545, 14, 2550, 492, 15995, 547, 199, 504, 26162, 492, 15995, 1726, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6008, 199, 199, 504, 366, 559, 77, 14, 992, 492, 12272, 12, 5673, 12, 11666, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 4152, 8200, 2556, 367, 2013, 7256, 2, 272, 3434, 275, 2202, 14, 7278, 15694, 63, 11958, 272, 2505, 275, 2202, 14, 7278, 15694, 63, 9032, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 3654, 85, 297, 2850, 2473, 297, 2053, 534, 2473, 297, 1720, 628, 17768, 314, 3434, 370, 675, 531, 267, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 2060, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 20430, 367, 2505, 370, 675, 531, 267, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 2124, 297, 2053, 534, 2124, 297, 1595, 534, 740, 297, 1169, 1720, 628, 4131, 7256, 701, 4770, 334, 2613, 1423, 5403, 1126, 4770, 6320, 267, 1798, 14, 525, 63, 2094, 3654, 78, 297, 2850, 354, 297, 2053, 534, 354, 297, 1720, 628, 4131, 7256, 701, 536, 334, 7898, 3965, 6320, 267, 1798, 14, 525, 63, 2094, 4517, 2861, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 1858, 8200, 1678, 367, 1006, 7256, 531, 267, 1798, 14, 525, 63, 2094, 4517, 3183, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 1720, 628, 2585, 440, 5965, 1678, 3050, 531, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 347, 1218, 63, 3112, 8, 3112, 12, 1676, 29, 403, 304, 288, 367, 859, 315, 4621, 26, 355, 333, 275, 5673, 8, 1782, 29, 1782, 12, 1676, 29, 1708, 12, 536, 29, 578, 459, 354, 995, 1777, 63, 344, 29, 578, 459, 2064, 63, 344, 995, 2574, 3012, 29, 578, 459, 2171, 995, 24983, 29, 549, 9, 355, 333, 14, 2117, 342, 355, 1218, 63, 3112, 8, 578, 14, 362, 360, 3112, 297, 14431, 1676, 29, 77, 9, 398, 327, 23934, 267, 340, 1511, 459, 2473, 2565, 288, 291, 14, 2473, 275, 1511, 459, 2473, 418, 267, 340, 1511, 459, 2060, 2565, 288, 291, 14, 2060, 275, 18354, 480, 6139, 26, 6099, 398, 327, 23115, 370, 8200, 1454, 4702, 7256, 267, 2243, 63, 513, 275, 12272, 14, 1462, 14, 1541, 8, 1205, 29, 549, 9, 398, 327, 1553, 2124, 26, 15783, 1454, 7256, 30226, 370, 2013, 4770, 8, 83, 9, 267, 340, 1511, 459, 2124, 2565, 288, 15424, 275, 11666, 14, 1462, 14, 1541, 8, 5464, 363, 262, 29, 1419, 459, 2124, 1105, 288, 340, 15424, 26, 355, 4770, 63, 1247, 275, 359, 83, 14, 354, 367, 308, 315, 15424, 61, 355, 291, 14, 2703, 14, 952, 480, 9602, 8200, 367, 3520, 15424, 26, 8352, 908, 5102, 1987, 904, 8, 2124, 63, 1247, 1724, 288, 587, 26, 355, 746, 14393, 480, 4395, 503, 1655, 15424, 2013, 1325, 7179, 1911, 2685, 288, 2243, 63, 513, 275, 2243, 63, 513, 14, 1541, 8, 8085, 363, 2124, 363, 262, 29, 8619, 9, 398, 327, 1553, 354, 26, 9388, 7256, 701, 536, 4877, 282, 5163, 267, 340, 1511, 459, 354, 2565, 288, 2243, 63, 513, 275, 2243, 63, 513, 14, 1541, 8, 354, 363, 3621, 2145, 29, 1419, 459, 354, 1105, 398, 327, 1553, 2861, 26, 19634, 8200, 666, 367, 627, 452, 10, 7256, 267, 340, 1511, 459, 2861, 2565, 288, 291, 14, 2703, 14, 952, 480, 9171, 26, 26848, 8200, 367, 1006, 7256, 1, 8538, 269, 666, 911, 506, 20200, 14, 334, 306, 2861, 6320, 398, 327, 1553, 3183, 26, 19634, 316, 666, 1325, 440, 12928, 314, 3050, 267, 340, 1511, 459, 3183, 2565, 288, 291, 14, 2703, 14, 952, 480, 9171, 26, 19337, 666, 911, 440, 506, 6290, 1, 334, 306, 3183, 6320, 398, 2243, 63, 835, 275, 2243, 63, 513, 14, 835, 342, 267, 291, 14, 2703, 14, 952, 480, 538, 2643, 1052, 7256, 1396, 1674, 908, 8, 1782, 63, 835, 430, 398, 367, 284, 12, 2243, 315, 3874, 8, 1782, 63, 513, 12, 1343, 29, 17, 304, 953, 291, 14, 2703, 14, 952, 10994, 2440, 14698, 61, 24702, 3680, 908, 8, 73, 12, 2243, 63, 835, 12, 2243, 14, 354, 395, 13401, 13275, 953, 327, 8232, 21325, 7256, 288, 340, 440, 2243, 14, 1205, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 16856, 6320, 355, 1980, 953, 327, 8232, 7256, 1928, 5062, 63, 711, 663, 288, 340, 440, 2243, 14, 3327, 63, 711, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 889, 5062, 3531, 663, 6320, 355, 1980, 953, 327, 8232, 7256, 1314, 1172, 2575, 2757, 315, 782, 269, 5299, 340, 440, 9689, 282, 2615, 1678, 288, 340, 2243, 14, 2171, 436, 440, 1511, 459, 2861, 2565, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 3571, 26, 5009, 1674, 908, 8, 1782, 14, 2171, 430, 355, 1980, 953, 11785, 275, 2243, 14, 362, 63, 4354, 63, 1258, 342, 288, 340, 440, 11785, 26, 355, 291, 14, 2703, 14, 952, 480, 30472, 334, 889, 11785, 1890, 2808, 367, 4298, 5009, 1674, 908, 8, 1782, 14, 3246, 430, 355, 1980, 953, 327, 15175, 370, 2243, 436, 8044, 8200, 2256, 288, 862, 26, 355, 543, 11785, 8, 1782, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 465, 8985, 63, 1258, 26, 490, 8200, 275, 8985, 63, 1258, 14, 362, 63, 7212, 342, 288, 871, 13483, 26, 355, 746, 288, 871, 334, 27942, 12, 15995, 1726, 304, 355, 291, 14, 2703, 14, 952, 480, 10348, 1125, 9124, 355, 1980, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 2703, 14, 952, 480, 547, 26, 8352, 908, 8, 69, 430, 355, 1980, 953, 340, 1511, 459, 9833, 418, 690, 413, 26, 355, 291, 14, 2703, 14, 952, 10804, 355, 291, 14, 2703, 14, 952, 4582, 84, 3571, 26, 8352, 908, 8, 7212, 459, 31187, 2545, 2171, 5156, 355, 291, 14, 2703, 14, 952, 4582, 84, 5831, 26, 8352, 908, 8, 7212, 459, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shupelneker/gae_new_structure
boilerplate/_lib/utils.py
25
7368
# *-* coding: UTF-8 *-* # standard library imports import os import re import random import hashlib import logging import string import unicodedata from datetime import datetime, timedelta import Cookie import webapp2 def random_string(size=6, chars=string.ascii_letters + string.digits): """ Generate random string """ return ''.join(random.choice(chars) for _ in range(size)) def hashing(plaintext, salt="", sha="512"): """ Returns the hashed and encrypted hexdigest of a plaintext and salt""" app = webapp2.get_app() # Hashing if sha == "1": phrase = hashlib.sha1() elif sha == "256": phrase = hashlib.sha256() else: phrase = hashlib.sha512() phrase.update("%s@%s" % (plaintext, salt)) phrase_digest = phrase.hexdigest() # Encryption (PyCrypto) # wow... it's so secure :) try: from Crypto.Cipher import AES mode = AES.MODE_CBC # We can not generate random initialization vector because is difficult to retrieve them later without knowing # a priori the hash to match. We take 16 bytes from the hexdigest to make the vectors different for each hashed # plaintext. iv = phrase_digest[:16] encryptor = AES.new(app.config.get('aes_key'), mode, iv) ciphertext = [encryptor.encrypt(chunk) for chunk in chunks(phrase_digest, 16)] return ''.join(ciphertext) except Exception, e: logging.error("CRYPTO is not running: {}".format(e)) raise def chunks(list, size): """ Yield successive sized chunks from list. """ for i in xrange(0, len(list), size): yield list[i:i + size] def encode(plainText): num = 0 key = "0123456789abcdefghijklmnopqrstuvwxyz" key += "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for c in plainText: num = (num << 8) + ord(c) encodedMsg = "" while num > 0: encodedMsg = key[num % len(key)] + encodedMsg num /= len(key) return encodedMsg def decode(encodedMsg): num = 0 key = "0123456789abcdefghijklmnopqrstuvwxyz" key += "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for c in encodedMsg: num = num * len(key) + key.index(c) text = "" while num > 0: text = chr(num % 256) + text num /= 256 return text def write_cookie(cls, COOKIE_NAME, COOKIE_VALUE, path, expires=7200): """ Write a cookie @path = could be a cls.request.path to set a specific path @expires = seconds (integer) to expire the cookie, by default 2 hours () expires = 7200 # 2 hours expires = 1209600 # 2 weeks expires = 2629743 # 1 month """ # days, seconds, then other fields. time_expire = datetime.now() + timedelta(seconds=expires) time_expire = time_expire.strftime("%a, %d-%b-%Y %H:%M:%S GMT") cls.response.headers.add_header( 'Set-Cookie', COOKIE_NAME + '=' + COOKIE_VALUE + '; expires=' + str(time_expire) + '; path=' + path + '; HttpOnly') return def read_cookie(cls, name): """ Use: cook.read(cls, COOKIE_NAME) """ string_cookie = os.environ.get('HTTP_COOKIE', '') cls.cookie = Cookie.SimpleCookie() cls.cookie.load(string_cookie) value = None if cls.cookie.get(name): value = cls.cookie[name].value return value def get_date_time(format="%Y-%m-%d %H:%M:%S", UTC_OFFSET=3): """ Get date and time in UTC with a specific format By default it UTC = -3 (Chilean Time) """ local_datetime = datetime.now() now = local_datetime - timedelta(hours=UTC_OFFSET) if format != "datetimeProperty": now = now.strftime(format) # now = datetime.fromtimestamp(1321925140.78) return now EMAIL_REGEXP = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$" ALPHANUMERIC_REGEXP = "^\w+$" VALID_USERNAME_REGEXP = "^(\w+([\-\.])?\w*)$" NAME_LASTNAME_REGEXP = "^[a-zA-ZàáâäãåąćęèéêëìíîïłńòóôöõøùúûüÿýżźñçčšžÀÁÂÄÃÅĄĆĘÈÉÊËÌÍÎÏŁŃÒÓÔÖÕØÙÚÛÜŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.'-]*$" def is_email_valid(email): if len(email) > 7: if re.match(EMAIL_REGEXP, email) != None: return 1 return 0 def is_alphanumeric(field): if re.match(ALPHANUMERIC_REGEXP, field) is not None: return 1 return 0 def get_device(cls): # TODO: Remove this function uastring = cls.request.user_agent or 'unknown' is_mobile = (("Mobile" in uastring and "Safari" in uastring) or \ ("Windows Phone OS" in uastring and "IEMobile" in uastring) or \ ("Blackberry") in uastring) if "MSIE" in uastring: browser = "Explorer" elif "Firefox" in uastring: browser = "Firefox" elif "Presto" in uastring: browser = "Opera" elif "Android" in uastring and "AppleWebKit" in uastring: browser = "Chrome for Android" elif "iPhone" in uastring and "AppleWebKit" in uastring: browser = "Safari for iPhone" elif "iPod" in uastring and "AppleWebKit" in uastring: browser = "Safari for iPod" elif "iPad" in uastring and "AppleWebKit" in uastring: browser = "Safari for iPad" elif "Chrome" in uastring: browser = "Chrome" elif "AppleWebKit" in uastring: browser = "Safari" else: browser = "unknown" device = { "is_mobile": is_mobile, "browser": browser, "uastring": uastring } return device def set_device_cookie_and_return_bool(cls, force=""): """ set a cookie for device (dvc) returning a dict and set cookie Cookie value has to be "mobile" or "desktop" string """ if force != "": # force cookie to param device_cookie = force elif cls.request.get("device") == "": # ask for cookie of device device_cookie = str(read_cookie(cls, "dvc")) if not device_cookie or device_cookie == "None" or device_cookie == "": # If cookie has an error, check which device is been used if get_device(cls)["is_mobile"]: device_cookie = "mobile" else: device_cookie = "desktop" else: # set cookie to param 'is_mobile' value directly device_cookie = cls.request.get("device") # Set Cookie for Two weeks with 'device_cookie' value write_cookie(cls, "dvc", str(device_cookie), "/", 1209600) return device_cookie == "mobile" def slugify(value): """ Normalizes string, converts to lowercase, removes non-ascii characters, and converts spaces to hyphens. For use in urls and filenames From Django's "django/template/defaultfilters.py". """ _slugify_strip_re = re.compile(r'[^\w\s-]') _slugify_hyphenate_re = re.compile(r'[-\s]+') if not isinstance(value, unicode): value = unicode(value) value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') value = unicode(_slugify_strip_re.sub('', value).strip().lower()) return _slugify_hyphenate_re.sub('-', value) def parse_if_int(s): """Try to parse a string to an int. Return the int on success or string on failure. Useful for parsing entity ids from urls when entity ids could be manually assigned strings or automatically assigned numbers. """ try: return int(s) except ValueError: return s
lgpl-3.0
[ 3, 627, 13, 10, 2803, 26, 9094, 13, 24, 627, 13, 10, 199, 199, 3, 4465, 3555, 8925, 199, 646, 747, 199, 646, 295, 199, 646, 2196, 199, 646, 8337, 199, 646, 2050, 199, 646, 1059, 199, 646, 23128, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 14798, 199, 646, 24812, 18, 421, 199, 318, 2196, 63, 875, 8, 890, 29, 22, 12, 8365, 29, 875, 14, 4371, 63, 16415, 435, 1059, 14, 7022, 304, 272, 408, 7958, 2196, 1059, 408, 272, 372, 6522, 904, 8, 2355, 14, 5095, 8, 6574, 9, 367, 485, 315, 1425, 8, 890, 430, 421, 199, 318, 25223, 8, 17426, 12, 10105, 8772, 7793, 628, 7736, 2349, 272, 408, 1803, 314, 19871, 436, 14862, 6318, 5671, 402, 282, 18577, 436, 10105, 624, 272, 1145, 275, 24812, 18, 14, 362, 63, 571, 342, 339, 327, 16101, 316, 272, 340, 7793, 508, 298, 17, 582, 267, 21621, 275, 8337, 14, 4835, 17, 342, 272, 916, 7793, 508, 298, 3912, 582, 267, 21621, 275, 8337, 14, 4835, 3912, 342, 272, 587, 26, 267, 21621, 275, 8337, 14, 4835, 7736, 342, 272, 21621, 14, 873, 3647, 83, 19437, 83, 2, 450, 334, 17426, 12, 10105, 430, 272, 21621, 63, 5671, 275, 21621, 14, 11453, 342, 339, 327, 3447, 7950, 334, 2713, 17134, 9, 272, 327, 336, 583, 1396, 652, 1159, 880, 11153, 32428, 272, 862, 26, 267, 687, 18855, 14, 21967, 492, 19093, 398, 818, 275, 19093, 14, 6963, 63, 18255, 398, 327, 2136, 883, 440, 3550, 2196, 11097, 5477, 2952, 365, 29870, 370, 8044, 3062, 2945, 1928, 5715, 316, 267, 327, 282, 6791, 73, 314, 2631, 370, 1336, 14, 2136, 5452, 3193, 2783, 687, 314, 6318, 5671, 370, 1852, 314, 11102, 3365, 367, 1924, 19871, 267, 327, 18577, 14, 267, 18831, 275, 21621, 63, 5671, 1491, 975, 61, 267, 14645, 269, 275, 19093, 14, 1222, 8, 571, 14, 888, 14, 362, 360, 17499, 63, 498, 659, 818, 12, 18831, 9, 267, 29147, 275, 359, 11929, 269, 14, 11929, 8, 4604, 9, 367, 3728, 315, 8291, 8, 10906, 63, 5671, 12, 3193, 1874, 267, 372, 6522, 904, 8, 27661, 9, 272, 871, 2186, 12, 325, 26, 267, 2050, 14, 705, 480, 2944, 7431, 2566, 365, 440, 3879, 26, 8352, 908, 8, 69, 430, 267, 746, 421, 199, 318, 8291, 8, 513, 12, 1568, 304, 272, 408, 23771, 27028, 3398, 308, 1759, 8291, 687, 769, 14, 408, 339, 367, 284, 315, 4945, 8, 16, 12, 822, 8, 513, 395, 1568, 304, 267, 1995, 769, 59, 73, 26, 73, 435, 1568, 61, 421, 199, 318, 3752, 8, 6104, 1872, 304, 272, 1967, 275, 378, 272, 790, 275, 298, 11371, 23459, 2, 272, 790, 847, 298, 28114, 2, 272, 367, 286, 315, 8971, 1872, 26, 1967, 275, 334, 1507, 5213, 1695, 9, 435, 6206, 8, 67, 9, 272, 5737, 6173, 275, 3087, 272, 1830, 1967, 690, 378, 26, 267, 5737, 6173, 275, 790, 59, 1507, 450, 822, 8, 498, 1874, 435, 5737, 6173, 267, 1967, 12257, 822, 8, 498, 9, 272, 372, 5737, 6173, 421, 199, 318, 4849, 8, 8167, 6173, 304, 272, 1967, 275, 378, 272, 790, 275, 298, 11371, 23459, 2, 272, 790, 847, 298, 28114, 2, 272, 367, 286, 315, 5737, 6173, 26, 1967, 275, 1967, 627, 822, 8, 498, 9, 435, 790, 14, 1080, 8, 67, 9, 272, 1318, 275, 3087, 272, 1830, 1967, 690, 378, 26, 267, 1318, 275, 8678, 8, 1507, 450, 7633, 9, 435, 1318, 267, 1967, 12257, 7633, 272, 372, 1318, 421, 199, 318, 2218, 63, 5306, 8, 1886, 12, 5099, 3593, 4332, 63, 2339, 12, 5099, 3593, 4332, 63, 7041, 12, 931, 12, 12261, 29, 23, 1840, 304, 272, 408, 272, 6990, 282, 5494, 272, 768, 515, 275, 4293, 506, 282, 843, 14, 1069, 14, 515, 370, 663, 282, 2488, 931, 272, 768, 12342, 275, 4696, 334, 4115, 9, 370, 16667, 314, 5494, 12, 701, 849, 499, 10857, 6248, 272, 12261, 275, 1520, 1840, 327, 499, 10857, 272, 12261, 275, 13960, 2534, 383, 327, 499, 29540, 272, 12261, 275, 7875, 1398, 21712, 327, 413, 5794, 272, 408, 339, 327, 7609, 12, 4696, 12, 2066, 1163, 1504, 14, 272, 900, 63, 14691, 275, 2197, 14, 2131, 342, 435, 6871, 8, 4515, 29, 12342, 9, 272, 900, 63, 14691, 275, 900, 63, 14691, 14, 6205, 3647, 65, 12, 450, 68, 3295, 66, 3295, 57, 450, 40, 2689, 45, 2689, 51, 19152, 531, 339, 843, 14, 1310, 14, 2139, 14, 525, 63, 1291, 8, 267, 283, 1084, 13, 7810, 297, 267, 5099, 3593, 4332, 63, 2339, 435, 14051, 435, 5099, 3593, 4332, 63, 7041, 435, 14289, 12261, 534, 435, 620, 8, 521, 63, 14691, 9, 435, 14289, 931, 534, 435, 931, 435, 14289, 4760, 5903, 358, 272, 372, 421, 199, 318, 1586, 63, 5306, 8, 1886, 12, 536, 304, 272, 408, 3645, 26, 512, 745, 14, 739, 8, 1886, 12, 5099, 3593, 4332, 63, 2339, 9, 408, 339, 1059, 63, 5306, 275, 747, 14, 2314, 14, 362, 360, 2856, 63, 13665, 297, 4074, 272, 843, 14, 5306, 275, 14798, 14, 3184, 7810, 342, 272, 843, 14, 5306, 14, 912, 8, 875, 63, 5306, 9, 272, 574, 275, 488, 272, 340, 843, 14, 5306, 14, 362, 8, 354, 304, 267, 574, 275, 843, 14, 5306, 59, 354, 1055, 585, 339, 372, 574, 421, 199, 318, 664, 63, 602, 63, 521, 8, 908, 5961, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 401, 12174, 63, 14839, 29, 19, 304, 272, 408, 272, 2372, 1434, 436, 900, 315, 12174, 543, 282, 2488, 1475, 1362, 4885, 849, 652, 12174, 275, 446, 19, 334, 1049, 441, 290, 4703, 9, 272, 408, 339, 2257, 63, 2083, 275, 2197, 14, 2131, 342, 272, 3063, 275, 2257, 63, 2083, 446, 6871, 8, 8419, 29, 11288, 63, 14839, 9, 272, 340, 1475, 1137, 298, 2083, 3697, 582, 267, 3063, 275, 3063, 14, 6205, 8, 908, 9, 267, 327, 259, 3063, 275, 2197, 14, 18531, 8, 6557, 1167, 821, 10037, 14, 2277, 9, 272, 372, 3063, 421, 199, 10089, 63, 10710, 48, 275, 18129, 6977, 1103, 32, 27910, 59, 31, 2788, 65, 13, 6353, 13, 58, 16, 13, 25, 1103, 13, 20942, 2807, 20942, 779, 65 ]
[ 627, 13, 10, 2803, 26, 9094, 13, 24, 627, 13, 10, 199, 199, 3, 4465, 3555, 8925, 199, 646, 747, 199, 646, 295, 199, 646, 2196, 199, 646, 8337, 199, 646, 2050, 199, 646, 1059, 199, 646, 23128, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 14798, 199, 646, 24812, 18, 421, 199, 318, 2196, 63, 875, 8, 890, 29, 22, 12, 8365, 29, 875, 14, 4371, 63, 16415, 435, 1059, 14, 7022, 304, 272, 408, 7958, 2196, 1059, 408, 272, 372, 6522, 904, 8, 2355, 14, 5095, 8, 6574, 9, 367, 485, 315, 1425, 8, 890, 430, 421, 199, 318, 25223, 8, 17426, 12, 10105, 8772, 7793, 628, 7736, 2349, 272, 408, 1803, 314, 19871, 436, 14862, 6318, 5671, 402, 282, 18577, 436, 10105, 624, 272, 1145, 275, 24812, 18, 14, 362, 63, 571, 342, 339, 327, 16101, 316, 272, 340, 7793, 508, 298, 17, 582, 267, 21621, 275, 8337, 14, 4835, 17, 342, 272, 916, 7793, 508, 298, 3912, 582, 267, 21621, 275, 8337, 14, 4835, 3912, 342, 272, 587, 26, 267, 21621, 275, 8337, 14, 4835, 7736, 342, 272, 21621, 14, 873, 3647, 83, 19437, 83, 2, 450, 334, 17426, 12, 10105, 430, 272, 21621, 63, 5671, 275, 21621, 14, 11453, 342, 339, 327, 3447, 7950, 334, 2713, 17134, 9, 272, 327, 336, 583, 1396, 652, 1159, 880, 11153, 32428, 272, 862, 26, 267, 687, 18855, 14, 21967, 492, 19093, 398, 818, 275, 19093, 14, 6963, 63, 18255, 398, 327, 2136, 883, 440, 3550, 2196, 11097, 5477, 2952, 365, 29870, 370, 8044, 3062, 2945, 1928, 5715, 316, 267, 327, 282, 6791, 73, 314, 2631, 370, 1336, 14, 2136, 5452, 3193, 2783, 687, 314, 6318, 5671, 370, 1852, 314, 11102, 3365, 367, 1924, 19871, 267, 327, 18577, 14, 267, 18831, 275, 21621, 63, 5671, 1491, 975, 61, 267, 14645, 269, 275, 19093, 14, 1222, 8, 571, 14, 888, 14, 362, 360, 17499, 63, 498, 659, 818, 12, 18831, 9, 267, 29147, 275, 359, 11929, 269, 14, 11929, 8, 4604, 9, 367, 3728, 315, 8291, 8, 10906, 63, 5671, 12, 3193, 1874, 267, 372, 6522, 904, 8, 27661, 9, 272, 871, 2186, 12, 325, 26, 267, 2050, 14, 705, 480, 2944, 7431, 2566, 365, 440, 3879, 26, 8352, 908, 8, 69, 430, 267, 746, 421, 199, 318, 8291, 8, 513, 12, 1568, 304, 272, 408, 23771, 27028, 3398, 308, 1759, 8291, 687, 769, 14, 408, 339, 367, 284, 315, 4945, 8, 16, 12, 822, 8, 513, 395, 1568, 304, 267, 1995, 769, 59, 73, 26, 73, 435, 1568, 61, 421, 199, 318, 3752, 8, 6104, 1872, 304, 272, 1967, 275, 378, 272, 790, 275, 298, 11371, 23459, 2, 272, 790, 847, 298, 28114, 2, 272, 367, 286, 315, 8971, 1872, 26, 1967, 275, 334, 1507, 5213, 1695, 9, 435, 6206, 8, 67, 9, 272, 5737, 6173, 275, 3087, 272, 1830, 1967, 690, 378, 26, 267, 5737, 6173, 275, 790, 59, 1507, 450, 822, 8, 498, 1874, 435, 5737, 6173, 267, 1967, 12257, 822, 8, 498, 9, 272, 372, 5737, 6173, 421, 199, 318, 4849, 8, 8167, 6173, 304, 272, 1967, 275, 378, 272, 790, 275, 298, 11371, 23459, 2, 272, 790, 847, 298, 28114, 2, 272, 367, 286, 315, 5737, 6173, 26, 1967, 275, 1967, 627, 822, 8, 498, 9, 435, 790, 14, 1080, 8, 67, 9, 272, 1318, 275, 3087, 272, 1830, 1967, 690, 378, 26, 267, 1318, 275, 8678, 8, 1507, 450, 7633, 9, 435, 1318, 267, 1967, 12257, 7633, 272, 372, 1318, 421, 199, 318, 2218, 63, 5306, 8, 1886, 12, 5099, 3593, 4332, 63, 2339, 12, 5099, 3593, 4332, 63, 7041, 12, 931, 12, 12261, 29, 23, 1840, 304, 272, 408, 272, 6990, 282, 5494, 272, 768, 515, 275, 4293, 506, 282, 843, 14, 1069, 14, 515, 370, 663, 282, 2488, 931, 272, 768, 12342, 275, 4696, 334, 4115, 9, 370, 16667, 314, 5494, 12, 701, 849, 499, 10857, 6248, 272, 12261, 275, 1520, 1840, 327, 499, 10857, 272, 12261, 275, 13960, 2534, 383, 327, 499, 29540, 272, 12261, 275, 7875, 1398, 21712, 327, 413, 5794, 272, 408, 339, 327, 7609, 12, 4696, 12, 2066, 1163, 1504, 14, 272, 900, 63, 14691, 275, 2197, 14, 2131, 342, 435, 6871, 8, 4515, 29, 12342, 9, 272, 900, 63, 14691, 275, 900, 63, 14691, 14, 6205, 3647, 65, 12, 450, 68, 3295, 66, 3295, 57, 450, 40, 2689, 45, 2689, 51, 19152, 531, 339, 843, 14, 1310, 14, 2139, 14, 525, 63, 1291, 8, 267, 283, 1084, 13, 7810, 297, 267, 5099, 3593, 4332, 63, 2339, 435, 14051, 435, 5099, 3593, 4332, 63, 7041, 435, 14289, 12261, 534, 435, 620, 8, 521, 63, 14691, 9, 435, 14289, 931, 534, 435, 931, 435, 14289, 4760, 5903, 358, 272, 372, 421, 199, 318, 1586, 63, 5306, 8, 1886, 12, 536, 304, 272, 408, 3645, 26, 512, 745, 14, 739, 8, 1886, 12, 5099, 3593, 4332, 63, 2339, 9, 408, 339, 1059, 63, 5306, 275, 747, 14, 2314, 14, 362, 360, 2856, 63, 13665, 297, 4074, 272, 843, 14, 5306, 275, 14798, 14, 3184, 7810, 342, 272, 843, 14, 5306, 14, 912, 8, 875, 63, 5306, 9, 272, 574, 275, 488, 272, 340, 843, 14, 5306, 14, 362, 8, 354, 304, 267, 574, 275, 843, 14, 5306, 59, 354, 1055, 585, 339, 372, 574, 421, 199, 318, 664, 63, 602, 63, 521, 8, 908, 5961, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 401, 12174, 63, 14839, 29, 19, 304, 272, 408, 272, 2372, 1434, 436, 900, 315, 12174, 543, 282, 2488, 1475, 1362, 4885, 849, 652, 12174, 275, 446, 19, 334, 1049, 441, 290, 4703, 9, 272, 408, 339, 2257, 63, 2083, 275, 2197, 14, 2131, 342, 272, 3063, 275, 2257, 63, 2083, 446, 6871, 8, 8419, 29, 11288, 63, 14839, 9, 272, 340, 1475, 1137, 298, 2083, 3697, 582, 267, 3063, 275, 3063, 14, 6205, 8, 908, 9, 267, 327, 259, 3063, 275, 2197, 14, 18531, 8, 6557, 1167, 821, 10037, 14, 2277, 9, 272, 372, 3063, 421, 199, 10089, 63, 10710, 48, 275, 18129, 6977, 1103, 32, 27910, 59, 31, 2788, 65, 13, 6353, 13, 58, 16, 13, 25, 1103, 13, 20942, 2807, 20942, 779, 65, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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980
""" Tests for the logic in input type mako templates. """ import unittest import capa import os.path import json from lxml import etree from mako.template import Template as MakoTemplate from mako import exceptions from capa.inputtypes import Status class TemplateError(Exception): """ Error occurred while rendering a Mako template. """ pass class TemplateTestCase(unittest.TestCase): """ Utilitites for testing templates. """ # Subclasses override this to specify the file name of the template # to be loaded from capa/templates. # The template name should include the .html extension: # for example: choicegroup.html TEMPLATE_NAME = None def setUp(self): """ Load the template under test. """ super(TemplateTestCase, self).setUp() capa_path = capa.__path__[0] self.template_path = os.path.join(capa_path, 'templates', self.TEMPLATE_NAME) with open(self.template_path) as f: self.template = MakoTemplate(f.read()) def render_to_xml(self, context_dict): """ Render the template using the `context_dict` dict. Returns an `etree` XML element. """ # add dummy STATIC_URL to template context context_dict.setdefault("STATIC_URL", "/dummy-static/") try: xml_str = self.template.render_unicode(**context_dict) except: raise TemplateError(exceptions.text_error_template().render()) # Attempt to construct an XML tree from the template # This makes it easy to use XPath to make assertions, rather # than dealing with a string. # We modify the string slightly by wrapping it in <test> # tags, to ensure it has one root element. try: xml = etree.fromstring("<test>" + xml_str + "</test>") except Exception as exc: raise TemplateError("Could not parse XML from '{0}': {1}".format( xml_str, str(exc))) else: return xml def assert_has_xpath(self, xml_root, xpath, context_dict, exact_num=1): """ Asserts that the xml tree has an element satisfying `xpath`. `xml_root` is an etree XML element `xpath` is an XPath string, such as `'/foo/bar'` `context` is used to print a debugging message `exact_num` is the exact number of matches to expect. """ message = ("XML does not have %d match(es) for xpath '%s'\nXML: %s\nContext: %s" % (exact_num, str(xpath), etree.tostring(xml_root), str(context_dict))) self.assertEqual(len(xml_root.xpath(xpath)), exact_num, msg=message) def assert_no_xpath(self, xml_root, xpath, context_dict): """ Asserts that the xml tree does NOT have an element satisfying `xpath`. `xml_root` is an etree XML element `xpath` is an XPath string, such as `'/foo/bar'` `context` is used to print a debugging message """ self.assert_has_xpath(xml_root, xpath, context_dict, exact_num=0) def assert_has_text(self, xml_root, xpath, text, exact=True): """ Find the element at `xpath` in `xml_root` and assert that its text is `text`. `xml_root` is an etree XML element `xpath` is an XPath string, such as `'/foo/bar'` `text` is the expected text that the element should contain If multiple elements are found, checks the first one. If no elements are found, the assertion fails. """ element_list = xml_root.xpath(xpath) self.assertTrue(len(element_list) > 0, "Could not find element at '%s'" % str(xpath)) if exact: self.assertEqual(text, element_list[0].text) else: self.assertIn(text, element_list[0].text) class ChoiceGroupTemplateTest(TemplateTestCase): """ Test mako template for `<choicegroup>` input. """ TEMPLATE_NAME = 'choicegroup.html' def setUp(self): choices = [('1', 'choice 1'), ('2', 'choice 2'), ('3', 'choice 3')] self.context = {'id': '1', 'choices': choices, 'status': Status('correct'), 'label': 'test', 'input_type': 'checkbox', 'name_array_suffix': '1', 'value': '3'} super(ChoiceGroupTemplateTest, self).setUp() def test_problem_marked_correct(self): """ Test conditions under which the entire problem (not a particular option) is marked correct. """ self.context['status'] = Status('correct') self.context['input_type'] = 'checkbox' self.context['value'] = ['1', '2'] # Should mark the entire problem correct xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status correct']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options self.assert_no_xpath(xml, "//label[@class='choicegroup_incorrect']", self.context) self.assert_no_xpath(xml, "//label[@class='choicegroup_correct']", self.context) def test_problem_marked_incorrect(self): """ Test all conditions under which the entire problem (not a particular option) is marked incorrect. """ conditions = [ {'status': Status('incorrect'), 'input_type': 'radio', 'value': ''}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': []}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': ['2']}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': ['2', '3']}, {'status': Status('incomplete'), 'input_type': 'radio', 'value': ''}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': []}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': ['2']}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': ['2', '3']}] for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status incorrect']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options self.assert_no_xpath(xml, "//label[@class='choicegroup_incorrect']", self.context) self.assert_no_xpath(xml, "//label[@class='choicegroup_correct']", self.context) def test_problem_marked_unsubmitted(self): """ Test all conditions under which the entire problem (not a particular option) is marked unanswered. """ conditions = [ {'status': Status('unsubmitted'), 'input_type': 'radio', 'value': ''}, {'status': Status('unsubmitted'), 'input_type': 'radio', 'value': []}, {'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': []}, {'input_type': 'radio', 'value': ''}, {'input_type': 'radio', 'value': []}, {'input_type': 'checkbox', 'value': []}, {'input_type': 'checkbox', 'value': ['1']}, {'input_type': 'checkbox', 'value': ['1', '2']}] self.context['status'] = Status('unanswered') for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status unanswered']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options self.assert_no_xpath(xml, "//label[@class='choicegroup_incorrect']", self.context) self.assert_no_xpath(xml, "//label[@class='choicegroup_correct']", self.context) def test_option_marked_correct(self): """ Test conditions under which a particular option (not the entire problem) is marked correct. """ conditions = [ {'input_type': 'radio', 'value': '2'}, {'input_type': 'radio', 'value': ['2']}] self.context['status'] = Status('correct') for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//label[@class='choicegroup_correct']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark the whole problem xpath = "//div[@class='indicator-container']/span" self.assert_no_xpath(xml, xpath, self.context) def test_option_marked_incorrect(self): """ Test conditions under which a particular option (not the entire problem) is marked incorrect. """ conditions = [ {'input_type': 'radio', 'value': '2'}, {'input_type': 'radio', 'value': ['2']}] self.context['status'] = Status('incorrect') for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//label[@class='choicegroup_incorrect']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark the whole problem xpath = "//div[@class='indicator-container']/span" self.assert_no_xpath(xml, xpath, self.context) def test_never_show_correctness(self): """ Test conditions under which we tell the template to NOT show correct/incorrect, but instead show a message. This is used, for example, by the Justice course to ask questions without specifying a correct answer. When the student responds, the problem displays "Thank you for your response" """ conditions = [ {'input_type': 'radio', 'status': Status('correct'), 'value': ''}, {'input_type': 'radio', 'status': Status('correct'), 'value': '2'}, {'input_type': 'radio', 'status': Status('correct'), 'value': ['2']}, {'input_type': 'radio', 'status': Status('incorrect'), 'value': '2'}, {'input_type': 'radio', 'status': Status('incorrect'), 'value': []}, {'input_type': 'radio', 'status': Status('incorrect'), 'value': ['2']}, {'input_type': 'checkbox', 'status': Status('correct'), 'value': []}, {'input_type': 'checkbox', 'status': Status('correct'), 'value': ['2']}, {'input_type': 'checkbox', 'status': Status('incorrect'), 'value': []}, {'input_type': 'checkbox', 'status': Status('incorrect'), 'value': ['2']}] self.context['show_correctness'] = 'never' self.context['submitted_message'] = 'Test message' for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) # Should NOT mark the entire problem correct/incorrect xpath = "//div[@class='indicator-container']/span[@class='status correct']" self.assert_no_xpath(xml, xpath, self.context) xpath = "//div[@class='indicator-container']/span[@class='status incorrect']" self.assert_no_xpath(xml, xpath, self.context) # Should NOT mark individual options self.assert_no_xpath(xml, "//label[@class='choicegroup_incorrect']", self.context) self.assert_no_xpath(xml, "//label[@class='choicegroup_correct']", self.context) # Expect to see the message self.assert_has_text(xml, "//div[@class='capa_alert']", self.context['submitted_message']) def test_no_message_before_submission(self): """ Ensure that we don't show the `submitted_message` before submitting. """ conditions = [ {'input_type': 'radio', 'status': Status('unsubmitted'), 'value': ''}, {'input_type': 'radio', 'status': Status('unsubmitted'), 'value': []}, {'input_type': 'checkbox', 'status': Status('unsubmitted'), 'value': []}, # These tests expose bug #365 # When the bug is fixed, uncomment these cases. #{'input_type': 'radio', 'status': 'unsubmitted', 'value': '2'}, #{'input_type': 'radio', 'status': 'unsubmitted', 'value': ['2']}, #{'input_type': 'radio', 'status': 'unsubmitted', 'value': '2'}, #{'input_type': 'radio', 'status': 'unsubmitted', 'value': ['2']}, #{'input_type': 'checkbox', 'status': 'unsubmitted', 'value': ['2']}, #{'input_type': 'checkbox', 'status': 'unsubmitted', 'value': ['2']}] ] self.context['show_correctness'] = 'never' self.context['submitted_message'] = 'Test message' for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) # Expect that we do NOT see the message yet self.assert_no_xpath(xml, "//div[@class='capa_alert']", self.context) def test_label(self): xml = self.render_to_xml(self.context) xpath = "//fieldset[@aria-label='%s']" % self.context['label'] self.assert_has_xpath(xml, xpath, self.context) class TextlineTemplateTest(TemplateTestCase): """ Test mako template for `<textline>` input. """ TEMPLATE_NAME = 'textline.html' def setUp(self): self.context = {'id': '1', 'status': Status('correct'), 'label': 'test', 'value': '3', 'preprocessor': None, 'trailing_text': None} super(TextlineTemplateTest, self).setUp() def test_section_class(self): cases = [({}, ' capa_inputtype textline'), ({'do_math': True}, 'text-input-dynamath capa_inputtype textline'), ({'inline': True}, ' capa_inputtype inline textline'), ({'do_math': True, 'inline': True}, 'text-input-dynamath capa_inputtype inline textline'), ] for (context, css_class) in cases: base_context = self.context.copy() base_context.update(context) xml = self.render_to_xml(base_context) xpath = "//div[@class='%s']" % css_class self.assert_has_xpath(xml, xpath, self.context) def test_status(self): cases = [('correct', 'correct', 'correct'), ('unsubmitted', 'unanswered', 'unanswered'), ('incorrect', 'incorrect', 'incorrect'), ('incomplete', 'incorrect', 'incomplete')] for (context_status, div_class, status_mark) in cases: self.context['status'] = Status(context_status) xml = self.render_to_xml(self.context) # Expect that we get a <div> with correct class xpath = "//div[@class='%s ']" % div_class self.assert_has_xpath(xml, xpath, self.context) # Expect that we get a <span> with class="status" # (used to by CSS to draw the green check / red x) self.assert_has_text(xml, "//span[@class='status']/span[@class='sr']", status_mark, exact=False) def test_label(self): xml = self.render_to_xml(self.context) xpath = "//input[@aria-label='%s']" % self.context['label'] self.assert_has_xpath(xml, xpath, self.context) def test_hidden(self): self.context['hidden'] = True xml = self.render_to_xml(self.context) xpath = "//div[@style='display:none;']" self.assert_has_xpath(xml, xpath, self.context) xpath = "//input[@style='display:none;']" self.assert_has_xpath(xml, xpath, self.context) def test_do_math(self): self.context['do_math'] = True xml = self.render_to_xml(self.context) xpath = "//input[@class='math']" self.assert_has_xpath(xml, xpath, self.context) xpath = "//div[@class='equation']" self.assert_has_xpath(xml, xpath, self.context) xpath = "//textarea[@id='input_1_dynamath']" self.assert_has_xpath(xml, xpath, self.context) def test_size(self): self.context['size'] = '20' xml = self.render_to_xml(self.context) xpath = "//input[@size='20']" self.assert_has_xpath(xml, xpath, self.context) def test_preprocessor(self): self.context['preprocessor'] = {'class_name': 'test_class', 'script_src': 'test_script'} xml = self.render_to_xml(self.context) xpath = "//div[contains(@class, 'text-input-dynamath_data') and @data-preprocessor='test_class']" self.assert_has_xpath(xml, xpath, self.context) xpath = "//div[@class='script_placeholder' and @data-src='test_script']" self.assert_has_xpath(xml, xpath, self.context) def test_do_inline_and_preprocessor(self): self.context['preprocessor'] = {'class_name': 'test_class', 'script_src': 'test_script'} self.context['inline'] = True xml = self.render_to_xml(self.context) xpath = "//div[contains(@class, 'text-input-dynamath_data inline') and @data-preprocessor='test_class']" self.assert_has_xpath(xml, xpath, self.context) def test_do_inline(self): cases = [('correct', 'correct'), ('unsubmitted', 'unanswered'), ('incorrect', 'incorrect'), ('incomplete', 'incorrect')] self.context['inline'] = True for (context_status, div_class) in cases: self.context['status'] = Status(context_status) xml = self.render_to_xml(self.context) # Expect that we get a <div> with correct class xpath = "//div[@class='%s inline']" % div_class self.assert_has_xpath(xml, xpath, self.context) def test_message(self): self.context['msg'] = "Test message" xml = self.render_to_xml(self.context) xpath = "//span[@class='message']" self.assert_has_text(xml, xpath, self.context['msg']) class FormulaEquationInputTemplateTest(TemplateTestCase): """ Test make template for `<formulaequationinput>`s. """ TEMPLATE_NAME = 'formulaequationinput.html' def setUp(self): self.context = { 'id': 2, 'value': 'PREFILLED_VALUE', 'status': Status('unsubmitted'), 'label': 'test', 'previewer': 'file.js', 'reported_status': 'REPORTED_STATUS', 'trailing_text': None, } super(FormulaEquationInputTemplateTest, self).setUp() def test_no_size(self): xml = self.render_to_xml(self.context) self.assert_no_xpath(xml, "//input[@size]", self.context) def test_size(self): self.context['size'] = '40' xml = self.render_to_xml(self.context) self.assert_has_xpath(xml, "//input[@size='40']", self.context) class AnnotationInputTemplateTest(TemplateTestCase): """ Test mako template for `<annotationinput>` input. """ TEMPLATE_NAME = 'annotationinput.html' def setUp(self): self.context = {'id': 2, 'value': '<p>Test value</p>', 'title': '<h1>This is a title</h1>', 'text': '<p><b>This</b> is a test.</p>', 'comment': '<p>This is a test comment</p>', 'comment_prompt': '<p>This is a test comment prompt</p>', 'comment_value': '<p>This is the value of a test comment</p>', 'tag_prompt': '<p>This is a tag prompt</p>', 'options': [], 'has_options_value': False, 'debug': False, 'status': Status('unsubmitted'), 'return_to_annotation': False, 'msg': '<p>This is a test message</p>', } super(AnnotationInputTemplateTest, self).setUp() def test_return_to_annotation(self): """ Test link for `Return to Annotation` appears if and only if the flag is set. """ xpath = "//a[@class='annotation-return']" # If return_to_annotation set, then show the link self.context['return_to_annotation'] = True xml = self.render_to_xml(self.context) self.assert_has_xpath(xml, xpath, self.context) # Otherwise, do not show the links self.context['return_to_annotation'] = False xml = self.render_to_xml(self.context) self.assert_no_xpath(xml, xpath, self.context) def test_option_selection(self): """ Test that selected options are selected. """ # Create options 0-4 and select option 2 self.context['options_value'] = [2] self.context['options'] = [ {'id': id_num, 'choice': 'correct', 'description': '<p>Unescaped <b>HTML {0}</b></p>'.format(id_num)} for id_num in range(5)] xml = self.render_to_xml(self.context) # Expect that each option description is visible # with unescaped HTML. # Since the HTML is unescaped, we can traverse the XML tree for id_num in range(5): xpath = "//span[@data-id='{0}']/p/b".format(id_num) self.assert_has_text(xml, xpath, 'HTML {0}'.format(id_num), exact=False) # Expect that the correct option is selected xpath = "//span[contains(@class,'selected')]/p/b" self.assert_has_text(xml, xpath, 'HTML 2', exact=False) def test_submission_status(self): """ Test that the submission status displays correctly. """ # Test cases of `(input_status, expected_css_class)` tuples test_cases = [('unsubmitted', 'unanswered'), ('incomplete', 'incorrect'), ('incorrect', 'incorrect')] for (input_status, expected_css_class) in test_cases: self.context['status'] = Status(input_status) xml = self.render_to_xml(self.context) xpath = "//span[@class='status {0}']".format(expected_css_class) self.assert_has_xpath(xml, xpath, self.context) # If individual options are being marked, then expect # just the option to be marked incorrect, not the whole problem self.context['has_options_value'] = True self.context['status'] = Status('incorrect') xpath = "//span[@class='incorrect']" xml = self.render_to_xml(self.context) self.assert_no_xpath(xml, xpath, self.context) def test_display_html_comment(self): """ Test that HTML comment and comment prompt render. """ self.context['comment'] = "<p>Unescaped <b>comment HTML</b></p>" self.context['comment_prompt'] = "<p>Prompt <b>prompt HTML</b></p>" self.context['text'] = "<p>Unescaped <b>text</b></p>" xml = self.render_to_xml(self.context) # Because the HTML is unescaped, we should be able to # descend to the <b> tag xpath = "//div[@class='block']/p/b" self.assert_has_text(xml, xpath, 'prompt HTML') xpath = "//div[@class='block block-comment']/p/b" self.assert_has_text(xml, xpath, 'comment HTML') xpath = "//div[@class='block block-highlight']/p/b" self.assert_has_text(xml, xpath, 'text') def test_display_html_tag_prompt(self): """ Test that HTML tag prompts render. """ self.context['tag_prompt'] = "<p>Unescaped <b>HTML</b></p>" xml = self.render_to_xml(self.context) # Because the HTML is unescaped, we should be able to # descend to the <b> tag xpath = "//div[@class='block']/p/b" self.assert_has_text(xml, xpath, 'HTML') class MathStringTemplateTest(TemplateTestCase): """ Test mako template for `<mathstring>` input. """ TEMPLATE_NAME = 'mathstring.html' def setUp(self): self.context = {'isinline': False, 'mathstr': '', 'tail': ''} super(MathStringTemplateTest, self).setUp() def test_math_string_inline(self): self.context['isinline'] = True self.context['mathstr'] = 'y = ax^2 + bx + c' xml = self.render_to_xml(self.context) xpath = "//section[@class='math-string']/span[1]" self.assert_has_text(xml, xpath, '[mathjaxinline]y = ax^2 + bx + c[/mathjaxinline]') def test_math_string_not_inline(self): self.context['isinline'] = False self.context['mathstr'] = 'y = ax^2 + bx + c' xml = self.render_to_xml(self.context) xpath = "//section[@class='math-string']/span[1]" self.assert_has_text(xml, xpath, '[mathjax]y = ax^2 + bx + c[/mathjax]') def test_tail_html(self): self.context['tail'] = "<p>This is some <b>tail</b> <em>HTML</em></p>" xml = self.render_to_xml(self.context) # HTML from `tail` should NOT be escaped. # We should be able to traverse it as part of the XML tree xpath = "//section[@class='math-string']/span[2]/p/b" self.assert_has_text(xml, xpath, 'tail') xpath = "//section[@class='math-string']/span[2]/p/em" self.assert_has_text(xml, xpath, 'HTML') class OptionInputTemplateTest(TemplateTestCase): """ Test mako template for `<optioninput>` input. """ TEMPLATE_NAME = 'optioninput.html' def setUp(self): self.context = { 'id': 2, 'options': [], 'status': Status('unsubmitted'), 'label': 'test', 'value': 0 } super(OptionInputTemplateTest, self).setUp() def test_select_options(self): # Create options 0-4, and select option 2 self.context['options'] = [(id_num, '<b>Option {0}</b>'.format(id_num)) for id_num in range(5)] self.context['value'] = 2 xml = self.render_to_xml(self.context) # Should have a dummy default xpath = "//option[@value='option_2_dummy_default']" self.assert_has_xpath(xml, xpath, self.context) # Should have each of the options, with the correct description # The description HTML should NOT be escaped # (that's why we descend into the <b> tag) for id_num in range(5): xpath = "//option[@value='{0}']/b".format(id_num) self.assert_has_text(xml, xpath, 'Option {0}'.format(id_num)) # Should have the correct option selected xpath = "//option[@selected='true']/b" self.assert_has_text(xml, xpath, 'Option 2') def test_status(self): # Test cases, where each tuple represents # `(input_status, expected_css_class)` test_cases = [('unsubmitted', 'status unanswered'), ('correct', 'status correct'), ('incorrect', 'status incorrect'), ('incomplete', 'status incorrect')] for (input_status, expected_css_class) in test_cases: self.context['status'] = Status(input_status) xml = self.render_to_xml(self.context) xpath = "//span[@class='{0}']".format(expected_css_class) self.assert_has_xpath(xml, xpath, self.context) def test_label(self): xml = self.render_to_xml(self.context) xpath = "//select[@aria-label='%s']" % self.context['label'] self.assert_has_xpath(xml, xpath, self.context) class DragAndDropTemplateTest(TemplateTestCase): """ Test mako template for `<draganddropinput>` input. """ TEMPLATE_NAME = 'drag_and_drop_input.html' def setUp(self): self.context = {'id': 2, 'drag_and_drop_json': '', 'value': 0, 'status': Status('unsubmitted'), 'msg': ''} super(DragAndDropTemplateTest, self).setUp() def test_status(self): # Test cases, where each tuple represents # `(input_status, expected_css_class, expected_text)` test_cases = [('unsubmitted', 'unanswered', 'unanswered'), ('correct', 'correct', 'correct'), ('incorrect', 'incorrect', 'incorrect'), ('incomplete', 'incorrect', 'incomplete')] for (input_status, expected_css_class, expected_text) in test_cases: self.context['status'] = Status(input_status) xml = self.render_to_xml(self.context) # Expect a <div> with the status xpath = "//div[@class='{0}']".format(expected_css_class) self.assert_has_xpath(xml, xpath, self.context) # Expect a <p> with the status xpath = "//p[@class='status']" self.assert_has_text(xml, xpath, expected_text, exact=False) def test_drag_and_drop_json_html(self): json_with_html = json.dumps({'test': '<p>Unescaped <b>HTML</b></p>'}) self.context['drag_and_drop_json'] = json_with_html xml = self.render_to_xml(self.context) # Assert that the JSON-encoded string was inserted without # escaping the HTML. We should be able to traverse the XML tree. xpath = "//div[@class='drag_and_drop_problem_json']/p/b" self.assert_has_text(xml, xpath, 'HTML') class ChoiceTextGroupTemplateTest(TemplateTestCase): """Test mako template for `<choicetextgroup>` input""" TEMPLATE_NAME = 'choicetext.html' VALUE_DICT = {'1_choiceinput_0bc': '1_choiceinput_0bc', '1_choiceinput_0_textinput_0': '0', '1_choiceinput_1_textinput_0': '0'} EMPTY_DICT = {'1_choiceinput_0_textinput_0': '', '1_choiceinput_1_textinput_0': ''} BOTH_CHOICE_CHECKBOX = {'1_choiceinput_0bc': 'choiceinput_0', '1_choiceinput_1bc': 'choiceinput_1', '1_choiceinput_0_textinput_0': '0', '1_choiceinput_1_textinput_0': '0'} WRONG_CHOICE_CHECKBOX = {'1_choiceinput_1bc': 'choiceinput_1', '1_choiceinput_0_textinput_0': '0', '1_choiceinput_1_textinput_0': '0'} def setUp(self): choices = [ ( '1_choiceinput_0bc', [ {'tail_text': '', 'type': 'text', 'value': '', 'contents': ''}, {'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_0_textinput_0'}, ] ), ( '1_choiceinput_1bc', [ {'tail_text': '', 'type': 'text', 'value': '', 'contents': ''}, {'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_1_textinput_0'}, ] ) ] self.context = { 'id': '1', 'choices': choices, 'status': Status('correct'), 'input_type': 'radio', 'label': 'choicetext label', 'value': self.VALUE_DICT, } super(ChoiceTextGroupTemplateTest, self).setUp() def test_grouping_tag(self): """ Tests whether we are using a section or a label to wrap choice elements. Section is used for checkbox, so inputting text does not deselect """ input_tags = ('radio', 'checkbox') self.context['status'] = Status('correct') xpath = "//section[@id='forinput1_choiceinput_0bc']" self.context['value'] = {} for input_type in input_tags: self.context['input_type'] = input_type xml = self.render_to_xml(self.context) self.assert_has_xpath(xml, xpath, self.context) def test_problem_marked_correct(self): """Test conditions under which the entire problem (not a particular option) is marked correct""" self.context['status'] = Status('correct') self.context['input_type'] = 'checkbox' self.context['value'] = self.VALUE_DICT # Should mark the entire problem correct xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status correct']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options self.assert_no_xpath(xml, "//label[@class='choicetextgroup_incorrect']", self.context) self.assert_no_xpath(xml, "//label[@class='choicetextgroup_correct']", self.context) def test_problem_marked_incorrect(self): """Test all conditions under which the entire problem (not a particular option) is marked incorrect""" grouping_tags = {'radio': 'label', 'checkbox': 'section'} conditions = [ {'status': Status('incorrect'), 'input_type': 'radio', 'value': {}}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': self.WRONG_CHOICE_CHECKBOX}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': self.BOTH_CHOICE_CHECKBOX}, {'status': Status('incorrect'), 'input_type': 'checkbox', 'value': self.VALUE_DICT}, {'status': Status('incomplete'), 'input_type': 'radio', 'value': {}}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': self.WRONG_CHOICE_CHECKBOX}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': self.BOTH_CHOICE_CHECKBOX}, {'status': Status('incomplete'), 'input_type': 'checkbox', 'value': self.VALUE_DICT}] for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status incorrect']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options grouping_tag = grouping_tags[test_conditions['input_type']] self.assert_no_xpath(xml, "//{0}[@class='choicetextgroup_incorrect']".format(grouping_tag), self.context) self.assert_no_xpath(xml, "//{0}[@class='choicetextgroup_correct']".format(grouping_tag), self.context) def test_problem_marked_unsubmitted(self): """Test all conditions under which the entire problem (not a particular option) is marked unanswered""" grouping_tags = {'radio': 'label', 'checkbox': 'section'} conditions = [ {'status': Status('unsubmitted'), 'input_type': 'radio', 'value': {}}, {'status': Status('unsubmitted'), 'input_type': 'radio', 'value': self.EMPTY_DICT}, {'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': {}}, {'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.EMPTY_DICT}, {'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.VALUE_DICT}, {'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.BOTH_CHOICE_CHECKBOX}, ] self.context['status'] = Status('unanswered') for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//div[@class='indicator-container']/span[@class='status unanswered']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark individual options grouping_tag = grouping_tags[test_conditions['input_type']] self.assert_no_xpath(xml, "//{0}[@class='choicetextgroup_incorrect']".format(grouping_tag), self.context) self.assert_no_xpath(xml, "//{0}[@class='choicetextgroup_correct']".format(grouping_tag), self.context) def test_option_marked_correct(self): """Test conditions under which a particular option (not the entire problem) is marked correct.""" conditions = [ {'input_type': 'radio', 'value': self.VALUE_DICT}] self.context['status'] = 'correct' for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//section[@id='forinput1_choiceinput_0bc' and\ @class='choicetextgroup_correct']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark the whole problem xpath = "//div[@class='indicator-container']/span" self.assert_no_xpath(xml, xpath, self.context) def test_option_marked_incorrect(self): """Test conditions under which a particular option (not the entire problem) is marked incorrect.""" conditions = [ {'input_type': 'radio', 'value': self.VALUE_DICT}] self.context['status'] = 'incorrect' for test_conditions in conditions: self.context.update(test_conditions) xml = self.render_to_xml(self.context) xpath = "//section[@id='forinput1_choiceinput_0bc' and\ @class='choicetextgroup_incorrect']" self.assert_has_xpath(xml, xpath, self.context) # Should NOT mark the whole problem xpath = "//div[@class='indicator-container']/span" self.assert_no_xpath(xml, xpath, self.context) def test_label(self): xml = self.render_to_xml(self.context) xpath = "//fieldset[@aria-label='%s']" % self.context['label'] self.assert_has_xpath(xml, xpath, self.context)
agpl-3.0
[ 624, 199, 2925, 367, 314, 9661, 315, 1324, 730, 26834, 7009, 14, 199, 624, 199, 199, 646, 2882, 199, 646, 28068, 199, 646, 747, 14, 515, 199, 646, 2022, 199, 504, 14490, 492, 7559, 199, 504, 26834, 14, 1160, 492, 5458, 465, 603, 23564, 4231, 199, 504, 26834, 492, 4967, 199, 504, 28068, 14, 1210, 1313, 492, 9795, 421, 199, 533, 5458, 547, 8, 1726, 304, 272, 408, 272, 4520, 8920, 1830, 14066, 282, 603, 23564, 1978, 14, 272, 408, 272, 986, 421, 199, 533, 5458, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 738, 280, 317, 280, 744, 367, 5343, 7009, 14, 272, 408, 339, 327, 20196, 4278, 642, 370, 4165, 314, 570, 536, 402, 314, 1978, 272, 327, 370, 506, 6511, 687, 28068, 15, 5876, 14, 272, 327, 710, 1978, 536, 1077, 2387, 314, 1275, 1360, 3329, 26, 272, 327, 367, 2893, 26, 7141, 923, 14, 1360, 272, 24877, 63, 2339, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 7190, 314, 1978, 1334, 511, 14, 267, 408, 267, 1613, 8, 4231, 1746, 12, 291, 680, 5996, 342, 267, 28068, 63, 515, 275, 28068, 855, 515, 12298, 16, 61, 267, 291, 14, 1160, 63, 515, 275, 747, 14, 515, 14, 904, 8, 18182, 63, 515, 12, 5101, 283, 5876, 297, 5101, 291, 14, 7433, 63, 2339, 9, 267, 543, 1551, 8, 277, 14, 1160, 63, 515, 9, 465, 289, 26, 288, 291, 14, 1160, 275, 603, 23564, 4231, 8, 70, 14, 739, 1012, 339, 347, 3795, 63, 475, 63, 1652, 8, 277, 12, 1067, 63, 807, 304, 267, 408, 267, 17769, 314, 1978, 1808, 314, 658, 1100, 63, 807, 64, 1211, 14, 267, 1803, 376, 658, 9464, 64, 4692, 1819, 14, 267, 408, 267, 327, 1050, 7283, 27815, 63, 2632, 370, 1978, 1067, 267, 1067, 63, 807, 14, 5486, 480, 10449, 63, 2632, 401, 3286, 5869, 13, 1986, 13589, 267, 862, 26, 288, 2748, 63, 495, 275, 291, 14, 1160, 14, 3352, 63, 2975, 3682, 1100, 63, 807, 9, 267, 871, 26, 288, 746, 5458, 547, 8, 3924, 14, 505, 63, 705, 63, 1160, 1252, 3352, 1012, 398, 327, 23115, 370, 6982, 376, 4692, 3123, 687, 314, 1978, 267, 327, 961, 7704, 652, 8837, 370, 675, 1323, 2042, 370, 1852, 22835, 12, 7830, 267, 327, 2419, 23654, 543, 282, 1059, 14, 267, 327, 2136, 2811, 314, 1059, 18023, 701, 19696, 652, 315, 665, 396, 30, 267, 327, 3762, 12, 370, 4868, 652, 965, 1373, 1738, 1819, 14, 267, 862, 26, 288, 2748, 275, 7559, 14, 13521, 6757, 396, 4335, 435, 2748, 63, 495, 435, 15683, 396, 9579, 267, 871, 2186, 465, 3178, 26, 288, 746, 5458, 547, 480, 6531, 440, 2198, 4692, 687, 5041, 16, 93, 356, 469, 17, 5469, 908, 8, 1816, 2748, 63, 495, 12, 620, 8, 2804, 1724, 267, 587, 26, 288, 372, 2748, 339, 347, 702, 63, 1989, 63, 8006, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1067, 63, 807, 12, 5835, 63, 1507, 29, 17, 304, 267, 408, 267, 10716, 83, 626, 314, 2748, 3123, 965, 376, 1819, 23082, 316, 658, 8006, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 1100, 64, 365, 1202, 370, 870, 282, 10201, 1245, 267, 658, 7327, 63, 1507, 64, 365, 314, 5835, 1329, 402, 4450, 370, 4282, 14, 267, 408, 267, 1245, 275, 1689, 4317, 1630, 440, 1172, 450, 68, 1336, 8, 397, 9, 367, 14462, 1543, 83, 1154, 78, 4317, 26, 450, 83, 60, 78, 2998, 26, 450, 83, 2, 673, 450, 334, 7327, 63, 1507, 12, 620, 8, 8006, 395, 7559, 14, 14028, 8, 1652, 63, 1231, 395, 620, 8, 1100, 63, 807, 1724, 398, 291, 14, 629, 8, 552, 8, 1652, 63, 1231, 14, 8006, 8, 8006, 1826, 5835, 63, 1507, 12, 1499, 29, 1188, 9, 339, 347, 702, 63, 889, 63, 8006, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1067, 63, 807, 304, 267, 408, 267, 10716, 83, 626, 314, 2748, 3123, 1630, 2845, 1172, 376, 1819, 267, 23082, 316, 658, 8006, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 1100, 64, 365, 1202, 370, 870, 282, 10201, 1245, 267, 408, 267, 291, 14, 479, 63, 1989, 63, 8006, 8, 1652, 63, 1231, 12, 14462, 12, 1067, 63, 807, 12, 5835, 63, 1507, 29, 16, 9, 339, 347, 702, 63, 1989, 63, 505, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1318, 12, 5835, 29, 549, 304, 267, 408, 267, 6668, 314, 1819, 737, 658, 8006, 64, 315, 658, 1652, 63, 1231, 64, 436, 702, 267, 626, 2399, 1318, 365, 658, 505, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 505, 64, 365, 314, 1420, 1318, 626, 314, 1819, 1077, 1395, 398, 982, 3663, 4008, 787, 1911, 12, 5920, 314, 1642, 1373, 14, 267, 982, 949, 4008, 787, 1911, 12, 314, 14412, 6918, 14, 267, 408, 267, 1819, 63, 513, 275, 2748, 63, 1231, 14, 8006, 8, 8006, 9, 267, 291, 14, 1815, 8, 552, 8, 2108, 63, 513, 9, 690, 378, 12, 717, 298, 6531, 440, 2342, 1819, 737, 1543, 83, 4065, 450, 620, 8, 8006, 430, 398, 340, 5835, 26, 288, 291, 14, 629, 8, 505, 12, 1819, 63, 513, 59, 16, 1055, 505, 9, 267, 587, 26, 288, 291, 14, 4080, 8, 505, 12, 1819, 63, 513, 59, 16, 1055, 505, 9, 421, 199, 533, 16053, 2448, 4231, 774, 8, 4231, 1746, 304, 272, 408, 272, 1379, 26834, 1978, 367, 658, 28, 5095, 923, 8637, 1324, 14, 272, 408, 339, 24877, 63, 2339, 275, 283, 5095, 923, 14, 1360, 7, 339, 347, 3613, 8, 277, 304, 267, 3415, 275, 4274, 17, 297, 283, 5095, 413, 659, 661, 18, 297, 283, 5095, 499, 659, 661, 19, 297, 283, 5095, 650, 5440, 267 ]
[ 199, 2925, 367, 314, 9661, 315, 1324, 730, 26834, 7009, 14, 199, 624, 199, 199, 646, 2882, 199, 646, 28068, 199, 646, 747, 14, 515, 199, 646, 2022, 199, 504, 14490, 492, 7559, 199, 504, 26834, 14, 1160, 492, 5458, 465, 603, 23564, 4231, 199, 504, 26834, 492, 4967, 199, 504, 28068, 14, 1210, 1313, 492, 9795, 421, 199, 533, 5458, 547, 8, 1726, 304, 272, 408, 272, 4520, 8920, 1830, 14066, 282, 603, 23564, 1978, 14, 272, 408, 272, 986, 421, 199, 533, 5458, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 738, 280, 317, 280, 744, 367, 5343, 7009, 14, 272, 408, 339, 327, 20196, 4278, 642, 370, 4165, 314, 570, 536, 402, 314, 1978, 272, 327, 370, 506, 6511, 687, 28068, 15, 5876, 14, 272, 327, 710, 1978, 536, 1077, 2387, 314, 1275, 1360, 3329, 26, 272, 327, 367, 2893, 26, 7141, 923, 14, 1360, 272, 24877, 63, 2339, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 7190, 314, 1978, 1334, 511, 14, 267, 408, 267, 1613, 8, 4231, 1746, 12, 291, 680, 5996, 342, 267, 28068, 63, 515, 275, 28068, 855, 515, 12298, 16, 61, 267, 291, 14, 1160, 63, 515, 275, 747, 14, 515, 14, 904, 8, 18182, 63, 515, 12, 5101, 283, 5876, 297, 5101, 291, 14, 7433, 63, 2339, 9, 267, 543, 1551, 8, 277, 14, 1160, 63, 515, 9, 465, 289, 26, 288, 291, 14, 1160, 275, 603, 23564, 4231, 8, 70, 14, 739, 1012, 339, 347, 3795, 63, 475, 63, 1652, 8, 277, 12, 1067, 63, 807, 304, 267, 408, 267, 17769, 314, 1978, 1808, 314, 658, 1100, 63, 807, 64, 1211, 14, 267, 1803, 376, 658, 9464, 64, 4692, 1819, 14, 267, 408, 267, 327, 1050, 7283, 27815, 63, 2632, 370, 1978, 1067, 267, 1067, 63, 807, 14, 5486, 480, 10449, 63, 2632, 401, 3286, 5869, 13, 1986, 13589, 267, 862, 26, 288, 2748, 63, 495, 275, 291, 14, 1160, 14, 3352, 63, 2975, 3682, 1100, 63, 807, 9, 267, 871, 26, 288, 746, 5458, 547, 8, 3924, 14, 505, 63, 705, 63, 1160, 1252, 3352, 1012, 398, 327, 23115, 370, 6982, 376, 4692, 3123, 687, 314, 1978, 267, 327, 961, 7704, 652, 8837, 370, 675, 1323, 2042, 370, 1852, 22835, 12, 7830, 267, 327, 2419, 23654, 543, 282, 1059, 14, 267, 327, 2136, 2811, 314, 1059, 18023, 701, 19696, 652, 315, 665, 396, 30, 267, 327, 3762, 12, 370, 4868, 652, 965, 1373, 1738, 1819, 14, 267, 862, 26, 288, 2748, 275, 7559, 14, 13521, 6757, 396, 4335, 435, 2748, 63, 495, 435, 15683, 396, 9579, 267, 871, 2186, 465, 3178, 26, 288, 746, 5458, 547, 480, 6531, 440, 2198, 4692, 687, 5041, 16, 93, 356, 469, 17, 5469, 908, 8, 1816, 2748, 63, 495, 12, 620, 8, 2804, 1724, 267, 587, 26, 288, 372, 2748, 339, 347, 702, 63, 1989, 63, 8006, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1067, 63, 807, 12, 5835, 63, 1507, 29, 17, 304, 267, 408, 267, 10716, 83, 626, 314, 2748, 3123, 965, 376, 1819, 23082, 316, 658, 8006, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 1100, 64, 365, 1202, 370, 870, 282, 10201, 1245, 267, 658, 7327, 63, 1507, 64, 365, 314, 5835, 1329, 402, 4450, 370, 4282, 14, 267, 408, 267, 1245, 275, 1689, 4317, 1630, 440, 1172, 450, 68, 1336, 8, 397, 9, 367, 14462, 1543, 83, 1154, 78, 4317, 26, 450, 83, 60, 78, 2998, 26, 450, 83, 2, 673, 450, 334, 7327, 63, 1507, 12, 620, 8, 8006, 395, 7559, 14, 14028, 8, 1652, 63, 1231, 395, 620, 8, 1100, 63, 807, 1724, 398, 291, 14, 629, 8, 552, 8, 1652, 63, 1231, 14, 8006, 8, 8006, 1826, 5835, 63, 1507, 12, 1499, 29, 1188, 9, 339, 347, 702, 63, 889, 63, 8006, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1067, 63, 807, 304, 267, 408, 267, 10716, 83, 626, 314, 2748, 3123, 1630, 2845, 1172, 376, 1819, 267, 23082, 316, 658, 8006, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 1100, 64, 365, 1202, 370, 870, 282, 10201, 1245, 267, 408, 267, 291, 14, 479, 63, 1989, 63, 8006, 8, 1652, 63, 1231, 12, 14462, 12, 1067, 63, 807, 12, 5835, 63, 1507, 29, 16, 9, 339, 347, 702, 63, 1989, 63, 505, 8, 277, 12, 2748, 63, 1231, 12, 14462, 12, 1318, 12, 5835, 29, 549, 304, 267, 408, 267, 6668, 314, 1819, 737, 658, 8006, 64, 315, 658, 1652, 63, 1231, 64, 436, 702, 267, 626, 2399, 1318, 365, 658, 505, 2313, 398, 658, 1652, 63, 1231, 64, 365, 376, 7559, 4692, 1819, 267, 658, 8006, 64, 365, 376, 1323, 2042, 1059, 12, 4066, 465, 658, 9807, 1421, 15, 1700, 7, 64, 267, 658, 505, 64, 365, 314, 1420, 1318, 626, 314, 1819, 1077, 1395, 398, 982, 3663, 4008, 787, 1911, 12, 5920, 314, 1642, 1373, 14, 267, 982, 949, 4008, 787, 1911, 12, 314, 14412, 6918, 14, 267, 408, 267, 1819, 63, 513, 275, 2748, 63, 1231, 14, 8006, 8, 8006, 9, 267, 291, 14, 1815, 8, 552, 8, 2108, 63, 513, 9, 690, 378, 12, 717, 298, 6531, 440, 2342, 1819, 737, 1543, 83, 4065, 450, 620, 8, 8006, 430, 398, 340, 5835, 26, 288, 291, 14, 629, 8, 505, 12, 1819, 63, 513, 59, 16, 1055, 505, 9, 267, 587, 26, 288, 291, 14, 4080, 8, 505, 12, 1819, 63, 513, 59, 16, 1055, 505, 9, 421, 199, 533, 16053, 2448, 4231, 774, 8, 4231, 1746, 304, 272, 408, 272, 1379, 26834, 1978, 367, 658, 28, 5095, 923, 8637, 1324, 14, 272, 408, 339, 24877, 63, 2339, 275, 283, 5095, 923, 14, 1360, 7, 339, 347, 3613, 8, 277, 304, 267, 3415, 275, 4274, 17, 297, 283, 5095, 413, 659, 661, 18, 297, 283, 5095, 499, 659, 661, 19, 297, 283, 5095, 650, 5440, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ran5515/DeepDecision
tensorflow/contrib/timeseries/python/timeseries/state_space_models/state_space_model.py
8
56990
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Abstract base for state space models.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc import collections import numpy from tensorflow.contrib.layers.python.layers import layers from tensorflow.contrib.timeseries.python.timeseries import math_utils from tensorflow.contrib.timeseries.python.timeseries import model from tensorflow.contrib.timeseries.python.timeseries import model_utils from tensorflow.contrib.timeseries.python.timeseries.feature_keys import TrainEvalFeatures from tensorflow.contrib.timeseries.python.timeseries.state_space_models import kalman_filter from tensorflow.python.estimator import estimator_lib from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_math_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope class StateSpaceModelConfiguration( collections.namedtuple( typename="StateSpaceModelConfiguration", field_names=[ "num_features", "use_observation_noise", "dtype", "covariance_prior_fn", "bayesian_prior_weighting", "filtering_postprocessor", "trainable_start_state", "exogenous_noise_increases", "exogenous_noise_decreases", "exogenous_feature_columns", "exogenous_update_condition", "filtering_maximum_posterior_variance_ratio", "filtering_minimum_posterior_variance", "transition_covariance_initial_log_scale_bias", "static_unrolling_window_size_threshold"])): """Configuration options for StateSpaceModels.""" def __new__( cls, num_features=1, use_observation_noise=True, dtype=dtypes.float32, covariance_prior_fn=math_utils.log_noninformative_covariance_prior, bayesian_prior_weighting=True, filtering_postprocessor=None, trainable_start_state=False, exogenous_noise_increases=True, exogenous_noise_decreases=False, exogenous_feature_columns=None, exogenous_update_condition=None, filtering_maximum_posterior_variance_ratio=1e6, filtering_minimum_posterior_variance=0., transition_covariance_initial_log_scale_bias=-5., static_unrolling_window_size_threshold=None): """Configuration options for StateSpaceModels. Args: num_features: Output dimension for model use_observation_noise: If true, observations are modeled as noisy functions of the current state. If false, observations are a deterministic function of the current state. Only applicable to the top-level model in an ensemble. Consider also changing the transition_covariance_initial_log_scale_bias when disabling observation noise, as its default setting assumes that observation noise is part of the model. dtype: The float dtype to use when defining the model. covariance_prior_fn: A function mapping from a covariance matrix to a scalar value (e.g. log likelihood) which can be summed across matrices. Defaults to an independent Jeffreys prior on the diagonal elements (regularizing as log(1. / variance)). To use a flat prior (i.e. no regularization), set to `lambda _: 0.`. Defaults to relatively uninformative priors on state transition and observation noise, which have the effect of encouraging low-noise solutions which provide confident predictions when possible. Without regularization, transition noise tends to remain high, and multi-step predictions are under-confident. bayesian_prior_weighting: If True, weights the prior (covariance_prior_fn) based on an estimate of the full dataset size. If False, weights it based on the mini-batch window size, which (while statistically improper) can lead to more desirable low-noise solutions in cases where the full dataset is large enough to overwhelm the prior. filtering_postprocessor: A FilteringStepPostprocessor object to use, useful for ignoring anomalies in training data. trainable_start_state: If True, start state may depend on trainable Variables. If False, it will not. exogenous_noise_increases: If True, exogenous regressors can add to model state, increasing uncertainty. If both this parameter and exogenous_noise_decreases are False, exogenous regressors are ignored. exogenous_noise_decreases: If True, exogenous regressors can "set" model state, decreasing uncertainty. If both this parameter and exogenous_noise_increases are False, exogenous regressors are ignored. exogenous_feature_columns: A list of tf.contrib.layers.FeatureColumn objects (for example tf.contrib.layers.embedding_column) corresponding to exogenous features which provide extra information to the model but are not part of the series to be predicted. Passed to tf.contrib.layers.input_from_feature_columns. exogenous_update_condition: A function taking two Tensor arguments `times` (shape [batch size]) and `features` (a dictionary mapping exogenous feature keys to Tensors with shapes [batch size, ...]) and returning a boolean Tensor with shape [batch size] indicating whether state should be updated using exogenous features for each part of the batch. Where it is False, no exogenous update is performed. If None (default), exogenous updates are always performed. Useful for avoiding "leaky" frequent exogenous updates when sparse updates are desired. Called only during graph construction. filtering_maximum_posterior_variance_ratio: The maximum allowed ratio of two diagonal entries in a state covariance matrix just prior to filtering. Lower values mean that filtering will be more numerically stable, at the cost of artificially increasing estimated uncertainty in some cases. This parameter can be important when learning a transition matrix. filtering_minimum_posterior_variance: The minimum diagonal value in a state covariance matrix just prior to filtering, preventing numerical instability due to deterministic beliefs (sometimes an issue when learning transition matrices). This value should be set several orders of magnitude below any expected minimum state uncertainty. transition_covariance_initial_log_scale_bias: Controls the initial tradeoff between the transition noise covariance matrix and the observation noise covariance matrix, on a log scale (the elements of the transition noise covariance matrix are proportional to `e^{X + transition_covariance_initial_log_scale_bias}` where `X` is learned and may depend on input statistics, observation noise covariance is proportional to `e^{Y - transition_covariance_initial_log_scale_bias}`). For models *with* observation noise, -5 is a reasonable value. Models which do not use observation noise, and are not part of an ensemble which does use observation noise, should have this set to 0 or more to avoid numerical issues due to filtering with too little noise. static_unrolling_window_size_threshold: Only relevant for the top-level StateSpaceModel in an ensemble; enables switching between static and dynamic looping (if not None, default, meaning that no static unrolling is performed) based on the window size (windows with this size and smaller will have their graphs unrolled statically). See the SequentialTimeSeriesModel constructor for details. Returns: A StateSpaceModelConfiguration object. """ if exogenous_feature_columns is None: exogenous_feature_columns = [] return super(StateSpaceModelConfiguration, cls).__new__( cls, num_features, use_observation_noise, dtype, covariance_prior_fn, bayesian_prior_weighting, filtering_postprocessor, trainable_start_state, exogenous_noise_increases, exogenous_noise_decreases, exogenous_feature_columns, exogenous_update_condition, filtering_maximum_posterior_variance_ratio, filtering_minimum_posterior_variance, transition_covariance_initial_log_scale_bias, static_unrolling_window_size_threshold) class StateSpaceModel(model.SequentialTimeSeriesModel): """Base class for linear state space models. Sub-classes can specify the model to be learned by overriding get_state_transition, get_noise_transform, and get_observation_model. See kalman_filter.py for a detailed description of the class of models covered by StateSpaceModel. Briefly, state space models are defined by a state transition equation: state[t] = StateTransition * state[t-1] + NoiseTransform * StateNoise[t] + ExogenousNoiseIncreasing[t] StateNoise[t] ~ Gaussian(0, StateNoiseCovariance) ExogenousNoiseIncreasing[t] ~ Gaussian(ExogenousNoiseIncreasingMean[t], ExogenousNoiseIncreasingCovariance[t]) And an observation model: observation[t] = ObservationModel * state[t] + ObservationNoise[t] ObservationNoise[t] ~ Gaussian(0, ObservationNoiseCovariance) Additionally, exogenous regressors can act as observations, decreasing uncertainty: ExogenousNoiseDecreasingObservation[t] ~ Gaussian( ExogenousNoiseDecreasingMean[t], ExogenousNoiseDecreasingCovariance[t]) Attributes: kalman_filter: If initialize_graph has been called, the initialized KalmanFilter to use for inference. None otherwise. prior_state_mean: If initialize_graph has been called, a Variable-parameterized Tensor with shape [state dimension]; the initial prior mean for one or more time series. None otherwise. prior_state_var: If initialize_graph has been called, a Variable-parameterized Tensor with shape [state dimension x state dimension]; the initial prior covariance. None otherwise. state_transition_noise_covariance: If initialize_graph has been called, a Variable-parameterized Tensor with shape [state noise dimension x state noise dimension] indicating the amount of noise added at each transition. """ def __init__(self, configuration): """Initialize a state space model. Args: configuration: A StateSpaceModelConfiguration object. """ self._configuration = configuration if configuration.filtering_postprocessor is not None: filtering_postprocessor_names = ( configuration.filtering_postprocessor.output_names) else: filtering_postprocessor_names = [] super(StateSpaceModel, self).__init__( train_output_names=(["mean", "covariance", "log_likelihood"] + filtering_postprocessor_names), predict_output_names=["mean", "covariance"], num_features=configuration.num_features, dtype=configuration.dtype, exogenous_feature_columns=configuration.exogenous_feature_columns, exogenous_update_condition=configuration.exogenous_update_condition, static_unrolling_window_size_threshold= configuration.static_unrolling_window_size_threshold) self._kalman_filter = None self.prior_state_mean = None self.prior_state_var = None self.state_transition_noise_covariance = None self._total_observation_count = None self._observation_noise_covariance = None # Capture the current variable scope and use it to define all model # variables. Especially useful for ensembles, where variables may be defined # for every component model in one function call, which would otherwise # prevent the user from separating variables from different models into # different scopes. self._variable_scope = variable_scope.get_variable_scope() def transition_power_noise_accumulator(self, num_steps): r"""Sum a transitioned covariance matrix over a number of steps. Computes \sum_{i=0}^{num_steps - 1} ( state_transition^i * state_transition_noise_covariance * (state_transition^i)^T) If special cases are available, overriding this function can lead to more efficient inferences. Args: num_steps: A [...] shape integer Tensor with numbers of steps to compute power sums for. Returns: The computed power sum, with shape [..., state dimension, state dimension]. """ # TODO(allenl): This general case should use cumsum if transition_to_powers # can be computed in constant time (important for correlated ensembles, # where transition_power_noise_accumulator special cases cannot be # aggregated from member models). noise_transform = ops.convert_to_tensor(self.get_noise_transform(), self.dtype) noise_transformed = math_ops.matmul( math_ops.matmul(noise_transform, self.state_transition_noise_covariance), noise_transform, transpose_b=True) noise_additions = math_utils.power_sums_tensor( math_ops.reduce_max(num_steps) + 1, ops.convert_to_tensor(self.get_state_transition(), dtype=self.dtype), noise_transformed) return array_ops.gather(noise_additions, indices=num_steps) def transition_to_powers(self, powers): """Raise the transition matrix to a batch of powers. Computes state_transition^powers. If special cases are available, overriding this function can lead to more efficient inferences. Args: powers: A [...] shape integer Tensor with powers to raise the transition matrix to. Returns: The computed matrix powers, with shape [..., state dimension, state dimension]. """ return math_utils.matrix_to_powers( ops.convert_to_tensor(self.get_state_transition(), dtype=self.dtype), powers) def _window_initializer(self, times, state): """Prepare to impute across the gaps in a window.""" _, _, priors_from_time = state times = ops.convert_to_tensor(times) priors_from_time = ops.convert_to_tensor(priors_from_time) with ops.control_dependencies([ control_flow_ops.Assert( math_ops.reduce_all(priors_from_time <= times[:, 0]), [priors_from_time, times[:, 0]], summarize=100) ]): times = array_ops.identity(times) intra_batch_gaps = array_ops.reshape(times[:, 1:] - times[:, :-1], [-1]) starting_gaps = times[:, 0] - priors_from_time # Pre-define transition matrices raised to powers (and their sums) for every # gap in this window. This avoids duplicate computation (for example many # steps will use the transition matrix raised to the first power) and # batches the computation rather than doing it inside the per-step loop. unique_gaps, _ = array_ops.unique( array_ops.concat([intra_batch_gaps, starting_gaps], axis=0)) self._window_power_sums = self.transition_power_noise_accumulator( unique_gaps) self._window_transition_powers = self.transition_to_powers(unique_gaps) self._window_gap_sizes = unique_gaps def _lookup_window_caches(self, caches, indices): _, window_power_ids = array_ops.unique( array_ops.concat( [ self._window_gap_sizes, math_ops.cast( indices, self._window_gap_sizes.dtype) ], axis=0)) all_gathered_indices = [] for cache in caches: gathered_indices = array_ops.gather( cache, window_power_ids[-array_ops.shape(indices)[0]:]) gathered_indices.set_shape(indices.get_shape().concatenate( gathered_indices.get_shape()[-2:])) all_gathered_indices.append(gathered_indices) return all_gathered_indices def _cached_transition_powers_and_sums(self, num_steps): return self._lookup_window_caches( caches=[self._window_transition_powers, self._window_power_sums], indices=num_steps) def _imputation_step(self, current_times, state): """Add state transition noise to catch `state` up to `current_times`. State space models are inherently sequential, so we need to "predict through" any missing time steps to catch up each element of the batch to its next observation/prediction time. Args: current_times: A [batch size] Tensor of times to impute up to, not inclusive. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] Returns: Imputed model state corresponding to the `state` argument. """ estimated_state, estimated_state_var, previous_times = state catchup_times = current_times - previous_times non_negative_assertion = control_flow_ops.Assert( math_ops.reduce_all(catchup_times >= 0), [ "Negative imputation interval", catchup_times, current_times, previous_times ], summarize=100) with ops.control_dependencies([non_negative_assertion]): transition_matrices, transition_noise_sums = ( # pylint: disable=unbalanced-tuple-unpacking self._cached_transition_powers_and_sums(catchup_times)) estimated_state = self._kalman_filter.predict_state_mean( estimated_state, transition_matrices) estimated_state_var = self._kalman_filter.predict_state_var( estimated_state_var, transition_matrices, transition_noise_sums) return (estimated_state, estimated_state_var, previous_times + catchup_times) def _filtering_step(self, current_times, current_values, state, predictions): """Compute posteriors and accumulate one-step-ahead predictions. Args: current_times: A [batch size] Tensor for times for each observation. current_values: A [batch size] Tensor of values for each observaiton. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] predictions: A dictionary containing mean and covariance Tensors, the output of _prediction_step. Returns: A tuple of (posteriors, outputs): posteriors: Model state updated to take `current_values` into account. outputs: The `predictions` dictionary updated to include "loss" and "log_likelihood" entries (loss simply being negative log likelihood). """ estimated_state, estimated_state_covariance, previous_times = state observation_model = self.get_broadcasted_observation_model(current_times) imputed_to_current_step_assert = control_flow_ops.Assert( math_ops.reduce_all(math_ops.equal(current_times, previous_times)), ["Attempted to perform filtering without imputation/prediction"]) with ops.control_dependencies([imputed_to_current_step_assert]): estimated_state_covariance = math_utils.clip_covariance( estimated_state_covariance, self._configuration.filtering_maximum_posterior_variance_ratio, self._configuration.filtering_minimum_posterior_variance) (filtered_state, filtered_state_covariance, log_prob) = self._kalman_filter.do_filter( estimated_state=estimated_state, estimated_state_covariance=estimated_state_covariance, predicted_observation=predictions["mean"], predicted_observation_covariance=predictions["covariance"], observation=current_values, observation_model=observation_model, observation_noise=self._observation_noise_covariance) filtered_state = (filtered_state, filtered_state_covariance, current_times) log_prob.set_shape(current_times.get_shape()) predictions["loss"] = -log_prob predictions["log_likelihood"] = log_prob if self._configuration.filtering_postprocessor is not None: return self._configuration.filtering_postprocessor.process_filtering_step( current_times=current_times, current_values=current_values, predicted_state=state, filtered_state=filtered_state, outputs=predictions) return (filtered_state, predictions) def _prediction_step(self, current_times, state): """Make a prediction based on `state`. Computes predictions based on the current `state`, checking that it has already been updated (in `_imputation_step`) to `current_times`. Args: current_times: A [batch size] Tensor for times to make predictions for. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] Returns: A tuple of (updated state, predictions): updated state: Model state with added transition noise. predictions: A dictionary with "mean" and "covariance", having shapes "mean": [batch size x num features] "covariance: [batch size x num features x num features] """ estimated_state, estimated_state_var, previous_times = state advanced_to_current_assert = control_flow_ops.Assert( math_ops.reduce_all(math_ops.equal(current_times, previous_times)), ["Attempted to predict without imputation"]) with ops.control_dependencies([advanced_to_current_assert]): observation_model = self.get_broadcasted_observation_model(current_times) predicted_obs, predicted_obs_var = ( self._kalman_filter.observed_from_state( state_mean=estimated_state, state_var=estimated_state_var, observation_model=observation_model, observation_noise=self._observation_noise_covariance)) predicted_obs_var.set_shape( ops.convert_to_tensor(current_times).get_shape() .concatenate([self.num_features, self.num_features])) predicted_obs.set_shape(current_times.get_shape().concatenate( (self.num_features,))) predicted_obs_var.set_shape(current_times.get_shape().concatenate( (self.num_features, self.num_features))) predictions = { "mean": predicted_obs, "covariance": predicted_obs_var} state = (estimated_state, estimated_state_var, current_times) return (state, predictions) def _exogenous_noise_decreasing(self, current_times, exogenous_values, state): """Update state with exogenous regressors, decreasing uncertainty. Constructs a mean and covariance based on transformations of `exogenous_values`, then performs Bayesian inference on the constructed observation. This has the effect of lowering uncertainty. This update refines or overrides previous inferences, useful for modeling exogenous inputs which "set" state, e.g. we dumped boiling water on the thermometer so we're pretty sure it's 100 degrees C. Args: current_times: A [batch size] Tensor of times for the exogenous values being input. exogenous_values: A [batch size x exogenous input dimension] Tensor of exogenous values for each part of the batch. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] Returns: Updated state taking the exogenous regressors into account (with lower uncertainty than the input state). """ estimated_state, estimated_state_covariance, previous_times = state state_transition = ops.convert_to_tensor( self.get_state_transition(), dtype=self.dtype) state_dimension = state_transition.get_shape()[0].value # Learning the observation model would be redundant since we transform # `exogenous_values` to the state space via a linear transformation anyway. observation_model = linalg_ops.eye( state_dimension, batch_shape=array_ops.shape(exogenous_values)[:-1], dtype=self.dtype) with variable_scope.variable_scope("exogenous_noise_decreasing_covariance"): observation_noise = math_utils.transform_to_covariance_matrices( exogenous_values, state_dimension) with variable_scope.variable_scope( "exogenous_noise_decreasing_observation"): observation = layers.fully_connected( exogenous_values, state_dimension, activation_fn=None) # Pretend that we are making an observation with an observation model equal # to the identity matrix (i.e. a direct observation of the latent state), # with learned observation noise. posterior_state, posterior_state_var = ( self._kalman_filter.posterior_from_prior_state( prior_state=estimated_state, prior_state_var=estimated_state_covariance, observation=observation, observation_model=observation_model, predicted_observations=( estimated_state, # The predicted noise covariance is noise due to current state # uncertainty plus noise learned based on the exogenous # observation (a somewhat trivial call to # self._kalman_filter.observed_from_state has been omitted). observation_noise + estimated_state_covariance), observation_noise=observation_noise)) return (posterior_state, posterior_state_var, previous_times) def _exogenous_noise_increasing(self, current_times, exogenous_values, state): """Update state with exogenous regressors, increasing uncertainty. Adds to the state mean a linear transformation of `exogenous_values`, and increases uncertainty by constructing a covariance matrix based on `exogenous_values` and adding it to the state covariance. This update is useful for modeling changes relative to current state, e.g. the furnace turned on so the temperature will be increasing at an additional 1 degree per minute with some uncertainty, this uncertainty being added to our current uncertainty in the per-minute change in temperature. Args: current_times: A [batch size] Tensor of times for the exogenous values being input. exogenous_values: A [batch size x exogenous input dimension] Tensor of exogenous values for each part of the batch. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] Returns: Updated state taking the exogenous regressors into account (with higher uncertainty than the input state). """ start_mean, start_covariance, previous_times = state with variable_scope.variable_scope("exogenous_noise_increasing_mean"): mean_addition = layers.fully_connected( exogenous_values, start_mean.get_shape()[1].value, activation_fn=None) state_dimension = start_covariance.get_shape()[1].value with variable_scope.variable_scope("exogenous_noise_increasing_covariance"): covariance_addition = ( math_utils.transform_to_covariance_matrices( exogenous_values, state_dimension)) return (start_mean + mean_addition, start_covariance + covariance_addition, previous_times) def _exogenous_input_step( self, current_times, current_exogenous_regressors, state): """Update state with exogenous regressors. Allows both increases and decreases in uncertainty. Args: current_times: A [batch size] Tensor of times for the exogenous values being input. current_exogenous_regressors: A [batch size x exogenous input dimension] Tensor of exogenous values for each part of the batch. state: A tuple of (mean, covariance, previous_times) having shapes mean; [batch size x state dimension] covariance; [batch size x state dimension x state dimension] previous_times; [batch size] Returns: Updated state taking the exogenous regressors into account. """ if self._configuration.exogenous_noise_decreases: state = self._exogenous_noise_decreasing( current_times, current_exogenous_regressors, state) if self._configuration.exogenous_noise_increases: state = self._exogenous_noise_increasing( current_times, current_exogenous_regressors, state) return state def _loss_additions(self, times, values, mode): """Add regularization during training.""" if mode == estimator_lib.ModeKeys.TRAIN: if (self._input_statistics is not None and self._configuration.bayesian_prior_weighting): normalization = 1. / math_ops.cast( self._input_statistics.total_observation_count, self.dtype) else: # If there is no total observation count recorded, or if we are not # doing a Bayesian prior weighting, assumes/pretends that the full # dataset size is the window size. normalization = 1. / math_ops.cast( array_ops.shape(times)[1], self.dtype) transition_contribution = ops.convert_to_tensor( self._configuration.covariance_prior_fn( self.state_transition_noise_covariance), dtype=self.dtype) if (self._configuration.use_observation_noise and self._observation_noise_covariance is not None): observation_contribution = ops.convert_to_tensor( self._configuration.covariance_prior_fn( self._observation_noise_covariance), dtype=self.dtype) regularization_sum = transition_contribution + observation_contribution else: regularization_sum = transition_contribution return -normalization * regularization_sum else: return array_ops.zeros([], dtype=self.dtype) def _variable_observation_transition_tradeoff_log(self): """Define a variable to trade off observation and transition noise.""" return variable_scope.get_variable( name="observation_transition_tradeoff_log_scale", initializer=constant_op.constant( -self._configuration.transition_covariance_initial_log_scale_bias, dtype=self.dtype), dtype=self.dtype) def _define_parameters(self, observation_transition_tradeoff_log=None): """Define extra model-specific parameters. Models should wrap any variables defined here in the model's variable scope. Args: observation_transition_tradeoff_log: An ensemble-global parameter controlling the tradeoff between observation noise and transition noise. If its value is not None, component transition noise should scale with e^-observation_transition_tradeoff_log. """ with variable_scope.variable_scope(self._variable_scope): # A scalar which allows the optimizer to quickly shift from observation # noise to transition noise (this value is subtracted from log transition # noise and added to log observation noise). if observation_transition_tradeoff_log is None: self._observation_transition_tradeoff_log_scale = ( self._variable_observation_transition_tradeoff_log()) else: self._observation_transition_tradeoff_log_scale = ( observation_transition_tradeoff_log) self.state_transition_noise_covariance = ( self.get_state_transition_noise_covariance()) def _set_input_statistics(self, input_statistics=None): super(StateSpaceModel, self).initialize_graph( input_statistics=input_statistics) def initialize_graph(self, input_statistics=None): """Define variables and ops relevant to the top-level model in an ensemble. For generic model parameters, _define_parameters() is called recursively on all members of an ensemble. Args: input_statistics: A math_utils.InputStatistics object containing input statistics. If None, data-independent defaults are used, which may result in longer or unstable training. """ self._set_input_statistics(input_statistics=input_statistics) self._define_parameters() with variable_scope.variable_scope(self._variable_scope): self._observation_noise_covariance = ops.convert_to_tensor( self.get_observation_noise_covariance(), dtype=self.dtype) self._kalman_filter = kalman_filter.KalmanFilter(dtype=self.dtype) (self.prior_state_mean, self.prior_state_var) = self._make_priors() def _make_priors(self): """Creates and returns model priors.""" prior_state_covariance = self.get_prior_covariance() prior_state_mean = self.get_prior_mean() return (prior_state_mean, prior_state_covariance) def get_prior_covariance(self): """Constructs a variable prior covariance with data-based initialization. Models should wrap any variables defined here in the model's variable scope. Returns: A two-dimensional [state dimension, state dimension] floating point Tensor with a (positive definite) prior state covariance matrix. """ with variable_scope.variable_scope(self._variable_scope): state_dimension = ops.convert_to_tensor( self.get_state_transition()).get_shape()[0].value if self._configuration.trainable_start_state: base_covariance = math_utils.variable_covariance_matrix( state_dimension, "prior_state_var", dtype=self.dtype) else: return linalg_ops.eye(state_dimension, dtype=self.dtype) if self._input_statistics is not None: # Make sure initial latent value uncertainty is at least on the same # scale as noise in the data. covariance_multiplier = math_ops.reduce_max( self._input_statistics.series_start_moments.variance) return base_covariance * gen_math_ops.maximum( covariance_multiplier, 1.0) else: return base_covariance def get_prior_mean(self): """Constructs a Variable-parameterized prior mean. Models should wrap any variables defined here in the model's variable scope. Returns: A one-dimensional floating point Tensor with shape [state dimension] indicating the prior mean. """ with variable_scope.variable_scope(self._variable_scope): state_transition = ops.convert_to_tensor( self.get_state_transition(), dtype=self.dtype) state_dimension = state_transition.get_shape()[0].value return variable_scope.get_variable( name="prior_state_mean", shape=[state_dimension], dtype=self.dtype, trainable=self._configuration.trainable_start_state) # TODO(allenl): It would be nice if the generation were done with TensorFlow # ops, and if the model parameters were somehow set instead of being passed # around in a dictionary. Maybe unconditional generation should be through a # special set of initializers? def random_model_parameters(self, seed=None): if self.num_features != 1: raise NotImplementedError("Generation for multivariate state space models" " is not currently implemented.") if seed: numpy.random.seed(seed) state_dimension, noise_dimension = ops.convert_to_tensor( self.get_noise_transform()).get_shape().as_list() transition_var = 1.0 / numpy.random.gamma(shape=10., scale=10., size=[noise_dimension]) initial_state = numpy.random.normal(size=[state_dimension]) params_dict = {} if self.prior_state_mean is not None: params_dict[self.prior_state_mean] = initial_state if self.state_transition_noise_covariance is not None: params_dict[self.state_transition_noise_covariance] = numpy.diag( transition_var) if self.prior_state_var is not None: params_dict[self.prior_state_var] = numpy.zeros( [state_dimension, state_dimension]) if self._configuration.use_observation_noise: observation_var = 1.0 / numpy.random.gamma(shape=4, scale=4) params_dict[self._observation_noise_covariance] = [[observation_var]] return params_dict def generate(self, number_of_series, series_length, model_parameters=None, seed=None, add_observation_noise=None): if seed is not None: numpy.random.seed(seed) if self.num_features != 1: raise NotImplementedError("Generation for multivariate state space models" " is not currently implemented.") if add_observation_noise is None: add_observation_noise = self._configuration.use_observation_noise if model_parameters is None: model_parameters = {} transitions = ops.convert_to_tensor( self.get_state_transition(), dtype=self.dtype).eval( feed_dict=model_parameters) noise_transform = ops.convert_to_tensor(self.get_noise_transform()).eval( feed_dict=model_parameters) noise_dimension = noise_transform.shape[1] get_passed_or_trained_value = model_utils.parameter_switch(model_parameters) transition_var = numpy.diag(get_passed_or_trained_value( self.state_transition_noise_covariance)) transition_std = numpy.sqrt(transition_var) if add_observation_noise: observation_var = get_passed_or_trained_value( self._observation_noise_covariance)[0][0] observation_std = numpy.sqrt(observation_var) initial_state = get_passed_or_trained_value(self.prior_state_mean) current_state = numpy.tile(numpy.expand_dims(initial_state, 0), [number_of_series, 1]) observations = numpy.zeros([number_of_series, series_length]) observation_models = self.get_broadcasted_observation_model( times=math_ops.range(series_length)).eval(feed_dict=model_parameters) for timestep, observation_model in enumerate(observation_models): current_state = numpy.dot(current_state, transitions.T) current_state += numpy.dot( numpy.random.normal( loc=numpy.zeros([number_of_series, noise_dimension]), scale=numpy.tile(numpy.expand_dims(transition_std, 0), [number_of_series, 1])), noise_transform.T) observation_mean = numpy.dot(current_state, observation_model[0].T) if add_observation_noise: observations[:, timestep] = numpy.random.normal(loc=observation_mean, scale=observation_std) else: observations[:, timestep] = observation_mean observations = numpy.expand_dims(observations, -1) times = numpy.tile( numpy.expand_dims(numpy.arange(observations.shape[1]), 0), [observations.shape[0], 1]) return {TrainEvalFeatures.TIMES: times, TrainEvalFeatures.VALUES: observations} @abc.abstractmethod def get_state_transition(self): """Specifies the state transition model to use. Returns: A [state dimension x state dimension] Tensor specifying how states transition from one timestep to the next. """ pass @abc.abstractmethod def get_noise_transform(self): """Specifies the noise transition model to use. Returns: A [state dimension x state noise dimension] Tensor specifying how noise (generated with shape [state noise dimension]) affects the model's state. """ pass @abc.abstractmethod def get_observation_model(self, times): """Specifies the observation model to use. Args: times: A [batch dimension] int32 Tensor with times for each part of the batch, on which the observation model can depend. Returns: This function, when overridden, has three possible return values: - A [state dimension] Tensor with a static, univariate observation model. - A [self.num_features x state dimension] static, multivariate model. - A [batch dimension x self.num_features x state dimension] observation model, which may depend on `times`. See get_broadcasted_observation_model for details of the broadcasting. """ pass def get_broadcasted_observation_model(self, times): """Broadcast this model's observation model if necessary. The model can define a univariate observation model which will be broadcast over both self.num_features and the batch dimension of `times`. The model can define a multi-variate observation model which does not depend on `times`, and it will be broadcast over the batch dimension of `times`. Finally, the model can define a multi-variate observation model with a batch dimension, which will not be broadcast. Args: times: A [batch dimension] int32 Tensor with times for each part of the batch, on which the observation model can depend. Returns: A [batch dimension x self.num_features x state dimension] Tensor specifying the observation model to use for each time in `times` and each feature. """ unbroadcasted_model = ops.convert_to_tensor( self.get_observation_model(times), dtype=self.dtype) unbroadcasted_shape = (unbroadcasted_model.get_shape() .with_rank_at_least(1).with_rank_at_most(3)) if unbroadcasted_shape.ndims is None: # Pass through fully undefined shapes, but make sure they're rank 3 at # graph eval time assert_op = control_flow_ops.Assert( math_ops.equal(array_ops.rank(unbroadcasted_model), 3), [array_ops.shape(unbroadcasted_model)]) with ops.control_dependencies([assert_op]): return array_ops.identity(unbroadcasted_model) if unbroadcasted_shape.ndims == 1: # Unbroadcasted shape [state dimension] broadcasted_model = array_ops.tile( array_ops.reshape(tensor=unbroadcasted_model, shape=[1, 1, -1]), [array_ops.shape(times)[0], self.num_features, 1]) elif unbroadcasted_shape.ndims == 2: # Unbroadcasted shape [num features x state dimension] broadcasted_model = array_ops.tile( array_ops.expand_dims(unbroadcasted_model, dim=0), [array_ops.shape(times)[0], 1, 1]) elif unbroadcasted_shape.ndims == 3: broadcasted_model = unbroadcasted_model broadcasted_model.get_shape().assert_has_rank(3) return broadcasted_model def get_state_transition_noise_covariance( self, minimum_initial_variance=1e-5): state_noise_transform = ops.convert_to_tensor( self.get_noise_transform(), dtype=self.dtype) state_noise_dimension = state_noise_transform.get_shape()[1].value if self._input_statistics is not None: feature_variance = self._input_statistics.series_start_moments.variance initial_transition_noise_scale = math_ops.log( gen_math_ops.maximum( math_ops.reduce_mean(feature_variance) / math_ops.cast( self._input_statistics.total_observation_count, self.dtype), minimum_initial_variance)) else: initial_transition_noise_scale = 0. # Generally high transition noise is undesirable; we want to set it quite # low to start so that we don't need too much training to get to good # solutions (i.e. with confident predictions into the future if possible), # but not so low that training can't yield a high transition noise if the # data demands it. initial_transition_noise_scale -= ( self._observation_transition_tradeoff_log_scale) return math_utils.variable_covariance_matrix( state_noise_dimension, "state_transition_noise", dtype=self.dtype, initial_overall_scale_log=initial_transition_noise_scale) def get_observation_noise_covariance(self, minimum_initial_variance=1e-5): if self._configuration.use_observation_noise: if self._input_statistics is not None: # Get variance across the first few values in each batch for each # feature, for an initial observation noise (over-)estimate. feature_variance = self._input_statistics.series_start_moments.variance else: feature_variance = None if feature_variance is not None: feature_variance = gen_math_ops.maximum(feature_variance, minimum_initial_variance) return math_utils.variable_covariance_matrix( size=self.num_features, dtype=self.dtype, name="observation_noise_covariance", initial_diagonal_values=feature_variance, initial_overall_scale_log=( self._observation_transition_tradeoff_log_scale)) else: return array_ops.zeros( shape=[self.num_features, self.num_features], name="observation_noise_covariance", dtype=self.dtype) def get_start_state(self): """Defines and returns a non-batched prior state and covariance.""" # TODO(allenl,vitalyk): Add an option for non-Gaussian priors once extended # Kalman filtering is implemented (ideally any Distribution object). if self._input_statistics is not None: start_time = self._input_statistics.start_time else: start_time = array_ops.zeros([], dtype=dtypes.int64) return (self.prior_state_mean, self.prior_state_var, start_time - 1) def get_features_for_timesteps(self, timesteps): """Get features for a batch of timesteps. Default to no features.""" return array_ops.zeros([array_ops.shape(timesteps)[0], 0], dtype=self.dtype) class StateSpaceEnsemble(StateSpaceModel): """Base class for combinations of state space models.""" def __init__(self, ensemble_members, configuration): """Initialize the ensemble by specifying its members. Args: ensemble_members: A list of StateSpaceModel objects which will be included in this ensemble. configuration: A StateSpaceModelConfiguration object. """ self._ensemble_members = ensemble_members super(StateSpaceEnsemble, self).__init__(configuration=configuration) def _set_input_statistics(self, input_statistics): super(StateSpaceEnsemble, self)._set_input_statistics(input_statistics) for member in self._ensemble_members: member._set_input_statistics(input_statistics) # pylint: disable=protected-access def _loss_additions(self, times, values, mode): # Allow sub-models to regularize return (super(StateSpaceEnsemble, self)._loss_additions( times, values, mode) + math_ops.add_n([ member._loss_additions(times, values, mode) # pylint: disable=protected-access for member in self._ensemble_members ])) def _compute_blocked(self, member_fn, name): with variable_scope.variable_scope(self._variable_scope): return math_utils.block_diagonal( [member_fn(member) for member in self._ensemble_members], dtype=self.dtype, name=name) def transition_to_powers(self, powers): return self._compute_blocked( member_fn=lambda member: member.transition_to_powers(powers), name="ensemble_transition_to_powers") def _define_parameters(self, observation_transition_tradeoff_log=None): with variable_scope.variable_scope(self._variable_scope): if observation_transition_tradeoff_log is None: # Define the tradeoff parameter between observation and transition noise # once for the whole ensemble, and pass it down to members. observation_transition_tradeoff_log = ( self._variable_observation_transition_tradeoff_log()) for member in self._ensemble_members: member._define_parameters(observation_transition_tradeoff_log=( # pylint: disable=protected-access observation_transition_tradeoff_log)) super(StateSpaceEnsemble, self)._define_parameters( observation_transition_tradeoff_log =observation_transition_tradeoff_log) def random_model_parameters(self, seed=None): param_union = {} for i, member in enumerate(self._ensemble_members): member_params = member.random_model_parameters( seed=seed + i if seed else None) param_union.update(member_params) param_union.update( super(StateSpaceEnsemble, self).random_model_parameters(seed=seed)) return param_union def get_prior_mean(self): return array_ops.concat( values=[member.get_prior_mean() for member in self._ensemble_members], axis=0, name="ensemble_prior_state_mean") def get_state_transition(self): return self._compute_blocked( member_fn= lambda member: member.get_state_transition(), name="ensemble_state_transition") def get_noise_transform(self): return self._compute_blocked( member_fn= lambda member: member.get_noise_transform(), name="ensemble_noise_transform") def get_observation_model(self, times): raise NotImplementedError("No un-broadcasted observation model defined for" " ensembles.") def get_broadcasted_observation_model(self, times): """Computes a combined observation model based on member models. The effect is that predicted observations from each model are summed. Args: times: A [batch dimension] int32 Tensor with times for each part of the batch, on which member observation models can depend. Returns: A [batch dimension x num features x combined state dimension] Tensor with the combined observation model. """ member_observation_models = [ ops.convert_to_tensor( member.get_broadcasted_observation_model(times), dtype=self.dtype) for member in self._ensemble_members ] return array_ops.concat(values=member_observation_models, axis=2) class StateSpaceIndependentEnsemble(StateSpaceEnsemble): """Implements ensembles of independent state space models. Useful for fitting multiple independent state space models together while keeping their specifications decoupled. The "ensemble" is simply a state space model with the observation models of its members concatenated, and the transition matrices and noise transforms stacked in block-diagonal matrices. This means that the dimensionality of the ensemble's state is the sum of those of its components, which can lead to slow and memory-intensive training and inference as the posterior (shape [state dimension x state dimension]) gets large. Each individual model j's state at time t is defined by: state[t, j] = StateTransition[j] * state[t-1, j] + NoiseTransform[j] * StateNoise[t, j] StateNoise[t, j] ~ Gaussian(0, StateNoiseCovariance[j]) and the ensemble observation model is: observation[t] = Sum { ObservationModel[j] * state[t, j] } + ObservationNoise[t] ObservationNoise[t] ~ Gaussian(0, ObservationNoiseCovariance) """ def transition_power_noise_accumulator(self, num_steps): return self._compute_blocked( member_fn=lambda m: m.transition_power_noise_accumulator(num_steps), name="ensemble_power_noise_accumulator") def get_prior_covariance(self): """Construct the ensemble prior covariance based on component models.""" return self._compute_blocked( member_fn= lambda member: member.get_prior_covariance(), name="ensemble_prior_state_covariance") def get_state_transition_noise_covariance(self): """Construct the ensemble transition noise covariance from components.""" return self._compute_blocked( member_fn= lambda member: member.state_transition_noise_covariance, name="ensemble_state_transition_noise") # TODO(allenl): It would be nice to have replicated feature models which are # identical batched together to reduce the graph size. # TODO(allenl): Support for sharing M independent models across N features, with # N > M. # TODO(allenl): Stack component prior covariances while allowing cross-model # correlations to be learned (currently a full covariance prior is learned, but # custom component model covariances are not used). class StateSpaceCorrelatedFeaturesEnsemble(StateSpaceEnsemble): """An correlated ensemble where each model represents a feature. Unlike `StateSpaceIndependentEnsemble`, a full state transition noise covariance matrix is learned for this ensemble; the models are not assumed to be independent. Rather than concatenating observation models (i.e. summing the contributions of each model to each feature), StateSpaceCorrelatedFeaturesEnsemble stacks observation models diagonally, meaning that each model corresponds to one feature of the series. Behaves like (and is) a single state space model where: StateTransition = Diag(StateTransition[j] for models j) ObservationModel = Diag(ObservationModel[j] for models j) Note that each ObservationModel[j] is a [1 x S_j] matrix (S_j being the state dimension of model j), i.e. a univariate model. The combined model is multivariate, the number of features of the series being equal to the number of component models in the ensemble. """ def __init__(self, ensemble_members, configuration): """Specify the ensemble's configuration and component models. Args: ensemble_members: A list of `StateSpaceModel` objects, with length equal to `configuration.num_features`. Each of these models, which must be univariate, corresponds to a single feature of the time series. configuration: A StateSpaceModelConfiguration object. Raises: ValueError: If the length of `ensemble_members` does not equal the number of features in the series, or any component is not univariate. """ if len(ensemble_members) != configuration.num_features: raise ValueError( "The number of members in a StateSpaceCorrelatedFeaturesEnsemble " "must equal the number of features in the time series.") for member in ensemble_members: if member.num_features != 1: raise ValueError( "StateSpaceCorrelatedFeaturesEnsemble components must be " "univariate.") super(StateSpaceCorrelatedFeaturesEnsemble, self).__init__( ensemble_members=ensemble_members, configuration=configuration) def transition_power_noise_accumulator(self, num_steps): """Use a noise accumulator special case when possible.""" if len(self._ensemble_members) == 1: # If this is a univariate series, we should use the special casing built # into the single component model. return self._ensemble_members[0].transition_power_noise_accumulator( num_steps=num_steps) # If we have multiple features, and therefore multiple models, we have # introduced correlations which make noise accumulation more # complicated. Here we fall back to the general case, since we can't just # aggregate member special cases. return super(StateSpaceCorrelatedFeaturesEnsemble, self).transition_power_noise_accumulator(num_steps=num_steps) def get_broadcasted_observation_model(self, times): """Stack observation models diagonally.""" def _member_observation_model(member): return ops.convert_to_tensor( member.get_broadcasted_observation_model(times), dtype=self.dtype) return self._compute_blocked(member_fn=_member_observation_model, name="feature_ensemble_observation_model")
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 8458, 1300, 367, 1174, 4601, 1709, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 5055, 199, 199, 646, 2680, 199, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 9393, 199, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 3473, 63, 1208, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1402, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1402, 63, 1208, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 4445, 63, 1612, 492, 16732, 10006, 10807, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 1022, 279, 1237, 63, 1541, 199, 199, 504, 3228, 14, 1548, 14, 8627, 492, 8943, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 3442, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 421, 199, 533, 8511, 7643, 1685, 5688, 8, 272, 5055, 14, 18921, 8, 267, 19151, 628, 2223, 7643, 1685, 5688, 401, 267, 901, 63, 1247, 1524, 288, 298, 1507, 63, 3179, 401, 298, 1180, 63, 24299, 63, 11838, 401, 298, 2271, 401, 288, 298, 15024, 63, 13775, 63, 2324, 401, 298, 19558, 69, 6214, 63, 13775, 63, 3463, 316, 401, 288, 298, 24133, 63, 1932, 6459, 401, 298, 18575, 63, 928, 63, 929, 401, 288, 298, 23919, 287, 1785, 63, 11838, 63, 262, 1353, 3274, 401, 298, 23919, 287, 1785, 63, 11838, 63, 271, 1353, 3274, 401, 288, 298, 23919, 287, 1785, 63, 4445, 63, 3406, 401, 298, 23919, 287, 1785, 63, 873, 63, 5394, 401, 288, 298, 24133, 63, 11555, 63, 31228, 63, 6221, 63, 6884, 401, 288, 298, 24133, 63, 10700, 63, 31228, 63, 6221, 401, 288, 298, 14143, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 401, 288, 298, 1986, 63, 324, 31562, 63, 3806, 63, 890, 63, 7227, 3135, 304, 523, 408, 5688, 1511, 367, 8511, 7643, 20474, 1041, 819, 347, 636, 1222, 721, 489, 843, 12, 489, 1967, 63, 3179, 29, 17, 12, 489, 675, 63, 24299, 63, 11838, 29, 549, 12, 489, 2152, 29, 5717, 14, 1609, 708, 12, 489, 13263, 63, 13775, 63, 2324, 29, 3442, 63, 1208, 14, 793, 63, 2865, 27666, 63, 15024, 63, 13775, 12, 489, 30933, 69, 6214, 63, 13775, 63, 3463, 316, 29, 549, 12, 489, 14545, 63, 1932, 6459, 29, 403, 12, 489, 17029, 63, 928, 63, 929, 29, 797, 12, 489, 444, 26300, 1785, 63, 11838, 63, 262, 1353, 3274, 29, 549, 12, 489, 444, 26300, 1785, 63, 11838, 63, 271, 1353, 3274, 29, 797, 12, 489, 444, 26300, 1785, 63, 4445, 63, 3406, 29, 403, 12, 489, 444, 26300, 1785, 63, 873, 63, 5394, 29, 403, 12, 489, 14545, 63, 11555, 63, 31228, 63, 6221, 63, 6884, 29, 17, 69, 22, 12, 489, 14545, 63, 10700, 63, 31228, 63, 6221, 29, 16, 2020, 489, 14116, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 4022, 21, 2020, 489, 2955, 63, 324, 31562, 63, 3806, 63, 890, 63, 7227, 29, 403, 304, 272, 408, 5688, 1511, 367, 8511, 7643, 20474, 14, 339, 3033, 26, 489, 1967, 63, 3179, 26, 7242, 6240, 367, 1402, 489, 675, 63, 24299, 63, 11838, 26, 982, 2549, 12, 19739, 787, 818, 1146, 465, 949, 19765, 267, 3423, 402, 314, 1453, 1174, 14, 982, 3055, 12, 19739, 787, 282, 267, 25286, 805, 402, 314, 1453, 1174, 14, 5972, 3964, 370, 314, 267, 2746, 13, 1896, 1402, 315, 376, 19965, 14, 24413, 2597, 13729, 314, 267, 14116, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 1380, 30723, 20038, 267, 11145, 12, 465, 2399, 849, 4260, 15194, 626, 20038, 11145, 365, 1777, 402, 267, 314, 1402, 14, 489, 2152, 26, 710, 2069, 2152, 370, 675, 1380, 12669, 314, 1402, 14, 489, 13263, 63, 13775, 63, 2324, 26, 437, 805, 4412, 687, 282, 13263, 3634, 370, 282, 881, 6917, 574, 334, 69, 14, 71, 14, 943, 22046, 9, 1314, 883, 506, 3089, 3594, 9371, 881, 12627, 14, 7827, 370, 376, 12717, 1603, 3609, 264, 588, 6791, 641, 314, 16788, 881, 4008, 334, 7898, 9147, 465, 943, 8, 17, 14, 1182, 11773, 4992, 4005, 675, 282, 6829, 6791, 881, 334, 73, 14, 69, 14, 949, 21095, 395, 663, 370, 658, 2734, 24700, 378, 14, 2313, 221, 7827, 370, 881, 13773, 9462, 625, 27666, 1979, 1384, 641, 1174, 14116, 436, 20038, 881, 11145, 12, 1314, 1172, 314, 7763, 402, 655, 25715, 7407, 6465, 13, 11838, 24886, 1314, 881, 5647, 406, 329, 1326, 7914, 1380, 3962, 14, 23952, 21095, 12, 881, 14116, 11145, 16685, 795, 370, 5706, 4721, 12, 436, 3510, 13, 2926, 7914, 787 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 8458, 1300, 367, 1174, 4601, 1709, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 5055, 199, 199, 646, 2680, 199, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 9393, 199, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 3473, 63, 1208, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1402, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1402, 63, 1208, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 4445, 63, 1612, 492, 16732, 10006, 10807, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 1022, 279, 1237, 63, 1541, 199, 199, 504, 3228, 14, 1548, 14, 8627, 492, 8943, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 3442, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 421, 199, 533, 8511, 7643, 1685, 5688, 8, 272, 5055, 14, 18921, 8, 267, 19151, 628, 2223, 7643, 1685, 5688, 401, 267, 901, 63, 1247, 1524, 288, 298, 1507, 63, 3179, 401, 298, 1180, 63, 24299, 63, 11838, 401, 298, 2271, 401, 288, 298, 15024, 63, 13775, 63, 2324, 401, 298, 19558, 69, 6214, 63, 13775, 63, 3463, 316, 401, 288, 298, 24133, 63, 1932, 6459, 401, 298, 18575, 63, 928, 63, 929, 401, 288, 298, 23919, 287, 1785, 63, 11838, 63, 262, 1353, 3274, 401, 298, 23919, 287, 1785, 63, 11838, 63, 271, 1353, 3274, 401, 288, 298, 23919, 287, 1785, 63, 4445, 63, 3406, 401, 298, 23919, 287, 1785, 63, 873, 63, 5394, 401, 288, 298, 24133, 63, 11555, 63, 31228, 63, 6221, 63, 6884, 401, 288, 298, 24133, 63, 10700, 63, 31228, 63, 6221, 401, 288, 298, 14143, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 401, 288, 298, 1986, 63, 324, 31562, 63, 3806, 63, 890, 63, 7227, 3135, 304, 523, 408, 5688, 1511, 367, 8511, 7643, 20474, 1041, 819, 347, 636, 1222, 721, 489, 843, 12, 489, 1967, 63, 3179, 29, 17, 12, 489, 675, 63, 24299, 63, 11838, 29, 549, 12, 489, 2152, 29, 5717, 14, 1609, 708, 12, 489, 13263, 63, 13775, 63, 2324, 29, 3442, 63, 1208, 14, 793, 63, 2865, 27666, 63, 15024, 63, 13775, 12, 489, 30933, 69, 6214, 63, 13775, 63, 3463, 316, 29, 549, 12, 489, 14545, 63, 1932, 6459, 29, 403, 12, 489, 17029, 63, 928, 63, 929, 29, 797, 12, 489, 444, 26300, 1785, 63, 11838, 63, 262, 1353, 3274, 29, 549, 12, 489, 444, 26300, 1785, 63, 11838, 63, 271, 1353, 3274, 29, 797, 12, 489, 444, 26300, 1785, 63, 4445, 63, 3406, 29, 403, 12, 489, 444, 26300, 1785, 63, 873, 63, 5394, 29, 403, 12, 489, 14545, 63, 11555, 63, 31228, 63, 6221, 63, 6884, 29, 17, 69, 22, 12, 489, 14545, 63, 10700, 63, 31228, 63, 6221, 29, 16, 2020, 489, 14116, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 4022, 21, 2020, 489, 2955, 63, 324, 31562, 63, 3806, 63, 890, 63, 7227, 29, 403, 304, 272, 408, 5688, 1511, 367, 8511, 7643, 20474, 14, 339, 3033, 26, 489, 1967, 63, 3179, 26, 7242, 6240, 367, 1402, 489, 675, 63, 24299, 63, 11838, 26, 982, 2549, 12, 19739, 787, 818, 1146, 465, 949, 19765, 267, 3423, 402, 314, 1453, 1174, 14, 982, 3055, 12, 19739, 787, 282, 267, 25286, 805, 402, 314, 1453, 1174, 14, 5972, 3964, 370, 314, 267, 2746, 13, 1896, 1402, 315, 376, 19965, 14, 24413, 2597, 13729, 314, 267, 14116, 63, 15024, 63, 2747, 63, 793, 63, 3467, 63, 8160, 1380, 30723, 20038, 267, 11145, 12, 465, 2399, 849, 4260, 15194, 626, 20038, 11145, 365, 1777, 402, 267, 314, 1402, 14, 489, 2152, 26, 710, 2069, 2152, 370, 675, 1380, 12669, 314, 1402, 14, 489, 13263, 63, 13775, 63, 2324, 26, 437, 805, 4412, 687, 282, 13263, 3634, 370, 282, 881, 6917, 574, 334, 69, 14, 71, 14, 943, 22046, 9, 1314, 883, 506, 3089, 3594, 9371, 881, 12627, 14, 7827, 370, 376, 12717, 1603, 3609, 264, 588, 6791, 641, 314, 16788, 881, 4008, 334, 7898, 9147, 465, 943, 8, 17, 14, 1182, 11773, 4992, 4005, 675, 282, 6829, 6791, 881, 334, 73, 14, 69, 14, 949, 21095, 395, 663, 370, 658, 2734, 24700, 378, 14, 2313, 221, 7827, 370, 881, 13773, 9462, 625, 27666, 1979, 1384, 641, 1174, 14116, 436, 20038, 881, 11145, 12, 1314, 1172, 314, 7763, 402, 655, 25715, 7407, 6465, 13, 11838, 24886, 1314, 881, 5647, 406, 329, 1326, 7914, 1380, 3962, 14, 23952, 21095, 12, 881, 14116, 11145, 16685, 795, 370, 5706, 4721, 12, 436, 3510, 13, 2926, 7914, 787, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jelugbo/hebs_repo
lms/djangoapps/bulk_email/migrations/0001_initial.py
182
6854
# -*- coding: utf-8 -*- from south.db import db from south.v2 import SchemaMigration class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'CourseEmail' db.create_table('bulk_email_courseemail', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('sender', self.gf('django.db.models.fields.related.ForeignKey')(default=1, to=orm['auth.User'], null=True, blank=True)), ('hash', self.gf('django.db.models.fields.CharField')(max_length=128, db_index=True)), ('subject', self.gf('django.db.models.fields.CharField')(max_length=128, blank=True)), ('html_message', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), ('modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('course_id', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), ('to', self.gf('django.db.models.fields.CharField')(default='myself', max_length=64)), )) db.send_create_signal('bulk_email', ['CourseEmail']) # Adding model 'Optout' db.create_table('bulk_email_optout', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('email', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), ('course_id', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), )) db.send_create_signal('bulk_email', ['Optout']) # Adding unique constraint on 'Optout', fields ['email', 'course_id'] db.create_unique('bulk_email_optout', ['email', 'course_id']) def backwards(self, orm): # Removing unique constraint on 'Optout', fields ['email', 'course_id'] db.delete_unique('bulk_email_optout', ['email', 'course_id']) # Deleting model 'CourseEmail' db.delete_table('bulk_email_courseemail') # Deleting model 'Optout' db.delete_table('bulk_email_optout') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'bulk_email.courseemail': { 'Meta': {'object_name': 'CourseEmail'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'hash': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_index': 'True'}), 'html_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'sender': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}), 'subject': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'to': ('django.db.models.fields.CharField', [], {'default': "'myself'", 'max_length': '64'}) }, 'bulk_email.optout': { 'Meta': {'unique_together': "(('email', 'course_id'),)", 'object_name': 'Optout'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'email': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, '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'}) } } complete_apps = ['bulk_email']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 6979, 7035, 7, 267, 1592, 14, 981, 63, 1224, 360, 9377, 63, 2123, 63, 1972, 2123, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 8114, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 885, 29, 17, 12, 370, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 5875, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 4596, 29, 549, 1826, 288, 661, 1360, 63, 1188, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1972, 63, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 475, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 1662, 277, 297, 1390, 63, 1267, 29, 772, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 9377, 63, 2123, 297, 788, 6979, 7035, 1105, 398, 327, 12934, 1402, 283, 4619, 475, 337, 7, 267, 1592, 14, 981, 63, 1224, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 2123, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1972, 63, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 9377, 63, 2123, 297, 788, 4619, 475, 337, 1105, 398, 327, 12934, 3747, 5828, 641, 283, 4619, 475, 337, 297, 1504, 788, 2123, 297, 283, 1972, 63, 344, 418, 267, 1592, 14, 981, 63, 3235, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 788, 2123, 297, 283, 1972, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 29343, 3747, 5828, 641, 283, 4619, 475, 337, 297, 1504, 788, 2123, 297, 283, 1972, 63, 344, 418, 267, 1592, 14, 1807, 63, 3235, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 788, 2123, 297, 283, 1972, 63, 344, 1105, 398, 327, 15920, 1402, 283, 6979, 7035, 7, 267, 1592, 14, 1807, 63, 1224, 360, 9377, 63, 2123, 63, 1972, 2123, 358, 398, 327, 15920, 1402, 283, 4619, 475, 337, 7, 267, 1592, 14, 1807, 63, 1224, 360, 9377, 63, 2123, 63, 411, 475, 337, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 6979, 7035, 7, 267, 1592, 14, 981, 63, 1224, 360, 9377, 63, 2123, 63, 1972, 2123, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 8114, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 885, 29, 17, 12, 370, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 5875, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 4596, 29, 549, 1826, 288, 661, 1360, 63, 1188, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1972, 63, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 475, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 1662, 277, 297, 1390, 63, 1267, 29, 772, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 9377, 63, 2123, 297, 788, 6979, 7035, 1105, 398, 327, 12934, 1402, 283, 4619, 475, 337, 7, 267, 1592, 14, 981, 63, 1224, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 2123, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1972, 63, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 9377, 63, 2123, 297, 788, 4619, 475, 337, 1105, 398, 327, 12934, 3747, 5828, 641, 283, 4619, 475, 337, 297, 1504, 788, 2123, 297, 283, 1972, 63, 344, 418, 267, 1592, 14, 981, 63, 3235, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 788, 2123, 297, 283, 1972, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 29343, 3747, 5828, 641, 283, 4619, 475, 337, 297, 1504, 788, 2123, 297, 283, 1972, 63, 344, 418, 267, 1592, 14, 1807, 63, 3235, 360, 9377, 63, 2123, 63, 411, 475, 337, 297, 788, 2123, 297, 283, 1972, 63, 344, 1105, 398, 327, 15920, 1402, 283, 6979, 7035, 7, 267, 1592, 14, 1807, 63, 1224, 360, 9377, 63, 2123, 63, 1972, 2123, 358, 398, 327, 15920, 1402, 283, 4619, 475, 337, 7, 267, 1592, 14, 1807, 63, 1224, 360, 9377, 63, 2123, 63, 411, 475, 337, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
linhdh/SnakeRepellerOnMbed50
mbed-os/tools/export/qtcreator/__init__.py
21
2260
""" mbed SDK Copyright (c) 2014-2017 ARM Limited 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 os.path import splitext, basename from tools.targets import TARGET_MAP from tools.export.exporters import Exporter from tools.export.makefile import GccArm class QtCreator(GccArm): NAME = 'QtCreator' MBED_CONFIG_HEADER_SUPPORTED = True def generate(self): self.resources.win_to_unix() defines = [] # list of tuples ('D'/'U', [key, value]) (value is optional) forced_includes = [] # list of strings sources = [] # list of strings include_paths = [] # list of strings next_is_include = False for f in self.flags['c_flags'] + self.flags['cxx_flags']: f=f.strip() if next_is_include: forced_includes.append(f) next_is_include = False continue if f.startswith('-D'): defines.append(('D', f[2:].split('=', 1))) elif f.startswith('-U'): defines.append(('U', [f[2:]])) elif f == "-include": next_is_include = True for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']: sources.extend(getattr(self.resources, r_type)) include_paths = self.resources.inc_dirs ctx = { 'defines': defines, 'forced_includes': forced_includes, 'sources': sources, 'include_paths': self.resources.inc_dirs } for ext in ['creator', 'files', 'includes', 'config']: self.gen_file('qtcreator/%s.tmpl' % ext, ctx, "%s.%s" % (self.project_name, ext)) # finally, generate the Makefile super(QtCreator, self).generate()
gpl-2.0
[ 624, 199, 3665, 15610, 199, 7384, 334, 67, 9, 6927, 13, 10680, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 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, 624, 199, 504, 747, 14, 515, 492, 2249, 7699, 12, 9593, 199, 504, 7249, 14, 4684, 492, 26134, 63, 5443, 199, 504, 7249, 14, 3790, 14, 1474, 27568, 492, 7910, 3968, 199, 504, 7249, 14, 3790, 14, 13941, 492, 598, 2055, 1596, 77, 199, 199, 533, 3959, 17523, 8, 39, 2055, 1596, 77, 304, 272, 13637, 275, 283, 4238, 17523, 7, 339, 19487, 1149, 63, 5569, 63, 7311, 63, 15925, 275, 715, 339, 347, 3550, 8, 277, 304, 267, 291, 14, 4435, 14, 2676, 63, 475, 63, 11864, 342, 398, 7890, 260, 275, 942, 327, 769, 402, 6346, 661, 36, 29957, 53, 297, 359, 498, 12, 574, 566, 334, 585, 365, 2716, 9, 267, 19565, 63, 9441, 275, 942, 327, 769, 402, 3326, 267, 5274, 260, 275, 942, 327, 769, 402, 3326, 267, 2387, 63, 3771, 257, 275, 942, 327, 769, 402, 3326, 398, 2163, 63, 374, 63, 2613, 275, 756, 267, 367, 289, 315, 291, 14, 2469, 459, 67, 63, 2469, 418, 435, 291, 14, 2469, 459, 9634, 63, 2469, 2565, 288, 289, 29, 70, 14, 1913, 342, 288, 340, 2163, 63, 374, 63, 2613, 26, 355, 19565, 63, 9441, 14, 740, 8, 70, 9, 355, 2163, 63, 374, 63, 2613, 275, 756, 355, 1980, 288, 340, 289, 14, 2460, 3654, 36, 735, 355, 7890, 14, 740, 4725, 36, 297, 289, 59, 18, 11455, 1294, 25283, 413, 1724, 288, 916, 289, 14, 2460, 3654, 53, 735, 355, 7890, 14, 740, 4725, 53, 297, 359, 70, 59, 18, 2938, 2459, 288, 916, 289, 508, 3905, 2613, 582, 355, 2163, 63, 374, 63, 2613, 275, 715, 398, 367, 519, 63, 466, 315, 788, 2139, 297, 283, 67, 63, 4553, 297, 283, 83, 63, 4553, 297, 283, 5910, 63, 4553, 2565, 288, 5274, 14, 2880, 8, 5675, 8, 277, 14, 4435, 12, 519, 63, 466, 430, 398, 2387, 63, 3771, 275, 291, 14, 4435, 14, 6559, 63, 3220, 398, 4027, 275, 469, 288, 283, 14334, 356, 7890, 12, 288, 283, 28074, 63, 9441, 356, 19565, 63, 9441, 12, 288, 283, 4553, 356, 5274, 12, 288, 283, 2613, 63, 3771, 356, 291, 14, 4435, 14, 6559, 63, 3220, 288, 789, 398, 367, 1599, 315, 788, 9986, 297, 283, 1725, 297, 283, 9441, 297, 283, 888, 2565, 288, 291, 14, 2268, 63, 493, 360, 8440, 9986, 3149, 83, 14, 11510, 7, 450, 1599, 12, 4027, 12, 2071, 83, 4111, 83, 2, 450, 334, 277, 14, 1715, 63, 354, 12, 1599, 430, 398, 327, 3753, 12, 3550, 314, 20618, 267, 1613, 8, 4238, 17523, 12, 291, 680, 4208, 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 ]
[ 199, 3665, 15610, 199, 7384, 334, 67, 9, 6927, 13, 10680, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 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, 624, 199, 504, 747, 14, 515, 492, 2249, 7699, 12, 9593, 199, 504, 7249, 14, 4684, 492, 26134, 63, 5443, 199, 504, 7249, 14, 3790, 14, 1474, 27568, 492, 7910, 3968, 199, 504, 7249, 14, 3790, 14, 13941, 492, 598, 2055, 1596, 77, 199, 199, 533, 3959, 17523, 8, 39, 2055, 1596, 77, 304, 272, 13637, 275, 283, 4238, 17523, 7, 339, 19487, 1149, 63, 5569, 63, 7311, 63, 15925, 275, 715, 339, 347, 3550, 8, 277, 304, 267, 291, 14, 4435, 14, 2676, 63, 475, 63, 11864, 342, 398, 7890, 260, 275, 942, 327, 769, 402, 6346, 661, 36, 29957, 53, 297, 359, 498, 12, 574, 566, 334, 585, 365, 2716, 9, 267, 19565, 63, 9441, 275, 942, 327, 769, 402, 3326, 267, 5274, 260, 275, 942, 327, 769, 402, 3326, 267, 2387, 63, 3771, 257, 275, 942, 327, 769, 402, 3326, 398, 2163, 63, 374, 63, 2613, 275, 756, 267, 367, 289, 315, 291, 14, 2469, 459, 67, 63, 2469, 418, 435, 291, 14, 2469, 459, 9634, 63, 2469, 2565, 288, 289, 29, 70, 14, 1913, 342, 288, 340, 2163, 63, 374, 63, 2613, 26, 355, 19565, 63, 9441, 14, 740, 8, 70, 9, 355, 2163, 63, 374, 63, 2613, 275, 756, 355, 1980, 288, 340, 289, 14, 2460, 3654, 36, 735, 355, 7890, 14, 740, 4725, 36, 297, 289, 59, 18, 11455, 1294, 25283, 413, 1724, 288, 916, 289, 14, 2460, 3654, 53, 735, 355, 7890, 14, 740, 4725, 53, 297, 359, 70, 59, 18, 2938, 2459, 288, 916, 289, 508, 3905, 2613, 582, 355, 2163, 63, 374, 63, 2613, 275, 715, 398, 367, 519, 63, 466, 315, 788, 2139, 297, 283, 67, 63, 4553, 297, 283, 83, 63, 4553, 297, 283, 5910, 63, 4553, 2565, 288, 5274, 14, 2880, 8, 5675, 8, 277, 14, 4435, 12, 519, 63, 466, 430, 398, 2387, 63, 3771, 275, 291, 14, 4435, 14, 6559, 63, 3220, 398, 4027, 275, 469, 288, 283, 14334, 356, 7890, 12, 288, 283, 28074, 63, 9441, 356, 19565, 63, 9441, 12, 288, 283, 4553, 356, 5274, 12, 288, 283, 2613, 63, 3771, 356, 291, 14, 4435, 14, 6559, 63, 3220, 288, 789, 398, 367, 1599, 315, 788, 9986, 297, 283, 1725, 297, 283, 9441, 297, 283, 888, 2565, 288, 291, 14, 2268, 63, 493, 360, 8440, 9986, 3149, 83, 14, 11510, 7, 450, 1599, 12, 4027, 12, 2071, 83, 4111, 83, 2, 450, 334, 277, 14, 1715, 63, 354, 12, 1599, 430, 398, 327, 3753, 12, 3550, 314, 20618, 267, 1613, 8, 4238, 17523, 12, 291, 680, 4208, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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am needs to be ported # TODO: generators.jam needs to have register_c_compiler. # # Copyright 2001 David Abrahams. # Copyright 2002-2006 Rene Rivera. # Copyright 2002-2003 Vladimir Prus. # Copyright (c) 2005 Reece H. Dunn. # Copyright 2006 Ilya Sokolov. # Copyright 2007 Roland Schwarz # Copyright 2007 Boris Gubenko. # Copyright 2008 Steven Watanabe # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import os import subprocess import re import bjam from b2.tools import unix, common, rc, pch, builtin from b2.build import feature, type, toolset, generators, property_set from b2.build.property import Property from b2.util.utility import os_name, on_windows from b2.manager import get_manager from b2.build.generators import Generator from b2.build.toolset import flags from b2.util.utility import to_seq __debug = None def debug(): global __debug if __debug is None: __debug = "--debug-configuration" in bjam.variable("ARGV") return __debug feature.extend('toolset', ['gcc']) toolset.inherit_generators('gcc', [], 'unix', ['unix.link', 'unix.link.dll']) toolset.inherit_flags('gcc', 'unix') toolset.inherit_rules('gcc', 'unix') generators.override('gcc.prebuilt', 'builtin.prebuilt') generators.override('gcc.searched-lib-generator', 'searched-lib-generator') # Target naming is determined by types/lib.jam and the settings below this # comment. # # On *nix: # libxxx.a static library # libxxx.so shared library # # On windows (mingw): # libxxx.lib static library # xxx.dll DLL # xxx.lib import library # # On windows (cygwin) i.e. <target-os>cygwin # libxxx.a static library # xxx.dll DLL # libxxx.dll.a import library # # Note: user can always override by using the <tag>@rule # This settings have been choosen, so that mingw # is in line with msvc naming conventions. For # cygwin the cygwin naming convention has been choosen. # Make the "o" suffix used for gcc toolset on all # platforms type.set_generated_target_suffix('OBJ', ['<toolset>gcc'], 'o') type.set_generated_target_suffix('STATIC_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'a') type.set_generated_target_suffix('IMPORT_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'dll.a') type.set_generated_target_prefix('IMPORT_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'lib') __machine_match = re.compile('^([^ ]+)') __version_match = re.compile('^([0-9.]+)') def init(version = None, command = None, options = None): """ Initializes the gcc toolset for the given version. If necessary, command may be used to specify where the compiler is located. The parameter 'options' is a space-delimited list of options, each one specified as <option-name>option-value. Valid option names are: cxxflags, linkflags and linker-type. Accepted linker-type values are gnu, darwin, osf, hpux or sun and the default value will be selected based on the current OS. Example: using gcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ; """ options = to_seq(options) command = to_seq(command) # Information about the gcc command... # The command. command = to_seq(common.get_invocation_command('gcc', 'g++', command)) # The root directory of the tool install. root = feature.get_values('<root>', options) ; # The bin directory where to find the command to execute. bin = None # The flavor of compiler. flavor = feature.get_values('<flavor>', options) # Autodetect the root and bin dir if not given. if command: if not bin: bin = common.get_absolute_tool_path(command[-1]) if not root: root = os.path.dirname(bin) # Autodetect the version and flavor if not given. if command: machine_info = subprocess.Popen(command + ['-dumpmachine'], stdout=subprocess.PIPE).communicate()[0] machine = __machine_match.search(machine_info).group(1) version_info = subprocess.Popen(command + ['-dumpversion'], stdout=subprocess.PIPE).communicate()[0] version = __version_match.search(version_info).group(1) if not flavor and machine.find('mingw') != -1: flavor = 'mingw' condition = None if flavor: condition = common.check_init_parameters('gcc', None, ('version', version), ('flavor', flavor)) else: condition = common.check_init_parameters('gcc', None, ('version', version)) if command: command = command[0] common.handle_options('gcc', condition, command, options) linker = feature.get_values('<linker-type>', options) if not linker: if os_name() == 'OSF': linker = 'osf' elif os_name() == 'HPUX': linker = 'hpux' ; else: linker = 'gnu' init_link_flags('gcc', linker, condition) # If gcc is installed in non-standard location, we'd need to add # LD_LIBRARY_PATH when running programs created with it (for unit-test/run # rules). if command: # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries # and all must be added to LD_LIBRARY_PATH. The linker will pick the # right onces. Note that we don't provide a clean way to build 32-bit # binary with 64-bit compiler, but user can always pass -m32 manually. lib_path = [os.path.join(root, 'bin'), os.path.join(root, 'lib'), os.path.join(root, 'lib32'), os.path.join(root, 'lib64')] if debug(): print 'notice: using gcc libraries ::', condition, '::', lib_path toolset.flags('gcc.link', 'RUN_PATH', condition, lib_path) # If it's not a system gcc install we should adjust the various programs as # needed to prefer using the install specific versions. This is essential # for correct use of MinGW and for cross-compiling. # - The archive builder. archiver = common.get_invocation_command('gcc', 'ar', feature.get_values('<archiver>', options), [bin], path_last=True) toolset.flags('gcc.archive', '.AR', condition, [archiver]) if debug(): print 'notice: using gcc archiver ::', condition, '::', archiver # - The resource compiler. rc_command = common.get_invocation_command_nodefault('gcc', 'windres', feature.get_values('<rc>', options), [bin], path_last=True) rc_type = feature.get_values('<rc-type>', options) if not rc_type: rc_type = 'windres' if not rc_command: # If we can't find an RC compiler we fallback to a null RC compiler that # creates empty object files. This allows the same Jamfiles to work # across the board. The null RC uses the assembler to create the empty # objects, so configure that. rc_command = common.get_invocation_command('gcc', 'as', [], [bin], path_last=True) rc_type = 'null' rc.configure(rc_command, condition, '<rc-type>' + rc_type) ###if [ os.name ] = NT ###{ ### # This causes single-line command invocation to not go through .bat files, ### # thus avoiding command-line length limitations. ### JAMSHELL = % ; ###} #FIXME: when register_c_compiler is moved to # generators, these should be updated builtin.register_c_compiler('gcc.compile.c++', ['CPP'], ['OBJ'], ['<toolset>gcc']) builtin.register_c_compiler('gcc.compile.c', ['C'], ['OBJ'], ['<toolset>gcc']) builtin.register_c_compiler('gcc.compile.asm', ['ASM'], ['OBJ'], ['<toolset>gcc']) # pch support # The compiler looks for a precompiled header in each directory just before it # looks for the include file in that directory. The name searched for is the # name specified in the #include directive with ".gch" suffix appended. The # logic in gcc-pch-generator will make sure that BASE_PCH suffix is appended to # full name of the header. type.set_generated_target_suffix('PCH', ['<toolset>gcc'], 'gch') # GCC-specific pch generator. class GccPchGenerator(pch.PchGenerator): # Inherit the __init__ method def run_pch(self, project, name, prop_set, sources): # Find the header in sources. Ignore any CPP sources. header = None for s in sources: if type.is_derived(s.type(), 'H'): header = s # Error handling: Base header file name should be the same as the base # precompiled header name. header_name = header.name() header_basename = os.path.basename(header_name).rsplit('.', 1)[0] if header_basename != name: location = project.project_module ###FIXME: raise Exception() ### errors.user-error "in" $(location)": pch target name `"$(name)"' should be the same as the base name of header file `"$(header-name)"'" ; pch_file = Generator.run(self, project, name, prop_set, [header]) # return result of base class and pch-file property as usage-requirements # FIXME: what about multiple results from generator.run? return (property_set.create([Property('pch-file', pch_file[0]), Property('cflags', '-Winvalid-pch')]), pch_file) # Calls the base version specifying source's name as the name of the created # target. As result, the PCH will be named whatever.hpp.gch, and not # whatever.gch. def generated_targets(self, sources, prop_set, project, name = None): name = sources[0].name() return Generator.generated_targets(self, sources, prop_set, project, name) # Note: the 'H' source type will catch both '.h' header and '.hpp' header. The # latter have HPP type, but HPP type is derived from H. The type of compilation # is determined entirely by the destination type. generators.register(GccPchGenerator('gcc.compile.c.pch', False, ['H'], ['C_PCH'], ['<pch>on', '<toolset>gcc' ])) generators.register(GccPchGenerator('gcc.compile.c++.pch', False, ['H'], ['CPP_PCH'], ['<pch>on', '<toolset>gcc' ])) # Override default do-nothing generators. generators.override('gcc.compile.c.pch', 'pch.default-c-pch-generator') generators.override('gcc.compile.c++.pch', 'pch.default-cpp-pch-generator') flags('gcc.compile', 'PCH_FILE', ['<pch>on'], ['<pch-file>']) # Declare flags and action for compilation flags('gcc.compile', 'OPTIONS', ['<optimization>off'], ['-O0']) flags('gcc.compile', 'OPTIONS', ['<optimization>speed'], ['-O3']) flags('gcc.compile', 'OPTIONS', ['<optimization>space'], ['-Os']) flags('gcc.compile', 'OPTIONS', ['<inlining>off'], ['-fno-inline']) flags('gcc.compile', 'OPTIONS', ['<inlining>on'], ['-Wno-inline']) flags('gcc.compile', 'OPTIONS', ['<inlining>full'], ['-finline-functions', '-Wno-inline']) flags('gcc.compile', 'OPTIONS', ['<warnings>off'], ['-w']) flags('gcc.compile', 'OPTIONS', ['<warnings>on'], ['-Wall']) flags('gcc.compile', 'OPTIONS', ['<warnings>all'], ['-Wall', '-pedantic']) flags('gcc.compile', 'OPTIONS', ['<warnings-as-errors>on'], ['-Werror']) flags('gcc.compile', 'OPTIONS', ['<debug-symbols>on'], ['-g']) flags('gcc.compile', 'OPTIONS', ['<profiling>on'], ['-pg']) flags('gcc.compile.c++', 'OPTIONS', ['<rtti>off'], ['-fno-rtti']) flags('gcc.compile.c++', 'OPTIONS', ['<exception-handling>off'], ['-fno-exceptions']) # On cygwin and mingw, gcc generates position independent code by default, and # warns if -fPIC is specified. This might not be the right way of checking if # we're using cygwin. For example, it's possible to run cygwin gcc from NT # shell, or using crosscompiling. But we'll solve that problem when it's time. # In that case we'll just add another parameter to 'init' and move this login # inside 'init'. if not os_name () in ['CYGWIN', 'NT']: # This logic will add -fPIC for all compilations: # # lib a : a.cpp b ; # obj b : b.cpp ; # exe c : c.cpp a d ; # obj d : d.cpp ; # # This all is fine, except that 'd' will be compiled with -fPIC even though # it's not needed, as 'd' is used only in exe. However, it's hard to detect # where a target is going to be used. Alternative, we can set -fPIC only # when main target type is LIB but than 'b' will be compiled without -fPIC. # In x86-64 that will lead to link errors. So, compile everything with # -fPIC. # # Yet another alternative would be to create propagated <sharedable> # feature, and set it when building shared libraries, but that's hard to # implement and will increase target path length even more. flags('gcc.compile', 'OPTIONS', ['<link>shared'], ['-fPIC']) if os_name() != 'NT' and os_name() != 'OSF' and os_name() != 'HPUX': # OSF does have an option called -soname but it doesn't seem to work as # expected, therefore it has been disabled. HAVE_SONAME = '' SONAME_OPTION = '-h' flags('gcc.compile', 'USER_OPTIONS', [], ['<cflags>']) flags('gcc.compile.c++', 'USER_OPTIONS',[], ['<cxxflags>']) flags('gcc.compile', 'DEFINES', [], ['<define>']) flags('gcc.compile', 'INCLUDES', [], ['<include>']) engine = get_manager().engine() engine.register_action('gcc.compile.c++.pch', '"$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"') engine.register_action('gcc.compile.c.pch', '"$(CONFIG_COMMAND)" -x c-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"') def gcc_compile_cpp(targets, sources, properties): # Some extensions are compiled as C++ by default. For others, we need to # pass -x c++. We could always pass -x c++ but distcc does not work with it. extension = os.path.splitext (sources [0]) [1] lang = '' if not extension in ['.cc', '.cp', '.cxx', '.cpp', '.c++', '.C']: lang = '-x c++' get_manager().engine().set_target_variable (targets, 'LANG', lang) engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE')) def gcc_compile_c(targets, sources, properties): engine = get_manager().engine() # If we use the name g++ then default file suffix -> language mapping does # not work. So have to pass -x option. Maybe, we can work around this by # allowing the user to specify both C and C++ compiler names. #if $(>:S) != .c #{ engine.set_target_variable (targets, 'LANG', '-x c') #} engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE')) engine.register_action( 'gcc.compile.c++', '"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-128 $(OPTIONS) ' + '$(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" ' + '-c -o "$(<:W)" "$(>:W)"', function=gcc_compile_cpp, bound_list=['PCH_FILE']) engine.register_action( 'gcc.compile.c', '"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) ' + '-I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"', function=gcc_compile_c, bound_list=['PCH_FILE']) def gcc_compile_asm(targets, sources, properties): get_manager().engine().set_target_variable(targets, 'LANG', '-x assembler-with-cpp') engine.register_action( 'gcc.compile.asm', '"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"', function=gcc_compile_asm) class GccLinkingGenerator(unix.UnixLinkingGenerator): """ The class which check that we don't try to use the <runtime-link>static property while creating or using shared library, since it's not supported by gcc/libc. """ def run(self, project, name, ps, sources): # TODO: Replace this with the use of a target-os property. no_static_link = False if bjam.variable('UNIX'): no_static_link = True; ##FIXME: what does this mean? ## { ## switch [ modules.peek : JAMUNAME ] ## { ## case * : no-static-link = true ; ## } ## } reason = None if no_static_link and ps.get('runtime-link') == 'static': if ps.get('link') == 'shared': reason = "On gcc, DLL can't be build with '<runtime-link>static'." elif type.is_derived(self.target_types[0], 'EXE'): for s in sources: source_type = s.type() if source_type and type.is_derived(source_type, 'SHARED_LIB'): reason = "On gcc, using DLLS together with the " +\ "<runtime-link>static options is not possible " if reason: print 'warning:', reason print 'warning:',\ "It is suggested to use '<runtime-link>static' together",\ "with '<link>static'." ; return else: generated_targets = unix.UnixLinkingGenerator.run(self, project, name, ps, sources) return generated_targets if on_windows(): flags('gcc.link.dll', '.IMPLIB-COMMAND', [], ['-Wl,--out-implib,']) generators.register( GccLinkingGenerator('gcc.link', True, ['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'], [ 'EXE' ], [ '<toolset>gcc' ])) generators.register( GccLinkingGenerator('gcc.link.dll', True, ['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'], ['IMPORT_LIB', 'SHARED_LIB'], ['<toolset>gcc'])) else: generators.register( GccLinkingGenerator('gcc.link', True, ['LIB', 'OBJ'], ['EXE'], ['<toolset>gcc'])) generators.register( GccLinkingGenerator('gcc.link.dll', True, ['LIB', 'OBJ'], ['SHARED_LIB'], ['<toolset>gcc'])) # Declare flags for linking. # First, the common flags. flags('gcc.link', 'OPTIONS', ['<debug-symbols>on'], ['-g']) flags('gcc.link', 'OPTIONS', ['<profiling>on'], ['-pg']) flags('gcc.link', 'USER_OPTIONS', [], ['<linkflags>']) flags('gcc.link', 'LINKPATH', [], ['<library-path>']) flags('gcc.link', 'FINDLIBS-ST', [], ['<find-static-library>']) flags('gcc.link', 'FINDLIBS-SA', [], ['<find-shared-library>']) flags('gcc.link', 'LIBRARIES', [], ['<library-file>']) # For <runtime-link>static we made sure there are no dynamic libraries in the # link. On HP-UX not all system libraries exist as archived libraries (for # example, there is no libunwind.a), so, on this platform, the -static option # cannot be specified. if os_name() != 'HPUX': flags('gcc.link', 'OPTIONS', ['<runtime-link>static'], ['-static']) # Now, the vendor specific flags. # The parameter linker can be either gnu, darwin, osf, hpux or sun. def init_link_flags(toolset, linker, condition): """ Now, the vendor specific flags. The parameter linker can be either gnu, darwin, osf, hpux or sun. """ toolset_link = toolset + '.link' if linker == 'gnu': # Strip the binary when no debugging is needed. We use --strip-all flag # as opposed to -s since icc (intel's compiler) is generally # option-compatible with and inherits from the gcc toolset, but does not # support -s. # FIXME: what does unchecked translate to? flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,--strip-all']) # : unchecked ; flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ; flags(toolset_link, 'RPATH_LINK', condition, ['<xdll-path>']) # : unchecked ; flags(toolset_link, 'START-GROUP', condition, ['-Wl,--start-group'])# : unchecked ; flags(toolset_link, 'END-GROUP', condition, ['-Wl,--end-group']) # : unchecked ; # gnu ld has the ability to change the search behaviour for libraries # referenced by -l switch. These modifiers are -Bstatic and -Bdynamic # and change search for -l switches that follow them. The following list # shows the tried variants. # The search stops at the first variant that has a match. # *nix: -Bstatic -lxxx # libxxx.a # # *nix: -Bdynamic -lxxx # libxxx.so # libxxx.a # # windows (mingw,cygwin) -Bstatic -lxxx # libxxx.a # xxx.lib # # windows (mingw,cygwin) -Bdynamic -lxxx # libxxx.dll.a # xxx.dll.a # libxxx.a # xxx.lib # cygxxx.dll (*) # libxxx.dll # xxx.dll # libxxx.a # # (*) This is for cygwin # Please note that -Bstatic and -Bdynamic are not a guarantee that a # static or dynamic lib indeed gets linked in. The switches only change # search patterns! # On *nix mixing shared libs with static runtime is not a good idea. flags(toolset_link, 'FINDLIBS-ST-PFX', map(lambda x: x + '/<runtime-link>shared', condition), ['-Wl,-Bstatic']) # : unchecked ; flags(toolset_link, 'FINDLIBS-SA-PFX', map(lambda x: x + '/<runtime-link>shared', condition), ['-Wl,-Bdynamic']) # : unchecked ; # On windows allow mixing of static and dynamic libs with static # runtime. flags(toolset_link, 'FINDLIBS-ST-PFX', map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition), ['-Wl,-Bstatic']) # : unchecked ; flags(toolset_link, 'FINDLIBS-SA-PFX', map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition), ['-Wl,-Bdynamic']) # : unchecked ; flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition), ['-Wl,-Bstatic']) # : unchecked ; elif linker == 'darwin': # On Darwin, the -s option to ld does not work unless we pass -static, # and passing -static unconditionally is a bad idea. So, don't pass -s. # at all, darwin.jam will use separate 'strip' invocation. flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ; flags(toolset_link, 'RPATH_LINK', condition, ['<xdll-path>']) # : unchecked ; elif linker == 'osf': # No --strip-all, just -s. flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,-s']) # : unchecked ; flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ; # This does not supports -R. flags(toolset_link, 'RPATH_OPTION', condition, ['-rpath']) # : unchecked ; # -rpath-link is not supported at all. elif linker == 'sun': flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,-s']) # : unchecked ; flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ; # Solaris linker does not have a separate -rpath-link, but allows to use # -L for the same purpose. flags(toolset_link, 'LINKPATH', condition, ['<xdll-path>']) # : unchecked ; # This permits shared libraries with non-PIC code on Solaris. # VP, 2004/09/07: Now that we have -fPIC hardcode in link.dll, the # following is not needed. Whether -fPIC should be hardcoded, is a # separate question. # AH, 2004/10/16: it is still necessary because some tests link against # static libraries that were compiled without PIC. flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<link>shared', condition), ['-mimpure-text']) # : unchecked ; elif linker == 'hpux': flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,-s']) # : unchecked ; flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<link>shared', condition), ['-fPIC']) # : unchecked ; else: # FIXME: errors.user_error( "$(toolset) initialization: invalid linker '$(linker)' " + "The value '$(linker)' specified for <linker> is not recognized. " + "Possible values are 'gnu', 'darwin', 'osf', 'hpux' or 'sun'") # Declare actions for linking. def gcc_link(targets, sources, properties): engine = get_manager().engine() engine.set_target_variable(targets, 'SPACE', ' ') # Serialize execution of the 'link' action, since running N links in # parallel is just slower. For now, serialize only gcc links, it might be a # good idea to serialize all links. engine.set_target_variable(targets, 'JAM_SEMAPHORE', '<s>gcc-link-semaphore') engine.register_action( 'gcc.link', '"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' + '-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' + '-Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" ' + '$(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' + '-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' + '$(OPTIONS) $(USER_OPTIONS)', function=gcc_link, bound_list=['LIBRARIES']) # Default value. Mostly for the sake of intel-linux that inherits from gcc, but # does not have the same logic to set the .AR variable. We can put the same # logic in intel-linux, but that's hardly worth the trouble as on Linux, 'ar' is # always available. __AR = 'ar' flags('gcc.archive', 'AROPTIONS', [], ['<archiveflags>']) def gcc_archive(targets, sources, properties): # Always remove archive and start again. Here's rationale from # # Andre Hentz: # # I had a file, say a1.c, that was included into liba.a. I moved a1.c to # a2.c, updated my Jamfiles and rebuilt. My program was crashing with absurd # errors. After some debugging I traced it back to the fact that a1.o was # *still* in liba.a # # Rene Rivera: # # Originally removing the archive was done by splicing an RM onto the # archive action. That makes archives fail to build on NT when they have # many files because it will no longer execute the action directly and blow # the line length limit. Instead we remove the file in a different action, # just before building the archive. clean = targets[0] + '(clean)' bjam.call('TEMPORARY', clean) bjam.call('NOCARE', clean) engine = get_manager().engine() engine.set_target_variable('LOCATE', clean, bjam.call('get-target-variable', targets, 'LOCATE')) engine.add_dependency(clean, sources) engine.add_dependency(targets, clean) engine.set_update_action('common.RmTemps', clean, targets) # Declare action for creating static libraries. # The letter 'r' means to add files to the archive with replacement. Since we # remove archive, we don't care about replacement, but there's no option "add # without replacement". # The letter 'c' suppresses the warning in case the archive does not exists yet. # That warning is produced only on some platforms, for whatever reasons. engine.register_action('gcc.archive', '"$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"', function=gcc_archive, flags=['piecemeal']) def gcc_link_dll(targets, sources, properties): engine = get_manager().engine() engine.set_target_variable(targets, 'SPACE', ' ') engine.set_target_variable(targets, 'JAM_SEMAPHORE', '<s>gcc-link-semaphore') engine.set_target_variable(targets, "HAVE_SONAME", HAVE_SONAME) engine.set_target_variable(targets, "SONAME_OPTION", SONAME_OPTION) engine.register_action( 'gcc.link.dll', # Differ from 'link' above only by -shared. '"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' + '-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' + '"$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" ' + '$(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ' + '-shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' + '-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' + '$(OPTIONS) $(USER_OPTIONS)', function = gcc_link_dll, bound_list=['LIBRARIES']) # Set up threading support. It's somewhat contrived, so perform it at the end, # to avoid cluttering other code. if on_windows(): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-mthreads']) elif bjam.variable('UNIX'): jamuname = bjam.variable('JAMUNAME') host_os_name = jamuname[0] if host_os_name.startswith('SunOS'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthreads']) flags('gcc', 'FINDLIBS-SA', [], ['rt']) elif host_os_name == 'BeOS': # BeOS has no threading options, don't set anything here. pass elif host_os_name.endswith('BSD'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) # there is no -lrt on BSD elif host_os_name == 'DragonFly': flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) # there is no -lrt on BSD - DragonFly is a FreeBSD variant, # which anoyingly doesn't say it's a *BSD. elif host_os_name == 'IRIX': # gcc on IRIX does not support multi-threading, don't set anything here. pass elif host_os_name == 'Darwin': # Darwin has no threading options, don't set anything here. pass else: flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) flags('gcc', 'FINDLIBS-SA', [], ['rt']) def cpu_flags(toolset, variable, architecture, instruction_set, values, default=None): #FIXME: for some reason this fails. Probably out of date feature code ## if default: ## flags(toolset, variable, ## ['<architecture>' + architecture + '/<instruction-set>'], ## values) flags(toolset, variable, #FIXME: same as above [##'<architecture>/<instruction-set>' + instruction_set, '<architecture>' + architecture + '/<instruction-set>' + instruction_set], values) # Set architecture/instruction-set options. # # x86 and compatible flags('gcc', 'OPTIONS', ['<architecture>x86/<address-model>32'], ['-m32']) flags('gcc', 'OPTIONS', ['<architecture>x86/<address-model>64'], ['-m64']) cpu_flags('gcc', 'OPTIONS', 'x86', 'native', ['-march=native']) cpu_flags('gcc', 'OPTIONS', 'x86', 'i486', ['-march=i486']) cpu_flags('gcc', 'OPTIONS', 'x86', 'i586', ['-march=i586']) cpu_flags('gcc', 'OPTIONS', 'x86', 'i686', ['-march=i686'], default=True) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium', ['-march=pentium']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium-mmx', ['-march=pentium-mmx']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentiumpro', ['-march=pentiumpro']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium2', ['-march=pentium2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium3', ['-march=pentium3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium3m', ['-march=pentium3m']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium-m', ['-march=pentium-m']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium4', ['-march=pentium4']) cpu_flags('gcc', 'OPTIONS', 'x86', 'pentium4m', ['-march=pentium4m']) cpu_flags('gcc', 'OPTIONS', 'x86', 'prescott', ['-march=prescott']) cpu_flags('gcc', 'OPTIONS', 'x86', 'nocona', ['-march=nocona']) cpu_flags('gcc', 'OPTIONS', 'x86', 'core2', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'conroe', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'conroe-xe', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'conroe-l', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'allendale', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'wolfdale', ['-march=core2', '-msse4.1']) cpu_flags('gcc', 'OPTIONS', 'x86', 'merom', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'merom-xe', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'kentsfield', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'kentsfield-xe', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'yorksfield', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'penryn', ['-march=core2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'corei7', ['-march=corei7']) cpu_flags('gcc', 'OPTIONS', 'x86', 'nehalem', ['-march=corei7']) cpu_flags('gcc', 'OPTIONS', 'x86', 'corei7-avx', ['-march=corei7-avx']) cpu_flags('gcc', 'OPTIONS', 'x86', 'sandy-bridge', ['-march=corei7-avx']) cpu_flags('gcc', 'OPTIONS', 'x86', 'core-avx-i', ['-march=core-avx-i']) cpu_flags('gcc', 'OPTIONS', 'x86', 'ivy-bridge', ['-march=core-avx-i']) cpu_flags('gcc', 'OPTIONS', 'x86', 'haswell', ['-march=core-avx-i', '-mavx2', '-mfma', '-mbmi', '-mbmi2', '-mlzcnt']) cpu_flags('gcc', 'OPTIONS', 'x86', 'k6', ['-march=k6']) cpu_flags('gcc', 'OPTIONS', 'x86', 'k6-2', ['-march=k6-2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'k6-3', ['-march=k6-3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon', ['-march=athlon']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon-tbird', ['-march=athlon-tbird']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon-4', ['-march=athlon-4']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon-xp', ['-march=athlon-xp']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon-mp', ['-march=athlon-mp']) ## cpu_flags('gcc', 'OPTIONS', 'x86', 'k8', ['-march=k8']) cpu_flags('gcc', 'OPTIONS', 'x86', 'opteron', ['-march=opteron']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon64', ['-march=athlon64']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon-fx', ['-march=athlon-fx']) cpu_flags('gcc', 'OPTIONS', 'x86', 'k8-sse3', ['-march=k8-sse3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'opteron-sse3', ['-march=opteron-sse3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'athlon64-sse3', ['-march=athlon64-sse3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'amdfam10', ['-march=amdfam10']) cpu_flags('gcc', 'OPTIONS', 'x86', 'barcelona', ['-march=barcelona']) cpu_flags('gcc', 'OPTIONS', 'x86', 'bdver1', ['-march=bdver1']) cpu_flags('gcc', 'OPTIONS', 'x86', 'bdver2', ['-march=bdver2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'bdver3', ['-march=bdver3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'btver1', ['-march=btver1']) cpu_flags('gcc', 'OPTIONS', 'x86', 'btver2', ['-march=btver2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'winchip-c6', ['-march=winchip-c6']) cpu_flags('gcc', 'OPTIONS', 'x86', 'winchip2', ['-march=winchip2']) cpu_flags('gcc', 'OPTIONS', 'x86', 'c3', ['-march=c3']) cpu_flags('gcc', 'OPTIONS', 'x86', 'c3-2', ['-march=c3-2']) ## cpu_flags('gcc', 'OPTIONS', 'x86', 'atom', ['-march=atom']) # Sparc flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>32'], ['-m32']) flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>64'], ['-m64']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'c3', ['-mcpu=c3'], default=True) cpu_flags('gcc', 'OPTIONS', 'sparc', 'v7', ['-mcpu=v7']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'cypress', ['-mcpu=cypress']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'v8', ['-mcpu=v8']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'supersparc', ['-mcpu=supersparc']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclite', ['-mcpu=sparclite']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'hypersparc', ['-mcpu=hypersparc']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclite86x', ['-mcpu=sparclite86x']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'f930', ['-mcpu=f930']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'f934', ['-mcpu=f934']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclet', ['-mcpu=sparclet']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'tsc701', ['-mcpu=tsc701']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'v9', ['-mcpu=v9']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'ultrasparc', ['-mcpu=ultrasparc']) cpu_flags('gcc', 'OPTIONS', 'sparc', 'ultrasparc3', ['-mcpu=ultrasparc3']) # RS/6000 & PowerPC flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>32'], ['-m32']) flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>64'], ['-m64']) cpu_flags('gcc', 'OPTIONS', 'power', '403', ['-mcpu=403']) cpu_flags('gcc', 'OPTIONS', 'power', '505', ['-mcpu=505']) cpu_flags('gcc', 'OPTIONS', 'power', '601', ['-mcpu=601']) cpu_flags('gcc', 'OPTIONS', 'power', '602', ['-mcpu=602']) cpu_flags('gcc', 'OPTIONS', 'power', '603', ['-mcpu=603']) cpu_flags('gcc', 'OPTIONS', 'power', '603e', ['-mcpu=603e']) cpu_flags('gcc', 'OPTIONS', 'power', '604', ['-mcpu=604']) cpu_flags('gcc', 'OPTIONS', 'power', '604e', ['-mcpu=604e']) cpu_flags('gcc', 'OPTIONS', 'power', '620', ['-mcpu=620']) cpu_flags('gcc', 'OPTIONS', 'power', '630', ['-mcpu=630']) cpu_flags('gcc', 'OPTIONS', 'power', '740', ['-mcpu=740']) cpu_flags('gcc', 'OPTIONS', 'power', '7400', ['-mcpu=7400']) cpu_flags('gcc', 'OPTIONS', 'power', '7450', ['-mcpu=7450']) cpu_flags('gcc', 'OPTIONS', 'power', '750', ['-mcpu=750']) cpu_flags('gcc', 'OPTIONS', 'power', '801', ['-mcpu=801']) cpu_flags('gcc', 'OPTIONS', 'power', '821', ['-mcpu=821']) cpu_flags('gcc', 'OPTIONS', 'power', '823', ['-mcpu=823']) cpu_flags('gcc', 'OPTIONS', 'power', '860', ['-mcpu=860']) cpu_flags('gcc', 'OPTIONS', 'power', '970', ['-mcpu=970']) cpu_flags('gcc', 'OPTIONS', 'power', '8540', ['-mcpu=8540']) cpu_flags('gcc', 'OPTIONS', 'power', 'power', ['-mcpu=power']) cpu_flags('gcc', 'OPTIONS', 'power', 'power2', ['-mcpu=power2']) cpu_flags('gcc', 'OPTIONS', 'power', 'power3', ['-mcpu=power3']) cpu_flags('gcc', 'OPTIONS', 'power', 'power4', ['-mcpu=power4']) cpu_flags('gcc', 'OPTIONS', 'power', 'power5', ['-mcpu=power5']) cpu_flags('gcc', 'OPTIONS', 'power', 'powerpc', ['-mcpu=powerpc']) cpu_flags('gcc', 'OPTIONS', 'power', 'powerpc64', ['-mcpu=powerpc64']) cpu_flags('gcc', 'OPTIONS', 'power', 'rios', ['-mcpu=rios']) cpu_flags('gcc', 'OPTIONS', 'power', 'rios1', ['-mcpu=rios1']) cpu_flags('gcc', 'OPTIONS', 'power', 'rios2', ['-mcpu=rios2']) cpu_flags('gcc', 'OPTIONS', 'power', 'rsc', ['-mcpu=rsc']) cpu_flags('gcc', 'OPTIONS', 'power', 'rs64a', ['-mcpu=rs64']) # AIX variant of RS/6000 & PowerPC flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>32/<target-os>aix'], ['-maix32']) flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>64/<target-os>aix'], ['-maix64']) flags('gcc', 'AROPTIONS', ['<architecture>power/<address-model>64/<target-os>aix'], ['-X 64'])
mit
[ 3, 9795, 26, 3769, 299, 1376, 701, 17854, 1856, 644, 16080, 7570, 199, 3, 3523, 6974, 26, 841, 2760, 1138, 199, 3, 3254, 26, 2863, 14, 16997, 4839, 370, 506, 299, 1376, 199, 3, 3254, 26, 16952, 14, 16997, 4839, 370, 1172, 2274, 63, 67, 63, 5772, 14, 199, 3, 199, 3, 1898, 12521, 20232, 437, 7828, 10670, 83, 14, 199, 3, 1898, 14790, 13, 7968, 820, 6349, 820, 4380, 65, 14, 199, 3, 1898, 14790, 13, 17919, 812, 416, 3572, 723, 510, 20791, 14, 199, 3, 221, 1898, 334, 67, 9, 11811, 799, 69, 301, 869, 14, 577, 324, 78, 14, 199, 3, 1898, 8315, 473, 590, 65, 428, 745, 79, 32555, 14, 199, 3, 1898, 10219, 820, 393, 460, 22985, 3281, 90, 199, 3, 1898, 10219, 699, 269, 374, 598, 456, 287, 7697, 14, 199, 3, 1898, 9079, 17854, 1856, 644, 16080, 7570, 199, 3, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 259, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 199, 3, 3515, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 199, 199, 646, 330, 16997, 199, 199, 504, 330, 18, 14, 2537, 492, 16572, 12, 2863, 12, 4819, 12, 27204, 12, 6762, 199, 504, 330, 18, 14, 1506, 492, 3878, 12, 730, 12, 20070, 12, 16952, 12, 3324, 63, 409, 199, 504, 330, 18, 14, 1506, 14, 1829, 492, 16158, 199, 504, 330, 18, 14, 1974, 14, 16877, 492, 747, 63, 354, 12, 641, 63, 8258, 199, 504, 330, 18, 14, 2609, 492, 664, 63, 2609, 199, 504, 330, 18, 14, 1506, 14, 20748, 492, 15042, 199, 504, 330, 18, 14, 1506, 14, 12081, 492, 3285, 199, 504, 330, 18, 14, 1974, 14, 16877, 492, 370, 63, 3610, 4388, 199, 363, 1757, 275, 488, 199, 199, 318, 3105, 837, 272, 2288, 636, 1757, 272, 340, 636, 1757, 365, 488, 26, 267, 636, 1757, 275, 4320, 1757, 13, 4758, 2, 315, 330, 16997, 14, 1975, 480, 11611, 54, 531, 260, 272, 372, 636, 1757, 199, 199, 4445, 14, 2880, 360, 12081, 297, 788, 13112, 1105, 421, 199, 12081, 14, 6486, 63, 20748, 360, 13112, 297, 990, 283, 11864, 297, 788, 11864, 14, 1073, 297, 283, 11864, 14, 1073, 14, 9259, 1105, 199, 12081, 14, 6486, 63, 2469, 360, 13112, 297, 283, 11864, 358, 199, 12081, 14, 6486, 63, 4423, 360, 13112, 297, 283, 11864, 358, 199, 199, 20748, 14, 4415, 360, 13112, 14, 657, 11730, 297, 283, 5351, 14, 657, 11730, 358, 199, 20748, 14, 4415, 360, 13112, 14, 1733, 379, 13, 773, 13, 4679, 297, 283, 1733, 379, 13, 773, 13, 4679, 358, 199, 199, 3, 10256, 19720, 365, 12037, 701, 2943, 15, 773, 14, 16997, 436, 314, 2202, 5084, 642, 199, 3, 3721, 14, 199, 3, 199, 3, 4068, 627, 78, 1148, 26, 199, 3, 258, 1973, 10013, 14, 65, 258, 2955, 3555, 199, 3, 258, 1973, 10013, 14, 1152, 259, 5709, 3555, 199, 3, 199, 3, 4068, 10061, 334, 14566, 87, 304, 199, 3, 258, 1973, 10013, 14, 773, 257, 2955, 3555, 199, 3, 258, 26571, 14, 9259, 420, 577, 4464, 199, 3, 258, 26571, 14, 773, 420, 492, 3555, 199, 3, 199, 3, 4068, 10061, 334, 16680, 9, 284, 14, 69, 14, 665, 1375, 13, 736, 30, 16680, 199, 3, 258, 1973, 10013, 14, 65, 258, 2955, 3555, 199, 3, 258, 26571, 14, 9259, 420, 577, 4464, 199, 3, 258, 1973, 10013, 14, 9259, 14, 65, 492, 3555, 199, 3, 199, 3, 3390, 26, 922, 883, 3544, 4278, 701, 1808, 314, 665, 1450, 30, 32, 2200, 199, 3, 755, 961, 2202, 1172, 2757, 2468, 79, 2464, 12, 880, 626, 333, 316, 87, 199, 3, 755, 365, 315, 1004, 543, 333, 10599, 19720, 8758, 852, 14, 2104, 199, 3, 755, 23941, 314, 23941, 19720, 16129, 965, 2757, 2468, 79, 2464, 14, 199, 199, 3, 4155, 314, 298, 79, 2, 4739, 1202, 367, 19443, 20070, 641, 1006, 199, 3, 10677, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 15862, 297, 12329, 12081, 30, 13112, 995, 283, 79, 358, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 10449, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 65, 358, 199, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 17576, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 9259, 14, 65, 358, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 1861, 360, 17576, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 773, 358, 199, 199, 363, 6744, 63, 1431, 275, 295, 14, 2014, 9097, 7059, 1622, 11, 5942, 199, 363, 1023, 63, 1431, 275, 295, 14, 2014, 9097, 779, 16, 13, 25, 32455, 5942, 199, 199, 318, 4205, 8, 1023, 275, 488, 12, 1414, 275, 488, 12, 1511, 275, 488, 304, 272, 408, 267, 6026, 6491, 314, 19443, 20070, 367, 314, 1627, 1015, 14, 982, 5784, 12, 1414, 1443, 267, 506, 1202, 370, 4165, 2382, 314, 6365, 365, 16180, 14, 710, 2725, 283, 1419, 7, 365, 282, 267, 4601, 13, 25672, 769, 402, 1511, 12, 1924, 1373, 2013, 465, 267, 665, 1422, 13, 354, 30, 1422, 13, 585, 14, 4821, 945, 1561, 787, 26, 17280, 1949, 1550, 12, 2142, 2469, 436, 267, 17261, 13, 466, 14, 4473, 7203, 17261, 13, 466, 1338, 787, 486, 4850, 12, 366, 22822, 12, 747, 70, 12, 20962, 2521, 503, 26668, 267, 436, 314, 849, 574, 911, 506, 4895, 4079, 641, 314, 1453, 4403, 14, 267, 5679, 26, 881, 1808, 19443, 520, 650, 14, 20, 520, 520, 665, 11859, 1949, 1550, 30, 1421, 665, 1073, 2469, 30, 1700, 665, 20311, 13, 466, 30, 11846, 8700, 272, 408, 339, 1511, 275, 370, 63, 3610, 8, 1419, 9, 272, 1414, 275, 370, 63, 3610, 8, 1531, 9, 339, 327, 17064, 3595, 314, 19443, 1414, 1396, 272, 327, 257, 710, 1414, 14, 272, 1414, 275, 370, 63, 3610, 8, 2330, 14, 362, 63 ]
[ 9795, 26, 3769, 299, 1376, 701, 17854, 1856, 644, 16080, 7570, 199, 3, 3523, 6974, 26, 841, 2760, 1138, 199, 3, 3254, 26, 2863, 14, 16997, 4839, 370, 506, 299, 1376, 199, 3, 3254, 26, 16952, 14, 16997, 4839, 370, 1172, 2274, 63, 67, 63, 5772, 14, 199, 3, 199, 3, 1898, 12521, 20232, 437, 7828, 10670, 83, 14, 199, 3, 1898, 14790, 13, 7968, 820, 6349, 820, 4380, 65, 14, 199, 3, 1898, 14790, 13, 17919, 812, 416, 3572, 723, 510, 20791, 14, 199, 3, 221, 1898, 334, 67, 9, 11811, 799, 69, 301, 869, 14, 577, 324, 78, 14, 199, 3, 1898, 8315, 473, 590, 65, 428, 745, 79, 32555, 14, 199, 3, 1898, 10219, 820, 393, 460, 22985, 3281, 90, 199, 3, 1898, 10219, 699, 269, 374, 598, 456, 287, 7697, 14, 199, 3, 1898, 9079, 17854, 1856, 644, 16080, 7570, 199, 3, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 259, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 199, 3, 3515, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 199, 199, 646, 330, 16997, 199, 199, 504, 330, 18, 14, 2537, 492, 16572, 12, 2863, 12, 4819, 12, 27204, 12, 6762, 199, 504, 330, 18, 14, 1506, 492, 3878, 12, 730, 12, 20070, 12, 16952, 12, 3324, 63, 409, 199, 504, 330, 18, 14, 1506, 14, 1829, 492, 16158, 199, 504, 330, 18, 14, 1974, 14, 16877, 492, 747, 63, 354, 12, 641, 63, 8258, 199, 504, 330, 18, 14, 2609, 492, 664, 63, 2609, 199, 504, 330, 18, 14, 1506, 14, 20748, 492, 15042, 199, 504, 330, 18, 14, 1506, 14, 12081, 492, 3285, 199, 504, 330, 18, 14, 1974, 14, 16877, 492, 370, 63, 3610, 4388, 199, 363, 1757, 275, 488, 199, 199, 318, 3105, 837, 272, 2288, 636, 1757, 272, 340, 636, 1757, 365, 488, 26, 267, 636, 1757, 275, 4320, 1757, 13, 4758, 2, 315, 330, 16997, 14, 1975, 480, 11611, 54, 531, 260, 272, 372, 636, 1757, 199, 199, 4445, 14, 2880, 360, 12081, 297, 788, 13112, 1105, 421, 199, 12081, 14, 6486, 63, 20748, 360, 13112, 297, 990, 283, 11864, 297, 788, 11864, 14, 1073, 297, 283, 11864, 14, 1073, 14, 9259, 1105, 199, 12081, 14, 6486, 63, 2469, 360, 13112, 297, 283, 11864, 358, 199, 12081, 14, 6486, 63, 4423, 360, 13112, 297, 283, 11864, 358, 199, 199, 20748, 14, 4415, 360, 13112, 14, 657, 11730, 297, 283, 5351, 14, 657, 11730, 358, 199, 20748, 14, 4415, 360, 13112, 14, 1733, 379, 13, 773, 13, 4679, 297, 283, 1733, 379, 13, 773, 13, 4679, 358, 199, 199, 3, 10256, 19720, 365, 12037, 701, 2943, 15, 773, 14, 16997, 436, 314, 2202, 5084, 642, 199, 3, 3721, 14, 199, 3, 199, 3, 4068, 627, 78, 1148, 26, 199, 3, 258, 1973, 10013, 14, 65, 258, 2955, 3555, 199, 3, 258, 1973, 10013, 14, 1152, 259, 5709, 3555, 199, 3, 199, 3, 4068, 10061, 334, 14566, 87, 304, 199, 3, 258, 1973, 10013, 14, 773, 257, 2955, 3555, 199, 3, 258, 26571, 14, 9259, 420, 577, 4464, 199, 3, 258, 26571, 14, 773, 420, 492, 3555, 199, 3, 199, 3, 4068, 10061, 334, 16680, 9, 284, 14, 69, 14, 665, 1375, 13, 736, 30, 16680, 199, 3, 258, 1973, 10013, 14, 65, 258, 2955, 3555, 199, 3, 258, 26571, 14, 9259, 420, 577, 4464, 199, 3, 258, 1973, 10013, 14, 9259, 14, 65, 492, 3555, 199, 3, 199, 3, 3390, 26, 922, 883, 3544, 4278, 701, 1808, 314, 665, 1450, 30, 32, 2200, 199, 3, 755, 961, 2202, 1172, 2757, 2468, 79, 2464, 12, 880, 626, 333, 316, 87, 199, 3, 755, 365, 315, 1004, 543, 333, 10599, 19720, 8758, 852, 14, 2104, 199, 3, 755, 23941, 314, 23941, 19720, 16129, 965, 2757, 2468, 79, 2464, 14, 199, 199, 3, 4155, 314, 298, 79, 2, 4739, 1202, 367, 19443, 20070, 641, 1006, 199, 3, 10677, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 15862, 297, 12329, 12081, 30, 13112, 995, 283, 79, 358, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 10449, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 65, 358, 199, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 4511, 360, 17576, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 9259, 14, 65, 358, 199, 466, 14, 409, 63, 10176, 63, 1375, 63, 1861, 360, 17576, 63, 5617, 297, 12329, 12081, 30, 13112, 297, 2650, 1375, 13, 736, 30, 16680, 995, 283, 773, 358, 199, 199, 363, 6744, 63, 1431, 275, 295, 14, 2014, 9097, 7059, 1622, 11, 5942, 199, 363, 1023, 63, 1431, 275, 295, 14, 2014, 9097, 779, 16, 13, 25, 32455, 5942, 199, 199, 318, 4205, 8, 1023, 275, 488, 12, 1414, 275, 488, 12, 1511, 275, 488, 304, 272, 408, 267, 6026, 6491, 314, 19443, 20070, 367, 314, 1627, 1015, 14, 982, 5784, 12, 1414, 1443, 267, 506, 1202, 370, 4165, 2382, 314, 6365, 365, 16180, 14, 710, 2725, 283, 1419, 7, 365, 282, 267, 4601, 13, 25672, 769, 402, 1511, 12, 1924, 1373, 2013, 465, 267, 665, 1422, 13, 354, 30, 1422, 13, 585, 14, 4821, 945, 1561, 787, 26, 17280, 1949, 1550, 12, 2142, 2469, 436, 267, 17261, 13, 466, 14, 4473, 7203, 17261, 13, 466, 1338, 787, 486, 4850, 12, 366, 22822, 12, 747, 70, 12, 20962, 2521, 503, 26668, 267, 436, 314, 849, 574, 911, 506, 4895, 4079, 641, 314, 1453, 4403, 14, 267, 5679, 26, 881, 1808, 19443, 520, 650, 14, 20, 520, 520, 665, 11859, 1949, 1550, 30, 1421, 665, 1073, 2469, 30, 1700, 665, 20311, 13, 466, 30, 11846, 8700, 272, 408, 339, 1511, 275, 370, 63, 3610, 8, 1419, 9, 272, 1414, 275, 370, 63, 3610, 8, 1531, 9, 339, 327, 17064, 3595, 314, 19443, 1414, 1396, 272, 327, 257, 710, 1414, 14, 272, 1414, 275, 370, 63, 3610, 8, 2330, 14, 362, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Juniper/neutron
neutron/db/migration/alembic_migrations/versions/3d2585038b95_vmware_nsx.py
16
2181
# Copyright 2014 OpenStack Foundation # # 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. # """VMware NSX rebranding Revision ID: 3d2585038b95 Revises: 157a5d299379 Create Date: 2014-02-11 18:18:34.319031 """ # revision identifiers, used by Alembic. revision = '3d2585038b95' down_revision = '157a5d299379' # Change to ['*'] if this migration applies to all plugins migration_for_plugins = [ 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', 'neutron.plugins.vmware.plugin.NsxPlugin', 'neutron.plugins.vmware.plugin.NsxServicePlugin' ] from alembic import op from neutron.db import migration def upgrade(active_plugins=None, options=None): if not migration.should_run(active_plugins, migration_for_plugins): return op.rename_table('nvp_network_bindings', 'tz_network_bindings') op.rename_table('nvp_multi_provider_networks', 'multi_provider_networks') engine = op.get_bind().engine if engine.name == 'postgresql': op.execute("ALTER TYPE nvp_network_bindings_binding_type " "RENAME TO tz_network_bindings_binding_type;") def downgrade(active_plugins=None, options=None): if not migration.should_run(active_plugins, migration_for_plugins): return engine = op.get_bind().engine if engine.name == 'postgresql': op.execute("ALTER TYPE tz_network_bindings_binding_type " "RENAME TO nvp_network_bindings_binding_type;") op.rename_table('multi_provider_networks', 'nvp_multi_provider_networks') op.rename_table('tz_network_bindings', 'nvp_network_bindings')
apache-2.0
[ 3, 1898, 6927, 14260, 2752, 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, 3, 199, 199, 624, 6849, 1068, 9380, 56, 295, 19026, 316, 199, 199, 12714, 2870, 26, 650, 68, 12234, 1400, 1703, 66, 2720, 199, 497, 433, 874, 26, 32400, 65, 21, 68, 10488, 12015, 199, 2499, 6148, 26, 6927, 13, 996, 13, 845, 6155, 26, 1085, 26, 1082, 14, 23538, 19225, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 19, 68, 12234, 1400, 1703, 66, 2720, 7, 199, 2110, 63, 5792, 275, 283, 10823, 65, 21, 68, 10488, 12015, 7, 199, 199, 3, 7743, 370, 788, 10, 418, 340, 642, 8367, 12966, 370, 1006, 8963, 199, 199, 8998, 63, 509, 63, 5265, 275, 359, 272, 283, 10271, 14, 5265, 14, 12165, 20936, 14, 20915, 5061, 14, 46, 11702, 5061, 54, 18, 297, 272, 283, 10271, 14, 5265, 14, 12165, 20936, 14, 20915, 3167, 5061, 14, 46, 11702, 23613, 5061, 297, 272, 283, 10271, 14, 5265, 14, 18970, 14, 2718, 14, 2438, 88, 5061, 297, 272, 283, 10271, 14, 5265, 14, 18970, 14, 2718, 14, 2438, 88, 3167, 5061, 7, 199, 61, 199, 199, 504, 30960, 20596, 492, 1687, 199, 199, 504, 8224, 14, 697, 492, 8367, 421, 199, 318, 10754, 8, 2682, 63, 5265, 29, 403, 12, 1511, 29, 403, 304, 272, 340, 440, 8367, 14, 5626, 63, 1065, 8, 2682, 63, 5265, 12, 8367, 63, 509, 63, 5265, 304, 267, 372, 339, 1687, 14, 8165, 63, 1224, 360, 78, 11702, 63, 1200, 63, 10880, 297, 283, 3903, 63, 1200, 63, 10880, 358, 272, 1687, 14, 8165, 63, 1224, 360, 78, 11702, 63, 3029, 63, 3780, 63, 7642, 297, 283, 3029, 63, 3780, 63, 7642, 358, 339, 6869, 275, 1687, 14, 362, 63, 3409, 1252, 3908, 272, 340, 6869, 14, 354, 508, 283, 15437, 356, 267, 1687, 14, 2526, 480, 19350, 11511, 302, 11702, 63, 1200, 63, 10880, 63, 9140, 63, 466, 298, 673, 298, 50, 11536, 2296, 5823, 63, 1200, 63, 10880, 63, 9140, 63, 466, 15027, 421, 199, 318, 32498, 8, 2682, 63, 5265, 29, 403, 12, 1511, 29, 403, 304, 272, 340, 440, 8367, 14, 5626, 63, 1065, 8, 2682, 63, 5265, 12, 8367, 63, 509, 63, 5265, 304, 267, 372, 339, 6869, 275, 1687, 14, 362, 63, 3409, 1252, 3908, 272, 340, 6869, 14, 354, 508, 283, 15437, 356, 267, 1687, 14, 2526, 480, 19350, 11511, 5823, 63, 1200, 63, 10880, 63, 9140, 63, 466, 298, 673, 298, 50, 11536, 2296, 302, 11702, 63, 1200, 63, 10880, 63, 9140, 63, 466, 15027, 339, 1687, 14, 8165, 63, 1224, 360, 3029, 63, 3780, 63, 7642, 297, 283, 78, 11702, 63, 3029, 63, 3780, 63, 7642, 358, 272, 1687, 14, 8165, 63, 1224, 360, 3903, 63, 1200, 63, 10880, 297, 283, 78, 11702, 63, 1200, 63, 10880, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 14260, 2752, 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, 3, 199, 199, 624, 6849, 1068, 9380, 56, 295, 19026, 316, 199, 199, 12714, 2870, 26, 650, 68, 12234, 1400, 1703, 66, 2720, 199, 497, 433, 874, 26, 32400, 65, 21, 68, 10488, 12015, 199, 2499, 6148, 26, 6927, 13, 996, 13, 845, 6155, 26, 1085, 26, 1082, 14, 23538, 19225, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 19, 68, 12234, 1400, 1703, 66, 2720, 7, 199, 2110, 63, 5792, 275, 283, 10823, 65, 21, 68, 10488, 12015, 7, 199, 199, 3, 7743, 370, 788, 10, 418, 340, 642, 8367, 12966, 370, 1006, 8963, 199, 199, 8998, 63, 509, 63, 5265, 275, 359, 272, 283, 10271, 14, 5265, 14, 12165, 20936, 14, 20915, 5061, 14, 46, 11702, 5061, 54, 18, 297, 272, 283, 10271, 14, 5265, 14, 12165, 20936, 14, 20915, 3167, 5061, 14, 46, 11702, 23613, 5061, 297, 272, 283, 10271, 14, 5265, 14, 18970, 14, 2718, 14, 2438, 88, 5061, 297, 272, 283, 10271, 14, 5265, 14, 18970, 14, 2718, 14, 2438, 88, 3167, 5061, 7, 199, 61, 199, 199, 504, 30960, 20596, 492, 1687, 199, 199, 504, 8224, 14, 697, 492, 8367, 421, 199, 318, 10754, 8, 2682, 63, 5265, 29, 403, 12, 1511, 29, 403, 304, 272, 340, 440, 8367, 14, 5626, 63, 1065, 8, 2682, 63, 5265, 12, 8367, 63, 509, 63, 5265, 304, 267, 372, 339, 1687, 14, 8165, 63, 1224, 360, 78, 11702, 63, 1200, 63, 10880, 297, 283, 3903, 63, 1200, 63, 10880, 358, 272, 1687, 14, 8165, 63, 1224, 360, 78, 11702, 63, 3029, 63, 3780, 63, 7642, 297, 283, 3029, 63, 3780, 63, 7642, 358, 339, 6869, 275, 1687, 14, 362, 63, 3409, 1252, 3908, 272, 340, 6869, 14, 354, 508, 283, 15437, 356, 267, 1687, 14, 2526, 480, 19350, 11511, 302, 11702, 63, 1200, 63, 10880, 63, 9140, 63, 466, 298, 673, 298, 50, 11536, 2296, 5823, 63, 1200, 63, 10880, 63, 9140, 63, 466, 15027, 421, 199, 318, 32498, 8, 2682, 63, 5265, 29, 403, 12, 1511, 29, 403, 304, 272, 340, 440, 8367, 14, 5626, 63, 1065, 8, 2682, 63, 5265, 12, 8367, 63, 509, 63, 5265, 304, 267, 372, 339, 6869, 275, 1687, 14, 362, 63, 3409, 1252, 3908, 272, 340, 6869, 14, 354, 508, 283, 15437, 356, 267, 1687, 14, 2526, 480, 19350, 11511, 5823, 63, 1200, 63, 10880, 63, 9140, 63, 466, 298, 673, 298, 50, 11536, 2296, 302, 11702, 63, 1200, 63, 10880, 63, 9140, 63, 466, 15027, 339, 1687, 14, 8165, 63, 1224, 360, 3029, 63, 3780, 63, 7642, 297, 283, 78, 11702, 63, 3029, 63, 3780, 63, 7642, 358, 272, 1687, 14, 8165, 63, 1224, 360, 3903, 63, 1200, 63, 10880, 297, 283, 78, 11702, 63, 1200, 63, 10880, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gsehub/edx-platform
lms/djangoapps/verify_student/tests/test_fake_software_secure.py
13
2781
""" Tests for the fake software secure response. """ from django.test import TestCase from mock import patch from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification from student.tests.factories import UserFactory from util.testing import UrlResetMixin class SoftwareSecureFakeViewTest(UrlResetMixin, TestCase): """ Base class to test the fake software secure view. """ URLCONF_MODULES = ['verify_student.urls'] def setUp(self, **kwargs): enable_software_secure_fake = kwargs.get('enable_software_secure_fake', False) with patch.dict('django.conf.settings.FEATURES', {'ENABLE_SOFTWARE_SECURE_FAKE': enable_software_secure_fake}): super(SoftwareSecureFakeViewTest, self).setUp() self.user = UserFactory.create(username="test", password="test") self.attempt = SoftwareSecurePhotoVerification.objects.create(user=self.user) self.client.login(username="test", password="test") class SoftwareSecureFakeViewDisabledTest(SoftwareSecureFakeViewTest): """ Test the fake software secure response when feature flag 'ENABLE_SOFTWARE_SECURE_FAKE' is not enabled. """ shard = 4 def setUp(self): super(SoftwareSecureFakeViewDisabledTest, self).setUp(enable_software_secure_fake=False) def test_get_method_without_enable_feature_flag(self): """ Test that the user gets 404 response if the feature flag 'ENABLE_SOFTWARE_SECURE_FAKE' is not enabled. """ response = self.client.get( '/verify_student/software-secure-fake-response' ) self.assertEqual(response.status_code, 404) class SoftwareSecureFakeViewEnabledTest(SoftwareSecureFakeViewTest): """ Test the fake software secure response when feature flag 'ENABLE_SOFTWARE_SECURE_FAKE' is enabled. """ shard = 4 def setUp(self): super(SoftwareSecureFakeViewEnabledTest, self).setUp(enable_software_secure_fake=True) def test_get_method_without_logged_in_user(self): """ Test that the user gets 302 response if that user is not logged in. """ self.client.logout() response = self.client.get( '/verify_student/software-secure-fake-response' ) self.assertEqual(response.status_code, 302) def test_get_method(self): """ Test that GET method of fake software secure view uses the most recent attempt for the logged-in user. """ response = self.client.get( '/verify_student/software-secure-fake-response' ) self.assertEqual(response.status_code, 200) self.assertIn('EdX-ID', response.content) self.assertIn('results_callback', response.content)
agpl-3.0
[ 624, 199, 2925, 367, 314, 4026, 2032, 11153, 1177, 14, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1683, 492, 3371, 199, 199, 504, 21577, 14, 16432, 14, 4712, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 421, 199, 533, 2290, 24117, 8249, 2768, 774, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 272, 3523, 1021, 370, 511, 314, 4026, 2032, 11153, 2455, 14, 272, 408, 339, 2851, 3103, 63, 21194, 275, 788, 4712, 63, 5500, 14, 3603, 418, 339, 347, 3613, 8, 277, 12, 1011, 958, 304, 267, 4756, 63, 15619, 63, 7817, 63, 3183, 275, 2074, 14, 362, 360, 4296, 63, 15619, 63, 7817, 63, 3183, 297, 756, 9, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 26734, 63, 20696, 63, 14623, 356, 4756, 63, 15619, 63, 7817, 63, 3183, 22558, 288, 1613, 8, 10337, 24117, 8249, 2768, 774, 12, 291, 680, 5996, 342, 398, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 396, 401, 2505, 628, 396, 531, 267, 291, 14, 16880, 275, 2290, 24117, 21258, 22595, 14, 1462, 14, 981, 8, 751, 29, 277, 14, 751, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 396, 401, 2505, 628, 396, 531, 421, 199, 533, 2290, 24117, 8249, 2768, 15049, 774, 8, 10337, 24117, 8249, 2768, 774, 304, 272, 408, 272, 1379, 314, 4026, 2032, 11153, 1177, 1380, 3878, 3305, 272, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 440, 5223, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 10337, 24117, 8249, 2768, 15049, 774, 12, 291, 680, 5996, 8, 4296, 63, 15619, 63, 7817, 63, 3183, 29, 797, 9, 339, 347, 511, 63, 362, 63, 765, 63, 7395, 63, 4296, 63, 4445, 63, 4173, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 922, 7545, 7901, 1177, 340, 314, 3878, 3305, 267, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 440, 5223, 14, 267, 408, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 398, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 421, 199, 533, 2290, 24117, 8249, 2768, 6589, 774, 8, 10337, 24117, 8249, 2768, 774, 304, 272, 408, 272, 1379, 314, 4026, 2032, 11153, 1177, 1380, 3878, 3305, 272, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 5223, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 10337, 24117, 8249, 2768, 6589, 774, 12, 291, 680, 5996, 8, 4296, 63, 15619, 63, 7817, 63, 3183, 29, 549, 9, 339, 347, 511, 63, 362, 63, 765, 63, 7395, 63, 12419, 63, 262, 63, 751, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 922, 7545, 11485, 1177, 340, 626, 922, 365, 440, 10367, 315, 14, 267, 408, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 339, 347, 511, 63, 362, 63, 765, 8, 277, 304, 267, 408, 267, 1379, 626, 9576, 1083, 402, 4026, 2032, 11153, 2455, 4440, 314, 4750, 8058, 267, 7427, 367, 314, 10367, 13, 262, 922, 14, 267, 408, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 398, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 8751, 56, 13, 998, 297, 1177, 14, 1317, 9, 267, 291, 14, 4080, 360, 2604, 63, 3058, 297, 1177, 14, 1317, 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 ]
[ 199, 2925, 367, 314, 4026, 2032, 11153, 1177, 14, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1683, 492, 3371, 199, 199, 504, 21577, 14, 16432, 14, 4712, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 421, 199, 533, 2290, 24117, 8249, 2768, 774, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 272, 3523, 1021, 370, 511, 314, 4026, 2032, 11153, 2455, 14, 272, 408, 339, 2851, 3103, 63, 21194, 275, 788, 4712, 63, 5500, 14, 3603, 418, 339, 347, 3613, 8, 277, 12, 1011, 958, 304, 267, 4756, 63, 15619, 63, 7817, 63, 3183, 275, 2074, 14, 362, 360, 4296, 63, 15619, 63, 7817, 63, 3183, 297, 756, 9, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 26734, 63, 20696, 63, 14623, 356, 4756, 63, 15619, 63, 7817, 63, 3183, 22558, 288, 1613, 8, 10337, 24117, 8249, 2768, 774, 12, 291, 680, 5996, 342, 398, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 396, 401, 2505, 628, 396, 531, 267, 291, 14, 16880, 275, 2290, 24117, 21258, 22595, 14, 1462, 14, 981, 8, 751, 29, 277, 14, 751, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 396, 401, 2505, 628, 396, 531, 421, 199, 533, 2290, 24117, 8249, 2768, 15049, 774, 8, 10337, 24117, 8249, 2768, 774, 304, 272, 408, 272, 1379, 314, 4026, 2032, 11153, 1177, 1380, 3878, 3305, 272, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 440, 5223, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 10337, 24117, 8249, 2768, 15049, 774, 12, 291, 680, 5996, 8, 4296, 63, 15619, 63, 7817, 63, 3183, 29, 797, 9, 339, 347, 511, 63, 362, 63, 765, 63, 7395, 63, 4296, 63, 4445, 63, 4173, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 922, 7545, 7901, 1177, 340, 314, 3878, 3305, 267, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 440, 5223, 14, 267, 408, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 398, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 421, 199, 533, 2290, 24117, 8249, 2768, 6589, 774, 8, 10337, 24117, 8249, 2768, 774, 304, 272, 408, 272, 1379, 314, 4026, 2032, 11153, 1177, 1380, 3878, 3305, 272, 283, 8898, 63, 26734, 63, 20696, 63, 14623, 7, 365, 5223, 14, 272, 408, 272, 11814, 275, 841, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 10337, 24117, 8249, 2768, 6589, 774, 12, 291, 680, 5996, 8, 4296, 63, 15619, 63, 7817, 63, 3183, 29, 549, 9, 339, 347, 511, 63, 362, 63, 765, 63, 7395, 63, 12419, 63, 262, 63, 751, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 922, 7545, 11485, 1177, 340, 626, 922, 365, 440, 10367, 315, 14, 267, 408, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 339, 347, 511, 63, 362, 63, 765, 8, 277, 304, 267, 408, 267, 1379, 626, 9576, 1083, 402, 4026, 2032, 11153, 2455, 4440, 314, 4750, 8058, 267, 7427, 367, 314, 10367, 13, 262, 922, 14, 267, 408, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 288, 1994, 4712, 63, 5500, 15, 15619, 13, 7817, 13, 3183, 13, 1310, 7, 267, 776, 398, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 360, 8751, 56, 13, 998, 297, 1177, 14, 1317, 9, 267, 291, 14, 4080, 360, 2604, 63, 3058, 297, 1177, 14, 1317, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sh4t/Sick-Beard
lib/imdb/_logging.py
143
2171
""" _logging module (imdb package). This module provides the logging facilities used by the imdb package. Copyright 2009-2010 Davide Alberani <da@erlug.linux.it> 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import logging LEVELS = {'debug': logging.DEBUG, 'info': logging.INFO, 'warn': logging.WARNING, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL} imdbpyLogger = logging.getLogger('imdbpy') imdbpyStreamHandler = logging.StreamHandler() imdbpyFormatter = logging.Formatter('%(asctime)s %(levelname)s [%(name)s]' \ ' %(pathname)s:%(lineno)d: %(message)s') imdbpyStreamHandler.setFormatter(imdbpyFormatter) imdbpyLogger.addHandler(imdbpyStreamHandler) def setLevel(level): """Set logging level for the main logger.""" level = level.lower().strip() imdbpyLogger.setLevel(LEVELS.get(level, logging.NOTSET)) imdbpyLogger.log(imdbpyLogger.level, 'set logging threshold to "%s"', logging.getLevelName(imdbpyLogger.level)) #imdbpyLogger.setLevel(logging.DEBUG) # It can be an idea to have a single function to log and warn: #import warnings #def log_and_warn(msg, args=None, logger=None, level=None): # """Log the message and issue a warning.""" # if logger is None: # logger = imdbpyLogger # if level is None: # level = logging.WARNING # if args is None: # args = () # #warnings.warn(msg % args, stacklevel=0) # logger.log(level, msg % args)
gpl-3.0
[ 624, 199, 63, 4806, 859, 334, 17117, 2559, 680, 199, 199, 2765, 859, 6571, 314, 2050, 30242, 7999, 1202, 701, 314, 18232, 2559, 14, 199, 199, 7384, 8937, 13, 6542, 577, 65, 5624, 4580, 605, 26455, 665, 983, 32, 281, 32047, 14, 5135, 14, 390, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 646, 2050, 199, 199, 906, 2524, 5296, 275, 791, 1757, 356, 2050, 14, 5287, 12, 267, 283, 815, 356, 2050, 14, 4531, 12, 267, 283, 4050, 356, 2050, 14, 9171, 12, 267, 283, 3764, 356, 2050, 14, 9171, 12, 267, 283, 705, 356, 2050, 14, 3170, 12, 267, 283, 13138, 356, 2050, 14, 21539, 93, 421, 199, 17117, 647, 4455, 275, 2050, 14, 5572, 360, 17117, 647, 358, 199, 17117, 647, 22482, 275, 2050, 14, 22482, 342, 199, 17117, 647, 7772, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 359, 2840, 354, 9, 83, 6616, 971, 2511, 283, 2818, 12445, 9, 83, 19648, 3469, 9, 68, 26, 2818, 1188, 9, 83, 358, 199, 17117, 647, 22482, 14, 26076, 8, 17117, 647, 7772, 9, 199, 17117, 647, 4455, 14, 18826, 8, 17117, 647, 22482, 9, 199, 199, 318, 663, 4670, 8, 1896, 304, 272, 408, 1084, 2050, 2166, 367, 314, 2446, 2512, 1041, 272, 2166, 275, 2166, 14, 2325, 1252, 1913, 342, 272, 18232, 647, 4455, 14, 13548, 8, 906, 2524, 5296, 14, 362, 8, 1896, 12, 2050, 14, 4609, 3597, 430, 272, 18232, 647, 4455, 14, 793, 8, 17117, 647, 4455, 14, 1896, 12, 283, 409, 2050, 8765, 370, 2071, 83, 6949, 490, 2050, 14, 362, 4670, 985, 8, 17117, 647, 4455, 14, 1896, 430, 421, 199, 3, 17117, 647, 4455, 14, 13548, 8, 4806, 14, 5287, 9, 421, 199, 3, 2779, 883, 506, 376, 16819, 370, 1172, 282, 2849, 805, 370, 943, 436, 7987, 26, 199, 3, 646, 3598, 199, 3, 318, 943, 63, 460, 63, 4050, 8, 1328, 12, 1249, 29, 403, 12, 2512, 29, 403, 12, 2166, 29, 403, 304, 199, 3, 259, 408, 2445, 314, 1245, 436, 4976, 282, 5721, 1041, 199, 3, 259, 340, 2512, 365, 488, 26, 199, 3, 263, 2512, 275, 18232, 647, 4455, 199, 3, 259, 340, 2166, 365, 488, 26, 199, 3, 263, 2166, 275, 2050, 14, 9171, 199, 3, 259, 340, 1249, 365, 488, 26, 199, 3, 263, 1249, 275, 6248, 199, 3, 259, 327, 5451, 14, 4050, 8, 1328, 450, 1249, 12, 13232, 29, 16, 9, 199, 3, 259, 2512, 14, 793, 8, 1896, 12, 1499, 450, 1249, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 63, 4806, 859, 334, 17117, 2559, 680, 199, 199, 2765, 859, 6571, 314, 2050, 30242, 7999, 1202, 701, 314, 18232, 2559, 14, 199, 199, 7384, 8937, 13, 6542, 577, 65, 5624, 4580, 605, 26455, 665, 983, 32, 281, 32047, 14, 5135, 14, 390, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 646, 2050, 199, 199, 906, 2524, 5296, 275, 791, 1757, 356, 2050, 14, 5287, 12, 267, 283, 815, 356, 2050, 14, 4531, 12, 267, 283, 4050, 356, 2050, 14, 9171, 12, 267, 283, 3764, 356, 2050, 14, 9171, 12, 267, 283, 705, 356, 2050, 14, 3170, 12, 267, 283, 13138, 356, 2050, 14, 21539, 93, 421, 199, 17117, 647, 4455, 275, 2050, 14, 5572, 360, 17117, 647, 358, 199, 17117, 647, 22482, 275, 2050, 14, 22482, 342, 199, 17117, 647, 7772, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 359, 2840, 354, 9, 83, 6616, 971, 2511, 283, 2818, 12445, 9, 83, 19648, 3469, 9, 68, 26, 2818, 1188, 9, 83, 358, 199, 17117, 647, 22482, 14, 26076, 8, 17117, 647, 7772, 9, 199, 17117, 647, 4455, 14, 18826, 8, 17117, 647, 22482, 9, 199, 199, 318, 663, 4670, 8, 1896, 304, 272, 408, 1084, 2050, 2166, 367, 314, 2446, 2512, 1041, 272, 2166, 275, 2166, 14, 2325, 1252, 1913, 342, 272, 18232, 647, 4455, 14, 13548, 8, 906, 2524, 5296, 14, 362, 8, 1896, 12, 2050, 14, 4609, 3597, 430, 272, 18232, 647, 4455, 14, 793, 8, 17117, 647, 4455, 14, 1896, 12, 283, 409, 2050, 8765, 370, 2071, 83, 6949, 490, 2050, 14, 362, 4670, 985, 8, 17117, 647, 4455, 14, 1896, 430, 421, 199, 3, 17117, 647, 4455, 14, 13548, 8, 4806, 14, 5287, 9, 421, 199, 3, 2779, 883, 506, 376, 16819, 370, 1172, 282, 2849, 805, 370, 943, 436, 7987, 26, 199, 3, 646, 3598, 199, 3, 318, 943, 63, 460, 63, 4050, 8, 1328, 12, 1249, 29, 403, 12, 2512, 29, 403, 12, 2166, 29, 403, 304, 199, 3, 259, 408, 2445, 314, 1245, 436, 4976, 282, 5721, 1041, 199, 3, 259, 340, 2512, 365, 488, 26, 199, 3, 263, 2512, 275, 18232, 647, 4455, 199, 3, 259, 340, 2166, 365, 488, 26, 199, 3, 263, 2166, 275, 2050, 14, 9171, 199, 3, 259, 340, 1249, 365, 488, 26, 199, 3, 263, 1249, 275, 6248, 199, 3, 259, 327, 5451, 14, 4050, 8, 1328, 450, 1249, 12, 13232, 29, 16, 9, 199, 3, 259, 2512, 14, 793, 8, 1896, 12, 1499, 450, 1249, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nishigori/boto
tests/unit/manage/test_ssh.py
114
2004
#!/usr/bin/env python # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved # # 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, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing 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 MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR 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. # try: import paramiko from boto.manage.cmdshell import SSHClient except ImportError: paramiko = None SSHClient = None from tests.compat import mock, unittest class TestSSHTimeout(unittest.TestCase): @unittest.skipIf(not paramiko, 'Paramiko missing') def test_timeout(self): client_tmp = paramiko.SSHClient def client_mock(): client = client_tmp() client.connect = mock.Mock(name='connect') return client paramiko.SSHClient = client_mock paramiko.RSAKey.from_private_key_file = mock.Mock() server = mock.Mock() test = SSHClient(server) self.assertEqual(test._ssh_client.connect.call_args[1]['timeout'], None) test2 = SSHClient(server, timeout=30) self.assertEqual(test2._ssh_client.connect.call_args[1]['timeout'], 30)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 199, 893, 26, 272, 492, 26162, 272, 687, 6055, 14, 9053, 14, 1760, 5641, 492, 12027, 3041, 199, 2590, 3545, 26, 272, 26162, 275, 488, 272, 12027, 3041, 275, 488, 199, 199, 504, 2295, 14, 5819, 492, 1683, 12, 2882, 421, 199, 533, 1379, 13716, 6372, 8, 2796, 14, 1746, 304, 272, 768, 2796, 14, 15118, 8, 1397, 26162, 12, 283, 4098, 16625, 4124, 358, 272, 347, 511, 63, 2593, 8, 277, 304, 267, 1890, 63, 2791, 275, 26162, 14, 13716, 3041, 398, 347, 1890, 63, 1805, 837, 288, 1890, 275, 1890, 63, 2791, 342, 288, 1890, 14, 2242, 275, 1683, 14, 3346, 8, 354, 534, 2242, 358, 288, 372, 1890, 398, 26162, 14, 13716, 3041, 275, 1890, 63, 1805, 267, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 275, 1683, 14, 3346, 342, 398, 1654, 275, 1683, 14, 3346, 342, 267, 511, 275, 12027, 3041, 8, 1000, 9, 398, 291, 14, 629, 8, 396, 423, 5510, 63, 1258, 14, 2242, 14, 1250, 63, 589, 59, 17, 2733, 2593, 995, 488, 9, 398, 511, 18, 275, 12027, 3041, 8, 1000, 12, 2653, 29, 1216, 9, 398, 291, 14, 629, 8, 396, 18, 423, 5510, 63, 1258, 14, 2242, 14, 1250, 63, 589, 59, 17, 2733, 2593, 995, 4233, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 199, 893, 26, 272, 492, 26162, 272, 687, 6055, 14, 9053, 14, 1760, 5641, 492, 12027, 3041, 199, 2590, 3545, 26, 272, 26162, 275, 488, 272, 12027, 3041, 275, 488, 199, 199, 504, 2295, 14, 5819, 492, 1683, 12, 2882, 421, 199, 533, 1379, 13716, 6372, 8, 2796, 14, 1746, 304, 272, 768, 2796, 14, 15118, 8, 1397, 26162, 12, 283, 4098, 16625, 4124, 358, 272, 347, 511, 63, 2593, 8, 277, 304, 267, 1890, 63, 2791, 275, 26162, 14, 13716, 3041, 398, 347, 1890, 63, 1805, 837, 288, 1890, 275, 1890, 63, 2791, 342, 288, 1890, 14, 2242, 275, 1683, 14, 3346, 8, 354, 534, 2242, 358, 288, 372, 1890, 398, 26162, 14, 13716, 3041, 275, 1890, 63, 1805, 267, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 275, 1683, 14, 3346, 342, 398, 1654, 275, 1683, 14, 3346, 342, 267, 511, 275, 12027, 3041, 8, 1000, 9, 398, 291, 14, 629, 8, 396, 423, 5510, 63, 1258, 14, 2242, 14, 1250, 63, 589, 59, 17, 2733, 2593, 995, 488, 9, 398, 511, 18, 275, 12027, 3041, 8, 1000, 12, 2653, 29, 1216, 9, 398, 291, 14, 629, 8, 396, 18, 423, 5510, 63, 1258, 14, 2242, 14, 1250, 63, 589, 59, 17, 2733, 2593, 995, 4233, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
austinzheng/swift
utils/swift-api-dump.py
25
11781
#!/usr/bin/env python # This tool dumps imported Swift APIs to help validate changes in the # projection of (Objective-)C APIs into Swift, which is a function of the # (Objective-)C APIs, any API notes added on top of those APIs, and the # Clang importer itself. One can execute it to dump the API of a given # module within a particular SDK, e.g., UIKit from the iOS SDK as seen in # Swift 4 compatibility mode: # # /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir \ # -m UIKit -s iphoneos # # The "-m" argument can be omitted, in which case the script will collect # all of the frameworks in the named SDK(s) and dump their APIs. # # One can supply multiple SDKs, written as a list. For example, to # dump the API for all frameworks across macOS, iOS, watchOS, and tvOS, # in Swift 4.2, use: # # /path/to/bin/dir/swift-api-dump.py -swift-version 4.2 -o output-dir \ # -s macosx iphoneos watchos appletvos # from __future__ import print_function import argparse import multiprocessing import os import re import subprocess import sys DEFAULT_TARGET_BASED_ON_SDK = { 'macosx': 'x86_64-apple-macosx10.11', 'iphoneos': 'arm64-apple-ios9.0', 'iphonesimulator': 'x86_64-apple-ios9.0', 'watchos': 'armv7k-apple-watchos2.0', 'watchos.simulator': 'i386-apple-watchos2.0', 'appletvos': 'arm64-apple-tvos9', 'appletvos.simulator': 'x86_64-apple-tvos9', } SKIPPED_FRAMEWORKS = { 'AppKitScripting', 'CalendarStore', 'CoreMIDIServer', 'DrawSprocket', 'DVComponentGlue', 'InstallerPlugins', 'InstantMessage', 'JavaFrameEmbedding', 'JavaVM', 'Kerberos', 'Kernel', 'LDAP', 'Message', 'PCSC', 'PubSub', 'QTKit', 'QuickTime', 'Ruby', 'Scripting', 'SyncServices', 'System', 'Tk', 'VideoDecodeAcceleration', 'vecLib', } def create_parser(): script_path = os.path.dirname(sys.argv[0]) script_path = os.path.abspath(script_path) default_swift_ide_test = '%s/swift-ide-test' % (script_path) parser = argparse.ArgumentParser( description="Dumps imported Swift APIs for a module or SDK", prog='swift-api-dump.py', usage='%(prog)s -s iphoneos') parser.add_argument('-m', '--module', help='The module name.') parser.add_argument('-j', '--jobs', type=int, help='The number of parallel jobs to execute') parser.add_argument('-s', '--sdk', nargs='+', required=True, help="The SDKs to use.") parser.add_argument('-t', '--target', help="The target triple to use.") parser.add_argument('-i', '--swift-ide-test', default=default_swift_ide_test, help="The swift-ide-test executable.") parser.add_argument('-o', '--output-dir', default=os.getcwd(), help='Directory to which the output will be emitted.') parser.add_argument('-q', '--quiet', action='store_true', help='Suppress printing of status messages.') parser.add_argument('-v', '--verbose', action='store_true', help='Print extra information.') parser.add_argument('-F', '--framework-dir', action='append', help='Add additional framework directories') parser.add_argument('-iframework', '--system-framework-dir', action='append', help='Add additional system framework directories') parser.add_argument('-I', '--include-dir', action='append', help='Add additional include directories') parser.add_argument('--enable-infer-import-as-member', action='store_true', help='Infer when a global could be imported as a ' + 'member.') parser.add_argument('-swift-version', metavar='N', help='the Swift version to use') parser.add_argument('-show-overlay', action='store_true', help='Show overlay API in addition to Objective-C ' + 'module API') parser.add_argument('-show-doc-comments', action='store_true', help='Show documentation comments') parser.add_argument('-show-unavailable', action='store_true', help='Show declarations that are unavailable in Swift') return parser def output_command_result_to_file(command_args, filename): with open(filename, 'w') as output_file: subprocess.call(command_args, stdout=output_file) def run_command(args): proc = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate() exitcode = proc.returncode return (exitcode, out, err) # Collect the set of submodules for the given module. def collect_submodules(common_args, module): # Execute swift-ide-test to print the interface. my_args = ['-module-print-submodules', '-module-to-print=%s' % (module)] (exitcode, out, _) = run_command(common_args + my_args) if exitcode != 0: print( 'error: submodule collection failed for module %s with error %d' % (module, exitcode)) return () # Find all of the submodule imports. import_matcher = re.compile(r'.*import\s+%s\.([A-Za-z_0-9.]+)' % (module)) submodules = set() for line in out.splitlines(): match = import_matcher.match(line) if match: submodules.add(match.group(1)) return sorted(list(submodules)) # Print out the command we're about to execute def print_command(cmd, outfile=""): retstr = " ".join(cmd) if outfile != "": retstr += " > " + outfile print(retstr) # Dump the API for the given module. def dump_module_api((cmd, extra_dump_args, output_dir, module, quiet, verbose)): # Collect the submodules submodules = collect_submodules(cmd, module) # Dump the top-level module if verbose: print("mkdir -p %s/%s" % (output_dir, module)) subprocess.call(['mkdir', '-p', ('%s/%s' % (output_dir, module))]) output_file = '%s/%s/%s.swift' % (output_dir, module, module) if not quiet: print('Writing %s...' % output_file) top_level_cmd = cmd + extra_dump_args + ['-module-to-print=%s' % (module)] if verbose: print_command(top_level_cmd, output_file) output_command_result_to_file(top_level_cmd, output_file) # Dump each submodule. for submodule in submodules: output_file = '%s/%s/%s.swift' % (output_dir, module, submodule) if not quiet: print('Writing %s...' % output_file) full_submodule = '%s.%s' % (module, submodule) submodule_cmd = cmd + extra_dump_args submodule_cmd = submodule_cmd + \ ['-module-to-print=%s' % (full_submodule)] if verbose: print_command(submodule_cmd, output_file) output_command_result_to_file(submodule_cmd, output_file) return def pretty_sdk_name(sdk): if sdk.find("macosx") == 0: return 'macOS' if sdk.find("iphoneos") == 0: return 'iOS' if sdk.find("watchos") == 0: return 'watchOS' if sdk.find("appletvos") == 0: return 'tvOS' return 'unknownOS' # Collect the set of frameworks we should dump def collect_frameworks(sdk): (exitcode, sdk_path, _) = run_command( ["xcrun", "--show-sdk-path", "-sdk", sdk]) if exitcode != 0: print('error: framework collection failed to find SDK path for %s ' 'with error %d' % (sdk, exitcode)) return () sdk_path = sdk_path.rstrip() (exitcode, sdk_version, _) = run_command( ["xcrun", "--show-sdk-version", "-sdk", sdk]) if exitcode != 0: print('error: framework collection failed to find SDK version for %s ' 'with error %d' % (sdk, exitcode)) return () sdk_version = sdk_version.rstrip() print('Collecting frameworks from %s %s at %s' % (pretty_sdk_name(sdk), sdk_version, sdk_path)) # Collect all of the framework names frameworks_dir = '%s/System/Library/Frameworks' % sdk_path framework_matcher = re.compile(r'([A-Za-z_0-9.]+)\.framework') frameworks = set() for entry in os.listdir(frameworks_dir): match = framework_matcher.match(entry) if match: framework = match.group(1) if framework not in SKIPPED_FRAMEWORKS: frameworks.add(framework) return (sorted(list(frameworks)), sdk_path) def get_short_sdk_name(sdk): matched = re.match("[a-zA-Z]+", sdk) return matched.group(0) def create_dump_module_api_args(cmd_common, cmd_extra_args, sdk, module, target, output_dir, quiet, verbose): # Determine the SDK root and collect the set of frameworks. (frameworks, sdk_root) = collect_frameworks(sdk) # Figure out the "short" name of the SDK short_sdk_name = get_short_sdk_name(sdk) # Determine the default target. if target: sdk_target = target else: sdk_target = DEFAULT_TARGET_BASED_ON_SDK[short_sdk_name] # Determine the output idirectory pretty_sdk = pretty_sdk_name(short_sdk_name) sdk_output_dir = '%s/%s' % (output_dir, pretty_sdk) # Create the sets of arguments to dump_module_api. results = [] cmd = cmd_common + ['-sdk', sdk_root, '-target', sdk_target] if module: results.append( (cmd, cmd_extra_args, sdk_output_dir, module, quiet, verbose)) else: for framework in frameworks: results.append( (cmd, cmd_extra_args, sdk_output_dir, framework, quiet, verbose)) return results def main(): source_filename = 'swift-api-dump.swift' parser = create_parser() args = parser.parse_args() cmd_common = [ args.swift_ide_test, '-print-module', '-source-filename', source_filename, '-skip-overrides' ] # Add -module-print-skip-overlay if not args.show_overlay: cmd_common += ['-module-print-skip-overlay'] # Add -skip-print-doc-comments if not args.show_doc_comments: cmd_common += ['-skip-print-doc-comments'] # Add -skip-unavailable if not args.show_unavailable: cmd_common += ['-skip-unavailable'] # Add -F / -iframework / -I arguments. if args.framework_dir: for path in args.framework_dir: cmd_common = cmd_common + ['-F', path] if args.system_framework_dir: for path in args.system_framework_dir: cmd_common = cmd_common + ['-iframework', path] if args.include_dir: for path in args.include_dir: cmd_common = cmd_common + ['-I', path] # Determine the set of extra arguments we'll use. extra_args = ['-skip-imports'] if args.enable_infer_import_as_member: extra_args = extra_args + ['-enable-infer-import-as-member'] if args.swift_version: extra_args = extra_args + ['-swift-version', '%s' % args.swift_version] # Create a .swift file we can feed into swift-ide-test subprocess.call(['touch', source_filename]) # Construct the set of API dumps we should perform. jobs = [] for sdk in args.sdk: jobs = jobs + create_dump_module_api_args( cmd_common, extra_args, sdk, args.module, args.target, args.output_dir, args.quiet, args.verbose) # Execute the API dumps pool = multiprocessing.Pool(processes=args.jobs) pool.map(dump_module_api, jobs) # Remove the .swift file we fed into swift-ide-test subprocess.call(['rm', '-f', source_filename]) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 4744, 16864, 8439, 16666, 2949, 15913, 370, 1720, 4107, 4493, 315, 314, 199, 3, 14777, 402, 334, 29104, 13, 9, 35, 15913, 1901, 16666, 2949, 12, 1314, 365, 282, 805, 402, 314, 199, 3, 334, 29104, 13, 9, 35, 15913, 12, 1263, 3261, 12681, 3483, 641, 2746, 402, 5204, 15913, 12, 436, 314, 199, 3, 445, 4159, 13479, 6337, 14, 7309, 883, 5341, 652, 370, 5461, 314, 3261, 402, 282, 1627, 199, 3, 859, 4453, 282, 6770, 15610, 12, 325, 14, 71, 2020, 14041, 14591, 687, 314, 284, 3100, 15610, 465, 6775, 315, 199, 3, 16666, 2949, 841, 7163, 818, 26, 199, 3, 199, 3, 257, 1182, 515, 15, 475, 15, 1393, 15, 694, 15, 13215, 13, 1246, 13, 2724, 14, 647, 446, 13215, 13, 1023, 841, 446, 79, 1072, 13, 694, 971, 199, 3, 755, 446, 77, 14041, 14591, 446, 83, 284, 9339, 736, 199, 3, 199, 3, 710, 3905, 77, 2, 1423, 883, 506, 11684, 12, 315, 1314, 1930, 314, 2884, 911, 8775, 199, 3, 1006, 402, 314, 10059, 83, 315, 314, 4310, 15610, 8, 83, 9, 436, 5461, 3932, 15913, 14, 199, 3, 199, 3, 7309, 883, 17169, 3663, 15610, 83, 12, 5313, 465, 282, 769, 14, 2104, 2893, 12, 370, 199, 3, 5461, 314, 3261, 367, 1006, 10059, 83, 9371, 4497, 3100, 12, 284, 3100, 12, 9626, 3100, 12, 436, 13466, 3100, 12, 199, 3, 315, 16666, 2949, 841, 14, 18, 12, 675, 26, 199, 3, 199, 3, 221, 1182, 515, 15, 475, 15, 1393, 15, 694, 15, 13215, 13, 1246, 13, 2724, 14, 647, 446, 13215, 13, 1023, 841, 14, 18, 446, 79, 1072, 13, 694, 971, 199, 3, 420, 446, 83, 610, 24751, 284, 9339, 736, 9626, 736, 1145, 2723, 86, 736, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 12866, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 3472, 63, 9268, 63, 5825, 36, 63, 615, 63, 14939, 275, 469, 272, 283, 28546, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 28546, 709, 14, 845, 297, 272, 283, 28303, 736, 356, 283, 5362, 772, 13, 12820, 13, 9207, 25, 14, 16, 297, 272, 283, 28303, 20125, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 9207, 25, 14, 16, 297, 272, 283, 6821, 736, 356, 283, 5362, 86, 23, 75, 13, 12820, 13, 6821, 736, 18, 14, 16, 297, 272, 283, 6821, 736, 14, 20125, 356, 283, 73, 8040, 13, 12820, 13, 6821, 736, 18, 14, 16, 297, 272, 283, 571, 2723, 86, 736, 356, 283, 5362, 772, 13, 12820, 13, 6993, 736, 25, 297, 272, 283, 571, 2723, 86, 736, 14, 20125, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 6993, 736, 25, 297, 199, 93, 199, 199, 13525, 19359, 63, 12683, 8406, 51, 275, 469, 272, 283, 2640, 14591, 5229, 316, 297, 272, 283, 18688, 5502, 297, 272, 283, 5402, 45, 998, 1311, 23685, 297, 272, 283, 9654, 51, 496, 2284, 297, 272, 283, 6741, 7004, 39, 11322, 297, 272, 283, 27598, 19330, 297, 272, 283, 607, 4715, 2209, 297, 272, 283, 12576, 3160, 27907, 297, 272, 283, 12576, 6849, 297, 272, 283, 43, 281, 23920, 297, 272, 283, 14127, 297, 272, 283, 19534, 297, 272, 283, 2209, 297, 272, 283, 48, 3298, 35, 297, 272, 283, 18060, 2610, 297, 272, 283, 19229, 14591, 297, 272, 283, 19684, 1366, 297, 272, 283, 50, 10972, 297, 272, 283, 5229, 316, 297, 272, 283, 10878, 15803, 297, 272, 283, 3989, 297, 272, 283, 15189, 297, 272, 283, 9166, 9400, 1945, 29765, 297, 272, 283, 6046, 4728, 297, 199, 93, 421, 199, 318, 1218, 63, 2087, 837, 272, 2884, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 566, 272, 2884, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 1579, 63, 515, 9, 272, 849, 63, 13215, 63, 2655, 63, 396, 275, 1543, 83, 15, 13215, 13, 2655, 13, 396, 7, 450, 334, 1579, 63, 515, 9, 339, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 11772, 83, 8439, 16666, 2949, 15913, 367, 282, 859, 503, 15610, 401, 267, 13205, 534, 13215, 13, 1246, 13, 2724, 14, 647, 297, 267, 4503, 29342, 6595, 9, 83, 446, 83, 284, 9339, 736, 358, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 578, 297, 1720, 534, 1918, 859, 536, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 74, 297, 2850, 6920, 297, 730, 29, 442, 12, 717, 1720, 534, 1918, 1329, 402, 9861, 9643, 370, 5341, 358, 272, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 9277, 297, 9237, 534, 7386, 717, 1415, 29, 549, 12, 1720, 628, 1918, 15610, 83, 370, 675, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1375, 297, 1720, 628, 1918, 1347, 19671, 370, 675, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 73, 297, 2850, 13215, 13, 2655, 13, 396, 297, 717, 849, 29, 885, 63, 13215, 63, 2655, 63, 396, 12, 717, 1720, 628, 1918, 16275, 13, 2655, 13, 396, 7286, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 13, 694, 297, 849, 29, 736, 14, 9458, 1062, 717, 1720, 534, 6231, 370, 1314, 314, 1072, 911, 506, 19515, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 81, 297, 2850, 10243, 297, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 18334, 16116, 402, 2004, 3788, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 5375, 2402, 2556, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 38, 297, 2850, 4857, 13, 694, 297, 1595, 534, 740, 297, 717, 1720, 534, 1123, 4722, 10059, 6602, 358, 272, 1798, 14, 525, 63, 2094, 3654, 20052, 800, 297, 2850, 2253, 13, 4857, 13, 694, 297, 717, 1595, 534, 740, 297, 717, 1720, 534, 1123, 4722, 2656, 10059, 6602, 358, 272, 1798, 14, 525, 63, 2094, 3654, 41, 297, 2850, 2613, 13, 694, 297, 1595, 534, 740, 297, 717, 1720, 534, 1123, 4722, 2387, 6602, 358, 272, 1798, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 4744, 16864, 8439, 16666, 2949, 15913, 370, 1720, 4107, 4493, 315, 314, 199, 3, 14777, 402, 334, 29104, 13, 9, 35, 15913, 1901, 16666, 2949, 12, 1314, 365, 282, 805, 402, 314, 199, 3, 334, 29104, 13, 9, 35, 15913, 12, 1263, 3261, 12681, 3483, 641, 2746, 402, 5204, 15913, 12, 436, 314, 199, 3, 445, 4159, 13479, 6337, 14, 7309, 883, 5341, 652, 370, 5461, 314, 3261, 402, 282, 1627, 199, 3, 859, 4453, 282, 6770, 15610, 12, 325, 14, 71, 2020, 14041, 14591, 687, 314, 284, 3100, 15610, 465, 6775, 315, 199, 3, 16666, 2949, 841, 7163, 818, 26, 199, 3, 199, 3, 257, 1182, 515, 15, 475, 15, 1393, 15, 694, 15, 13215, 13, 1246, 13, 2724, 14, 647, 446, 13215, 13, 1023, 841, 446, 79, 1072, 13, 694, 971, 199, 3, 755, 446, 77, 14041, 14591, 446, 83, 284, 9339, 736, 199, 3, 199, 3, 710, 3905, 77, 2, 1423, 883, 506, 11684, 12, 315, 1314, 1930, 314, 2884, 911, 8775, 199, 3, 1006, 402, 314, 10059, 83, 315, 314, 4310, 15610, 8, 83, 9, 436, 5461, 3932, 15913, 14, 199, 3, 199, 3, 7309, 883, 17169, 3663, 15610, 83, 12, 5313, 465, 282, 769, 14, 2104, 2893, 12, 370, 199, 3, 5461, 314, 3261, 367, 1006, 10059, 83, 9371, 4497, 3100, 12, 284, 3100, 12, 9626, 3100, 12, 436, 13466, 3100, 12, 199, 3, 315, 16666, 2949, 841, 14, 18, 12, 675, 26, 199, 3, 199, 3, 221, 1182, 515, 15, 475, 15, 1393, 15, 694, 15, 13215, 13, 1246, 13, 2724, 14, 647, 446, 13215, 13, 1023, 841, 14, 18, 446, 79, 1072, 13, 694, 971, 199, 3, 420, 446, 83, 610, 24751, 284, 9339, 736, 9626, 736, 1145, 2723, 86, 736, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 12866, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 3472, 63, 9268, 63, 5825, 36, 63, 615, 63, 14939, 275, 469, 272, 283, 28546, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 28546, 709, 14, 845, 297, 272, 283, 28303, 736, 356, 283, 5362, 772, 13, 12820, 13, 9207, 25, 14, 16, 297, 272, 283, 28303, 20125, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 9207, 25, 14, 16, 297, 272, 283, 6821, 736, 356, 283, 5362, 86, 23, 75, 13, 12820, 13, 6821, 736, 18, 14, 16, 297, 272, 283, 6821, 736, 14, 20125, 356, 283, 73, 8040, 13, 12820, 13, 6821, 736, 18, 14, 16, 297, 272, 283, 571, 2723, 86, 736, 356, 283, 5362, 772, 13, 12820, 13, 6993, 736, 25, 297, 272, 283, 571, 2723, 86, 736, 14, 20125, 356, 283, 88, 1184, 63, 772, 13, 12820, 13, 6993, 736, 25, 297, 199, 93, 199, 199, 13525, 19359, 63, 12683, 8406, 51, 275, 469, 272, 283, 2640, 14591, 5229, 316, 297, 272, 283, 18688, 5502, 297, 272, 283, 5402, 45, 998, 1311, 23685, 297, 272, 283, 9654, 51, 496, 2284, 297, 272, 283, 6741, 7004, 39, 11322, 297, 272, 283, 27598, 19330, 297, 272, 283, 607, 4715, 2209, 297, 272, 283, 12576, 3160, 27907, 297, 272, 283, 12576, 6849, 297, 272, 283, 43, 281, 23920, 297, 272, 283, 14127, 297, 272, 283, 19534, 297, 272, 283, 2209, 297, 272, 283, 48, 3298, 35, 297, 272, 283, 18060, 2610, 297, 272, 283, 19229, 14591, 297, 272, 283, 19684, 1366, 297, 272, 283, 50, 10972, 297, 272, 283, 5229, 316, 297, 272, 283, 10878, 15803, 297, 272, 283, 3989, 297, 272, 283, 15189, 297, 272, 283, 9166, 9400, 1945, 29765, 297, 272, 283, 6046, 4728, 297, 199, 93, 421, 199, 318, 1218, 63, 2087, 837, 272, 2884, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 566, 272, 2884, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 1579, 63, 515, 9, 272, 849, 63, 13215, 63, 2655, 63, 396, 275, 1543, 83, 15, 13215, 13, 2655, 13, 396, 7, 450, 334, 1579, 63, 515, 9, 339, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 11772, 83, 8439, 16666, 2949, 15913, 367, 282, 859, 503, 15610, 401, 267, 13205, 534, 13215, 13, 1246, 13, 2724, 14, 647, 297, 267, 4503, 29342, 6595, 9, 83, 446, 83, 284, 9339, 736, 358, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 578, 297, 1720, 534, 1918, 859, 536, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 74, 297, 2850, 6920, 297, 730, 29, 442, 12, 717, 1720, 534, 1918, 1329, 402, 9861, 9643, 370, 5341, 358, 272, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 9277, 297, 9237, 534, 7386, 717, 1415, 29, 549, 12, 1720, 628, 1918, 15610, 83, 370, 675, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1375, 297, 1720, 628, 1918, 1347, 19671, 370, 675, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 73, 297, 2850, 13215, 13, 2655, 13, 396, 297, 717, 849, 29, 885, 63, 13215, 63, 2655, 63, 396, 12, 717, 1720, 628, 1918, 16275, 13, 2655, 13, 396, 7286, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 13, 694, 297, 849, 29, 736, 14, 9458, 1062, 717, 1720, 534, 6231, 370, 1314, 314, 1072, 911, 506, 19515, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 81, 297, 2850, 10243, 297, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 18334, 16116, 402, 2004, 3788, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 5375, 2402, 2556, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 38, 297, 2850, 4857, 13, 694, 297, 1595, 534, 740, 297, 717, 1720, 534, 1123, 4722, 10059, 6602, 358, 272, 1798, 14, 525, 63, 2094, 3654, 20052, 800, 297, 2850, 2253, 13, 4857, 13, 694, 297, 717, 1595, 534, 740, 297, 717, 1720, 534, 1123, 4722, 2656, 10059, 6602, 358, 272, 1798, 14, 525, 63, 2094, 3654, 41, 297, 2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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 ]
geodynamics/burnman
tests/test_planet.py
2
1989
from __future__ import absolute_import import unittest import os import sys sys.path.insert(1, os.path.abspath('..')) import warnings import burnman from burnman import minerals from burnman import seismic from burnman.planet import Planet from burnman.layer import Layer from burnman import mineral_helpers as helpers from util import BurnManTest import numpy as np def make_simple_planet(): core = Layer("core", np.linspace(0.e3,3480.e3,10)) core.set_material(burnman.minerals.other.Liquid_Fe_Anderson()) core.set_temperature_mode('user-defined', temperatures= 300.*np.ones_like(core.radii)) mantle = Layer("mantle", np.linspace(3480.e3, 6371.e3, 10)) mantle.set_material(burnman.minerals.SLB_2011.mg_bridgmanite()) mantle.set_temperature_mode('adiabatic', temperature_top = 1200) myplanet = Planet('earth_like',[core, mantle]) myplanet.make() return myplanet, core, mantle class test_planet(BurnManTest): def test_planet_1(self): myplanet, core, mantle = make_simple_planet() assert(myplanet.get_layer("core") == core) assert(myplanet.get_layer_by_radius(2000.e3) == core) assert(myplanet.get_layer_by_radius(4000.e3) == mantle) assert(myplanet.get_layer_by_radius(5000.e3) == mantle) self.assertFloatEqual(myplanet.pressure[0], 445219931774.84, tol=1.e-4) def test_sort_layers(self): myplanet, core, mantle = make_simple_planet() assert(myplanet.layers == [core, mantle]) def test_temperature(self): myplanet, core, mantle = make_simple_planet() self.assertArraysAlmostEqual(mantle.S, [mantle.S[-1] for S in mantle.S]) def test_evaluate(self): myplanet, core, mantle = make_simple_planet() alpha, rho = myplanet.evaluate(['alpha', 'rho'], myplanet.radii) self.assertFloatEqual(alpha[-2], myplanet.alpha[-2]) self.assertFloatEqual(rho[-2], myplanet.density[-2]) if __name__ == '__main__': unittest.main()
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 2882, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 646, 3598, 199, 199, 646, 330, 349, 1237, 199, 504, 330, 349, 1237, 492, 1748, 281, 2551, 199, 504, 330, 349, 1237, 492, 542, 374, 15003, 199, 504, 330, 349, 1237, 14, 28391, 492, 32427, 386, 199, 504, 330, 349, 1237, 14, 1897, 492, 11915, 199, 504, 330, 349, 1237, 492, 1748, 281, 279, 63, 7546, 465, 10897, 199, 199, 504, 4884, 492, 699, 349, 2395, 774, 199, 646, 2680, 465, 980, 421, 199, 318, 1852, 63, 4129, 63, 28391, 837, 272, 6170, 275, 11915, 480, 1018, 401, 980, 14, 11649, 8, 16, 14, 69, 19, 12, 1082, 1257, 14, 69, 19, 12, 709, 430, 272, 6170, 14, 409, 63, 9820, 8, 30736, 1237, 14, 827, 281, 2551, 14, 1848, 14, 13009, 28398, 63, 3456, 63, 2493, 424, 834, 1012, 272, 6170, 14, 409, 63, 12954, 63, 632, 360, 751, 13, 4037, 297, 2388, 281, 2093, 29, 9601, 2795, 1590, 14, 4548, 63, 2930, 8, 1018, 14, 12841, 73, 430, 339, 333, 867, 274, 275, 11915, 480, 77, 867, 274, 401, 980, 14, 11649, 8, 1082, 1257, 14, 69, 19, 12, 1227, 16124, 14, 69, 19, 12, 1616, 430, 272, 333, 867, 274, 14, 409, 63, 9820, 8, 30736, 1237, 14, 827, 281, 2551, 14, 4929, 34, 63, 8128, 14, 6649, 63, 14601, 71, 1237, 1175, 1012, 272, 333, 867, 274, 14, 409, 63, 12954, 63, 632, 360, 65, 328, 20338, 764, 297, 14843, 63, 2119, 275, 413, 1840, 9, 272, 3002, 28391, 275, 32427, 386, 360, 2210, 273, 63, 2930, 23993, 1018, 12, 333, 867, 274, 566, 272, 3002, 28391, 14, 1875, 342, 272, 372, 3002, 28391, 12, 6170, 12, 333, 867, 274, 421, 199, 533, 511, 63, 28391, 8, 34, 349, 2395, 774, 304, 272, 347, 511, 63, 28391, 63, 17, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 480, 1018, 531, 508, 6170, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 8269, 14, 69, 19, 9, 508, 6170, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 23641, 14, 69, 19, 9, 508, 333, 867, 274, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 13128, 14, 69, 19, 9, 508, 333, 867, 274, 9, 267, 291, 14, 479, 5136, 591, 8, 1662, 28391, 14, 21999, 59, 16, 467, 841, 2322, 2025, 1020, 2192, 15464, 14, 1349, 12, 9561, 29, 17, 14, 69, 13, 20, 9, 339, 347, 511, 63, 3191, 63, 4359, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 702, 8, 1662, 28391, 14, 4359, 508, 359, 1018, 12, 333, 867, 274, 566, 339, 347, 511, 63, 12954, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 291, 14, 479, 29033, 7331, 8, 77, 867, 274, 14, 51, 12, 359, 77, 867, 274, 14, 51, 1988, 17, 61, 367, 428, 315, 333, 867, 274, 14, 51, 566, 339, 347, 511, 63, 7383, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 5131, 12, 17908, 275, 3002, 28391, 14, 7383, 2941, 4468, 297, 283, 10412, 995, 3002, 28391, 14, 12841, 73, 9, 267, 291, 14, 479, 5136, 591, 8, 4468, 1988, 18, 467, 3002, 28391, 14, 4468, 1988, 18, 566, 267, 291, 14, 479, 5136, 591, 8, 10412, 1988, 18, 467, 3002, 28391, 14, 15669, 1988, 18, 566, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 2882, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 646, 3598, 199, 199, 646, 330, 349, 1237, 199, 504, 330, 349, 1237, 492, 1748, 281, 2551, 199, 504, 330, 349, 1237, 492, 542, 374, 15003, 199, 504, 330, 349, 1237, 14, 28391, 492, 32427, 386, 199, 504, 330, 349, 1237, 14, 1897, 492, 11915, 199, 504, 330, 349, 1237, 492, 1748, 281, 279, 63, 7546, 465, 10897, 199, 199, 504, 4884, 492, 699, 349, 2395, 774, 199, 646, 2680, 465, 980, 421, 199, 318, 1852, 63, 4129, 63, 28391, 837, 272, 6170, 275, 11915, 480, 1018, 401, 980, 14, 11649, 8, 16, 14, 69, 19, 12, 1082, 1257, 14, 69, 19, 12, 709, 430, 272, 6170, 14, 409, 63, 9820, 8, 30736, 1237, 14, 827, 281, 2551, 14, 1848, 14, 13009, 28398, 63, 3456, 63, 2493, 424, 834, 1012, 272, 6170, 14, 409, 63, 12954, 63, 632, 360, 751, 13, 4037, 297, 2388, 281, 2093, 29, 9601, 2795, 1590, 14, 4548, 63, 2930, 8, 1018, 14, 12841, 73, 430, 339, 333, 867, 274, 275, 11915, 480, 77, 867, 274, 401, 980, 14, 11649, 8, 1082, 1257, 14, 69, 19, 12, 1227, 16124, 14, 69, 19, 12, 1616, 430, 272, 333, 867, 274, 14, 409, 63, 9820, 8, 30736, 1237, 14, 827, 281, 2551, 14, 4929, 34, 63, 8128, 14, 6649, 63, 14601, 71, 1237, 1175, 1012, 272, 333, 867, 274, 14, 409, 63, 12954, 63, 632, 360, 65, 328, 20338, 764, 297, 14843, 63, 2119, 275, 413, 1840, 9, 272, 3002, 28391, 275, 32427, 386, 360, 2210, 273, 63, 2930, 23993, 1018, 12, 333, 867, 274, 566, 272, 3002, 28391, 14, 1875, 342, 272, 372, 3002, 28391, 12, 6170, 12, 333, 867, 274, 421, 199, 533, 511, 63, 28391, 8, 34, 349, 2395, 774, 304, 272, 347, 511, 63, 28391, 63, 17, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 480, 1018, 531, 508, 6170, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 8269, 14, 69, 19, 9, 508, 6170, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 23641, 14, 69, 19, 9, 508, 333, 867, 274, 9, 267, 702, 8, 1662, 28391, 14, 362, 63, 1897, 63, 991, 63, 8017, 8, 13128, 14, 69, 19, 9, 508, 333, 867, 274, 9, 267, 291, 14, 479, 5136, 591, 8, 1662, 28391, 14, 21999, 59, 16, 467, 841, 2322, 2025, 1020, 2192, 15464, 14, 1349, 12, 9561, 29, 17, 14, 69, 13, 20, 9, 339, 347, 511, 63, 3191, 63, 4359, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 702, 8, 1662, 28391, 14, 4359, 508, 359, 1018, 12, 333, 867, 274, 566, 339, 347, 511, 63, 12954, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 291, 14, 479, 29033, 7331, 8, 77, 867, 274, 14, 51, 12, 359, 77, 867, 274, 14, 51, 1988, 17, 61, 367, 428, 315, 333, 867, 274, 14, 51, 566, 339, 347, 511, 63, 7383, 8, 277, 304, 267, 3002, 28391, 12, 6170, 12, 333, 867, 274, 275, 1852, 63, 4129, 63, 28391, 342, 267, 5131, 12, 17908, 275, 3002, 28391, 14, 7383, 2941, 4468, 297, 283, 10412, 995, 3002, 28391, 14, 12841, 73, 9, 267, 291, 14, 479, 5136, 591, 8, 4468, 1988, 18, 467, 3002, 28391, 14, 4468, 1988, 18, 566, 267, 291, 14, 479, 5136, 591, 8, 10412, 1988, 18, 467, 3002, 28391, 14, 15669, 1988, 18, 566, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0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 0, 0 ]
mdaif/olympia
apps/versions/feeds.py
13
3897
from django.contrib.syndication.views import Feed from django.shortcuts import get_object_or_404 from django.utils.feedgenerator import DefaultFeed from jingo.helpers import datetime from tower import ugettext as _ import amo from amo.urlresolvers import reverse from amo.helpers import absolutify, url from amo.utils import urlparams from addons.models import Addon from versions.views import PER_PAGE class PagedFeed(DefaultFeed): page = None def add_page_relation(self, handler, rel, page): page = None if page == 1 else page url = urlparams(self.feed['feed_url'], page=page) handler.addQuickElement('atom:link', None, {'rel': rel, 'href': url}) def add_root_elements(self, handler): # set feed_url to current page page = None if self.page.number == 1 else self.page.number self.feed['feed_url'] = urlparams(self.feed['feed_url'], page=page) DefaultFeed.add_root_elements(self, handler) # http://tools.ietf.org/html/rfc5005#section-3 self.add_page_relation(handler, 'first', 1) if self.page.has_previous(): self.add_page_relation(handler, 'previous', self.page.previous_page_number()) if self.page.has_next(): self.add_page_relation(handler, 'next', self.page.next_page_number()) self.add_page_relation(handler, 'last', self.page.paginator.num_pages) class VersionsRss(Feed): feed_type = PagedFeed addon = None def get_object(self, request, addon_id, beta=False): """Get the Addon for which we are about to output the RSS feed of it Versions""" qs = Addon.objects self.addon = get_object_or_404(qs.id_or_slug(addon_id) & qs.valid()) status_list = (amo.STATUS_BETA,) if beta else amo.VALID_STATUSES items_qs = (self.addon.versions .filter(files__status__in=status_list) .distinct().order_by('-created')) self.feed_type.page = amo.utils.paginate(request, items_qs, PER_PAGE) return self.addon def title(self, addon): """Title for the feed""" return _(u'%s Version History' % addon.name) def link(self, addon): """Link for the feed""" return absolutify(url('home')) def description(self, addon): """Description for the feed""" return _('Version History with Changelogs') def items(self, obj): """Return the Versions for this Addon to be output as RSS <item>'s""" return self.feed_type.page def item_link(self, version): """Link for a particular version (<item><link>)""" return absolutify(version.get_url_path()) def item_title(self, version): """Title for particular version (<item><title>)""" # L10n: This is the Title for this Version of the Addon return u'{name} {version} - {created}'.format( name=self.addon.name, version=version.version, created=datetime(version.created)) def item_description(self, version): """Description for particular version (<item><description>)""" return version.releasenotes def item_guid(self, version): """Guid for a particuar version (<item><guid>)""" url = absolutify(reverse('addons.versions', args=[version.addon_id])) return "%s#version-%s" % (url, version.version) def item_author_name(self, version): """Author for a particuar version (<item><dc:creator>)""" # @todo should be able to output a <dc:creator for each author if version.addon.listed_authors: return version.addon.listed_authors[0].name else: return '' def item_pubdate(self, version): """Pubdate for a particuar version (<item><pubDate>)""" return version.created
bsd-3-clause
[ 504, 1639, 14, 2828, 14, 9466, 21171, 14, 4196, 492, 16261, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 1208, 14, 3871, 4679, 492, 3758, 7658, 199, 504, 1335, 316, 79, 14, 7546, 492, 2197, 199, 199, 504, 18915, 492, 10366, 465, 485, 199, 199, 646, 30235, 199, 504, 30235, 14, 16522, 492, 3837, 199, 504, 30235, 14, 7546, 492, 2853, 393, 935, 1399, 12, 1166, 199, 504, 30235, 14, 1208, 492, 1166, 1162, 199, 199, 504, 21293, 14, 992, 492, 29366, 199, 504, 5459, 14, 4196, 492, 13873, 63, 12898, 421, 199, 533, 510, 6028, 7658, 8, 2698, 7658, 304, 339, 2034, 275, 488, 339, 347, 1050, 63, 1606, 63, 5690, 8, 277, 12, 3016, 12, 4668, 12, 2034, 304, 267, 2034, 275, 488, 340, 2034, 508, 413, 587, 2034, 267, 1166, 275, 1166, 1162, 8, 277, 14, 3871, 459, 3871, 63, 633, 995, 2034, 29, 1606, 9, 267, 3016, 14, 525, 19684, 2162, 360, 4188, 26, 1073, 297, 488, 12, 791, 3369, 356, 4668, 12, 283, 6399, 356, 1166, 1552, 339, 347, 1050, 63, 1231, 63, 5527, 8, 277, 12, 3016, 304, 267, 327, 663, 4733, 63, 633, 370, 1453, 2034, 267, 2034, 275, 488, 340, 291, 14, 1606, 14, 1955, 508, 413, 587, 291, 14, 1606, 14, 1955, 267, 291, 14, 3871, 459, 3871, 63, 633, 418, 275, 1166, 1162, 8, 277, 14, 3871, 459, 3871, 63, 633, 995, 2034, 29, 1606, 9, 267, 3758, 7658, 14, 525, 63, 1231, 63, 5527, 8, 277, 12, 3016, 9, 398, 327, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 5783, 21, 3, 2792, 13, 19, 267, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2246, 297, 413, 9, 267, 340, 291, 14, 1606, 14, 1989, 63, 6352, 837, 288, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 6352, 297, 3521, 291, 14, 1606, 14, 6352, 63, 1606, 63, 1955, 1012, 267, 340, 291, 14, 1606, 14, 1989, 63, 2184, 837, 288, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2184, 297, 3521, 291, 14, 1606, 14, 2184, 63, 1606, 63, 1955, 1012, 267, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2019, 297, 291, 14, 1606, 14, 22073, 14, 1507, 63, 5856, 9, 421, 199, 533, 5444, 1356, 50, 385, 8, 7658, 304, 339, 4733, 63, 466, 275, 510, 6028, 7658, 272, 13553, 275, 488, 339, 347, 664, 63, 785, 8, 277, 12, 1056, 12, 13553, 63, 344, 12, 8201, 29, 797, 304, 267, 408, 1002, 314, 29366, 367, 1314, 781, 787, 3595, 370, 1072, 1779, 314, 30331, 4733, 402, 652, 5444, 1356, 624, 267, 6377, 275, 29366, 14, 1462, 267, 291, 14, 9291, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 6177, 14, 344, 63, 269, 63, 5464, 8, 9291, 63, 344, 9, 1253, 6377, 14, 1078, 1012, 398, 2004, 63, 513, 275, 334, 4393, 14, 6305, 63, 34, 15808, 4258, 340, 8201, 587, 30235, 14, 5600, 63, 6305, 654, 267, 2974, 63, 6177, 275, 334, 277, 14, 9291, 14, 6234, 490, 1275, 1541, 8, 1725, 363, 1205, 363, 262, 29, 1205, 63, 513, 9, 490, 1275, 12926, 1252, 1648, 63, 991, 3654, 3966, 1333, 267, 291, 14, 3871, 63, 466, 14, 1606, 275, 30235, 14, 1208, 14, 30979, 8, 1069, 12, 2974, 63, 6177, 12, 13873, 63, 12898, 9, 267, 372, 291, 14, 9291, 339, 347, 2538, 8, 277, 12, 13553, 304, 267, 408, 6888, 367, 314, 4733, 624, 267, 372, 12561, 85, 5956, 83, 3394, 27829, 7, 450, 13553, 14, 354, 9, 339, 347, 2142, 8, 277, 12, 13553, 304, 267, 408, 3834, 367, 314, 4733, 624, 267, 372, 2853, 393, 935, 1399, 8, 633, 360, 4219, 1333, 339, 347, 1369, 8, 277, 12, 13553, 304, 267, 408, 5831, 367, 314, 4733, 624, 267, 372, 4018, 3353, 27829, 543, 7743, 7270, 358, 339, 347, 2974, 8, 277, 12, 1559, 304, 267, 408, 1767, 314, 5444, 1356, 367, 642, 29366, 370, 506, 1072, 465, 30331, 665, 1053, 3524, 83, 624, 267, 372, 291, 14, 3871, 63, 466, 14, 1606, 339, 347, 1242, 63, 1073, 8, 277, 12, 1015, 304, 267, 408, 3834, 367, 282, 6770, 1015, 8642, 1053, 2535, 1073, 30, 9471, 267, 372, 2853, 393, 935, 1399, 8, 1023, 14, 362, 63, 633, 63, 515, 1012, 339, 347, 1242, 63, 1213, 8, 277, 12, 1015, 304, 267, 408, 6888, 367, 6770, 1015, 8642, 1053, 2535, 1213, 30, 9471, 267, 327, 491, 709, 78, 26, 961, 365, 314, 16881, 367, 642, 3394, 402, 314, 29366, 267, 372, 399, 16019, 354, 93, 469, 1023, 93, 446, 469, 3966, 5285, 908, 8, 288, 536, 29, 277, 14, 9291, 14, 354, 12, 1015, 29, 1023, 14, 1023, 12, 288, 2737, 29, 2083, 8, 1023, 14, 3966, 430, 339, 347, 1242, 63, 1802, 8, 277, 12, 1015, 304, 267, 408, 5831, 367, 6770, 1015, 8642, 1053, 2535, 1802, 30, 9471, 267, 372, 1015, 14, 3221, 5983, 339, 347, 1242, 63, 9473, 8, 277, 12, 1015, 304, 267, 408, 18834, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 9473, 30, 9471, 267, 1166, 275, 2853, 393, 935, 1399, 8, 4471, 360, 10788, 14, 6234, 297, 1249, 1524, 1023, 14, 9291, 63, 344, 2459, 267, 372, 2071, 83, 3, 1023, 3295, 83, 2, 450, 334, 633, 12, 1015, 14, 1023, 9, 339, 347, 1242, 63, 2502, 63, 354, 8, 277, 12, 1015, 304, 267, 408, 5949, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 3833, 26, 9986, 30, 9471, 267, 327, 768, 11396, 1077, 506, 7688, 370, 1072, 282, 665, 3833, 26, 9986, 367, 1924, 4132, 267, 340, 1015, 14, 9291, 14, 15023, 63, 8149, 26, 288, 372, 1015, 14, 9291, 14, 15023, 63, 8149, 59, 16, 1055, 354, 267, 587, 26, 288, 372, 2125, 339, 347, 1242, 63, 30218, 8, 277, 12, 1015, 304, 267, 408, 18060, 602, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 5645, 2506, 30, 9471, 267, 372, 1015, 14, 3966, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 2828, 14, 9466, 21171, 14, 4196, 492, 16261, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 1208, 14, 3871, 4679, 492, 3758, 7658, 199, 504, 1335, 316, 79, 14, 7546, 492, 2197, 199, 199, 504, 18915, 492, 10366, 465, 485, 199, 199, 646, 30235, 199, 504, 30235, 14, 16522, 492, 3837, 199, 504, 30235, 14, 7546, 492, 2853, 393, 935, 1399, 12, 1166, 199, 504, 30235, 14, 1208, 492, 1166, 1162, 199, 199, 504, 21293, 14, 992, 492, 29366, 199, 504, 5459, 14, 4196, 492, 13873, 63, 12898, 421, 199, 533, 510, 6028, 7658, 8, 2698, 7658, 304, 339, 2034, 275, 488, 339, 347, 1050, 63, 1606, 63, 5690, 8, 277, 12, 3016, 12, 4668, 12, 2034, 304, 267, 2034, 275, 488, 340, 2034, 508, 413, 587, 2034, 267, 1166, 275, 1166, 1162, 8, 277, 14, 3871, 459, 3871, 63, 633, 995, 2034, 29, 1606, 9, 267, 3016, 14, 525, 19684, 2162, 360, 4188, 26, 1073, 297, 488, 12, 791, 3369, 356, 4668, 12, 283, 6399, 356, 1166, 1552, 339, 347, 1050, 63, 1231, 63, 5527, 8, 277, 12, 3016, 304, 267, 327, 663, 4733, 63, 633, 370, 1453, 2034, 267, 2034, 275, 488, 340, 291, 14, 1606, 14, 1955, 508, 413, 587, 291, 14, 1606, 14, 1955, 267, 291, 14, 3871, 459, 3871, 63, 633, 418, 275, 1166, 1162, 8, 277, 14, 3871, 459, 3871, 63, 633, 995, 2034, 29, 1606, 9, 267, 3758, 7658, 14, 525, 63, 1231, 63, 5527, 8, 277, 12, 3016, 9, 398, 327, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 5783, 21, 3, 2792, 13, 19, 267, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2246, 297, 413, 9, 267, 340, 291, 14, 1606, 14, 1989, 63, 6352, 837, 288, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 6352, 297, 3521, 291, 14, 1606, 14, 6352, 63, 1606, 63, 1955, 1012, 267, 340, 291, 14, 1606, 14, 1989, 63, 2184, 837, 288, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2184, 297, 3521, 291, 14, 1606, 14, 2184, 63, 1606, 63, 1955, 1012, 267, 291, 14, 525, 63, 1606, 63, 5690, 8, 2232, 12, 283, 2019, 297, 291, 14, 1606, 14, 22073, 14, 1507, 63, 5856, 9, 421, 199, 533, 5444, 1356, 50, 385, 8, 7658, 304, 339, 4733, 63, 466, 275, 510, 6028, 7658, 272, 13553, 275, 488, 339, 347, 664, 63, 785, 8, 277, 12, 1056, 12, 13553, 63, 344, 12, 8201, 29, 797, 304, 267, 408, 1002, 314, 29366, 367, 1314, 781, 787, 3595, 370, 1072, 1779, 314, 30331, 4733, 402, 652, 5444, 1356, 624, 267, 6377, 275, 29366, 14, 1462, 267, 291, 14, 9291, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 6177, 14, 344, 63, 269, 63, 5464, 8, 9291, 63, 344, 9, 1253, 6377, 14, 1078, 1012, 398, 2004, 63, 513, 275, 334, 4393, 14, 6305, 63, 34, 15808, 4258, 340, 8201, 587, 30235, 14, 5600, 63, 6305, 654, 267, 2974, 63, 6177, 275, 334, 277, 14, 9291, 14, 6234, 490, 1275, 1541, 8, 1725, 363, 1205, 363, 262, 29, 1205, 63, 513, 9, 490, 1275, 12926, 1252, 1648, 63, 991, 3654, 3966, 1333, 267, 291, 14, 3871, 63, 466, 14, 1606, 275, 30235, 14, 1208, 14, 30979, 8, 1069, 12, 2974, 63, 6177, 12, 13873, 63, 12898, 9, 267, 372, 291, 14, 9291, 339, 347, 2538, 8, 277, 12, 13553, 304, 267, 408, 6888, 367, 314, 4733, 624, 267, 372, 12561, 85, 5956, 83, 3394, 27829, 7, 450, 13553, 14, 354, 9, 339, 347, 2142, 8, 277, 12, 13553, 304, 267, 408, 3834, 367, 314, 4733, 624, 267, 372, 2853, 393, 935, 1399, 8, 633, 360, 4219, 1333, 339, 347, 1369, 8, 277, 12, 13553, 304, 267, 408, 5831, 367, 314, 4733, 624, 267, 372, 4018, 3353, 27829, 543, 7743, 7270, 358, 339, 347, 2974, 8, 277, 12, 1559, 304, 267, 408, 1767, 314, 5444, 1356, 367, 642, 29366, 370, 506, 1072, 465, 30331, 665, 1053, 3524, 83, 624, 267, 372, 291, 14, 3871, 63, 466, 14, 1606, 339, 347, 1242, 63, 1073, 8, 277, 12, 1015, 304, 267, 408, 3834, 367, 282, 6770, 1015, 8642, 1053, 2535, 1073, 30, 9471, 267, 372, 2853, 393, 935, 1399, 8, 1023, 14, 362, 63, 633, 63, 515, 1012, 339, 347, 1242, 63, 1213, 8, 277, 12, 1015, 304, 267, 408, 6888, 367, 6770, 1015, 8642, 1053, 2535, 1213, 30, 9471, 267, 327, 491, 709, 78, 26, 961, 365, 314, 16881, 367, 642, 3394, 402, 314, 29366, 267, 372, 399, 16019, 354, 93, 469, 1023, 93, 446, 469, 3966, 5285, 908, 8, 288, 536, 29, 277, 14, 9291, 14, 354, 12, 1015, 29, 1023, 14, 1023, 12, 288, 2737, 29, 2083, 8, 1023, 14, 3966, 430, 339, 347, 1242, 63, 1802, 8, 277, 12, 1015, 304, 267, 408, 5831, 367, 6770, 1015, 8642, 1053, 2535, 1802, 30, 9471, 267, 372, 1015, 14, 3221, 5983, 339, 347, 1242, 63, 9473, 8, 277, 12, 1015, 304, 267, 408, 18834, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 9473, 30, 9471, 267, 1166, 275, 2853, 393, 935, 1399, 8, 4471, 360, 10788, 14, 6234, 297, 1249, 1524, 1023, 14, 9291, 63, 344, 2459, 267, 372, 2071, 83, 3, 1023, 3295, 83, 2, 450, 334, 633, 12, 1015, 14, 1023, 9, 339, 347, 1242, 63, 2502, 63, 354, 8, 277, 12, 1015, 304, 267, 408, 5949, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 3833, 26, 9986, 30, 9471, 267, 327, 768, 11396, 1077, 506, 7688, 370, 1072, 282, 665, 3833, 26, 9986, 367, 1924, 4132, 267, 340, 1015, 14, 9291, 14, 15023, 63, 8149, 26, 288, 372, 1015, 14, 9291, 14, 15023, 63, 8149, 59, 16, 1055, 354, 267, 587, 26, 288, 372, 2125, 339, 347, 1242, 63, 30218, 8, 277, 12, 1015, 304, 267, 408, 18060, 602, 367, 282, 623, 764, 85, 285, 1015, 221, 8642, 1053, 2535, 5645, 2506, 30, 9471, 267, 372, 1015, 14, 3966, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1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ansible
lib/ansible/modules/windows/win_find.py
22
10385
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Ansible, inc # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: win_find version_added: "2.3" short_description: return a list of files based on specific criteria description: - Return a list of files based on specified criteria. - Multiple criteria are AND'd together. - For non-Windows targets, use the M(find) module instead. options: age: description: - Select files or folders whose age is equal to or greater than the specified time. Use a negative age to find files equal to or less than the specified time. You can choose seconds, minutes, hours, days or weeks by specifying the first letter of an of those words (e.g., "2s", "10d", 1w"). required: false age_stamp: description: - Choose the file property against which we compare C(age). The default attribute we compare with is the last modification time. required: false default: mtime choices: ['atime', 'mtime', 'ctime'] checksum_algorithm: description: - Algorithm to determine the checksum of a file. Will throw an error if the host is unable to use specified algorithm. required: false default: sha1 choices: ['md5', 'sha1', 'sha256', 'sha384', 'sha512'] file_type: description: Type of file to search for required: false default: file choices: ['file', 'directory'] follow: description: - Set this to true to follow symlinks in the path. This needs to be used in conjunction with C(recurse). required: false default: false choices: ['true', 'false'] get_checksum: description: - Whether to return a checksum of the file in the return info (default sha1), use C(checksum_algorithm) to change from the default. required: false default: true choices: ['true', 'false'] hidden: description: Set this to include hidden files or folders required: false default: false choices: ['true', 'false'] paths: description: - List of paths of directories to search for files or folders in. This can be supplied as a single path or a list of paths. required: true patterns: description: - One or more (powershell or regex) patterns to compare filenames with. The type of pattern matching is controlled by C(use_regex) option. The patterns retrict the list of files or folders to be returned based on the filenames. For a file to be matched it only has to match with one pattern in a list provided. required: false recurse: description: - Will recursively descend into the directory looking for files or folders required: false default: false choices: ['true', 'false'] size: description: - Select files or folders whose size is equal to or greater than the specified size. Use a negative value to find files equal to or less than the specified size. You can specify the size with a suffix of the byte type i.e. kilo = k, mega = m... Size is not evaluated for symbolic links. required: false default: false use_regex: description: - Will set patterns to run as a regex check if true required: false default: false choices: ['true', 'false'] notes: - For non-Windows targets, use the M(find) module instead. author: "Jordan Borean (@jborean93)" ''' EXAMPLES = r''' # Find files in path - win_find: paths: D:\temp # Find hidden files in path - win_find: paths: D:\temp hidden: True # Find files in multiple paths - win_find: paths: ['C:\temp', 'D:\temp'] # Find files in directory while searching recursively - win_find: paths: D:\temp recurse: True # Find files in directory while following symlinks - win_find: paths: D:\temp recurse: True follow: True # Find files with .log and .out extension using powershell wildcards - win_find: paths: D:\temp patterns: ['*.log', '*.out'] # Find files in path based on regex pattern - win_find: paths: D:\temp patterns: 'out_\d{8}-\d{6}.log' # Find files older than 1 day - win_find: paths: D:\temp age: 86400 # Find files older than 1 day based on create time - win_find: paths: D:\temp age: 86400 age_stamp: ctime # Find files older than 1 day with unit syntax - win_find: paths: D:\temp age: 1d # Find files newer than 1 hour - win_find: paths: D:\temp age: -3600 # Find files newer than 1 hour with unit syntax - win_find: paths: D:\temp age: -1h # Find files larger than 1MB - win_find: paths: D:\temp size: 1048576 # Find files larger than 1GB with unit syntax - win_find: paths: D:\temp size: 1g # Find files smaller than 1MB - win_find: paths: D:\temp size: -1048576 # Find files smaller than 1GB with unit syntax - win_find: paths: D:\temp size: -1g # Find folders/symlinks in multiple paths - win_find: paths: ['C:\temp', 'D:\temp'] file_type: directory # Find files and return SHA256 checksum of files found - win_find: paths: C:\temp get_checksum: True checksum_algorithm: sha256 # Find files and do not return the checksum - win_find: path: C:\temp get_checksum: False ''' RETURN = r''' changed: description: Whether anything was chagned returned: always type: boolean sample: True examined: description: The number of files/folders that was checked returned: always type: int sample: 10 matched: description: The number of files/folders that match the criteria returned: always type: int sample: 2 files: description: Information on the files/folders that match the criteria returned as a list of dictionary elements for each file matched returned: success type: complex contains: attributes: description: attributes of the file at path in raw form returned: success, path exists type: string sample: "Archive, Hidden" checksum: description: The checksum of a file based on checksum_algorithm specified returned: success, path exists, path is a file, get_checksum == True type: string sample: 09cb79e8fc7453c84a07f644e441fd81623b7f98 creationtime: description: the create time of the file represented in seconds since epoch returned: success, path exists type: float sample: 1477984205.15 extension: description: the extension of the file at path returned: success, path exists, path is a file type: string sample: ".ps1" isarchive: description: if the path is ready for archiving or not returned: success, path exists type: boolean sample: True isdir: description: if the path is a directory or not returned: success, path exists type: boolean sample: True ishidden: description: if the path is hidden or not returned: success, path exists type: boolean sample: True islnk: description: if the path is a symbolic link or junction or not returned: success, path exists type: boolean sample: True isreadonly: description: if the path is read only or not returned: success, path exists type: boolean sample: True isshared: description: if the path is shared or not returned: success, path exists type: boolean sample: True lastaccesstime: description: the last access time of the file represented in seconds since epoch returned: success, path exists type: float sample: 1477984205.15 lastwritetime: description: the last modification time of the file represented in seconds since epoch returned: success, path exists type: float sample: 1477984205.15 lnk_source: description: the target of the symbolic link, will return null if not a link or the link is broken return: success, path exists, path is a symbolic link type: string sample: C:\temp owner: description: the owner of the file returned: success, path exists type: string sample: BUILTIN\Administrators path: description: the full absolute path to the file returned: success, path exists type: string sample: BUILTIN\Administrators sharename: description: the name of share if folder is shared returned: success, path exists, path is a directory and isshared == True type: string sample: file-share size: description: the size in bytes of a file or folder returned: success, path exists, path is not a link type: int sample: 1024 '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 2622, 12, 12864, 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, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 1623, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 372, 282, 769, 402, 1584, 4079, 641, 2488, 15647, 199, 1802, 26, 272, 446, 1432, 282, 769, 402, 1584, 4079, 641, 2013, 15647, 14, 272, 446, 14326, 15647, 787, 2401, 5121, 10451, 14, 272, 446, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 1623, 9, 859, 3140, 14, 199, 1419, 26, 272, 11437, 26, 267, 1369, 26, 288, 446, 9496, 1584, 503, 16533, 7447, 11437, 365, 4472, 370, 503, 8932, 2419, 1598, 314, 2013, 900, 14, 3645, 282, 6946, 11437, 370, 2342, 1584, 4472, 370, 503, 1598, 6656, 2419, 314, 2013, 900, 14, 2047, 883, 11496, 4696, 12, 9395, 12, 1598, 10857, 12, 7609, 503, 29540, 701, 9176, 314, 1642, 8082, 402, 376, 402, 1598, 5204, 5932, 334, 69, 14, 71, 2020, 298, 18, 83, 401, 298, 709, 68, 401, 413, 87, 3471, 267, 1415, 26, 3055, 272, 11437, 63, 2359, 26, 267, 1369, 26, 288, 446, 29826, 314, 570, 3324, 6169, 1314, 781, 6540, 445, 8, 474, 680, 710, 1598, 849, 2225, 781, 6540, 543, 365, 314, 2061, 7100, 900, 14, 267, 1415, 26, 3055, 267, 849, 26, 15005, 267, 3415, 26, 788, 27867, 297, 283, 8180, 297, 283, 20691, 418, 272, 9040, 63, 8833, 26, 267, 1369, 26, 288, 446, 23823, 370, 6705, 314, 9040, 402, 282, 570, 14, 12823, 7978, 376, 1125, 1598, 340, 314, 1591, 365, 17329, 370, 675, 2013, 5563, 14, 267, 1415, 26, 3055, 267, 849, 26, 7793, 17, 267, 3415, 26, 788, 1064, 21, 297, 283, 4835, 17, 297, 283, 4835, 3912, 297, 283, 4835, 8188, 297, 283, 4835, 7736, 418, 272, 570, 63, 466, 26, 267, 1369, 26, 2434, 402, 570, 370, 2754, 367, 267, 1415, 26, 3055, 267, 849, 26, 570, 267, 3415, 26, 788, 493, 297, 283, 3619, 418, 272, 2035, 26, 267, 1369, 26, 288, 446, 2494, 642, 370, 2549, 370, 2035, 19891, 315, 314, 931, 14, 961, 4839, 370, 1598, 506, 1202, 315, 22888, 543, 445, 8, 25786, 680, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 664, 63, 8928, 26, 267, 1369, 26, 288, 446, 7480, 370, 372, 282, 9040, 402, 314, 570, 315, 314, 372, 2256, 334, 885, 7793, 17, 395, 1598, 675, 445, 8, 8928, 63, 8833, 9, 370, 1570, 687, 314, 849, 14, 267, 1415, 26, 3055, 267, 849, 26, 2549, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 8752, 26, 267, 1369, 26, 2494, 642, 370, 2387, 8752, 1584, 503, 16533, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 3792, 26, 267, 1369, 26, 288, 446, 3820, 402, 3792, 402, 6602, 370, 2754, 367, 1584, 503, 16533, 315, 14, 1598, 961, 883, 506, 6841, 465, 282, 2849, 931, 503, 282, 769, 402, 3792, 14, 267, 1415, 26, 2549, 272, 7970, 26, 267, 1369, 26, 288, 446, 7309, 503, 1655, 334, 5652, 5641, 503, 5163, 9, 7970, 370, 6540, 6203, 1598, 543, 14, 710, 730, 402, 3851, 4877, 365, 22284, 701, 445, 8, 1180, 63, 3821, 9, 1598, 945, 14, 710, 7970, 4444, 319, 314, 769, 402, 1584, 503, 16533, 370, 506, 1598, 2138, 4079, 641, 314, 6203, 14, 2104, 282, 570, 370, 506, 7838, 652, 1598, 1454, 965, 370, 1336, 543, 1373, 3851, 315, 282, 769, 2741, 14, 267, 1415, 26, 3055, 272, 18011, 26, 267, 1369, 26, 288, 446, 12823, 15035, 16336, 1901, 314, 2082, 10023, 367, 1584, 1598, 503, 16533, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 1568, 26, 267, 1369, 26, 288, 446, 9496, 1584, 503, 16533, 7447, 1568, 365, 4472, 370, 503, 8932, 2419, 1598, 314, 2013, 1568, 14, 3645, 282, 6946, 574, 370, 2342, 1584, 4472, 370, 1598, 503, 6656, 2419, 314, 2013, 1568, 14, 2047, 883, 4165, 314, 1568, 543, 1598, 282, 4739, 402, 314, 3696, 730, 284, 14, 69, 14, 1022, 11737, 275, 1022, 12, 562, 5294, 275, 333, 1396, 14579, 365, 440, 1598, 13006, 367, 13673, 6220, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 675, 63, 3821, 26, 267, 1369, 26, 288, 446, 12823, 663, 7970, 370, 1255, 465, 282, 5163, 1104, 340, 2549, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 199, 5983, 26, 272, 446, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 1623, 9, 859, 3140, 14, 199, 2502, 26, 298, 42, 2181, 290, 699, 16293, 8593, 74, 656, 264, 290, 3129, 2924, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 3, 6668, 1584, 315, 931, 199, 13, 4747, 63, 1623, 26, 272, 3792, 26, 577, 3427, 808, 199 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 2622, 12, 12864, 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, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 1623, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 372, 282, 769, 402, 1584, 4079, 641, 2488, 15647, 199, 1802, 26, 272, 446, 1432, 282, 769, 402, 1584, 4079, 641, 2013, 15647, 14, 272, 446, 14326, 15647, 787, 2401, 5121, 10451, 14, 272, 446, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 1623, 9, 859, 3140, 14, 199, 1419, 26, 272, 11437, 26, 267, 1369, 26, 288, 446, 9496, 1584, 503, 16533, 7447, 11437, 365, 4472, 370, 503, 8932, 2419, 1598, 314, 2013, 900, 14, 3645, 282, 6946, 11437, 370, 2342, 1584, 4472, 370, 503, 1598, 6656, 2419, 314, 2013, 900, 14, 2047, 883, 11496, 4696, 12, 9395, 12, 1598, 10857, 12, 7609, 503, 29540, 701, 9176, 314, 1642, 8082, 402, 376, 402, 1598, 5204, 5932, 334, 69, 14, 71, 2020, 298, 18, 83, 401, 298, 709, 68, 401, 413, 87, 3471, 267, 1415, 26, 3055, 272, 11437, 63, 2359, 26, 267, 1369, 26, 288, 446, 29826, 314, 570, 3324, 6169, 1314, 781, 6540, 445, 8, 474, 680, 710, 1598, 849, 2225, 781, 6540, 543, 365, 314, 2061, 7100, 900, 14, 267, 1415, 26, 3055, 267, 849, 26, 15005, 267, 3415, 26, 788, 27867, 297, 283, 8180, 297, 283, 20691, 418, 272, 9040, 63, 8833, 26, 267, 1369, 26, 288, 446, 23823, 370, 6705, 314, 9040, 402, 282, 570, 14, 12823, 7978, 376, 1125, 1598, 340, 314, 1591, 365, 17329, 370, 675, 2013, 5563, 14, 267, 1415, 26, 3055, 267, 849, 26, 7793, 17, 267, 3415, 26, 788, 1064, 21, 297, 283, 4835, 17, 297, 283, 4835, 3912, 297, 283, 4835, 8188, 297, 283, 4835, 7736, 418, 272, 570, 63, 466, 26, 267, 1369, 26, 2434, 402, 570, 370, 2754, 367, 267, 1415, 26, 3055, 267, 849, 26, 570, 267, 3415, 26, 788, 493, 297, 283, 3619, 418, 272, 2035, 26, 267, 1369, 26, 288, 446, 2494, 642, 370, 2549, 370, 2035, 19891, 315, 314, 931, 14, 961, 4839, 370, 1598, 506, 1202, 315, 22888, 543, 445, 8, 25786, 680, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 664, 63, 8928, 26, 267, 1369, 26, 288, 446, 7480, 370, 372, 282, 9040, 402, 314, 570, 315, 314, 372, 2256, 334, 885, 7793, 17, 395, 1598, 675, 445, 8, 8928, 63, 8833, 9, 370, 1570, 687, 314, 849, 14, 267, 1415, 26, 3055, 267, 849, 26, 2549, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 8752, 26, 267, 1369, 26, 2494, 642, 370, 2387, 8752, 1584, 503, 16533, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 3792, 26, 267, 1369, 26, 288, 446, 3820, 402, 3792, 402, 6602, 370, 2754, 367, 1584, 503, 16533, 315, 14, 1598, 961, 883, 506, 6841, 465, 282, 2849, 931, 503, 282, 769, 402, 3792, 14, 267, 1415, 26, 2549, 272, 7970, 26, 267, 1369, 26, 288, 446, 7309, 503, 1655, 334, 5652, 5641, 503, 5163, 9, 7970, 370, 6540, 6203, 1598, 543, 14, 710, 730, 402, 3851, 4877, 365, 22284, 701, 445, 8, 1180, 63, 3821, 9, 1598, 945, 14, 710, 7970, 4444, 319, 314, 769, 402, 1584, 503, 16533, 370, 506, 1598, 2138, 4079, 641, 314, 6203, 14, 2104, 282, 570, 370, 506, 7838, 652, 1598, 1454, 965, 370, 1336, 543, 1373, 3851, 315, 282, 769, 2741, 14, 267, 1415, 26, 3055, 272, 18011, 26, 267, 1369, 26, 288, 446, 12823, 15035, 16336, 1901, 314, 2082, 10023, 367, 1584, 1598, 503, 16533, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 272, 1568, 26, 267, 1369, 26, 288, 446, 9496, 1584, 503, 16533, 7447, 1568, 365, 4472, 370, 503, 8932, 2419, 1598, 314, 2013, 1568, 14, 3645, 282, 6946, 574, 370, 2342, 1584, 4472, 370, 1598, 503, 6656, 2419, 314, 2013, 1568, 14, 2047, 883, 4165, 314, 1568, 543, 1598, 282, 4739, 402, 314, 3696, 730, 284, 14, 69, 14, 1022, 11737, 275, 1022, 12, 562, 5294, 275, 333, 1396, 14579, 365, 440, 1598, 13006, 367, 13673, 6220, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 675, 63, 3821, 26, 267, 1369, 26, 288, 446, 12823, 663, 7970, 370, 1255, 465, 282, 5163, 1104, 340, 2549, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 788, 2052, 297, 283, 3910, 418, 199, 5983, 26, 272, 446, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 1623, 9, 859, 3140, 14, 199, 2502, 26, 298, 42, 2181, 290, 699, 16293, 8593, 74, 656, 264, 290, 3129, 2924, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 3, 6668, 1584, 315, 931, 199, 13, 4747, 63, 1623, 26, 272, 3792, 26, 577, 3427, 808, 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,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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 ]
kswiat/django
tests/model_options/test_tablespaces.py
34
5513
from __future__ import unicode_literals from django.apps import apps from django.conf import settings from django.db import connection from django.core.management.color import no_style from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .models.tablespaces import (Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef) def sql_for_table(model): return '\n'.join(connection.creation.sql_create_model(model, no_style())[0]) def sql_for_index(model): return '\n'.join(connection.creation.sql_indexes_for_model(model, no_style())) # We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings # because they're evaluated when the model class is defined. As a consequence, # @override_settings doesn't work, and the tests depend class TablespacesTests(TestCase): def setUp(self): # The unmanaged models need to be removed after the test in order to # prevent bad interactions with the flush operation in other tests. self._old_models = apps.app_configs['model_options'].models.copy() for model in Article, Authors, Reviewers, Scientist: model._meta.managed = True def tearDown(self): for model in Article, Authors, Reviewers, Scientist: model._meta.managed = False apps.app_configs['model_options'].models = self._old_models apps.all_models['model_options'] = self._old_models apps.clear_cache() def assertNumContains(self, haystack, needle, count): real_count = haystack.count(needle) self.assertEqual(real_count, count, "Found %d instances of '%s', " "expected %d" % (real_count, needle, count)) @skipUnlessDBFeature('supports_tablespaces') def test_tablespace_for_model(self): sql = sql_for_table(Scientist).lower() if settings.DEFAULT_INDEX_TABLESPACE: # 1 for the table self.assertNumContains(sql, 'tbl_tbsp', 1) # 1 for the index on the primary key self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1) else: # 1 for the table + 1 for the index on the primary key self.assertNumContains(sql, 'tbl_tbsp', 2) @skipIfDBFeature('supports_tablespaces') def test_tablespace_ignored_for_model(self): # No tablespace-related SQL self.assertEqual(sql_for_table(Scientist), sql_for_table(ScientistRef)) @skipUnlessDBFeature('supports_tablespaces') def test_tablespace_for_indexed_field(self): sql = sql_for_table(Article).lower() if settings.DEFAULT_INDEX_TABLESPACE: # 1 for the table self.assertNumContains(sql, 'tbl_tbsp', 1) # 1 for the primary key + 1 for the index on code self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 2) else: # 1 for the table + 1 for the primary key + 1 for the index on code self.assertNumContains(sql, 'tbl_tbsp', 3) # 1 for the index on reference self.assertNumContains(sql, 'idx_tbsp', 1) @skipIfDBFeature('supports_tablespaces') def test_tablespace_ignored_for_indexed_field(self): # No tablespace-related SQL self.assertEqual(sql_for_table(Article), sql_for_table(ArticleRef)) @skipUnlessDBFeature('supports_tablespaces') def test_tablespace_for_many_to_many_field(self): sql = sql_for_table(Authors).lower() # The join table of the ManyToManyField goes to the model's tablespace, # and its indexes too, unless DEFAULT_INDEX_TABLESPACE is set. if settings.DEFAULT_INDEX_TABLESPACE: # 1 for the table self.assertNumContains(sql, 'tbl_tbsp', 1) # 1 for the primary key self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1) else: # 1 for the table + 1 for the index on the primary key self.assertNumContains(sql, 'tbl_tbsp', 2) self.assertNumContains(sql, 'idx_tbsp', 0) sql = sql_for_index(Authors).lower() # The ManyToManyField declares no db_tablespace, its indexes go to # the model's tablespace, unless DEFAULT_INDEX_TABLESPACE is set. if settings.DEFAULT_INDEX_TABLESPACE: self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 2) else: self.assertNumContains(sql, 'tbl_tbsp', 2) self.assertNumContains(sql, 'idx_tbsp', 0) sql = sql_for_table(Reviewers).lower() # The join table of the ManyToManyField goes to the model's tablespace, # and its indexes too, unless DEFAULT_INDEX_TABLESPACE is set. if settings.DEFAULT_INDEX_TABLESPACE: # 1 for the table self.assertNumContains(sql, 'tbl_tbsp', 1) # 1 for the primary key self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1) else: # 1 for the table + 1 for the index on the primary key self.assertNumContains(sql, 'tbl_tbsp', 2) self.assertNumContains(sql, 'idx_tbsp', 0) sql = sql_for_index(Reviewers).lower() # The ManyToManyField declares db_tablespace, its indexes go there. self.assertNumContains(sql, 'tbl_tbsp', 0) self.assertNumContains(sql, 'idx_tbsp', 2)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 949, 63, 2487, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 14, 1224, 10749, 492, 334, 7221, 12, 8281, 2891, 12, 6642, 12, 26705, 1192, 12, 272, 16578, 287, 5011, 12, 16578, 287, 5011, 2891, 9, 421, 199, 318, 3875, 63, 509, 63, 1224, 8, 1238, 304, 272, 372, 1557, 78, 1370, 904, 8, 2105, 14, 8782, 14, 3009, 63, 981, 63, 1238, 8, 1238, 12, 12933, 949, 63, 2487, 18756, 16, 566, 421, 199, 318, 3875, 63, 509, 63, 1080, 8, 1238, 304, 272, 372, 1557, 78, 1370, 904, 8, 2105, 14, 8782, 14, 3009, 63, 10116, 63, 509, 63, 1238, 8, 1238, 12, 18295, 949, 63, 2487, 4059, 421, 199, 3, 2136, 883, 1133, 511, 314, 6186, 63, 10129, 44, 9136, 436, 6186, 63, 10215, 63, 10129, 44, 9136, 2202, 199, 3, 2952, 2985, 3984, 13006, 1380, 314, 1402, 1021, 365, 3247, 14, 3709, 282, 406, 4041, 12, 199, 3, 768, 4415, 63, 1751, 3181, 1133, 1736, 12, 436, 314, 2295, 11687, 199, 533, 6957, 10749, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 710, 625, 11122, 1709, 1929, 370, 506, 4829, 2410, 314, 511, 315, 1865, 370, 267, 327, 7981, 4875, 315, 22990, 543, 314, 8976, 3439, 315, 1163, 2295, 14, 267, 291, 423, 1753, 63, 992, 275, 8686, 14, 571, 63, 7532, 459, 1238, 63, 1419, 2278, 992, 14, 1574, 342, 398, 367, 1402, 315, 8281, 12, 6642, 12, 26705, 1192, 12, 16578, 287, 5011, 26, 288, 1402, 423, 2024, 14, 11122, 275, 715, 339, 347, 6766, 8, 277, 304, 267, 367, 1402, 315, 8281, 12, 6642, 12, 26705, 1192, 12, 16578, 287, 5011, 26, 288, 1402, 423, 2024, 14, 11122, 275, 756, 398, 8686, 14, 571, 63, 7532, 459, 1238, 63, 1419, 2278, 992, 275, 291, 423, 1753, 63, 992, 267, 8686, 14, 452, 63, 992, 459, 1238, 63, 1419, 418, 275, 291, 423, 1753, 63, 992, 267, 8686, 14, 3584, 63, 1637, 342, 339, 347, 702, 5667, 6906, 8, 277, 12, 394, 1187, 2340, 12, 1929, 274, 12, 2338, 304, 267, 3363, 63, 835, 275, 394, 1187, 2340, 14, 835, 8, 9321, 274, 9, 267, 291, 14, 629, 8, 3093, 63, 835, 12, 2338, 12, 298, 3601, 450, 68, 4454, 402, 1543, 83, 297, 298, 355, 298, 2062, 450, 68, 2, 450, 334, 3093, 63, 835, 12, 1929, 274, 12, 2338, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 1238, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 29231, 287, 5011, 680, 2325, 342, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 413, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 499, 9, 339, 768, 15118, 18093, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 11996, 63, 509, 63, 1238, 8, 277, 304, 267, 327, 3091, 1817, 2638, 13, 2407, 5385, 267, 291, 14, 629, 8, 3009, 63, 509, 63, 1224, 8, 29231, 287, 5011, 395, 586, 3875, 63, 509, 63, 1224, 8, 29231, 287, 5011, 2891, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 16821, 63, 698, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 7221, 680, 2325, 342, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 5062, 790, 435, 413, 367, 314, 1478, 641, 1233, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 499, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 5062, 790, 435, 413, 367, 314, 1478, 641, 1233, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 650, 9, 398, 327, 413, 367, 314, 1478, 641, 3659, 267, 291, 14, 15872, 6906, 8, 3009, 12, 283, 2996, 63, 5842, 681, 297, 413, 9, 339, 768, 15118, 18093, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 11996, 63, 509, 63, 16821, 63, 698, 8, 277, 304, 267, 327, 3091, 1817, 2638, 13, 2407, 5385, 267, 291, 14, 629, 8, 3009, 63, 509, 63, 1224, 8, 7221, 395, 586, 3875, 63, 509, 63, 1224, 8, 7221, 2891, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 3479, 63, 475, 63, 3479, 63, 698, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 2817, 1384, 680, 2325, 342, 267, 327, 710, 4263, 1817, 402, 314, 28409, 13538, 370, 314, 1402, 1159, 1817, 2638, 12, 267, 327, 436, 2399, 10507, 4634, 12, 7444, 6186, 63, 10215, 63, 10129, 44, 9136, 365, 663, 14, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 413, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 949, 63, 2487, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 14, 1224, 10749, 492, 334, 7221, 12, 8281, 2891, 12, 6642, 12, 26705, 1192, 12, 272, 16578, 287, 5011, 12, 16578, 287, 5011, 2891, 9, 421, 199, 318, 3875, 63, 509, 63, 1224, 8, 1238, 304, 272, 372, 1557, 78, 1370, 904, 8, 2105, 14, 8782, 14, 3009, 63, 981, 63, 1238, 8, 1238, 12, 12933, 949, 63, 2487, 18756, 16, 566, 421, 199, 318, 3875, 63, 509, 63, 1080, 8, 1238, 304, 272, 372, 1557, 78, 1370, 904, 8, 2105, 14, 8782, 14, 3009, 63, 10116, 63, 509, 63, 1238, 8, 1238, 12, 18295, 949, 63, 2487, 4059, 421, 199, 3, 2136, 883, 1133, 511, 314, 6186, 63, 10129, 44, 9136, 436, 6186, 63, 10215, 63, 10129, 44, 9136, 2202, 199, 3, 2952, 2985, 3984, 13006, 1380, 314, 1402, 1021, 365, 3247, 14, 3709, 282, 406, 4041, 12, 199, 3, 768, 4415, 63, 1751, 3181, 1133, 1736, 12, 436, 314, 2295, 11687, 199, 533, 6957, 10749, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 710, 625, 11122, 1709, 1929, 370, 506, 4829, 2410, 314, 511, 315, 1865, 370, 267, 327, 7981, 4875, 315, 22990, 543, 314, 8976, 3439, 315, 1163, 2295, 14, 267, 291, 423, 1753, 63, 992, 275, 8686, 14, 571, 63, 7532, 459, 1238, 63, 1419, 2278, 992, 14, 1574, 342, 398, 367, 1402, 315, 8281, 12, 6642, 12, 26705, 1192, 12, 16578, 287, 5011, 26, 288, 1402, 423, 2024, 14, 11122, 275, 715, 339, 347, 6766, 8, 277, 304, 267, 367, 1402, 315, 8281, 12, 6642, 12, 26705, 1192, 12, 16578, 287, 5011, 26, 288, 1402, 423, 2024, 14, 11122, 275, 756, 398, 8686, 14, 571, 63, 7532, 459, 1238, 63, 1419, 2278, 992, 275, 291, 423, 1753, 63, 992, 267, 8686, 14, 452, 63, 992, 459, 1238, 63, 1419, 418, 275, 291, 423, 1753, 63, 992, 267, 8686, 14, 3584, 63, 1637, 342, 339, 347, 702, 5667, 6906, 8, 277, 12, 394, 1187, 2340, 12, 1929, 274, 12, 2338, 304, 267, 3363, 63, 835, 275, 394, 1187, 2340, 14, 835, 8, 9321, 274, 9, 267, 291, 14, 629, 8, 3093, 63, 835, 12, 2338, 12, 298, 3601, 450, 68, 4454, 402, 1543, 83, 297, 298, 355, 298, 2062, 450, 68, 2, 450, 334, 3093, 63, 835, 12, 1929, 274, 12, 2338, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 1238, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 29231, 287, 5011, 680, 2325, 342, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 413, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 499, 9, 339, 768, 15118, 18093, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 11996, 63, 509, 63, 1238, 8, 277, 304, 267, 327, 3091, 1817, 2638, 13, 2407, 5385, 267, 291, 14, 629, 8, 3009, 63, 509, 63, 1224, 8, 29231, 287, 5011, 395, 586, 3875, 63, 509, 63, 1224, 8, 29231, 287, 5011, 2891, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 16821, 63, 698, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 7221, 680, 2325, 342, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 5062, 790, 435, 413, 367, 314, 1478, 641, 1233, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 499, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 5062, 790, 435, 413, 367, 314, 1478, 641, 1233, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 650, 9, 398, 327, 413, 367, 314, 1478, 641, 3659, 267, 291, 14, 15872, 6906, 8, 3009, 12, 283, 2996, 63, 5842, 681, 297, 413, 9, 339, 768, 15118, 18093, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 11996, 63, 509, 63, 16821, 63, 698, 8, 277, 304, 267, 327, 3091, 1817, 2638, 13, 2407, 5385, 267, 291, 14, 629, 8, 3009, 63, 509, 63, 1224, 8, 7221, 395, 586, 3875, 63, 509, 63, 1224, 8, 7221, 2891, 430, 339, 768, 22424, 360, 9823, 63, 1224, 10749, 358, 272, 347, 511, 63, 26730, 63, 509, 63, 3479, 63, 475, 63, 3479, 63, 698, 8, 277, 304, 267, 3875, 275, 3875, 63, 509, 63, 1224, 8, 2817, 1384, 680, 2325, 342, 267, 327, 710, 4263, 1817, 402, 314, 28409, 13538, 370, 314, 1402, 1159, 1817, 2638, 12, 267, 327, 436, 2399, 10507, 4634, 12, 7444, 6186, 63, 10215, 63, 10129, 44, 9136, 365, 663, 14, 267, 340, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 26, 288, 327, 413, 367, 314, 1817, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 63, 5842, 681, 297, 413, 9, 288, 327, 413, 367, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 2202, 14, 3472, 63, 10215, 63, 10129, 44, 9136, 12, 413, 9, 267, 587, 26, 288, 327, 413, 367, 314, 1817, 435, 413, 367, 314, 1478, 641, 314, 5062, 790, 288, 291, 14, 15872, 6906, 8, 3009, 12, 283, 14806, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yencarnacion/jaikuengine
.google_appengine/lib/django-1.5/django/contrib/databrowse/datastructures.py
100
9090
""" These classes are light wrappers around Django's database API that provide convenience functionality and permalink functions for the databrowse app. """ from __future__ import unicode_literals from django.db import models from django.utils import formats from django.utils.text import capfirst from django.utils.encoding import smart_text, force_str, iri_to_uri from django.db.models.query import QuerySet from django.utils.encoding import python_2_unicode_compatible EMPTY_VALUE = '(None)' DISPLAY_SIZE = 100 class EasyModel(object): def __init__(self, site, model): self.site = site self.model = model self.model_list = list(site.registry.keys()) self.verbose_name = model._meta.verbose_name self.verbose_name_plural = model._meta.verbose_name_plural def __repr__(self): return force_str('<EasyModel for %s>' % self.model._meta.object_name) def model_databrowse(self): "Returns the ModelDatabrowse class for this model." return self.site.registry[self.model] def url(self): return '%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name) def objects(self, **kwargs): return self.get_query_set().filter(**kwargs) def get_query_set(self): easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet) easy_qs._easymodel = self return easy_qs def object_by_pk(self, pk): return EasyInstance(self, self.model._default_manager.get(pk=pk)) def sample_objects(self): for obj in self.model._default_manager.all()[:3]: yield EasyInstance(self, obj) def field(self, name): try: f = self.model._meta.get_field(name) except models.FieldDoesNotExist: return None return EasyField(self, f) def fields(self): return [EasyField(self, f) for f in (self.model._meta.fields + self.model._meta.many_to_many)] class EasyField(object): def __init__(self, easy_model, field): self.model, self.field = easy_model, field def __repr__(self): return force_str('<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def choices(self): for value, label in self.field.choices: yield EasyChoice(self.model, self, value, label) def url(self): if self.field.choices: return '%s%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name) elif self.field.rel: return '%s%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name) class EasyChoice(object): def __init__(self, easy_model, field, value, label): self.model, self.field = easy_model, field self.value, self.label = value, label def __repr__(self): return force_str('<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def url(self): return '%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value)) @python_2_unicode_compatible class EasyInstance(object): def __init__(self, easy_model, instance): self.model, self.instance = easy_model, instance def __repr__(self): return force_str('<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val())) def __str__(self): val = smart_text(self.instance) if len(val) > DISPLAY_SIZE: return val[:DISPLAY_SIZE] + '...' return val def pk(self): return self.instance._get_pk_val() def url(self): return '%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, iri_to_uri(self.pk())) def fields(self): """ Generator that yields EasyInstanceFields for each field in this EasyInstance's model. """ for f in self.model.model._meta.fields + self.model.model._meta.many_to_many: yield EasyInstanceField(self.model, self, f) def related_objects(self): """ Generator that yields dictionaries of all models that have this EasyInstance's model as a ForeignKey or ManyToManyField, along with lists of related objects. """ for rel_object in self.model.model._meta.get_all_related_objects() + self.model.model._meta.get_all_related_many_to_many_objects(): if rel_object.model not in self.model.model_list: continue # Skip models that aren't in the model_list em = EasyModel(self.model.site, rel_object.model) yield { 'model': em, 'related_field': rel_object.field.verbose_name, 'object_list': [EasyInstance(em, i) for i in getattr(self.instance, rel_object.get_accessor_name()).all()], } class EasyInstanceField(object): def __init__(self, easy_model, instance, field): self.model, self.field, self.instance = easy_model, field, instance self.raw_value = getattr(instance.instance, field.name) def __repr__(self): return force_str('<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def values(self): """ Returns a list of values for this field for this instance. It's a list so we can accomodate many-to-many fields. """ # This import is deliberately inside the function because it causes # some settings to be imported, and we don't want to do that at the # module level. if self.field.rel: if isinstance(self.field.rel, models.ManyToOneRel): objs = getattr(self.instance.instance, self.field.name) elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel return list(getattr(self.instance.instance, self.field.name).all()) elif self.field.choices: objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE) elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField): if self.raw_value: if isinstance(self.field, models.DateTimeField): objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT')) elif isinstance(self.field, models.TimeField): objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT')) else: objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT')) else: objs = EMPTY_VALUE elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField): objs = {True: 'Yes', False: 'No', None: 'Unknown'}[self.raw_value] else: objs = self.raw_value return [objs] def urls(self): "Returns a list of (value, URL) tuples." # First, check the urls() method for each plugin. plugin_urls = [] for plugin_name, plugin in self.model.model_databrowse().plugins.items(): urls = plugin.urls(plugin_name, self) if urls is not None: return zip(self.values(), urls) if self.field.rel: m = EasyModel(self.model.site, self.field.rel.to) if self.field.rel.to in self.model.model_list: lst = [] for value in self.values(): if value is None: continue url = '%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val())) lst.append((smart_text(value), url)) else: lst = [(value, None) for value in self.values()] elif self.field.choices: lst = [] for value in self.values(): url = '%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value)) lst.append((value, url)) elif isinstance(self.field, models.URLField): val = list(self.values())[0] lst = [(val, iri_to_uri(val))] else: lst = [(list(self.values())[0], None)] return lst class EasyQuerySet(QuerySet): """ When creating (or cloning to) an `EasyQuerySet`, make sure to set the `_easymodel` variable to the related `EasyModel`. """ def iterator(self, *args, **kwargs): for obj in super(EasyQuerySet, self).iterator(*args, **kwargs): yield EasyInstance(self._easymodel, obj) def _clone(self, *args, **kwargs): c = super(EasyQuerySet, self)._clone(*args, **kwargs) c._easymodel = self._easymodel return c
apache-2.0
[ 624, 199, 20676, 3992, 787, 10540, 17995, 6818, 5634, 1159, 3050, 3261, 626, 5647, 199, 388, 23329, 9330, 436, 1126, 2174, 2292, 3423, 367, 314, 366, 1936, 13300, 1145, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 6752, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 12, 3542, 63, 495, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 199, 13993, 63, 7041, 275, 8189, 403, 3171, 199, 20993, 63, 4305, 275, 2948, 199, 199, 533, 18951, 1685, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4770, 12, 1402, 304, 267, 291, 14, 2124, 275, 4770, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 1238, 63, 513, 275, 769, 8, 2124, 14, 5189, 14, 1612, 1012, 267, 291, 14, 3832, 63, 354, 275, 1402, 423, 2024, 14, 3832, 63, 354, 267, 291, 14, 3832, 63, 354, 63, 10019, 275, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 1685, 367, 450, 83, 3524, 450, 291, 14, 1238, 423, 2024, 14, 785, 63, 354, 9, 339, 347, 1402, 63, 68, 1936, 13300, 8, 277, 304, 267, 298, 3407, 314, 5822, 36, 1936, 13300, 1021, 367, 642, 1402, 2122, 267, 372, 291, 14, 2124, 14, 5189, 59, 277, 14, 1238, 61, 339, 347, 1166, 8, 277, 304, 267, 372, 1543, 83, 5, 83, 3149, 83, 4805, 450, 334, 277, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 423, 2024, 14, 578, 63, 354, 9, 339, 347, 2251, 8, 277, 12, 1011, 958, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 409, 1252, 1541, 3682, 958, 9, 339, 347, 664, 63, 1131, 63, 409, 8, 277, 304, 267, 8837, 63, 6177, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 1131, 63, 409, 19050, 6311, 8, 11645, 29, 28326, 13689, 9, 267, 8837, 63, 6177, 423, 13581, 1238, 275, 291, 267, 372, 8837, 63, 6177, 339, 347, 909, 63, 991, 63, 2051, 8, 277, 12, 3803, 304, 267, 372, 18951, 3244, 8, 277, 12, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 8, 2051, 29, 2051, 430, 339, 347, 2690, 63, 1462, 8, 277, 304, 267, 367, 1559, 315, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 20523, 19, 2189, 288, 1995, 18951, 3244, 8, 277, 12, 1559, 9, 339, 347, 901, 8, 277, 12, 536, 304, 267, 862, 26, 288, 289, 275, 291, 14, 1238, 423, 2024, 14, 362, 63, 698, 8, 354, 9, 267, 871, 1709, 14, 792, 7400, 26, 288, 372, 488, 267, 372, 18951, 792, 8, 277, 12, 289, 9, 339, 347, 1504, 8, 277, 304, 267, 372, 359, 28326, 792, 8, 277, 12, 289, 9, 367, 289, 315, 334, 277, 14, 1238, 423, 2024, 14, 955, 435, 291, 14, 1238, 423, 2024, 14, 3479, 63, 475, 63, 3479, 1874, 199, 199, 533, 18951, 792, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 901, 304, 267, 291, 14, 1238, 12, 291, 14, 698, 275, 8837, 63, 1238, 12, 901, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 792, 367, 450, 83, 4111, 83, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 698, 14, 354, 430, 339, 347, 3415, 8, 277, 304, 267, 367, 574, 12, 1768, 315, 291, 14, 698, 14, 4577, 26, 288, 1995, 18951, 9054, 8, 277, 14, 1238, 12, 291, 12, 574, 12, 1768, 9, 339, 347, 1166, 8, 277, 304, 267, 340, 291, 14, 698, 14, 4577, 26, 288, 372, 1543, 83, 5, 83, 3149, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 12, 291, 14, 698, 14, 354, 9, 267, 916, 291, 14, 698, 14, 3369, 26, 288, 372, 1543, 83, 5, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 9, 199, 199, 533, 18951, 9054, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 901, 12, 574, 12, 1768, 304, 267, 291, 14, 1238, 12, 291, 14, 698, 275, 8837, 63, 1238, 12, 901, 267, 291, 14, 585, 12, 291, 14, 1302, 275, 574, 12, 1768, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 9054, 367, 450, 83, 4111, 83, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 698, 14, 354, 430, 339, 347, 1166, 8, 277, 304, 267, 372, 1543, 83, 5, 83, 3149, 83, 3149, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 12, 291, 14, 698, 14, 698, 14, 354, 12, 24086, 63, 475, 63, 2302, 8, 277, 14, 585, 430, 199, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 18951, 3244, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 1256, 304, 267, 291, 14, 1238, 12, 291, 14, 842, 275, 8837, 63, 1238, 12, 1256, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 3244, 367, 450, 83, 4366, 83, 9, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 842, 423, 362, 63, 2051, 63, 637, 4059 ]
[ 199, 20676, 3992, 787, 10540, 17995, 6818, 5634, 1159, 3050, 3261, 626, 5647, 199, 388, 23329, 9330, 436, 1126, 2174, 2292, 3423, 367, 314, 366, 1936, 13300, 1145, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 6752, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 12, 3542, 63, 495, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 199, 13993, 63, 7041, 275, 8189, 403, 3171, 199, 20993, 63, 4305, 275, 2948, 199, 199, 533, 18951, 1685, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4770, 12, 1402, 304, 267, 291, 14, 2124, 275, 4770, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 1238, 63, 513, 275, 769, 8, 2124, 14, 5189, 14, 1612, 1012, 267, 291, 14, 3832, 63, 354, 275, 1402, 423, 2024, 14, 3832, 63, 354, 267, 291, 14, 3832, 63, 354, 63, 10019, 275, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 1685, 367, 450, 83, 3524, 450, 291, 14, 1238, 423, 2024, 14, 785, 63, 354, 9, 339, 347, 1402, 63, 68, 1936, 13300, 8, 277, 304, 267, 298, 3407, 314, 5822, 36, 1936, 13300, 1021, 367, 642, 1402, 2122, 267, 372, 291, 14, 2124, 14, 5189, 59, 277, 14, 1238, 61, 339, 347, 1166, 8, 277, 304, 267, 372, 1543, 83, 5, 83, 3149, 83, 4805, 450, 334, 277, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 423, 2024, 14, 578, 63, 354, 9, 339, 347, 2251, 8, 277, 12, 1011, 958, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 409, 1252, 1541, 3682, 958, 9, 339, 347, 664, 63, 1131, 63, 409, 8, 277, 304, 267, 8837, 63, 6177, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 1131, 63, 409, 19050, 6311, 8, 11645, 29, 28326, 13689, 9, 267, 8837, 63, 6177, 423, 13581, 1238, 275, 291, 267, 372, 8837, 63, 6177, 339, 347, 909, 63, 991, 63, 2051, 8, 277, 12, 3803, 304, 267, 372, 18951, 3244, 8, 277, 12, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 8, 2051, 29, 2051, 430, 339, 347, 2690, 63, 1462, 8, 277, 304, 267, 367, 1559, 315, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 20523, 19, 2189, 288, 1995, 18951, 3244, 8, 277, 12, 1559, 9, 339, 347, 901, 8, 277, 12, 536, 304, 267, 862, 26, 288, 289, 275, 291, 14, 1238, 423, 2024, 14, 362, 63, 698, 8, 354, 9, 267, 871, 1709, 14, 792, 7400, 26, 288, 372, 488, 267, 372, 18951, 792, 8, 277, 12, 289, 9, 339, 347, 1504, 8, 277, 304, 267, 372, 359, 28326, 792, 8, 277, 12, 289, 9, 367, 289, 315, 334, 277, 14, 1238, 423, 2024, 14, 955, 435, 291, 14, 1238, 423, 2024, 14, 3479, 63, 475, 63, 3479, 1874, 199, 199, 533, 18951, 792, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 901, 304, 267, 291, 14, 1238, 12, 291, 14, 698, 275, 8837, 63, 1238, 12, 901, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 792, 367, 450, 83, 4111, 83, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 698, 14, 354, 430, 339, 347, 3415, 8, 277, 304, 267, 367, 574, 12, 1768, 315, 291, 14, 698, 14, 4577, 26, 288, 1995, 18951, 9054, 8, 277, 14, 1238, 12, 291, 12, 574, 12, 1768, 9, 339, 347, 1166, 8, 277, 304, 267, 340, 291, 14, 698, 14, 4577, 26, 288, 372, 1543, 83, 5, 83, 3149, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 12, 291, 14, 698, 14, 354, 9, 267, 916, 291, 14, 698, 14, 3369, 26, 288, 372, 1543, 83, 5, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 9, 199, 199, 533, 18951, 9054, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 901, 12, 574, 12, 1768, 304, 267, 291, 14, 1238, 12, 291, 14, 698, 275, 8837, 63, 1238, 12, 901, 267, 291, 14, 585, 12, 291, 14, 1302, 275, 574, 12, 1768, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 9054, 367, 450, 83, 4111, 83, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 698, 14, 354, 430, 339, 347, 1166, 8, 277, 304, 267, 372, 1543, 83, 5, 83, 3149, 83, 3149, 83, 3149, 83, 4805, 450, 334, 277, 14, 1238, 14, 2124, 14, 1231, 63, 633, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 14, 1238, 423, 2024, 14, 578, 63, 354, 12, 291, 14, 698, 14, 698, 14, 354, 12, 24086, 63, 475, 63, 2302, 8, 277, 14, 585, 430, 199, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 18951, 3244, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8837, 63, 1238, 12, 1256, 304, 267, 291, 14, 1238, 12, 291, 14, 842, 275, 8837, 63, 1238, 12, 1256, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3542, 63, 495, 4827, 28326, 3244, 367, 450, 83, 4366, 83, 9, 3524, 450, 334, 277, 14, 1238, 14, 1238, 423, 2024, 14, 785, 63, 354, 12, 291, 14, 842, 423, 362, 63, 2051, 63, 637, 4059, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
specialkevin/ansible-modules-core
system/authorized_key.py
55
15877
#!/usr/bin/python # -*- coding: utf-8 -*- """ Ansible module to add authorized_keys for ssh logins. (c) 2012, Brad Olson <brado@movedbylight.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/>. """ DOCUMENTATION = ''' --- module: authorized_key short_description: Adds or removes an SSH authorized key description: - Adds or removes an SSH authorized key for a user from a remote host. version_added: "0.5" options: user: description: - The username on the remote host whose authorized_keys file will be modified required: true default: null key: description: - The SSH public key(s), as a string or (since 1.9) url (https://github.com/username.keys) required: true default: null path: description: - Alternate path to the authorized_keys file required: false default: "(homedir)+/.ssh/authorized_keys" version_added: "1.2" manage_dir: description: - Whether this module should manage the directory of the authorized key file. If set, the module will create the directory, as well as set the owner and permissions of an existing directory. Be sure to set C(manage_dir=no) if you are using an alternate directory for authorized_keys, as set with C(path), since you could lock yourself out of SSH access. See the example below. required: false choices: [ "yes", "no" ] default: "yes" version_added: "1.2" state: description: - Whether the given key (with the given key_options) should or should not be in the file required: false choices: [ "present", "absent" ] default: "present" key_options: description: - A string of ssh key options to be prepended to the key in the authorized_keys file required: false default: null version_added: "1.4" exclusive: description: - Whether to remove all other non-specified keys from the authorized_keys file. Multiple keys can be specified in a single C(key) string value by separating them by newlines. - This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration of the loop, if you want multiple keys in the file you need to pass them all to C(key) in a single batch as mentioned above. required: false choices: [ "yes", "no" ] default: "no" version_added: "1.9" description: - "Adds or removes authorized keys for particular user accounts" author: "Brad Olson (@bradobro)" ''' EXAMPLES = ''' # Example using key data from a local file on the management machine - authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" # Using github url as key source - authorized_key: user=charlie key=https://github.com/charlie.keys # Using alternate directory locations: - authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" path='/etc/ssh/authorized_keys/charlie' manage_dir=no # Using with_file - name: Set up authorized_keys for the deploy user authorized_key: user=deploy key="{{ item }}" with_file: - public_keys/doe-jane - public_keys/doe-john # Using key_options: - authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key_options='no-port-forwarding,from="10.0.1.1"' # Set up authorized_keys exclusively with one key - authorized_key: user=root key="{{ item }}" state=present exclusive=yes with_file: - public_keys/doe-jane ''' # Makes sure the public key line is present or absent in the user's .ssh/authorized_keys. # # Arguments # ========= # user = username # key = line to add to authorized_keys for user # path = path to the user's authorized_keys file (default: ~/.ssh/authorized_keys) # manage_dir = whether to create, and control ownership of the directory (default: true) # state = absent|present (default: present) # # see example in examples/playbooks import sys import os import pwd import os.path import tempfile import re import shlex class keydict(dict): """ a dictionary that maintains the order of keys as they are added """ # http://stackoverflow.com/questions/2328235/pythonextend-the-dict-class def __init__(self, *args, **kw): super(keydict,self).__init__(*args, **kw) self.itemlist = super(keydict,self).keys() def __setitem__(self, key, value): self.itemlist.append(key) super(keydict,self).__setitem__(key, value) def __iter__(self): return iter(self.itemlist) def keys(self): return self.itemlist def values(self): return [self[key] for key in self] def itervalues(self): return (self[key] for key in self) def keyfile(module, user, write=False, path=None, manage_dir=True): """ Calculate name of authorized keys file, optionally creating the directories and file, properly setting permissions. :param str user: name of user in passwd file :param bool write: if True, write changes to authorized_keys file (creating directories if needed) :param str path: if not None, use provided path rather than default of '~user/.ssh/authorized_keys' :param bool manage_dir: if True, create and set ownership of the parent dir of the authorized_keys file :return: full path string to authorized_keys for user """ if module.check_mode and path is not None: keysfile = path return keysfile try: user_entry = pwd.getpwnam(user) except KeyError, e: if module.check_mode and path is None: module.fail_json(msg="Either user must exist or you must provide full path to key file in check mode") module.fail_json(msg="Failed to lookup user %s: %s" % (user, str(e))) if path is None: homedir = user_entry.pw_dir sshdir = os.path.join(homedir, ".ssh") keysfile = os.path.join(sshdir, "authorized_keys") else: sshdir = os.path.dirname(path) keysfile = path if not write: return keysfile uid = user_entry.pw_uid gid = user_entry.pw_gid if manage_dir: if not os.path.exists(sshdir): os.mkdir(sshdir, 0700) if module.selinux_enabled(): module.set_default_selinux_context(sshdir, False) os.chown(sshdir, uid, gid) os.chmod(sshdir, 0700) if not os.path.exists(keysfile): basedir = os.path.dirname(keysfile) if not os.path.exists(basedir): os.makedirs(basedir) try: f = open(keysfile, "w") #touches file so we can set ownership and perms finally: f.close() if module.selinux_enabled(): module.set_default_selinux_context(keysfile, False) try: os.chown(keysfile, uid, gid) os.chmod(keysfile, 0600) except OSError: pass return keysfile def parseoptions(module, options): ''' reads a string containing ssh-key options and returns a dictionary of those options ''' options_dict = keydict() #ordered dict if options: try: # the following regex will split on commas while # ignoring those commas that fall within quotes regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') parts = regex.split(options)[1:-1] for part in parts: if "=" in part: (key, value) = part.split("=", 1) options_dict[key] = value elif part != ",": options_dict[part] = None except: module.fail_json(msg="invalid option string: %s" % options) return options_dict def parsekey(module, raw_key): ''' parses a key, which may or may not contain a list of ssh-key options at the beginning ''' VALID_SSH2_KEY_TYPES = [ 'ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-dss', 'ssh-rsa', ] options = None # connection options key = None # encrypted key string key_type = None # type of ssh key type_index = None # index of keytype in key string|list # remove comment yaml escapes raw_key = raw_key.replace('\#', '#') # split key safely lex = shlex.shlex(raw_key) lex.quotes = [] lex.commenters = '' #keep comment hashes lex.whitespace_split = True key_parts = list(lex) for i in range(0, len(key_parts)): if key_parts[i] in VALID_SSH2_KEY_TYPES: type_index = i key_type = key_parts[i] break # check for options if type_index is None: return None elif type_index > 0: options = " ".join(key_parts[:type_index]) # parse the options (if any) options = parseoptions(module, options) # get key after the type index key = key_parts[(type_index + 1)] # set comment to everything after the key if len(key_parts) > (type_index + 1): comment = " ".join(key_parts[(type_index + 2):]) return (key, key_type, options, comment) def readkeys(module, filename): if not os.path.isfile(filename): return {} keys = {} f = open(filename) for line in f.readlines(): key_data = parsekey(module, line) if key_data: # use key as identifier keys[key_data[0]] = key_data else: # for an invalid line, just append the line # to the array so it will be re-output later keys[line] = line f.close() return keys def writekeys(module, filename, keys): fd, tmp_path = tempfile.mkstemp('', 'tmp', os.path.dirname(filename)) f = open(tmp_path,"w") try: for index, key in keys.items(): try: (keyhash,type,options,comment) = key option_str = "" if options: option_strings = [] for option_key in options.keys(): if options[option_key]: option_strings.append("%s=%s" % (option_key, options[option_key])) else: option_strings.append("%s" % option_key) option_str = ",".join(option_strings) option_str += " " key_line = "%s%s %s %s\n" % (option_str, type, keyhash, comment) except: key_line = key f.writelines(key_line) except IOError, e: module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e))) f.close() module.atomic_move(tmp_path, filename) def enforce_state(module, params): """ Add or remove key. """ user = params["user"] key = params["key"] path = params.get("path", None) manage_dir = params.get("manage_dir", True) state = params.get("state", "present") key_options = params.get("key_options", None) exclusive = params.get("exclusive", False) error_msg = "Error getting key from: %s" # if the key is a url, request it and use it as key source if key.startswith("http"): try: resp, info = fetch_url(module, key) if info['status'] != 200: module.fail_json(msg=error_msg % key) else: key = resp.read() except Exception: module.fail_json(msg=error_msg % key) # extract individual keys into an array, skipping blank lines and comments key = [s for s in key.splitlines() if s and not s.startswith('#')] # check current state -- just get the filename, don't create file do_write = False params["keyfile"] = keyfile(module, user, do_write, path, manage_dir) existing_keys = readkeys(module, params["keyfile"]) # Add a place holder for keys that should exist in the state=present and # exclusive=true case keys_to_exist = [] # Check our new keys, if any of them exist we'll continue. for new_key in key: parsed_new_key = parsekey(module, new_key) if not parsed_new_key: module.fail_json(msg="invalid key specified: %s" % new_key) if key_options is not None: parsed_options = parseoptions(module, key_options) parsed_new_key = (parsed_new_key[0], parsed_new_key[1], parsed_options, parsed_new_key[3]) present = False matched = False non_matching_keys = [] if parsed_new_key[0] in existing_keys: present = True # Then we check if everything matches, including # the key type and options. If not, we append this # existing key to the non-matching list # We only want it to match everything when the state # is present if parsed_new_key != existing_keys[parsed_new_key[0]] and state == "present": non_matching_keys.append(existing_keys[parsed_new_key[0]]) else: matched = True # handle idempotent state=present if state=="present": keys_to_exist.append(parsed_new_key[0]) if len(non_matching_keys) > 0: for non_matching_key in non_matching_keys: if non_matching_key[0] in existing_keys: del existing_keys[non_matching_key[0]] do_write = True if not matched: existing_keys[parsed_new_key[0]] = parsed_new_key do_write = True elif state=="absent": if not matched: continue del existing_keys[parsed_new_key[0]] do_write = True # remove all other keys to honor exclusive if state == "present" and exclusive: to_remove = frozenset(existing_keys).difference(keys_to_exist) for key in to_remove: del existing_keys[key] do_write = True if do_write: if module.check_mode: module.exit_json(changed=True) writekeys(module, keyfile(module, user, do_write, path, manage_dir), existing_keys) params['changed'] = True else: if module.check_mode: module.exit_json(changed=False) return params def main(): module = AnsibleModule( argument_spec = dict( user = dict(required=True, type='str'), key = dict(required=True, type='str'), path = dict(required=False, type='str'), manage_dir = dict(required=False, type='bool', default=True), state = dict(default='present', choices=['absent','present']), key_options = dict(required=False, type='str'), unique = dict(default=False, type='bool'), exclusive = dict(default=False, type='bool'), ), supports_check_mode=True ) results = enforce_state(module, module.params) module.exit_json(**results) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.urls import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 10047, 859, 370, 1050, 18788, 63, 1612, 367, 8635, 4676, 83, 14, 199, 8, 67, 9, 6029, 12, 699, 9525, 593, 478, 265, 665, 7828, 1117, 32, 3539, 991, 4040, 14, 957, 30, 199, 199, 2765, 570, 365, 1777, 402, 2622, 199, 199, 10047, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 10047, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18788, 63, 498, 199, 3612, 63, 1802, 26, 15747, 503, 14185, 376, 12027, 18788, 790, 199, 1802, 26, 1362, 446, 15747, 503, 14185, 376, 12027, 18788, 790, 367, 282, 922, 687, 282, 3982, 1591, 14, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 922, 26, 272, 1369, 26, 489, 446, 710, 3434, 641, 314, 3982, 1591, 7447, 18788, 63, 1612, 570, 911, 506, 6042, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 790, 26, 272, 1369, 26, 489, 446, 710, 12027, 4575, 790, 8, 83, 395, 465, 282, 1059, 503, 334, 8585, 413, 14, 25, 9, 1166, 334, 2859, 921, 5031, 14, 957, 15, 2473, 14, 1612, 9, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 931, 26, 272, 1369, 26, 489, 446, 17669, 323, 931, 370, 314, 18788, 63, 1612, 570, 272, 1415, 26, 3055, 272, 849, 26, 7340, 4219, 694, 6393, 8083, 5510, 15, 11497, 63, 1612, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 9635, 63, 694, 26, 272, 1369, 26, 489, 446, 7480, 642, 859, 1077, 9635, 314, 2082, 402, 314, 18788, 790, 570, 14, 221, 982, 267, 663, 12, 314, 859, 911, 1218, 314, 2082, 12, 465, 5521, 465, 663, 314, 5771, 436, 3443, 267, 402, 376, 3411, 2082, 14, 6423, 3238, 370, 267, 663, 445, 8, 9053, 63, 694, 29, 889, 9, 340, 1265, 787, 1808, 376, 18034, 2082, 367, 267, 18788, 63, 1612, 12, 465, 663, 543, 445, 8, 515, 395, 3967, 1265, 4293, 4650, 28225, 734, 402, 267, 12027, 2879, 14, 1666, 314, 2893, 5084, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 5066, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 1627, 790, 334, 1045, 314, 1627, 790, 63, 1419, 9, 1077, 503, 1077, 440, 506, 315, 314, 570, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 849, 26, 298, 1881, 2, 523, 790, 63, 1419, 26, 272, 1369, 26, 489, 446, 437, 1059, 402, 8635, 790, 1511, 370, 506, 20247, 370, 314, 790, 315, 314, 18788, 63, 1612, 570, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 523, 13914, 26, 272, 1369, 26, 489, 446, 7480, 370, 2813, 1006, 1163, 2222, 13, 10085, 2883, 687, 314, 18788, 63, 1612, 570, 14, 14326, 2883, 267, 883, 506, 2013, 315, 282, 2849, 445, 8, 498, 9, 1059, 574, 701, 4216, 1958, 3062, 701, 14930, 14, 489, 446, 961, 945, 365, 440, 4438, 20381, 12, 880, 340, 1265, 675, 445, 8, 1045, 4602, 2360, 652, 911, 506, 13914, 1126, 8494, 267, 402, 314, 4438, 12, 340, 1265, 2934, 3663, 2883, 315, 314, 570, 1265, 1929, 370, 986, 3062, 1006, 370, 445, 8, 498, 9, 315, 282, 267, 2849, 3522, 465, 26239, 3432, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 25, 2, 199, 1802, 26, 272, 446, 298, 14995, 503, 14185, 18788, 2883, 367, 6770, 922, 12639, 2, 199, 2502, 26, 298, 34, 9525, 593, 478, 265, 8593, 7828, 1117, 20670, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1808, 790, 666, 687, 282, 2257, 570, 641, 314, 10041, 6844, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 199, 199, 3, 11719, 12869, 1166, 465, 790, 1350, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 790, 29, 2859, 921, 5031, 14, 957, 15, 1560, 21530, 14, 1612, 199, 199, 3, 11719, 18034, 2082, 9918, 26, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 2116, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 2116, 931, 8805, 6839, 15, 5510, 15, 11497, 63, 1612, 15, 1560, 21530, 7, 2116, 9635, 63, 694, 29, 889, 199, 199, 3, 11719, 543, 63, 493, 199, 13, 536, 26, 2494, 1536, 18788, 63, 1612, 367, 314, 12287, 922, 523, 18788, 63, 498, 26, 922, 29, 11060, 2116, 790, 628, 3638, 1242, 7820, 523, 543, 63, 493, 26, 272, 446, 4575, 63, 1612, 15, 1117, 69, 13, 74, 5865, 272, 446, 4575, 63, 1612, 15, 1117, 69, 13, 20216, 199, 199, 3, 11719, 790, 63, 1419, 26, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 2116, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 2116, 790, 63, 1419, 534, 889, 13, 719, 13, 21513, 12, 504, 628, 709, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 10047, 859, 370, 1050, 18788, 63, 1612, 367, 8635, 4676, 83, 14, 199, 8, 67, 9, 6029, 12, 699, 9525, 593, 478, 265, 665, 7828, 1117, 32, 3539, 991, 4040, 14, 957, 30, 199, 199, 2765, 570, 365, 1777, 402, 2622, 199, 199, 10047, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 10047, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18788, 63, 498, 199, 3612, 63, 1802, 26, 15747, 503, 14185, 376, 12027, 18788, 790, 199, 1802, 26, 1362, 446, 15747, 503, 14185, 376, 12027, 18788, 790, 367, 282, 922, 687, 282, 3982, 1591, 14, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 922, 26, 272, 1369, 26, 489, 446, 710, 3434, 641, 314, 3982, 1591, 7447, 18788, 63, 1612, 570, 911, 506, 6042, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 790, 26, 272, 1369, 26, 489, 446, 710, 12027, 4575, 790, 8, 83, 395, 465, 282, 1059, 503, 334, 8585, 413, 14, 25, 9, 1166, 334, 2859, 921, 5031, 14, 957, 15, 2473, 14, 1612, 9, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 931, 26, 272, 1369, 26, 489, 446, 17669, 323, 931, 370, 314, 18788, 63, 1612, 570, 272, 1415, 26, 3055, 272, 849, 26, 7340, 4219, 694, 6393, 8083, 5510, 15, 11497, 63, 1612, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 9635, 63, 694, 26, 272, 1369, 26, 489, 446, 7480, 642, 859, 1077, 9635, 314, 2082, 402, 314, 18788, 790, 570, 14, 221, 982, 267, 663, 12, 314, 859, 911, 1218, 314, 2082, 12, 465, 5521, 465, 663, 314, 5771, 436, 3443, 267, 402, 376, 3411, 2082, 14, 6423, 3238, 370, 267, 663, 445, 8, 9053, 63, 694, 29, 889, 9, 340, 1265, 787, 1808, 376, 18034, 2082, 367, 267, 18788, 63, 1612, 12, 465, 663, 543, 445, 8, 515, 395, 3967, 1265, 4293, 4650, 28225, 734, 402, 267, 12027, 2879, 14, 1666, 314, 2893, 5084, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 5066, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 1627, 790, 334, 1045, 314, 1627, 790, 63, 1419, 9, 1077, 503, 1077, 440, 506, 315, 314, 570, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 849, 26, 298, 1881, 2, 523, 790, 63, 1419, 26, 272, 1369, 26, 489, 446, 437, 1059, 402, 8635, 790, 1511, 370, 506, 20247, 370, 314, 790, 315, 314, 18788, 63, 1612, 570, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 523, 13914, 26, 272, 1369, 26, 489, 446, 7480, 370, 2813, 1006, 1163, 2222, 13, 10085, 2883, 687, 314, 18788, 63, 1612, 570, 14, 14326, 2883, 267, 883, 506, 2013, 315, 282, 2849, 445, 8, 498, 9, 1059, 574, 701, 4216, 1958, 3062, 701, 14930, 14, 489, 446, 961, 945, 365, 440, 4438, 20381, 12, 880, 340, 1265, 675, 445, 8, 1045, 4602, 2360, 652, 911, 506, 13914, 1126, 8494, 267, 402, 314, 4438, 12, 340, 1265, 2934, 3663, 2883, 315, 314, 570, 1265, 1929, 370, 986, 3062, 1006, 370, 445, 8, 498, 9, 315, 282, 267, 2849, 3522, 465, 26239, 3432, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 25, 2, 199, 1802, 26, 272, 446, 298, 14995, 503, 14185, 18788, 2883, 367, 6770, 922, 12639, 2, 199, 2502, 26, 298, 34, 9525, 593, 478, 265, 8593, 7828, 1117, 20670, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1808, 790, 666, 687, 282, 2257, 570, 641, 314, 10041, 6844, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 199, 199, 3, 11719, 12869, 1166, 465, 790, 1350, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 790, 29, 2859, 921, 5031, 14, 957, 15, 1560, 21530, 14, 1612, 199, 199, 3, 11719, 18034, 2082, 9918, 26, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 2116, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 2116, 931, 8805, 6839, 15, 5510, 15, 11497, 63, 1612, 15, 1560, 21530, 7, 2116, 9635, 63, 694, 29, 889, 199, 199, 3, 11719, 543, 63, 493, 199, 13, 536, 26, 2494, 1536, 18788, 63, 1612, 367, 314, 12287, 922, 523, 18788, 63, 498, 26, 922, 29, 11060, 2116, 790, 628, 3638, 1242, 7820, 523, 543, 63, 493, 26, 272, 446, 4575, 63, 1612, 15, 1117, 69, 13, 74, 5865, 272, 446, 4575, 63, 1612, 15, 1117, 69, 13, 20216, 199, 199, 3, 11719, 790, 63, 1419, 26, 199, 13, 18788, 63, 498, 26, 922, 29, 1560, 21530, 2116, 790, 628, 3638, 4237, 360, 493, 297, 1994, 4219, 15, 1560, 21530, 8083, 5510, 15, 344, 63, 13487, 14, 5645, 358, 7820, 2116, 790, 63, 1419, 534, 889, 13, 719, 13, 21513, 12, 504, 628, 709, 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, 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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 ]
TeamExodus/external_chromium_org
content/test/gpu/gpu_tests/memory_test.py
26
4403
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import memory_test_expectations import page_sets from telemetry import benchmark from telemetry.page import page_test from telemetry.core.platform import tracing_category_filter from telemetry.core.platform import tracing_options from telemetry.timeline import counter from telemetry.timeline import model MEMORY_LIMIT_MB = 192 SINGLE_TAB_LIMIT_MB = 192 WIGGLE_ROOM_MB = 12 test_harness_script = r""" var domAutomationController = {}; domAutomationController._finished = false; domAutomationController.send = function(msg) { // This should wait until all effects of memory management complete. // We will need to wait until all // 1. pending commits from the main thread to the impl thread in the // compositor complete (for visible compositors). // 2. allocations that the renderer's impl thread will make due to the // compositor and WebGL are completed. // 3. pending GpuMemoryManager::Manage() calls to manage are made. // 4. renderers' OnMemoryAllocationChanged callbacks in response to // manager are made. // Each step in this sequence can cause trigger the next (as a 1-2-3-4-1 // cycle), so we will need to pump this cycle until it stabilizes. // Pump the cycle 8 times (in principle it could take an infinite number // of iterations to settle). var rafCount = 0; // Impl-side painting has changed the behavior of this test. // Currently the background of the page shows up checkerboarded // initially, causing the test to fail because the memory // allocation is too low (no root layer). Temporarily increase the // rAF count to 32 in order to make the test work reliably again. // crbug.com/373098 // TODO(kbr): revert this change and put it back to 8 iterations. var totalRafCount = 32; function pumpRAF() { if (rafCount == totalRafCount) { domAutomationController._finished = true; return; } ++rafCount; window.requestAnimationFrame(pumpRAF); } pumpRAF(); } window.domAutomationController = domAutomationController; window.addEventListener("load", function() { useGpuMemory(%d); }, false); """ % MEMORY_LIMIT_MB class _MemoryValidator(page_test.PageTest): def ValidateAndMeasurePage(self, page, tab, results): timeline_data = tab.browser.platform.tracing_controller.Stop() timeline_model = model.TimelineModel(timeline_data) for process in timeline_model.GetAllProcesses(): if 'gpu.GpuMemoryUsage' in process.counters: counter = process.GetCounter('gpu', 'GpuMemoryUsage') mb_used = counter.samples[-1] / 1048576 if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB: raise page_test.Failure(self._FormatException('low', mb_used)) if mb_used - WIGGLE_ROOM_MB > MEMORY_LIMIT_MB: raise page_test.Failure(self._FormatException('high', mb_used)) def CustomizeBrowserOptions(self, options): options.AppendExtraBrowserArgs('--enable-logging') options.AppendExtraBrowserArgs( '--force-gpu-mem-available-mb=%s' % MEMORY_LIMIT_MB) def WillNavigateToPage(self, page, tab): # FIXME: Remove webkit.console when blink.console lands in chromium and the # ref builds are updated. crbug.com/386847 custom_categories = ['webkit.console', 'blink.console', 'gpu'] category_filter = tracing_category_filter.TracingCategoryFilter() for c in custom_categories: category_filter.AddIncludedCategory(c) options = tracing_options.TracingOptions() options.enable_chrome_trace = True tab.browser.platform.tracing_controller.Start(options, category_filter, 60) def _FormatException(self, low_or_high, mb_used): return 'Memory allocation too %s (was %d MB, should be %d MB +/- %d MB)' % ( low_or_high, mb_used, SINGLE_TAB_LIMIT_MB, WIGGLE_ROOM_MB) class MemoryTest(benchmark.Benchmark): """Tests GPU memory limits""" test = _MemoryValidator def CreateExpectations(self, page_set): return memory_test_expectations.MemoryTestExpectations() def CreatePageSet(self, options): page_set = page_sets.MemoryTestsPageSet() for page in page_set.pages: page.script_to_evaluate_on_commit = test_harness_script return page_set
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 646, 4402, 63, 396, 63, 15752, 199, 646, 2034, 63, 2193, 199, 199, 504, 17298, 492, 12338, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1018, 14, 3246, 492, 23465, 63, 3710, 63, 1541, 199, 504, 17298, 14, 1018, 14, 3246, 492, 23465, 63, 1419, 199, 504, 17298, 14, 19369, 492, 7055, 199, 504, 17298, 14, 19369, 492, 1402, 199, 199, 19495, 63, 13387, 63, 4567, 275, 13567, 199, 16425, 63, 10129, 63, 13387, 63, 4567, 275, 13567, 199, 55, 1277, 12827, 63, 1092, 7474, 63, 4567, 275, 3144, 199, 199, 396, 63, 23569, 63, 1579, 275, 519, 624, 523, 2729, 8266, 3358, 1615, 7506, 275, 27978, 523, 8266, 3358, 1615, 7506, 423, 8669, 275, 3055, 27, 819, 8266, 3358, 1615, 7506, 14, 2254, 275, 805, 8, 1328, 9, 469, 272, 5001, 961, 1077, 3618, 5133, 1006, 22414, 402, 4402, 10041, 4890, 14, 272, 5001, 2136, 911, 1929, 370, 3618, 5133, 1006, 272, 5001, 413, 14, 9413, 20835, 687, 314, 2446, 2462, 370, 314, 11512, 2462, 315, 314, 272, 5001, 259, 11395, 2221, 269, 4890, 334, 509, 8917, 11395, 2221, 1384, 680, 272, 5001, 499, 14, 741, 8022, 626, 314, 11889, 1159, 11512, 2462, 911, 1852, 7037, 370, 314, 272, 5001, 259, 11395, 2221, 269, 436, 6001, 2226, 787, 9709, 14, 272, 5001, 650, 14, 9413, 598, 3165, 8628, 2988, 447, 20588, 342, 4882, 370, 9635, 787, 6326, 14, 272, 5001, 841, 14, 2903, 26529, 7, 4068, 8628, 17794, 6970, 13484, 315, 1177, 370, 272, 5001, 259, 5256, 787, 6326, 14, 272, 5001, 7048, 3650, 315, 642, 3414, 883, 7675, 6804, 314, 2163, 334, 305, 282, 413, 13, 18, 13, 19, 13, 20, 13, 17, 272, 5001, 8643, 395, 880, 781, 911, 1929, 370, 31741, 642, 8643, 5133, 652, 410, 25007, 90, 397, 14, 339, 5001, 510, 1220, 314, 8643, 1695, 5431, 334, 262, 5448, 10352, 274, 652, 4293, 5452, 376, 15258, 1329, 272, 5001, 402, 10615, 370, 663, 1118, 680, 339, 2729, 660, 70, 2353, 275, 378, 27, 339, 5001, 473, 2421, 13, 2441, 32055, 316, 965, 2896, 314, 5953, 402, 642, 511, 14, 272, 5001, 13550, 314, 8020, 402, 314, 2034, 13703, 1536, 7739, 656, 12910, 272, 5001, 22801, 12, 25498, 314, 511, 370, 2449, 2952, 314, 4402, 272, 5001, 18723, 365, 4634, 6465, 334, 889, 1738, 4045, 680, 12540, 269, 11406, 19781, 314, 272, 5001, 519, 5699, 2338, 370, 4337, 315, 1865, 370, 1852, 314, 511, 1736, 16492, 6665, 4020, 14, 272, 5001, 2467, 1266, 14, 957, 15, 1401, 1216, 2905, 272, 5001, 3254, 8, 75, 3289, 304, 23347, 642, 1570, 436, 5324, 652, 1771, 370, 1695, 10615, 14, 272, 2729, 3141, 1537, 70, 2353, 275, 4337, 27, 339, 805, 31741, 2847, 38, 342, 469, 489, 340, 334, 345, 70, 2353, 508, 3141, 1537, 70, 2353, 9, 469, 267, 8266, 3358, 1615, 7506, 423, 8669, 275, 2549, 27, 267, 372, 27, 489, 789, 489, 32629, 345, 70, 2353, 27, 489, 4353, 14, 1069, 15957, 3160, 8, 29547, 2847, 38, 2736, 272, 789, 272, 31741, 2847, 38, 7303, 523, 789, 819, 4353, 14, 4556, 3358, 1615, 7506, 275, 8266, 3358, 1615, 7506, 27, 819, 4353, 14, 525, 2390, 10464, 480, 912, 401, 805, 342, 469, 272, 675, 39, 3165, 8628, 4042, 68, 2736, 523, 1660, 3055, 2736, 199, 624, 450, 31424, 5347, 63, 13387, 63, 4567, 199, 199, 533, 485, 8628, 8640, 8, 1606, 63, 396, 14, 3276, 774, 304, 523, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 2058, 304, 272, 20780, 63, 576, 275, 5174, 14, 5750, 14, 3246, 14, 21635, 63, 5538, 14, 6293, 342, 272, 20780, 63, 1238, 275, 1402, 14, 27097, 1685, 8, 19369, 63, 576, 9, 272, 367, 2112, 315, 20780, 63, 1238, 14, 24578, 25857, 837, 489, 340, 283, 6477, 14, 39, 3165, 8628, 7692, 7, 315, 2112, 14, 16558, 26, 267, 7055, 275, 2112, 14, 1002, 11348, 360, 6477, 297, 283, 39, 3165, 8628, 7692, 358, 267, 21187, 63, 2972, 275, 7055, 14, 3356, 1988, 17, 61, 1182, 413, 9941, 12255, 339, 340, 21187, 63, 2972, 435, 644, 1277, 12827, 63, 1092, 7474, 63, 4567, 665, 8655, 63, 10129, 63, 13387, 63, 4567, 26, 489, 746, 2034, 63, 396, 14, 6782, 8, 277, 423, 3484, 1726, 360, 674, 297, 21187, 63, 2972, 430, 339, 340, 21187, 63, 2972, 446, 644, 1277, 12827, 63, 1092, 7474, 63, 4567, 690, 31424, 5347, 63, 13387, 63, 4567, 26, 489, 746, 2034, 63, 396, 14, 6782, 8, 277, 423, 3484, 1726, 360, 6260, 297, 21187, 63, 2972, 430, 819, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 1511, 14, 8310, 7426, 11930, 6213, 4517, 4296, 13, 4806, 358, 272, 1511, 14, 8310, 7426, 11930, 6213, 8, 267, 2850, 3990, 13, 6477, 13, 5286, 13, 4561, 13, 887, 2458, 83, 7, 450, 31424, 5347, 63, 13387, 63, 4567, 9, 819, 347, 12823, 31914, 1378, 3276, 8, 277, 12, 2034, 12, 5174, 304, 272, 327, 7600, 26, 5852, 15804, 14, 6614, 1380, 330, 1073, 14, 6614, 634, 5915, 315, 682, 7419, 436, 314, 272, 327, 2984, 14723, 787, 4588, 14, 2467, 1266, 14, 957, 15, 8040, 15883, 272, 3537, 63, 8906, 275, 788, 12554, 14, 6614, 297, 283, 24042, 14, 6614, 297, 283, 6477, 418, 272, 4637, 63, 1541, 275, 23465, 63, 3710, 63, 1541, 14, 2437, 4477, 7841, 4131, 342, 272, 367, 286, 315, 3537, 63, 8906, 26, 267, 4637, 63, 1541, 14, 1123, 607, 3331, 7841, 8, 67, 9, 272, 1511, 275, 23465, 63, 1419, 14, 2437, 4477, 4558, 342, 272, 1511, 14, 4296, 63, 9887, 63, 3446, 275, 715, 272, 5174, 14, 5750, 14, 3246, 14, 21635, 63, 5538, 14, 3162, 8, 1419, 12, 4637, 63, 1541, 12, 5212, 9, 819, 347, 485, 3484, 1726, 8, 277, 12, 6465, 63, 269, 63, 6260, 12, 21187, 63, 2972, 304, 272, 372, 283, 8628, 18723, 4634, 450, 83, 334, 10274, 450, 68, 19487, 12, 1077, 506 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 646, 4402, 63, 396, 63, 15752, 199, 646, 2034, 63, 2193, 199, 199, 504, 17298, 492, 12338, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1018, 14, 3246, 492, 23465, 63, 3710, 63, 1541, 199, 504, 17298, 14, 1018, 14, 3246, 492, 23465, 63, 1419, 199, 504, 17298, 14, 19369, 492, 7055, 199, 504, 17298, 14, 19369, 492, 1402, 199, 199, 19495, 63, 13387, 63, 4567, 275, 13567, 199, 16425, 63, 10129, 63, 13387, 63, 4567, 275, 13567, 199, 55, 1277, 12827, 63, 1092, 7474, 63, 4567, 275, 3144, 199, 199, 396, 63, 23569, 63, 1579, 275, 519, 624, 523, 2729, 8266, 3358, 1615, 7506, 275, 27978, 523, 8266, 3358, 1615, 7506, 423, 8669, 275, 3055, 27, 819, 8266, 3358, 1615, 7506, 14, 2254, 275, 805, 8, 1328, 9, 469, 272, 5001, 961, 1077, 3618, 5133, 1006, 22414, 402, 4402, 10041, 4890, 14, 272, 5001, 2136, 911, 1929, 370, 3618, 5133, 1006, 272, 5001, 413, 14, 9413, 20835, 687, 314, 2446, 2462, 370, 314, 11512, 2462, 315, 314, 272, 5001, 259, 11395, 2221, 269, 4890, 334, 509, 8917, 11395, 2221, 1384, 680, 272, 5001, 499, 14, 741, 8022, 626, 314, 11889, 1159, 11512, 2462, 911, 1852, 7037, 370, 314, 272, 5001, 259, 11395, 2221, 269, 436, 6001, 2226, 787, 9709, 14, 272, 5001, 650, 14, 9413, 598, 3165, 8628, 2988, 447, 20588, 342, 4882, 370, 9635, 787, 6326, 14, 272, 5001, 841, 14, 2903, 26529, 7, 4068, 8628, 17794, 6970, 13484, 315, 1177, 370, 272, 5001, 259, 5256, 787, 6326, 14, 272, 5001, 7048, 3650, 315, 642, 3414, 883, 7675, 6804, 314, 2163, 334, 305, 282, 413, 13, 18, 13, 19, 13, 20, 13, 17, 272, 5001, 8643, 395, 880, 781, 911, 1929, 370, 31741, 642, 8643, 5133, 652, 410, 25007, 90, 397, 14, 339, 5001, 510, 1220, 314, 8643, 1695, 5431, 334, 262, 5448, 10352, 274, 652, 4293, 5452, 376, 15258, 1329, 272, 5001, 402, 10615, 370, 663, 1118, 680, 339, 2729, 660, 70, 2353, 275, 378, 27, 339, 5001, 473, 2421, 13, 2441, 32055, 316, 965, 2896, 314, 5953, 402, 642, 511, 14, 272, 5001, 13550, 314, 8020, 402, 314, 2034, 13703, 1536, 7739, 656, 12910, 272, 5001, 22801, 12, 25498, 314, 511, 370, 2449, 2952, 314, 4402, 272, 5001, 18723, 365, 4634, 6465, 334, 889, 1738, 4045, 680, 12540, 269, 11406, 19781, 314, 272, 5001, 519, 5699, 2338, 370, 4337, 315, 1865, 370, 1852, 314, 511, 1736, 16492, 6665, 4020, 14, 272, 5001, 2467, 1266, 14, 957, 15, 1401, 1216, 2905, 272, 5001, 3254, 8, 75, 3289, 304, 23347, 642, 1570, 436, 5324, 652, 1771, 370, 1695, 10615, 14, 272, 2729, 3141, 1537, 70, 2353, 275, 4337, 27, 339, 805, 31741, 2847, 38, 342, 469, 489, 340, 334, 345, 70, 2353, 508, 3141, 1537, 70, 2353, 9, 469, 267, 8266, 3358, 1615, 7506, 423, 8669, 275, 2549, 27, 267, 372, 27, 489, 789, 489, 32629, 345, 70, 2353, 27, 489, 4353, 14, 1069, 15957, 3160, 8, 29547, 2847, 38, 2736, 272, 789, 272, 31741, 2847, 38, 7303, 523, 789, 819, 4353, 14, 4556, 3358, 1615, 7506, 275, 8266, 3358, 1615, 7506, 27, 819, 4353, 14, 525, 2390, 10464, 480, 912, 401, 805, 342, 469, 272, 675, 39, 3165, 8628, 4042, 68, 2736, 523, 1660, 3055, 2736, 199, 624, 450, 31424, 5347, 63, 13387, 63, 4567, 199, 199, 533, 485, 8628, 8640, 8, 1606, 63, 396, 14, 3276, 774, 304, 523, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 2058, 304, 272, 20780, 63, 576, 275, 5174, 14, 5750, 14, 3246, 14, 21635, 63, 5538, 14, 6293, 342, 272, 20780, 63, 1238, 275, 1402, 14, 27097, 1685, 8, 19369, 63, 576, 9, 272, 367, 2112, 315, 20780, 63, 1238, 14, 24578, 25857, 837, 489, 340, 283, 6477, 14, 39, 3165, 8628, 7692, 7, 315, 2112, 14, 16558, 26, 267, 7055, 275, 2112, 14, 1002, 11348, 360, 6477, 297, 283, 39, 3165, 8628, 7692, 358, 267, 21187, 63, 2972, 275, 7055, 14, 3356, 1988, 17, 61, 1182, 413, 9941, 12255, 339, 340, 21187, 63, 2972, 435, 644, 1277, 12827, 63, 1092, 7474, 63, 4567, 665, 8655, 63, 10129, 63, 13387, 63, 4567, 26, 489, 746, 2034, 63, 396, 14, 6782, 8, 277, 423, 3484, 1726, 360, 674, 297, 21187, 63, 2972, 430, 339, 340, 21187, 63, 2972, 446, 644, 1277, 12827, 63, 1092, 7474, 63, 4567, 690, 31424, 5347, 63, 13387, 63, 4567, 26, 489, 746, 2034, 63, 396, 14, 6782, 8, 277, 423, 3484, 1726, 360, 6260, 297, 21187, 63, 2972, 430, 819, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 1511, 14, 8310, 7426, 11930, 6213, 4517, 4296, 13, 4806, 358, 272, 1511, 14, 8310, 7426, 11930, 6213, 8, 267, 2850, 3990, 13, 6477, 13, 5286, 13, 4561, 13, 887, 2458, 83, 7, 450, 31424, 5347, 63, 13387, 63, 4567, 9, 819, 347, 12823, 31914, 1378, 3276, 8, 277, 12, 2034, 12, 5174, 304, 272, 327, 7600, 26, 5852, 15804, 14, 6614, 1380, 330, 1073, 14, 6614, 634, 5915, 315, 682, 7419, 436, 314, 272, 327, 2984, 14723, 787, 4588, 14, 2467, 1266, 14, 957, 15, 8040, 15883, 272, 3537, 63, 8906, 275, 788, 12554, 14, 6614, 297, 283, 24042, 14, 6614, 297, 283, 6477, 418, 272, 4637, 63, 1541, 275, 23465, 63, 3710, 63, 1541, 14, 2437, 4477, 7841, 4131, 342, 272, 367, 286, 315, 3537, 63, 8906, 26, 267, 4637, 63, 1541, 14, 1123, 607, 3331, 7841, 8, 67, 9, 272, 1511, 275, 23465, 63, 1419, 14, 2437, 4477, 4558, 342, 272, 1511, 14, 4296, 63, 9887, 63, 3446, 275, 715, 272, 5174, 14, 5750, 14, 3246, 14, 21635, 63, 5538, 14, 3162, 8, 1419, 12, 4637, 63, 1541, 12, 5212, 9, 819, 347, 485, 3484, 1726, 8, 277, 12, 6465, 63, 269, 63, 6260, 12, 21187, 63, 2972, 304, 272, 372, 283, 8628, 18723, 4634, 450, 83, 334, 10274, 450, 68, 19487, 12, 1077, 506, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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( Event, Movie, Package, PackageNullFK, Person, Screening, ScreeningNullFK, ) # These are tests for #16715. The basic scheme is always the same: 3 models with # 2 relations. The first relation may be null, while the second is non-nullable. # In some cases, Django would pick the wrong join type for the second relation, # resulting in missing objects in the queryset. # # Model A # | (Relation A/B : nullable) # Model B # | (Relation B/C : non-nullable) # Model C # # Because of the possibility of NULL rows resulting from the LEFT OUTER JOIN # between Model A and Model B (i.e. instances of A without reference to B), # the second join must also be LEFT OUTER JOIN, so that we do not ignore # instances of A that do not reference B. # # Relation A/B can either be an explicit foreign key or an implicit reverse # relation such as introduced by one-to-one relations (through multi-table # inheritance). class NestedForeignKeysTests(TestCase): def setUp(self): self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) # This test failed in #16715 because in some cases INNER JOIN was selected # for the second foreign key relation instead of LEFT OUTER JOIN. def test_inheritance(self): Event.objects.create() Screening.objects.create(movie=self.movie) self.assertEqual(len(Event.objects.all()), 2) self.assertEqual(len(Event.objects.select_related('screening')), 2) # This failed. self.assertEqual(len(Event.objects.select_related('screening__movie')), 2) self.assertEqual(len(Event.objects.values()), 2) self.assertEqual(len(Event.objects.values('screening__pk')), 2) self.assertEqual(len(Event.objects.values('screening__movie__pk')), 2) self.assertEqual(len(Event.objects.values('screening__movie__title')), 2) # This failed. self.assertEqual(len(Event.objects.values('screening__movie__pk', 'screening__movie__title')), 2) # Simple filter/exclude queries for good measure. self.assertEqual(Event.objects.filter(screening__movie=self.movie).count(), 1) self.assertEqual(Event.objects.exclude(screening__movie=self.movie).count(), 1) # These all work because the second foreign key in the chain has null=True. def test_inheritance_null_FK(self): Event.objects.create() ScreeningNullFK.objects.create(movie=None) ScreeningNullFK.objects.create(movie=self.movie) self.assertEqual(len(Event.objects.all()), 3) self.assertEqual(len(Event.objects.select_related('screeningnullfk')), 3) self.assertEqual(len(Event.objects.select_related('screeningnullfk__movie')), 3) self.assertEqual(len(Event.objects.values()), 3) self.assertEqual(len(Event.objects.values('screeningnullfk__pk')), 3) self.assertEqual(len(Event.objects.values('screeningnullfk__movie__pk')), 3) self.assertEqual(len(Event.objects.values('screeningnullfk__movie__title')), 3) self.assertEqual(len(Event.objects.values('screeningnullfk__movie__pk', 'screeningnullfk__movie__title')), 3) self.assertEqual(Event.objects.filter(screeningnullfk__movie=self.movie).count(), 1) self.assertEqual(Event.objects.exclude(screeningnullfk__movie=self.movie).count(), 2) def test_null_exclude(self): screening = ScreeningNullFK.objects.create(movie=None) ScreeningNullFK.objects.create(movie=self.movie) self.assertEqual( list(ScreeningNullFK.objects.exclude(movie__id=self.movie.pk)), [screening]) # This test failed in #16715 because in some cases INNER JOIN was selected # for the second foreign key relation instead of LEFT OUTER JOIN. def test_explicit_ForeignKey(self): Package.objects.create() screening = Screening.objects.create(movie=self.movie) Package.objects.create(screening=screening) self.assertEqual(len(Package.objects.all()), 2) self.assertEqual(len(Package.objects.select_related('screening')), 2) self.assertEqual(len(Package.objects.select_related('screening__movie')), 2) self.assertEqual(len(Package.objects.values()), 2) self.assertEqual(len(Package.objects.values('screening__pk')), 2) self.assertEqual(len(Package.objects.values('screening__movie__pk')), 2) self.assertEqual(len(Package.objects.values('screening__movie__title')), 2) # This failed. self.assertEqual(len(Package.objects.values('screening__movie__pk', 'screening__movie__title')), 2) self.assertEqual(Package.objects.filter(screening__movie=self.movie).count(), 1) self.assertEqual(Package.objects.exclude(screening__movie=self.movie).count(), 1) # These all work because the second foreign key in the chain has null=True. def test_explicit_ForeignKey_NullFK(self): PackageNullFK.objects.create() screening = ScreeningNullFK.objects.create(movie=None) screening_with_movie = ScreeningNullFK.objects.create(movie=self.movie) PackageNullFK.objects.create(screening=screening) PackageNullFK.objects.create(screening=screening_with_movie) self.assertEqual(len(PackageNullFK.objects.all()), 3) self.assertEqual(len(PackageNullFK.objects.select_related('screening')), 3) self.assertEqual(len(PackageNullFK.objects.select_related('screening__movie')), 3) self.assertEqual(len(PackageNullFK.objects.values()), 3) self.assertEqual(len(PackageNullFK.objects.values('screening__pk')), 3) self.assertEqual(len(PackageNullFK.objects.values('screening__movie__pk')), 3) self.assertEqual(len(PackageNullFK.objects.values('screening__movie__title')), 3) self.assertEqual(len(PackageNullFK.objects.values('screening__movie__pk', 'screening__movie__title')), 3) self.assertEqual(PackageNullFK.objects.filter(screening__movie=self.movie).count(), 1) self.assertEqual(PackageNullFK.objects.exclude(screening__movie=self.movie).count(), 2) # Some additional tests for #16715. The only difference is the depth of the # nesting as we now use 4 models instead of 3 (and thus 3 relations). This # checks if promotion of join types works for deeper nesting too. class DeeplyNestedForeignKeysTests(TestCase): def setUp(self): self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) def test_inheritance(self): Event.objects.create() Screening.objects.create(movie=self.movie) self.assertEqual(len(Event.objects.all()), 2) self.assertEqual(len(Event.objects.select_related('screening__movie__director')), 2) self.assertEqual(len(Event.objects.values()), 2) self.assertEqual(len(Event.objects.values('screening__movie__director__pk')), 2) self.assertEqual(len(Event.objects.values('screening__movie__director__name')), 2) self.assertEqual( len(Event.objects.values('screening__movie__director__pk', 'screening__movie__director__name')), 2 ) self.assertEqual(len(Event.objects.values('screening__movie__pk', 'screening__movie__director__pk')), 2) self.assertEqual(len(Event.objects.values('screening__movie__pk', 'screening__movie__director__name')), 2) self.assertEqual(len(Event.objects.values('screening__movie__title', 'screening__movie__director__pk')), 2) self.assertEqual(len(Event.objects.values('screening__movie__title', 'screening__movie__director__name')), 2) self.assertEqual(Event.objects.filter(screening__movie__director=self.director).count(), 1) self.assertEqual(Event.objects.exclude(screening__movie__director=self.director).count(), 1) def test_explicit_ForeignKey(self): Package.objects.create() screening = Screening.objects.create(movie=self.movie) Package.objects.create(screening=screening) self.assertEqual(len(Package.objects.all()), 2) self.assertEqual(len(Package.objects.select_related('screening__movie__director')), 2) self.assertEqual(len(Package.objects.values()), 2) self.assertEqual(len(Package.objects.values('screening__movie__director__pk')), 2) self.assertEqual(len(Package.objects.values('screening__movie__director__name')), 2) self.assertEqual( len(Package.objects.values('screening__movie__director__pk', 'screening__movie__director__name')), 2 ) self.assertEqual(len(Package.objects.values('screening__movie__pk', 'screening__movie__director__pk')), 2) self.assertEqual(len(Package.objects.values('screening__movie__pk', 'screening__movie__director__name')), 2) self.assertEqual(len(Package.objects.values('screening__movie__title', 'screening__movie__director__pk')), 2) self.assertEqual(len(Package.objects.values('screening__movie__title', 'screening__movie__director__name')), 2) self.assertEqual(Package.objects.filter(screening__movie__director=self.director).count(), 1) self.assertEqual(Package.objects.exclude(screening__movie__director=self.director).count(), 1)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 272, 6763, 12, 31248, 12, 15665, 12, 15665, 8849, 21490, 12, 8028, 12, 17804, 316, 12, 17804, 316, 8849, 21490, 12, 199, 9, 421, 199, 3, 5723, 787, 2295, 367, 327, 10806, 1046, 14, 710, 5678, 5687, 365, 3544, 314, 2011, 26, 650, 1709, 543, 199, 3, 499, 16109, 14, 710, 1642, 5850, 1443, 506, 2973, 12, 1830, 314, 3499, 365, 2222, 13, 16375, 14, 199, 3, 1010, 2005, 5560, 12, 5634, 3955, 3732, 314, 6835, 4263, 730, 367, 314, 3499, 5850, 12, 199, 3, 9183, 315, 4124, 2251, 315, 314, 7594, 14, 199, 3, 199, 3, 257, 5822, 437, 199, 3, 257, 1204, 334, 12617, 437, 15, 34, 520, 7854, 9, 199, 3, 257, 5822, 699, 199, 3, 257, 1204, 334, 12617, 699, 15, 35, 520, 2222, 13, 16375, 9, 199, 3, 257, 5822, 445, 199, 3, 199, 3, 13821, 402, 314, 31077, 402, 5962, 4730, 9183, 687, 314, 6578, 31682, 10593, 199, 3, 3382, 5822, 437, 436, 5822, 699, 334, 73, 14, 69, 14, 4454, 402, 437, 1928, 3659, 370, 699, 395, 199, 3, 314, 3499, 4263, 1471, 2597, 506, 6578, 31682, 10593, 12, 880, 626, 781, 886, 440, 3686, 199, 3, 4454, 402, 437, 626, 886, 440, 3659, 699, 14, 199, 3, 199, 3, 23230, 437, 15, 34, 883, 1902, 506, 376, 5027, 11608, 790, 503, 376, 9227, 3837, 199, 3, 5850, 4066, 465, 21399, 701, 1373, 13, 475, 13, 368, 16109, 334, 8304, 3510, 13, 1224, 199, 3, 15433, 680, 199, 533, 23137, 20931, 6340, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 24712, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 8600, 651, 598, 8148, 455, 1182, 13861, 651, 1603, 4548, 358, 267, 291, 14, 10888, 275, 31248, 14, 1462, 14, 981, 8, 1213, 534, 6671, 369, 2018, 436, 314, 869, 16242, 10268, 382, 297, 487, 14521, 29, 277, 14, 24712, 9, 339, 327, 961, 511, 3405, 315, 327, 10806, 1046, 2952, 315, 2005, 5560, 32272, 10593, 1990, 4895, 272, 327, 367, 314, 3499, 11608, 790, 5850, 3140, 402, 6578, 31682, 10593, 14, 272, 347, 511, 63, 13136, 8, 277, 304, 267, 6763, 14, 1462, 14, 981, 342, 267, 17804, 316, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 452, 4000, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 3855, 499, 9, 267, 327, 961, 3405, 14, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 363, 10888, 3855, 499, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 4000, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 2051, 3855, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 2051, 3855, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 1213, 3855, 499, 9, 267, 327, 961, 3405, 14, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 2051, 297, 283, 5410, 316, 363, 10888, 363, 1213, 3855, 499, 9, 398, 327, 5870, 2457, 15, 5473, 9212, 367, 6954, 9775, 14, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 1541, 8, 5410, 316, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 5473, 8, 5410, 316, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 339, 327, 5723, 1006, 1736, 2952, 314, 3499, 11608, 790, 315, 314, 6036, 965, 2973, 29, 549, 14, 272, 347, 511, 63, 13136, 63, 2307, 63, 21490, 8, 277, 304, 267, 6763, 14, 1462, 14, 981, 342, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 403, 9, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 452, 4000, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 78, 348, 276, 75, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 3855, 650, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 4000, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 2051, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 2051, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 1213, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 2051, 297, 283, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 1213, 3855, 650, 9, 398, 291, 14, 629, 8, 2390, 14, 1462, 14, 1541, 8, 5410, 316, 78, 348, 276, 75, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 5473, 8, 5410, 316, 78, 348, 276, 75, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 499, 9, 339, 347, 511, 63, 2307, 63, 5473, 8, 277, 304, 267, 6426, 316, 275, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 403, 9, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 267, 291, 14, 629, 8, 288, 769, 8, 9616, 316, 8849, 21490, 14, 1462, 14, 5473, 8, 10888, 363, 344, 29, 277, 14, 10888, 14, 2051, 1826, 288, 359, 5410, 316, 566, 339 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 272, 6763, 12, 31248, 12, 15665, 12, 15665, 8849, 21490, 12, 8028, 12, 17804, 316, 12, 17804, 316, 8849, 21490, 12, 199, 9, 421, 199, 3, 5723, 787, 2295, 367, 327, 10806, 1046, 14, 710, 5678, 5687, 365, 3544, 314, 2011, 26, 650, 1709, 543, 199, 3, 499, 16109, 14, 710, 1642, 5850, 1443, 506, 2973, 12, 1830, 314, 3499, 365, 2222, 13, 16375, 14, 199, 3, 1010, 2005, 5560, 12, 5634, 3955, 3732, 314, 6835, 4263, 730, 367, 314, 3499, 5850, 12, 199, 3, 9183, 315, 4124, 2251, 315, 314, 7594, 14, 199, 3, 199, 3, 257, 5822, 437, 199, 3, 257, 1204, 334, 12617, 437, 15, 34, 520, 7854, 9, 199, 3, 257, 5822, 699, 199, 3, 257, 1204, 334, 12617, 699, 15, 35, 520, 2222, 13, 16375, 9, 199, 3, 257, 5822, 445, 199, 3, 199, 3, 13821, 402, 314, 31077, 402, 5962, 4730, 9183, 687, 314, 6578, 31682, 10593, 199, 3, 3382, 5822, 437, 436, 5822, 699, 334, 73, 14, 69, 14, 4454, 402, 437, 1928, 3659, 370, 699, 395, 199, 3, 314, 3499, 4263, 1471, 2597, 506, 6578, 31682, 10593, 12, 880, 626, 781, 886, 440, 3686, 199, 3, 4454, 402, 437, 626, 886, 440, 3659, 699, 14, 199, 3, 199, 3, 23230, 437, 15, 34, 883, 1902, 506, 376, 5027, 11608, 790, 503, 376, 9227, 3837, 199, 3, 5850, 4066, 465, 21399, 701, 1373, 13, 475, 13, 368, 16109, 334, 8304, 3510, 13, 1224, 199, 3, 15433, 680, 199, 533, 23137, 20931, 6340, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 24712, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 8600, 651, 598, 8148, 455, 1182, 13861, 651, 1603, 4548, 358, 267, 291, 14, 10888, 275, 31248, 14, 1462, 14, 981, 8, 1213, 534, 6671, 369, 2018, 436, 314, 869, 16242, 10268, 382, 297, 487, 14521, 29, 277, 14, 24712, 9, 339, 327, 961, 511, 3405, 315, 327, 10806, 1046, 2952, 315, 2005, 5560, 32272, 10593, 1990, 4895, 272, 327, 367, 314, 3499, 11608, 790, 5850, 3140, 402, 6578, 31682, 10593, 14, 272, 347, 511, 63, 13136, 8, 277, 304, 267, 6763, 14, 1462, 14, 981, 342, 267, 17804, 316, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 452, 4000, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 3855, 499, 9, 267, 327, 961, 3405, 14, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 363, 10888, 3855, 499, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 4000, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 2051, 3855, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 2051, 3855, 499, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 1213, 3855, 499, 9, 267, 327, 961, 3405, 14, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 363, 10888, 363, 2051, 297, 283, 5410, 316, 363, 10888, 363, 1213, 3855, 499, 9, 398, 327, 5870, 2457, 15, 5473, 9212, 367, 6954, 9775, 14, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 1541, 8, 5410, 316, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 5473, 8, 5410, 316, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 339, 327, 5723, 1006, 1736, 2952, 314, 3499, 11608, 790, 315, 314, 6036, 965, 2973, 29, 549, 14, 272, 347, 511, 63, 13136, 63, 2307, 63, 21490, 8, 277, 304, 267, 6763, 14, 1462, 14, 981, 342, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 403, 9, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 452, 4000, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 78, 348, 276, 75, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 2416, 63, 2407, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 3855, 650, 9, 398, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 4000, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 2051, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 2051, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 1213, 3855, 650, 9, 267, 291, 14, 629, 8, 552, 8, 2390, 14, 1462, 14, 1459, 360, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 2051, 297, 283, 5410, 316, 78, 348, 276, 75, 363, 10888, 363, 1213, 3855, 650, 9, 398, 291, 14, 629, 8, 2390, 14, 1462, 14, 1541, 8, 5410, 316, 78, 348, 276, 75, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 413, 9, 267, 291, 14, 629, 8, 2390, 14, 1462, 14, 5473, 8, 5410, 316, 78, 348, 276, 75, 363, 10888, 29, 277, 14, 10888, 680, 835, 1062, 499, 9, 339, 347, 511, 63, 2307, 63, 5473, 8, 277, 304, 267, 6426, 316, 275, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 403, 9, 267, 17804, 316, 8849, 21490, 14, 1462, 14, 981, 8, 10888, 29, 277, 14, 10888, 9, 267, 291, 14, 629, 8, 288, 769, 8, 9616, 316, 8849, 21490, 14, 1462, 14, 5473, 8, 10888, 363, 344, 29, 277, 14, 10888, 14, 2051, 1826, 288, 359, 5410, 316, 566, 339, 0 ]
[ 1, 1, 1, 1, 1,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atoServer
couchpotato/core/media/movie/charts/main.py
9
2409
import time from couchpotato.core.logger import CPLog from couchpotato.api import addApiView from couchpotato.core.event import addEvent,fireEvent from couchpotato.core.plugins.base import Plugin import tmdb3 log = CPLog(__name__) class Charts(Plugin): update_in_progress = False update_interval = 72 # hours def __init__(self): addApiView('charts.view', self.automationView) addEvent('app.load', self.setCrons) def setCrons(self): fireEvent('schedule.interval', 'charts.update_cache', self.updateViewCache, hours = self.update_interval) def automationView(self, force_update = False, **kwargs): if force_update: charts = self.updateViewCache() else: charts = self.getCache('charts_cached') if not charts: charts = self.updateViewCache() y=0 for chart in charts: x=0 for item in chart['list']: movie = tmdb3.Movie(item['imdb']) try: charts[y]['list'][x]['plot']=movie.overview charts[y]['list'][x]['titles'][0]=movie.title charts[y]['list'][x]['images']['poster'][0]=charts[y]['list'][x]['images']['poster_original'][y][:charts[y]['list'][x]['images']['poster_original'][0].rfind('/')+1]+movie.posters[0].filename except: x+=1 continue x+=1 y+=1 return { 'success': True, 'count': len(charts), 'charts': charts } def updateViewCache(self): if self.update_in_progress: while self.update_in_progress: time.sleep(1) catched_charts = self.getCache('charts_cached') if catched_charts: return catched_charts charts = [] try: self.update_in_progress = True charts = fireEvent('automation.get_chart_list', merge = True) for chart in charts: chart['hide_wanted'] = self.conf('hide_wanted') chart['hide_library'] = self.conf('hide_library') self.setCache('charts_cached', charts, timeout = self.update_interval * 3600) except: log.error('Failed refreshing charts') self.update_in_progress = False return charts
gpl-3.0
[ 646, 900, 199, 199, 504, 28877, 30780, 14, 1018, 14, 2921, 492, 19701, 2445, 199, 504, 28877, 30780, 14, 1246, 492, 1050, 7394, 2768, 199, 504, 28877, 30780, 14, 1018, 14, 1430, 492, 1050, 2390, 12, 8935, 2390, 199, 504, 28877, 30780, 14, 1018, 14, 5265, 14, 1095, 492, 11349, 199, 646, 7352, 697, 19, 199, 199, 793, 275, 19701, 2445, 3460, 354, 3368, 421, 199, 533, 24874, 83, 8, 5061, 304, 339, 1678, 63, 262, 63, 5734, 275, 756, 272, 1678, 63, 4284, 275, 15323, 327, 10857, 339, 347, 636, 826, 721, 277, 304, 267, 1050, 7394, 2768, 360, 31522, 14, 1345, 297, 291, 14, 23867, 2768, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 409, 35, 2641, 83, 9, 339, 347, 663, 35, 2641, 83, 8, 277, 304, 267, 8344, 2390, 360, 7211, 14, 4284, 297, 283, 31522, 14, 873, 63, 1637, 297, 291, 14, 873, 2768, 4437, 12, 10857, 275, 291, 14, 873, 63, 4284, 9, 339, 347, 25461, 2768, 8, 277, 12, 3542, 63, 873, 275, 756, 12, 1011, 958, 304, 398, 340, 3542, 63, 873, 26, 288, 10943, 83, 275, 291, 14, 873, 2768, 4437, 342, 267, 587, 26, 288, 10943, 83, 275, 291, 14, 362, 4437, 360, 31522, 63, 5245, 358, 288, 340, 440, 10943, 83, 26, 355, 10943, 83, 275, 291, 14, 873, 2768, 4437, 342, 267, 612, 29, 16, 267, 367, 10943, 315, 10943, 83, 26, 288, 671, 29, 16, 288, 367, 1242, 315, 10943, 459, 513, 2565, 355, 14360, 275, 7352, 697, 19, 14, 19088, 8, 1053, 459, 17117, 1105, 355, 862, 26, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 2798, 13784, 10888, 14, 21753, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 8916, 3488, 16, 10404, 10888, 14, 1213, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 3488, 16, 10404, 31522, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 63, 5043, 3488, 89, 19663, 31522, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 63, 5043, 3488, 16, 1055, 14542, 7825, 11, 17, 2807, 10888, 14, 1712, 878, 59, 16, 1055, 1501, 355, 871, 26, 490, 671, 10365, 17, 490, 1980, 355, 671, 10365, 17, 288, 612, 10365, 17, 27439, 372, 469, 288, 283, 3742, 356, 715, 12, 288, 283, 835, 356, 822, 8, 31522, 395, 288, 283, 31522, 356, 10943, 83, 267, 789, 339, 347, 1678, 2768, 4437, 8, 277, 304, 398, 340, 291, 14, 873, 63, 262, 63, 5734, 26, 288, 1830, 291, 14, 873, 63, 262, 63, 5734, 26, 355, 900, 14, 4532, 8, 17, 9, 288, 8579, 379, 63, 31522, 275, 291, 14, 362, 4437, 360, 31522, 63, 5245, 358, 288, 340, 8579, 379, 63, 31522, 26, 355, 372, 8579, 379, 63, 31522, 398, 10943, 83, 275, 942, 267, 862, 26, 288, 291, 14, 873, 63, 262, 63, 5734, 275, 715, 288, 10943, 83, 275, 8344, 2390, 360, 23867, 14, 362, 63, 9019, 63, 513, 297, 5389, 275, 715, 9, 288, 367, 10943, 315, 10943, 83, 26, 355, 10943, 459, 8191, 63, 19361, 418, 275, 291, 14, 2190, 360, 8191, 63, 19361, 358, 355, 10943, 459, 8191, 63, 4342, 418, 275, 291, 14, 2190, 360, 8191, 63, 4342, 358, 288, 291, 14, 409, 4437, 360, 31522, 63, 5245, 297, 10943, 83, 12, 2653, 275, 291, 14, 873, 63, 4284, 627, 15751, 9, 267, 871, 26, 288, 943, 14, 705, 360, 4276, 9236, 316, 10943, 83, 358, 398, 291, 14, 873, 63, 262, 63, 5734, 275, 756, 398, 372, 10943, 83, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 900, 199, 199, 504, 28877, 30780, 14, 1018, 14, 2921, 492, 19701, 2445, 199, 504, 28877, 30780, 14, 1246, 492, 1050, 7394, 2768, 199, 504, 28877, 30780, 14, 1018, 14, 1430, 492, 1050, 2390, 12, 8935, 2390, 199, 504, 28877, 30780, 14, 1018, 14, 5265, 14, 1095, 492, 11349, 199, 646, 7352, 697, 19, 199, 199, 793, 275, 19701, 2445, 3460, 354, 3368, 421, 199, 533, 24874, 83, 8, 5061, 304, 339, 1678, 63, 262, 63, 5734, 275, 756, 272, 1678, 63, 4284, 275, 15323, 327, 10857, 339, 347, 636, 826, 721, 277, 304, 267, 1050, 7394, 2768, 360, 31522, 14, 1345, 297, 291, 14, 23867, 2768, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 409, 35, 2641, 83, 9, 339, 347, 663, 35, 2641, 83, 8, 277, 304, 267, 8344, 2390, 360, 7211, 14, 4284, 297, 283, 31522, 14, 873, 63, 1637, 297, 291, 14, 873, 2768, 4437, 12, 10857, 275, 291, 14, 873, 63, 4284, 9, 339, 347, 25461, 2768, 8, 277, 12, 3542, 63, 873, 275, 756, 12, 1011, 958, 304, 398, 340, 3542, 63, 873, 26, 288, 10943, 83, 275, 291, 14, 873, 2768, 4437, 342, 267, 587, 26, 288, 10943, 83, 275, 291, 14, 362, 4437, 360, 31522, 63, 5245, 358, 288, 340, 440, 10943, 83, 26, 355, 10943, 83, 275, 291, 14, 873, 2768, 4437, 342, 267, 612, 29, 16, 267, 367, 10943, 315, 10943, 83, 26, 288, 671, 29, 16, 288, 367, 1242, 315, 10943, 459, 513, 2565, 355, 14360, 275, 7352, 697, 19, 14, 19088, 8, 1053, 459, 17117, 1105, 355, 862, 26, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 2798, 13784, 10888, 14, 21753, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 8916, 3488, 16, 10404, 10888, 14, 1213, 490, 10943, 83, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 3488, 16, 10404, 31522, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 63, 5043, 3488, 89, 19663, 31522, 59, 89, 2733, 513, 3488, 88, 2733, 4782, 2545, 20801, 63, 5043, 3488, 16, 1055, 14542, 7825, 11, 17, 2807, 10888, 14, 1712, 878, 59, 16, 1055, 1501, 355, 871, 26, 490, 671, 10365, 17, 490, 1980, 355, 671, 10365, 17, 288, 612, 10365, 17, 27439, 372, 469, 288, 283, 3742, 356, 715, 12, 288, 283, 835, 356, 822, 8, 31522, 395, 288, 283, 31522, 356, 10943, 83, 267, 789, 339, 347, 1678, 2768, 4437, 8, 277, 304, 398, 340, 291, 14, 873, 63, 262, 63, 5734, 26, 288, 1830, 291, 14, 873, 63, 262, 63, 5734, 26, 355, 900, 14, 4532, 8, 17, 9, 288, 8579, 379, 63, 31522, 275, 291, 14, 362, 4437, 360, 31522, 63, 5245, 358, 288, 340, 8579, 379, 63, 31522, 26, 355, 372, 8579, 379, 63, 31522, 398, 10943, 83, 275, 942, 267, 862, 26, 288, 291, 14, 873, 63, 262, 63, 5734, 275, 715, 288, 10943, 83, 275, 8344, 2390, 360, 23867, 14, 362, 63, 9019, 63, 513, 297, 5389, 275, 715, 9, 288, 367, 10943, 315, 10943, 83, 26, 355, 10943, 459, 8191, 63, 19361, 418, 275, 291, 14, 2190, 360, 8191, 63, 19361, 358, 355, 10943, 459, 8191, 63, 4342, 418, 275, 291, 14, 2190, 360, 8191, 63, 4342, 358, 288, 291, 14, 409, 4437, 360, 31522, 63, 5245, 297, 10943, 83, 12, 2653, 275, 291, 14, 873, 63, 4284, 627, 15751, 9, 267, 871, 26, 288, 943, 14, 705, 360, 4276, 9236, 316, 10943, 83, 358, 398, 291, 14, 873, 63, 262, 63, 5734, 275, 756, 398, 372, 10943, 83, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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-engine
packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/async_tasks_map.py
8
3443
# # ovirt-engine-setup -- ovirt engine setup # Copyright (C) 2013 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """ASYNC TASKS MAP Constant.""" ASYNC_TASKS_MAP = { '0': [ 'Unknown', 'Unknown Task', ], '1': [ 'AddVmCommand', 'Adding a virtual machine', ], '3': [ 'AddVmFromScratch', 'Adding a virtual machine from scrtach', ], '2': [ 'AddVmFromTemplate', 'Adding a virtual machine based on a template', ], '7': [ 'StopVmCommand', 'Stopping a virtual machine', ], '8': [ 'ShutdownVmCommand', 'Shutting down a virtual machine', ], '11': [ 'HibernateVmCommand', 'Hibernating a virtual machine', ], '12': [ 'RunVmCommand', 'Running a virtual machine', ], '13': [ 'RunVmOnceCommand', 'Running a virtual machine once', ], '14': [ 'MigrateVmCommand', 'Migrating a virtual machine', ], '16': [ 'MigrateVmToServerCommand', 'Migrating a virtual machine to a dedicated server', ], '15': [ 'InternalMigrateVmCommand', 'Migrating a virtual machine due to an internal engine flow', ], '23': [ 'ExportVmCommand', 'Exporting a virtual machine to an export domain', ], '24': [ 'ExportVmTemplateCommand', 'Exporting a template to an export domain', ], '26': [ 'ImportVmCommand', 'Importing a virtual machine from an export domain', ], '31': [ 'AddDiskToVmCommand', 'Adding disk to virtual machine', ], '32': [ 'RemoveDiskFromVmCommand', 'Removing disk from a virtual machine', ], '39': [ 'ImportVmTemplateCommand', 'Importing a temaplte from an export domain', ], '201': [ 'AddVmTemplateCommand', 'Adding a template', ], '203': [ 'RemoveVmTemplateCommand', 'Removing a template', ], '208': [ 'CreateSnapshotFromTemplateCommand', 'Creating a snapshot of a template', ], '210': [ 'MergeSnapshotCommand', 'Merging a snapshot of a virtual machine', ], '212': [ 'RemoveAllVmImagesCommand', 'Removing all images from virtual machine', ], '216': [ 'RemoveAllVmTemplateImageTemplatesCommand', 'Removing all images of a template', ], '226': [ 'MoveOrCopyTemplateCommand', 'Moving or Copying a template image', ], '228': [ 'MoveMultipleImageGroupCommand', 'Moving multiple disks', ], '314': [ 'RemoveVmFromPoolCommand ', 'Removing virtual maching from pool', ], '1010': [ 'LiveMigrateDisk', 'Migrating Live Disk', ], '1011': [ 'MoveDisk', 'Move Disk', ], }
apache-2.0
[ 3, 199, 3, 21353, 13, 3908, 13, 2758, 1553, 21353, 6869, 3272, 199, 3, 1898, 334, 35, 9, 6171, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 421, 199, 624, 26222, 6389, 377, 7946, 51, 603, 1282, 19991, 1041, 199, 199, 26222, 6389, 63, 17179, 51, 63, 5443, 275, 469, 272, 283, 16, 356, 359, 267, 283, 5912, 297, 267, 283, 5912, 8495, 297, 272, 2156, 272, 283, 17, 356, 359, 267, 283, 1123, 17402, 3110, 297, 267, 283, 20897, 282, 5791, 6844, 297, 272, 2156, 272, 283, 19, 356, 359, 267, 283, 1123, 17402, 2532, 51, 1556, 693, 297, 267, 283, 20897, 282, 5791, 6844, 687, 19270, 3077, 297, 272, 2156, 272, 283, 18, 356, 359, 267, 283, 1123, 17402, 2532, 4231, 297, 267, 283, 20897, 282, 5791, 6844, 4079, 641, 282, 1978, 297, 272, 2156, 272, 283, 23, 356, 359, 267, 283, 6293, 17402, 3110, 297, 267, 283, 6293, 4073, 282, 5791, 6844, 297, 272, 2156, 272, 283, 24, 356, 359, 267, 283, 20043, 17402, 3110, 297, 267, 283, 2662, 337, 1337, 3224, 282, 5791, 6844, 297, 272, 2156, 272, 283, 845, 356, 359, 267, 283, 16106, 605, 78, 323, 17402, 3110, 297, 267, 283, 16106, 605, 78, 1958, 282, 5791, 6844, 297, 272, 2156, 272, 283, 713, 356, 359, 267, 283, 2540, 17402, 3110, 297, 267, 283, 9602, 282, 5791, 6844, 297, 272, 2156, 272, 283, 969, 356, 359, 267, 283, 2540, 17402, 25690, 3110, 297, 267, 283, 9602, 282, 5791, 6844, 5403, 297, 272, 2156, 272, 283, 1079, 356, 359, 267, 283, 26641, 17402, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 297, 272, 2156, 272, 283, 975, 356, 359, 267, 283, 26641, 17402, 1378, 3120, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 370, 282, 29711, 1654, 297, 272, 2156, 272, 283, 1046, 356, 359, 267, 283, 8405, 26641, 17402, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 7037, 370, 376, 5007, 6869, 6369, 297, 272, 2156, 272, 283, 1789, 356, 359, 267, 283, 11399, 17402, 3110, 297, 267, 283, 11399, 316, 282, 5791, 6844, 370, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1194, 356, 359, 267, 283, 11399, 17402, 4231, 3110, 297, 267, 283, 11399, 316, 282, 1978, 370, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1479, 356, 359, 267, 283, 6295, 17402, 3110, 297, 267, 283, 6295, 316, 282, 5791, 6844, 687, 376, 4843, 2881, 297, 272, 2156, 272, 283, 2192, 356, 359, 267, 283, 1123, 10690, 1378, 17402, 3110, 297, 267, 283, 20897, 4543, 370, 5791, 6844, 297, 272, 2156, 272, 283, 708, 356, 359, 267, 283, 5587, 10690, 2532, 17402, 3110, 297, 267, 283, 23420, 4543, 687, 282, 5791, 6844, 297, 272, 2156, 272, 283, 1355, 356, 359, 267, 283, 6295, 17402, 4231, 3110, 297, 267, 283, 6295, 316, 282, 1565, 1130, 20740, 687, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1797, 356, 359, 267, 283, 1123, 17402, 4231, 3110, 297, 267, 283, 20897, 282, 1978, 297, 272, 2156, 272, 283, 11341, 356, 359, 267, 283, 5587, 17402, 4231, 3110, 297, 267, 283, 23420, 282, 1978, 297, 272, 2156, 272, 283, 10630, 356, 359, 267, 283, 2499, 12038, 2532, 4231, 3110, 297, 267, 283, 14380, 282, 5740, 402, 282, 1978, 297, 272, 2156, 272, 283, 12725, 356, 359, 267, 283, 11359, 12038, 3110, 297, 267, 283, 16797, 1540, 282, 5740, 402, 282, 5791, 6844, 297, 272, 2156, 272, 283, 11722, 356, 359, 267, 283, 28641, 17402, 18882, 3110, 297, 267, 283, 23420, 1006, 5935, 687, 5791, 6844, 297, 272, 2156, 272, 283, 9669, 356, 359, 267, 283, 28641, 17402, 4231, 3491, 17969, 3110, 297, 267, 283, 23420, 1006, 5935, 402, 282, 1978, 297, 272, 2156, 272, 283, 11085, 356, 359, 267, 283, 10370, 2844, 5116, 4231, 3110, 297, 267, 283, 29783, 503, 11247, 316, 282, 1978, 1834, 297, 272, 2156, 272, 283, 12048, 356, 359, 267, 283, 10370, 8433, 3491, 2448, 3110, 297, 267, 283, 29783, 3663, 17602, 297, 272, 2156, 272, 283, 8988, 356, 359, 267, 283, 5587, 17402, 2532, 5453, 3110, 1656, 267, 283, 23420, 5791, 14401, 316, 687, 4203, 297, 272, 2156, 272, 283, 4893, 16, 356, 359, 267, 283, 17458, 26641, 10690, 297, 267, 283, 19322, 10417, 24683, 26287, 297, 272, 2156, 272, 283, 4893, 17, 356, 359, 267, 283, 10370, 10690, 297, 267, 283, 10370, 26287, 297, 272, 2156, 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 ]
[ 199, 3, 21353, 13, 3908, 13, 2758, 1553, 21353, 6869, 3272, 199, 3, 1898, 334, 35, 9, 6171, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 421, 199, 624, 26222, 6389, 377, 7946, 51, 603, 1282, 19991, 1041, 199, 199, 26222, 6389, 63, 17179, 51, 63, 5443, 275, 469, 272, 283, 16, 356, 359, 267, 283, 5912, 297, 267, 283, 5912, 8495, 297, 272, 2156, 272, 283, 17, 356, 359, 267, 283, 1123, 17402, 3110, 297, 267, 283, 20897, 282, 5791, 6844, 297, 272, 2156, 272, 283, 19, 356, 359, 267, 283, 1123, 17402, 2532, 51, 1556, 693, 297, 267, 283, 20897, 282, 5791, 6844, 687, 19270, 3077, 297, 272, 2156, 272, 283, 18, 356, 359, 267, 283, 1123, 17402, 2532, 4231, 297, 267, 283, 20897, 282, 5791, 6844, 4079, 641, 282, 1978, 297, 272, 2156, 272, 283, 23, 356, 359, 267, 283, 6293, 17402, 3110, 297, 267, 283, 6293, 4073, 282, 5791, 6844, 297, 272, 2156, 272, 283, 24, 356, 359, 267, 283, 20043, 17402, 3110, 297, 267, 283, 2662, 337, 1337, 3224, 282, 5791, 6844, 297, 272, 2156, 272, 283, 845, 356, 359, 267, 283, 16106, 605, 78, 323, 17402, 3110, 297, 267, 283, 16106, 605, 78, 1958, 282, 5791, 6844, 297, 272, 2156, 272, 283, 713, 356, 359, 267, 283, 2540, 17402, 3110, 297, 267, 283, 9602, 282, 5791, 6844, 297, 272, 2156, 272, 283, 969, 356, 359, 267, 283, 2540, 17402, 25690, 3110, 297, 267, 283, 9602, 282, 5791, 6844, 5403, 297, 272, 2156, 272, 283, 1079, 356, 359, 267, 283, 26641, 17402, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 297, 272, 2156, 272, 283, 975, 356, 359, 267, 283, 26641, 17402, 1378, 3120, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 370, 282, 29711, 1654, 297, 272, 2156, 272, 283, 1046, 356, 359, 267, 283, 8405, 26641, 17402, 3110, 297, 267, 283, 19322, 10417, 282, 5791, 6844, 7037, 370, 376, 5007, 6869, 6369, 297, 272, 2156, 272, 283, 1789, 356, 359, 267, 283, 11399, 17402, 3110, 297, 267, 283, 11399, 316, 282, 5791, 6844, 370, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1194, 356, 359, 267, 283, 11399, 17402, 4231, 3110, 297, 267, 283, 11399, 316, 282, 1978, 370, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1479, 356, 359, 267, 283, 6295, 17402, 3110, 297, 267, 283, 6295, 316, 282, 5791, 6844, 687, 376, 4843, 2881, 297, 272, 2156, 272, 283, 2192, 356, 359, 267, 283, 1123, 10690, 1378, 17402, 3110, 297, 267, 283, 20897, 4543, 370, 5791, 6844, 297, 272, 2156, 272, 283, 708, 356, 359, 267, 283, 5587, 10690, 2532, 17402, 3110, 297, 267, 283, 23420, 4543, 687, 282, 5791, 6844, 297, 272, 2156, 272, 283, 1355, 356, 359, 267, 283, 6295, 17402, 4231, 3110, 297, 267, 283, 6295, 316, 282, 1565, 1130, 20740, 687, 376, 4843, 2881, 297, 272, 2156, 272, 283, 1797, 356, 359, 267, 283, 1123, 17402, 4231, 3110, 297, 267, 283, 20897, 282, 1978, 297, 272, 2156, 272, 283, 11341, 356, 359, 267, 283, 5587, 17402, 4231, 3110, 297, 267, 283, 23420, 282, 1978, 297, 272, 2156, 272, 283, 10630, 356, 359, 267, 283, 2499, 12038, 2532, 4231, 3110, 297, 267, 283, 14380, 282, 5740, 402, 282, 1978, 297, 272, 2156, 272, 283, 12725, 356, 359, 267, 283, 11359, 12038, 3110, 297, 267, 283, 16797, 1540, 282, 5740, 402, 282, 5791, 6844, 297, 272, 2156, 272, 283, 11722, 356, 359, 267, 283, 28641, 17402, 18882, 3110, 297, 267, 283, 23420, 1006, 5935, 687, 5791, 6844, 297, 272, 2156, 272, 283, 9669, 356, 359, 267, 283, 28641, 17402, 4231, 3491, 17969, 3110, 297, 267, 283, 23420, 1006, 5935, 402, 282, 1978, 297, 272, 2156, 272, 283, 11085, 356, 359, 267, 283, 10370, 2844, 5116, 4231, 3110, 297, 267, 283, 29783, 503, 11247, 316, 282, 1978, 1834, 297, 272, 2156, 272, 283, 12048, 356, 359, 267, 283, 10370, 8433, 3491, 2448, 3110, 297, 267, 283, 29783, 3663, 17602, 297, 272, 2156, 272, 283, 8988, 356, 359, 267, 283, 5587, 17402, 2532, 5453, 3110, 1656, 267, 283, 23420, 5791, 14401, 316, 687, 4203, 297, 272, 2156, 272, 283, 4893, 16, 356, 359, 267, 283, 17458, 26641, 10690, 297, 267, 283, 19322, 10417, 24683, 26287, 297, 272, 2156, 272, 283, 4893, 17, 356, 359, 267, 283, 10370, 10690, 297, 267, 283, 10370, 26287, 297, 272, 2156, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lauria/Samba4
source4/scripting/python/samba/tests/core.py
2
2175
#!/usr/bin/env python # Unix SMB/CIFS implementation. # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008 # # 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/>. # """Samba Python tests.""" import ldb import os import samba from samba.tests import TestCase, TestCaseInTempDir class SubstituteVarTestCase(TestCase): def test_empty(self): self.assertEquals("", samba.substitute_var("", {})) def test_nothing(self): self.assertEquals("foo bar", samba.substitute_var("foo bar", {"bar": "bla"})) def test_replace(self): self.assertEquals("foo bla", samba.substitute_var("foo ${bar}", {"bar": "bla"})) def test_broken(self): self.assertEquals("foo ${bdkjfhsdkfh sdkfh ", samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"})) def test_unknown_var(self): self.assertEquals("foo ${bla} gsff", samba.substitute_var("foo ${bla} gsff", {"bar": "bla"})) def test_check_all_substituted(self): samba.check_all_substituted("nothing to see here") self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}") class LdbExtensionTests(TestCaseInTempDir): def test_searchone(self): path = self.tempdir + "/searchone.ldb" l = samba.Ldb(path) try: l.add({"dn": "foo=dc", "bar": "bla"}) self.assertEquals("bla", l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar")) finally: del l os.unlink(path)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 13074, 2389, 34, 15, 3553, 7079, 4514, 14, 199, 3, 1898, 334, 35, 9, 1603, 352, 2626, 5444, 889, 79, 7879, 665, 74, 352, 2626, 32, 21693, 14, 1308, 30, 10219, 13, 9300, 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, 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, 3, 199, 199, 624, 51, 14310, 2018, 2295, 1041, 199, 199, 646, 634, 697, 199, 646, 747, 199, 646, 31710, 199, 504, 31710, 14, 2219, 492, 7640, 12, 7640, 607, 29008, 199, 199, 533, 4804, 25585, 5894, 1746, 8, 1746, 304, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 291, 14, 2947, 12398, 31710, 14, 20374, 63, 1391, 12398, 17003, 339, 347, 511, 63, 16323, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 4681, 401, 355, 31710, 14, 20374, 63, 1391, 480, 1421, 4681, 401, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 1814, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 330, 416, 401, 355, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 1700, 10750, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 15697, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 10839, 3691, 25775, 12853, 9277, 12853, 13628, 12853, 3872, 7205, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 3691, 25775, 12853, 9277, 12853, 13628, 12853, 3872, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 5187, 63, 1391, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 10839, 21244, 93, 8763, 556, 401, 8892, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 21244, 93, 8763, 556, 401, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 1074, 63, 452, 63, 14340, 4241, 8, 277, 304, 267, 31710, 14, 1074, 63, 452, 63, 14340, 4241, 480, 16323, 370, 1937, 2348, 531, 267, 291, 14, 1855, 8, 1726, 12, 31710, 14, 1074, 63, 452, 63, 14340, 4241, 12, 355, 298, 1763, 1007, 2221, 4241, 26, 10839, 3230, 5488, 689, 15412, 421, 199, 533, 491, 697, 6382, 2925, 8, 1746, 607, 29008, 304, 339, 347, 511, 63, 1733, 368, 8, 277, 304, 267, 931, 275, 291, 14, 11567, 435, 3286, 1733, 368, 14, 15793, 2, 267, 634, 275, 31710, 14, 44, 697, 8, 515, 9, 267, 862, 26, 288, 634, 14, 525, 6333, 4272, 582, 298, 1421, 29, 3833, 401, 298, 1700, 582, 298, 21244, 5984, 288, 291, 14, 2947, 480, 21244, 401, 355, 634, 14, 1733, 368, 8, 1095, 4272, 29, 15793, 14, 36, 78, 8, 76, 12, 298, 1421, 29, 3833, 1288, 2225, 628, 1700, 2237, 267, 3753, 26, 288, 2150, 634, 288, 747, 14, 7162, 8, 515, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 13074, 2389, 34, 15, 3553, 7079, 4514, 14, 199, 3, 1898, 334, 35, 9, 1603, 352, 2626, 5444, 889, 79, 7879, 665, 74, 352, 2626, 32, 21693, 14, 1308, 30, 10219, 13, 9300, 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, 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, 3, 199, 199, 624, 51, 14310, 2018, 2295, 1041, 199, 199, 646, 634, 697, 199, 646, 747, 199, 646, 31710, 199, 504, 31710, 14, 2219, 492, 7640, 12, 7640, 607, 29008, 199, 199, 533, 4804, 25585, 5894, 1746, 8, 1746, 304, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 291, 14, 2947, 12398, 31710, 14, 20374, 63, 1391, 12398, 17003, 339, 347, 511, 63, 16323, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 4681, 401, 355, 31710, 14, 20374, 63, 1391, 480, 1421, 4681, 401, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 1814, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 330, 416, 401, 355, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 1700, 10750, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 15697, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 10839, 3691, 25775, 12853, 9277, 12853, 13628, 12853, 3872, 7205, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 3691, 25775, 12853, 9277, 12853, 13628, 12853, 3872, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 5187, 63, 1391, 8, 277, 304, 267, 291, 14, 2947, 480, 1421, 10839, 21244, 93, 8763, 556, 401, 8892, 31710, 14, 20374, 63, 1391, 480, 1421, 10839, 21244, 93, 8763, 556, 401, 2420, 1700, 582, 298, 21244, 3570, 430, 339, 347, 511, 63, 1074, 63, 452, 63, 14340, 4241, 8, 277, 304, 267, 31710, 14, 1074, 63, 452, 63, 14340, 4241, 480, 16323, 370, 1937, 2348, 531, 267, 291, 14, 1855, 8, 1726, 12, 31710, 14, 1074, 63, 452, 63, 14340, 4241, 12, 355, 298, 1763, 1007, 2221, 4241, 26, 10839, 3230, 5488, 689, 15412, 421, 199, 533, 491, 697, 6382, 2925, 8, 1746, 607, 29008, 304, 339, 347, 511, 63, 1733, 368, 8, 277, 304, 267, 931, 275, 291, 14, 11567, 435, 3286, 1733, 368, 14, 15793, 2, 267, 634, 275, 31710, 14, 44, 697, 8, 515, 9, 267, 862, 26, 288, 634, 14, 525, 6333, 4272, 582, 298, 1421, 29, 3833, 401, 298, 1700, 582, 298, 21244, 5984, 288, 291, 14, 2947, 480, 21244, 401, 355, 634, 14, 1733, 368, 8, 1095, 4272, 29, 15793, 14, 36, 78, 8, 76, 12, 298, 1421, 29, 3833, 1288, 2225, 628, 1700, 2237, 267, 3753, 26, 288, 2150, 634, 288, 747, 14, 7162, 8, 515, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
crazyyoung01/vv
vn.qdp/pyscript/generate_md_functions.py
15
10378
# encoding: UTF-8 __author__ = 'CHENXY' from string import join from qdp_struct import structDict def processCallBack(line): orignalLine = line line = line.replace('\tvirtual void ', '') # 删除行首的无效内容 line = line.replace('{};\n', '') # 删除行尾的无效内容 content = line.split('(') cbName = content[0] # 回调函数名称 cbArgs = content[1] # 回调函数参数 if cbArgs[-1] == ' ': cbArgs = cbArgs.replace(') ', '') else: cbArgs = cbArgs.replace(')', '') cbArgsList = cbArgs.split(', ') # 将每个参数转化为列表 cbArgsTypeList = [] cbArgsValueList = [] for arg in cbArgsList: # 开始处理参数 content = arg.split(' ') if len(content) > 1: cbArgsTypeList.append(content[0]) # 参数类型列表 cbArgsValueList.append(content[1]) # 参数数据列表 createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine) createProcess(cbName, cbArgsTypeList, cbArgsValueList) # 生成.h文件中的process部分 process_line = 'void process' + cbName[2:] + '(Task task);\n' fheaderprocess.write(process_line) fheaderprocess.write('\n') # 生成.h文件中的on部分 if 'OnRspError' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict error, int id, bool last) {};\n' elif 'OnRsp' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error, int id, bool last) {};\n' elif 'OnRtn' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data) {};\n' elif 'OnErrRtn' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error) {};\n' else: on_line = '' fheaderon.write(on_line) fheaderon.write('\n') # 生成封装部分 createWrap(cbName) #---------------------------------------------------------------------- def createWrap(cbName): """在Python封装段代码中进行处理""" # 生成.h文件中的on部分 if 'OnRspError' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict error, int id, bool last)\n' override_line = '("on' + cbName[2:] + '")(error, id, last);\n' elif 'OnRsp' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error, int id, bool last)\n' override_line = '("on' + cbName[2:] + '")(data, error, id, last);\n' elif 'OnRtn' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data)\n' override_line = '("on' + cbName[2:] + '")(data);\n' elif 'OnErrRtn' in cbName: on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error)\n' override_line = '("on' + cbName[2:] + '")(data, error);\n' else: on_line = '' if on_line is not '': fwrap.write(on_line) fwrap.write('{\n') fwrap.write('\ttry\n') fwrap.write('\t{\n') fwrap.write('\t\tthis->get_override'+override_line) fwrap.write('\t}\n') fwrap.write('\tcatch (error_already_set const &)\n') fwrap.write('\t{\n') fwrap.write('\t\tPyErr_Print();\n') fwrap.write('\t}\n') fwrap.write('};\n') fwrap.write('\n') def createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine): # 从回调函数生成任务对象,并放入队列 funcline = orignalLine.replace('\tvirtual void ', 'void ' + apiName + '::') funcline = funcline.replace('{};', '') ftask.write(funcline) ftask.write('{\n') ftask.write("\tTask task = Task();\n") ftask.write("\ttask.task_name = " + cbName.upper() + ";\n") # define常量 global define_count fdefine.write("#define " + cbName.upper() + ' ' + str(define_count) + '\n') define_count = define_count + 1 # switch段代码 fswitch.write("case " + cbName.upper() + ':\n') fswitch.write("{\n") fswitch.write("\tthis->" + cbName.replace('On', 'process') + '(task);\n') fswitch.write("\tbreak;\n") fswitch.write("}\n") fswitch.write("\n") for i, type_ in enumerate(cbArgsTypeList): if type_ == 'int': ftask.write("\ttask.task_id = " + cbArgsValueList[i] + ";\n") elif type_ == 'bool': ftask.write("\ttask.task_last = " + cbArgsValueList[i] + ";\n") elif 'RspInfoField' in type_: ftask.write("\n") ftask.write("\tif (pRspInfo)\n") ftask.write("\t{\n") ftask.write("\t\ttask.task_error = " + cbArgsValueList[i] + ";\n") ftask.write("\t}\n") ftask.write("\telse\n") ftask.write("\t{\n") ftask.write("\t\tCQdpFtdcRspInfoField empty_error = CQdpFtdcRspInfoField();\n") ftask.write("\t\tmemset(&empty_error, 0, sizeof(empty_error));\n") ftask.write("\t\ttask.task_error = empty_error;\n") ftask.write("\t}\n") else: ftask.write("\n") ftask.write("\tif (" + cbArgsValueList[i][1:] + ")\n") ftask.write("\t{\n") ftask.write("\t\ttask.task_data = " + cbArgsValueList[i] + ";\n") ftask.write("\t}\n") ftask.write("\telse\n") ftask.write("\t{\n") ftask.write("\t\t" + type_ + " empty_data = " + type_ + "();\n") ftask.write("\t\tmemset(&empty_data, 0, sizeof(empty_data));\n") ftask.write("\t\ttask.task_data = empty_data;\n") ftask.write("\t}\n") ftask.write("\tthis->task_queue.push(task);\n") ftask.write("};\n") ftask.write("\n") def createProcess(cbName, cbArgsTypeList, cbArgsValueList): # 从队列中提取任务,并转化为python字典 fprocess.write("void " + apiName + '::' + cbName.replace('On', 'process') + '(Task task)' + "\n") fprocess.write("{\n") fprocess.write("\tPyLock lock;\n") onArgsList = [] for i, type_ in enumerate(cbArgsTypeList): if 'RspInfoField' in type_: fprocess.write("\t"+ type_ + ' task_error = any_cast<' + type_ + '>(task.task_error);\n') fprocess.write("\t"+ "dict error;\n") struct = structDict[type_] for key in struct.keys(): fprocess.write("\t"+ 'error["' + key + '"] = task_error.' + key + ';\n') fprocess.write("\n") onArgsList.append('error') elif type_ in structDict: fprocess.write("\t"+ type_ + ' task_data = any_cast<' + type_ + '>(task.task_data);\n') fprocess.write("\t"+ "dict data;\n") struct = structDict[type_] for key in struct.keys(): fprocess.write("\t"+ 'data["' + key + '"] = task_data.' + key + ';\n') fprocess.write("\n") onArgsList.append('data') elif type_ == 'bool': onArgsList.append('task.task_last') elif type_ == 'int': onArgsList.append('task.task_id') onArgs = join(onArgsList, ', ') fprocess.write('\tthis->' + cbName.replace('On', 'on') + '(' + onArgs +');\n') fprocess.write("};\n") fprocess.write("\n") def processFunction(line): line = line.replace('\tvirtual int ', '') # 删除行首的无效内容 line = line.replace(') = 0;\n', '') # 删除行尾的无效内容 content = line.split('(') fcName = content[0] # 回调函数名称 fcArgs = content[1] # 回调函数参数 fcArgs = fcArgs.replace(')', '') fcArgsList = fcArgs.split(', ') # 将每个参数转化为列表 fcArgsTypeList = [] fcArgsValueList = [] for arg in fcArgsList: # 开始处理参数 content = arg.split(' ') if len(content) > 1: fcArgsTypeList.append(content[0]) # 参数类型列表 fcArgsValueList.append(content[1]) # 参数数据列表 if len(fcArgsTypeList)>0 and fcArgsTypeList[0] in structDict: createFunction(fcName, fcArgsTypeList, fcArgsValueList) # 生成.h文件中的主动函数部分 if 'Req' in fcName: req_line = 'int req' + fcName[3:] + '(dict req, int nRequestID);\n' fheaderfunction.write(req_line) fheaderfunction.write('\n') def createFunction(fcName, fcArgsTypeList, fcArgsValueList): type_ = fcArgsTypeList[0] struct = structDict[type_] ffunction.write('int MdApi::req' + fcName[3:] + '(dict req, int nRequestID)\n') ffunction.write('{\n') ffunction.write('\t' + type_ +' myreq = ' + type_ + '();\n') ffunction.write('\tmemset(&myreq, 0, sizeof(myreq));\n') for key, value in struct.items(): if value == 'string': line = '\tgetStr(req, "' + key + '", myreq.' + key + ');\n' elif value == 'char': line = '\tgetChar(req, "' + key + '", &myreq.' + key + ');\n' elif value == 'int': line = '\tgetInt(req, "' + key + '", &myreq.' + key + ');\n' elif value == 'double': line = '\tgetDouble(req, "' + key + '", &myreq.' + key + ');\n' ffunction.write(line) ffunction.write('\tint i = this->api->' + fcName + '(&myreq, nRequestID);\n') ffunction.write('\treturn i;\n') ffunction.write('};\n') ffunction.write('\n') ######################################################### apiName = 'MdApi' fcpp = open('QdpFtdcMdApi.h', 'r') ftask = open('qdp_md_task.cpp', 'w') fprocess = open('qdp_md_process.cpp', 'w') ffunction = open('qdp_md_function.cpp', 'w') fdefine = open('qdp_md_define.cpp', 'w') fswitch = open('qdp_md_switch.cpp', 'w') fheaderprocess = open('qdp_md_header_process.h', 'w') fheaderon = open('qdp_md_header_on.h', 'w') fheaderfunction = open('qdp_md_header_function.h', 'w') fwrap = open('qdp_md_wrap.cpp', 'w') define_count = 1 for line in fcpp: if "\tvirtual void On" in line: processCallBack(line) elif "\tvirtual int" in line: processFunction(line) fcpp.close() ftask.close() fprocess.close() ffunction.close() fswitch.close() fdefine.close() fheaderprocess.close() fheaderon.close() fheaderfunction.close() fwrap.close()
mit
[ 3, 2644, 26, 9094, 13, 24, 199, 199, 363, 2502, 363, 275, 283, 1244, 742, 8195, 7, 199, 199, 504, 1059, 492, 4263, 199, 504, 1894, 5780, 63, 1820, 492, 2702, 2141, 4388, 199, 318, 2112, 2176, 4540, 8, 604, 304, 272, 503, 1030, 279, 3049, 275, 1004, 272, 1004, 275, 1004, 14, 1814, 2258, 84, 2065, 2309, 1656, 4074, 420, 327, 7094, 231, 255, 31459, 12609, 166, 100, 245, 8106, 11373, 255, 9221, 231, 17950, 228, 10270, 118, 272, 1004, 275, 1004, 14, 1814, 17519, 3779, 78, 297, 4074, 4483, 327, 7094, 231, 255, 31459, 12609, 15348, 123, 8106, 11373, 255, 9221, 231, 17950, 228, 10270, 118, 339, 1564, 275, 1004, 14, 1294, 14097, 358, 272, 7434, 985, 275, 1564, 59, 16, 61, 17907, 327, 7094, 250, 253, 165, 109, 226, 15977, 122, 12211, 21434, 19012, 109, 339, 7434, 6213, 275, 1564, 59, 17, 61, 17907, 327, 7094, 250, 253, 165, 109, 226, 15977, 122, 12211, 32549, 12211, 272, 340, 7434, 6213, 1988, 17, 61, 508, 283, 7596, 267, 7434, 6213, 275, 7434, 6213, 14, 1814, 15938, 1656, 4074, 272, 587, 26, 267, 7434, 6213, 275, 7434, 6213, 14, 1814, 15938, 297, 4074, 339, 7434, 6213, 1296, 275, 7434, 6213, 14, 1294, 5102, 5320, 463, 327, 7094, 109, 229, 28285, 238, 10722, 32549, 12211, 30229, 21018, 245, 24971, 32551, 23243, 339, 7434, 6213, 804, 1296, 275, 942, 272, 7434, 6213, 1110, 1296, 275, 942, 339, 367, 1680, 315, 7434, 6213, 1296, 26, 14516, 327, 7094, 121, 223, 25712, 234, 11546, 227, 24946, 32549, 12211, 267, 1564, 275, 1680, 14, 1294, 360, 5320, 267, 340, 822, 8, 1317, 9, 690, 413, 26, 288, 7434, 6213, 804, 1296, 14, 740, 8, 1317, 59, 16, 566, 3698, 327, 221, 32549, 12211, 10278, 32551, 23243, 288, 7434, 6213, 1110, 1296, 14, 740, 8, 1317, 59, 17, 566, 3515, 327, 221, 32549, 12211, 22730, 32551, 23243, 339, 1218, 4476, 8, 2894, 985, 12, 7434, 6213, 804, 1296, 12, 7434, 6213, 1110, 1296, 12, 503, 1030, 279, 3049, 9, 272, 1218, 3498, 8, 2894, 985, 12, 7434, 6213, 804, 1296, 12, 7434, 6213, 1110, 1296, 9, 2286, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 1412, 29570, 102, 21514, 272, 2112, 63, 604, 275, 283, 1647, 2112, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 4476, 2120, 6152, 78, 7, 272, 289, 1291, 1412, 14, 952, 8, 1412, 63, 604, 9, 272, 289, 1291, 1412, 14, 952, 2258, 78, 358, 339, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 265, 29570, 102, 21514, 272, 340, 283, 3314, 17796, 547, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 1125, 12, 1109, 1305, 12, 2155, 2061, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 17796, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 12, 1109, 1305, 12, 2155, 2061, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 5432, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 9, 1052, 3779, 78, 7, 272, 587, 26, 267, 641, 63, 604, 275, 2125, 272, 289, 1291, 265, 14, 952, 8, 265, 63, 604, 9, 272, 289, 1291, 265, 14, 952, 2258, 78, 358, 2286, 327, 221, 29319, 16888, 15348, 224, 29655, 228, 29570, 102, 21514, 272, 1218, 15991, 8, 2894, 985, 9, 16872, 199, 7656, 8648, 199, 318, 1218, 15991, 8, 2894, 985, 304, 272, 408, 21448, 4718, 15348, 224, 29655, 228, 163, 107, 114, 10635, 17088, 13201, 250, 12609, 11546, 227, 24946, 624, 272, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 265, 29570, 102, 21514, 272, 340, 283, 3314, 17796, 547, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 1125, 12, 1109, 1305, 12, 2155, 2061, 2862, 78, 7, 27144, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 705, 12, 1305, 12, 2061, 6152, 78, 7, 5591, 916, 283, 3314, 17796, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 12, 1109, 1305, 12, 2155, 2061, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 12, 1125, 12, 1305, 12, 2061, 6152, 78, 7, 5591, 916, 283, 3314, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 6152, 78, 7, 272, 916, 283, 3314, 5432, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 12, 1125, 6152, 78, 7, 272, 587, 26, 267, 641, 63, 604, 275, 2125, 5493, 340, 641, 63, 604, 365, 440, 8061, 267, 289, 3823, 14, 952, 8, 265, 63, 604, 9, 267, 289, 3823, 14, 952, 11117, 60, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 893, 60, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 12911, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 60, 84, 3749, 5118, 362, 63, 4415, 6828, 4415, 63, 604, 9, 267, 289, 3823, 14, 952, 2258, 84, 4988, 78, 358, 267, 289, 3823, 14, 952, 2258, 3641 ]
[ 2644, 26, 9094, 13, 24, 199, 199, 363, 2502, 363, 275, 283, 1244, 742, 8195, 7, 199, 199, 504, 1059, 492, 4263, 199, 504, 1894, 5780, 63, 1820, 492, 2702, 2141, 4388, 199, 318, 2112, 2176, 4540, 8, 604, 304, 272, 503, 1030, 279, 3049, 275, 1004, 272, 1004, 275, 1004, 14, 1814, 2258, 84, 2065, 2309, 1656, 4074, 420, 327, 7094, 231, 255, 31459, 12609, 166, 100, 245, 8106, 11373, 255, 9221, 231, 17950, 228, 10270, 118, 272, 1004, 275, 1004, 14, 1814, 17519, 3779, 78, 297, 4074, 4483, 327, 7094, 231, 255, 31459, 12609, 15348, 123, 8106, 11373, 255, 9221, 231, 17950, 228, 10270, 118, 339, 1564, 275, 1004, 14, 1294, 14097, 358, 272, 7434, 985, 275, 1564, 59, 16, 61, 17907, 327, 7094, 250, 253, 165, 109, 226, 15977, 122, 12211, 21434, 19012, 109, 339, 7434, 6213, 275, 1564, 59, 17, 61, 17907, 327, 7094, 250, 253, 165, 109, 226, 15977, 122, 12211, 32549, 12211, 272, 340, 7434, 6213, 1988, 17, 61, 508, 283, 7596, 267, 7434, 6213, 275, 7434, 6213, 14, 1814, 15938, 1656, 4074, 272, 587, 26, 267, 7434, 6213, 275, 7434, 6213, 14, 1814, 15938, 297, 4074, 339, 7434, 6213, 1296, 275, 7434, 6213, 14, 1294, 5102, 5320, 463, 327, 7094, 109, 229, 28285, 238, 10722, 32549, 12211, 30229, 21018, 245, 24971, 32551, 23243, 339, 7434, 6213, 804, 1296, 275, 942, 272, 7434, 6213, 1110, 1296, 275, 942, 339, 367, 1680, 315, 7434, 6213, 1296, 26, 14516, 327, 7094, 121, 223, 25712, 234, 11546, 227, 24946, 32549, 12211, 267, 1564, 275, 1680, 14, 1294, 360, 5320, 267, 340, 822, 8, 1317, 9, 690, 413, 26, 288, 7434, 6213, 804, 1296, 14, 740, 8, 1317, 59, 16, 566, 3698, 327, 221, 32549, 12211, 10278, 32551, 23243, 288, 7434, 6213, 1110, 1296, 14, 740, 8, 1317, 59, 17, 566, 3515, 327, 221, 32549, 12211, 22730, 32551, 23243, 339, 1218, 4476, 8, 2894, 985, 12, 7434, 6213, 804, 1296, 12, 7434, 6213, 1110, 1296, 12, 503, 1030, 279, 3049, 9, 272, 1218, 3498, 8, 2894, 985, 12, 7434, 6213, 804, 1296, 12, 7434, 6213, 1110, 1296, 9, 2286, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 1412, 29570, 102, 21514, 272, 2112, 63, 604, 275, 283, 1647, 2112, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 4476, 2120, 6152, 78, 7, 272, 289, 1291, 1412, 14, 952, 8, 1412, 63, 604, 9, 272, 289, 1291, 1412, 14, 952, 2258, 78, 358, 339, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 265, 29570, 102, 21514, 272, 340, 283, 3314, 17796, 547, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 1125, 12, 1109, 1305, 12, 2155, 2061, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 17796, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 12, 1109, 1305, 12, 2155, 2061, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 9, 1052, 3779, 78, 7, 272, 916, 283, 3314, 5432, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 9, 1052, 3779, 78, 7, 272, 587, 26, 267, 641, 63, 604, 275, 2125, 272, 289, 1291, 265, 14, 952, 8, 265, 63, 604, 9, 272, 289, 1291, 265, 14, 952, 2258, 78, 358, 2286, 327, 221, 29319, 16888, 15348, 224, 29655, 228, 29570, 102, 21514, 272, 1218, 15991, 8, 2894, 985, 9, 16872, 199, 7656, 8648, 199, 318, 1218, 15991, 8, 2894, 985, 304, 272, 408, 21448, 4718, 15348, 224, 29655, 228, 163, 107, 114, 10635, 17088, 13201, 250, 12609, 11546, 227, 24946, 624, 272, 327, 221, 29319, 16888, 14, 72, 29303, 17088, 8106, 265, 29570, 102, 21514, 272, 340, 283, 3314, 17796, 547, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 1125, 12, 1109, 1305, 12, 2155, 2061, 2862, 78, 7, 27144, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 705, 12, 1305, 12, 2061, 6152, 78, 7, 5591, 916, 283, 3314, 17796, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 12, 1109, 1305, 12, 2155, 2061, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 12, 1125, 12, 1305, 12, 2061, 6152, 78, 7, 5591, 916, 283, 3314, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 6152, 78, 7, 272, 916, 283, 3314, 5432, 50, 5889, 7, 315, 7434, 985, 26, 267, 641, 63, 604, 275, 283, 2065, 2309, 641, 7, 435, 7434, 985, 59, 18, 2938, 435, 8189, 807, 666, 12, 1211, 1125, 2862, 78, 7, 267, 4278, 63, 604, 275, 283, 480, 265, 7, 435, 7434, 985, 59, 18, 2938, 435, 283, 25232, 576, 12, 1125, 6152, 78, 7, 272, 587, 26, 267, 641, 63, 604, 275, 2125, 5493, 340, 641, 63, 604, 365, 440, 8061, 267, 289, 3823, 14, 952, 8, 265, 63, 604, 9, 267, 289, 3823, 14, 952, 11117, 60, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 893, 60, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 12911, 78, 358, 267, 289, 3823, 14, 952, 2258, 84, 60, 84, 3749, 5118, 362, 63, 4415, 6828, 4415, 63, 604, 9, 267, 289, 3823, 14, 952, 2258, 84, 4988, 78, 358, 267, 289, 3823, 14, 952, 2258, 3641, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
HiroIshikawa/21playground
flask-rethink/env/lib/python3.5/site-packages/pip/_vendor/colorama/win32.py
446
5121
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. # from winbase.h STDOUT = -11 STDERR = -12 try: import ctypes from ctypes import LibraryLoader windll = LibraryLoader(ctypes.WinDLL) from ctypes import wintypes except (AttributeError, ImportError): windll = None SetConsoleTextAttribute = lambda *_: None else: from ctypes import byref, Structure, c_char, POINTER COORD = wintypes._COORD class CONSOLE_SCREEN_BUFFER_INFO(Structure): """struct in wincon.h.""" _fields_ = [ ("dwSize", COORD), ("dwCursorPosition", COORD), ("wAttributes", wintypes.WORD), ("srWindow", wintypes.SMALL_RECT), ("dwMaximumWindowSize", COORD), ] def __str__(self): return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( self.dwSize.Y, self.dwSize.X , self.dwCursorPosition.Y, self.dwCursorPosition.X , self.wAttributes , self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right , self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X ) _GetStdHandle = windll.kernel32.GetStdHandle _GetStdHandle.argtypes = [ wintypes.DWORD, ] _GetStdHandle.restype = wintypes.HANDLE _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo _GetConsoleScreenBufferInfo.argtypes = [ wintypes.HANDLE, POINTER(CONSOLE_SCREEN_BUFFER_INFO), ] _GetConsoleScreenBufferInfo.restype = wintypes.BOOL _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute _SetConsoleTextAttribute.argtypes = [ wintypes.HANDLE, wintypes.WORD, ] _SetConsoleTextAttribute.restype = wintypes.BOOL _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition _SetConsoleCursorPosition.argtypes = [ wintypes.HANDLE, COORD, ] _SetConsoleCursorPosition.restype = wintypes.BOOL _FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA _FillConsoleOutputCharacterA.argtypes = [ wintypes.HANDLE, c_char, wintypes.DWORD, COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputCharacterA.restype = wintypes.BOOL _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute _FillConsoleOutputAttribute.argtypes = [ wintypes.HANDLE, wintypes.WORD, wintypes.DWORD, COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputAttribute.restype = wintypes.BOOL _SetConsoleTitleW = windll.kernel32.SetConsoleTitleA _SetConsoleTitleW.argtypes = [ wintypes.LPCSTR ] _SetConsoleTitleW.restype = wintypes.BOOL handles = { STDOUT: _GetStdHandle(STDOUT), STDERR: _GetStdHandle(STDERR), } def GetConsoleScreenBufferInfo(stream_id=STDOUT): handle = handles[stream_id] csbi = CONSOLE_SCREEN_BUFFER_INFO() success = _GetConsoleScreenBufferInfo( handle, byref(csbi)) return csbi def SetConsoleTextAttribute(stream_id, attrs): handle = handles[stream_id] return _SetConsoleTextAttribute(handle, attrs) def SetConsoleCursorPosition(stream_id, position, adjust=True): position = COORD(*position) # If the position is out of range, do nothing. if position.Y <= 0 or position.X <= 0: return # Adjust for Windows' SetConsoleCursorPosition: # 1. being 0-based, while ANSI is 1-based. # 2. expecting (x,y), while ANSI uses (y,x). adjusted_position = COORD(position.Y - 1, position.X - 1) if adjust: # Adjust for viewport's scroll position sr = GetConsoleScreenBufferInfo(STDOUT).srWindow adjusted_position.Y += sr.Top adjusted_position.X += sr.Left # Resume normal processing handle = handles[stream_id] return _SetConsoleCursorPosition(handle, adjusted_position) def FillConsoleOutputCharacter(stream_id, char, length, start): handle = handles[stream_id] char = c_char(char.encode()) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # Note that this is hard-coded for ANSI (vs wide) bytes. success = _FillConsoleOutputCharacterA( handle, char, length, start, byref(num_written)) return num_written.value def FillConsoleOutputAttribute(stream_id, attr, length, start): ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )''' handle = handles[stream_id] attribute = wintypes.WORD(attr) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # Note that this is hard-coded for ANSI (vs wide) bytes. return _FillConsoleOutputAttribute( handle, attribute, length, start, byref(num_written)) def SetConsoleTitle(title): return _SetConsoleTitleW(title)
mit
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 199, 3, 687, 4747, 1095, 14, 72, 199, 13850, 275, 446, 845, 199, 18472, 2666, 275, 446, 713, 199, 199, 893, 26, 272, 492, 5577, 272, 687, 5577, 492, 11243, 5455, 272, 22350, 275, 11243, 5455, 8, 9798, 14, 8886, 15982, 9, 272, 687, 5577, 492, 29762, 199, 2590, 334, 10227, 12, 3545, 304, 272, 22350, 275, 488, 272, 2494, 9270, 1872, 1646, 275, 2400, 627, 10388, 488, 199, 2836, 26, 272, 687, 5577, 492, 15968, 12, 21730, 12, 286, 63, 1560, 12, 6569, 339, 5099, 3731, 275, 29762, 423, 21901, 339, 1021, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 8, 10766, 304, 267, 408, 1820, 315, 4747, 388, 14, 72, 1041, 267, 485, 955, 63, 275, 359, 288, 1689, 10772, 2320, 401, 5099, 3731, 395, 288, 1689, 10772, 32766, 401, 5099, 3731, 395, 288, 1689, 87, 5379, 401, 29762, 14, 5172, 395, 288, 1689, 5474, 4301, 401, 29762, 14, 28570, 63, 4168, 395, 288, 1689, 10772, 10915, 4301, 2320, 401, 5099, 3731, 395, 267, 1622, 267, 347, 636, 495, 721, 277, 304, 288, 372, 25676, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 3171, 450, 334, 355, 291, 14, 10772, 2320, 14, 57, 12, 291, 14, 10772, 2320, 14, 56, 355, 2360, 291, 14, 10772, 32766, 14, 57, 12, 291, 14, 10772, 32766, 14, 56, 355, 2360, 291, 14, 87, 5379, 355, 2360, 291, 14, 5474, 4301, 14, 6105, 12, 291, 14, 5474, 4301, 14, 8185, 12, 291, 14, 5474, 4301, 14, 22886, 12, 291, 14, 5474, 4301, 14, 9121, 355, 2360, 291, 14, 10772, 10915, 4301, 2320, 14, 57, 12, 291, 14, 10772, 10915, 4301, 2320, 14, 56, 288, 776, 339, 485, 1002, 11976, 5940, 275, 22350, 14, 4989, 708, 14, 1002, 11976, 5940, 272, 485, 1002, 11976, 5940, 14, 10025, 275, 359, 267, 29762, 14, 24754, 12, 272, 1622, 272, 485, 1002, 11976, 5940, 14, 9990, 275, 29762, 14, 15885, 339, 485, 1002, 9270, 9616, 3299, 2354, 275, 22350, 14, 4989, 708, 14, 1002, 9270, 9616, 3299, 2354, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 6569, 8, 31774, 63, 25070, 63, 10960, 63, 4531, 395, 272, 1622, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 1872, 1646, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 1872, 1646, 272, 485, 1084, 9270, 1872, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 272, 1622, 272, 485, 1084, 9270, 1872, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 32766, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 32766, 272, 485, 1084, 9270, 32766, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 5099, 3731, 12, 272, 1622, 272, 485, 1084, 9270, 32766, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 14852, 33, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 14852, 33, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 286, 63, 1560, 12, 267, 29762, 14, 24754, 12, 267, 5099, 3731, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 1646, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 1646, 272, 485, 12914, 9270, 2959, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 267, 29762, 14, 24754, 12, 267, 5099, 3731, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 6888, 55, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 6888, 33, 272, 485, 1084, 9270, 6888, 55, 14, 10025, 275, 359, 267, 29762, 14, 44, 4222, 3027, 272, 1622, 272, 485, 1084, 9270, 6888, 55, 14, 9990, 275, 29762, 14, 16026, 339, 10022, 275, 469, 267, 4384, 12619, 26, 485, 1002, 11976, 5940, 8, 13850, 395, 267, 30118, 2666, 26, 485, 1002, 11976, 5940, 8, 18472, 2666, 395, 272, 789, 339, 347, 2372, 9270, 9616, 3299, 2354, 8, 1745, 63, 344, 29, 13850, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 7117, 4492, 275, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 342, 267, 3182, 275, 485, 1002, 9270, 9616, 3299, 2354, 8, 288, 2429, 12, 15968, 8, 1259, 4492, 430, 267, 372, 7117, 4492, 339, 347, 2494, 9270, 1872, 1646, 8, 1745, 63, 344, 12, 3290, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 2494, 9270, 32766, 8, 1745, 63, 344, 12, 3421, 12, 11311, 29, 549, 304, 267, 3421, 275, 5099, 3731, 2031, 3124, 9, 267, 327, 982, 314, 3421, 365, 734, 402, 1425, 12, 886, 6548, 14, 267, 340, 3421, 14, 57, 2695, 378, 503, 3421, 14, 56, 2695, 378, 26, 288, 372, 267, 327, 26412, 367, 5417, 7, 2494, 9270, 32766, 26, 267, 327, 259, 413, 14, 3769, 378, 13, 6788, 12, 1830, 25600, 365, 413, 13, 6788, 14, 267, 327, 259, 499, 14, 21055, 334, 88, 12, 89, 395, 1830, 25600, 4440, 334, 89, 12, 88, 680, 267, 19477, 63, 3124, 275, 5099, 3731, 8, 3124, 14, 57, 446, 413, 12, 3421, 14, 56, 446, 413, 9, 267, 340, 11311, 26, 288, 327, 26412, 367, 2455, 719, 1159, 13704, 3421, 288, 11483, 275, 2372, 9270, 9616, 3299, 2354, 8, 13850, 680, 5474, 4301, 288, 19477, 63, 3124, 14, 57, 847, 11483, 14, 6105, 288, 19477, 63, 3124, 14, 56, 847, 11483, 14, 8185, 267, 327, 3591, 940, 3293, 6661, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 32766, 8, 2479, 12, 19477, 63, 3124, 9, 339, 347, 24797, 9270, 2959, 14852, 8, 1745, 63, 344, 12, 1495, 12, 2582, 12, 1343, 304, 267, 2429, 275, 10022, 59, 1745, 63 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 199, 3, 687, 4747, 1095, 14, 72, 199, 13850, 275, 446, 845, 199, 18472, 2666, 275, 446, 713, 199, 199, 893, 26, 272, 492, 5577, 272, 687, 5577, 492, 11243, 5455, 272, 22350, 275, 11243, 5455, 8, 9798, 14, 8886, 15982, 9, 272, 687, 5577, 492, 29762, 199, 2590, 334, 10227, 12, 3545, 304, 272, 22350, 275, 488, 272, 2494, 9270, 1872, 1646, 275, 2400, 627, 10388, 488, 199, 2836, 26, 272, 687, 5577, 492, 15968, 12, 21730, 12, 286, 63, 1560, 12, 6569, 339, 5099, 3731, 275, 29762, 423, 21901, 339, 1021, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 8, 10766, 304, 267, 408, 1820, 315, 4747, 388, 14, 72, 1041, 267, 485, 955, 63, 275, 359, 288, 1689, 10772, 2320, 401, 5099, 3731, 395, 288, 1689, 10772, 32766, 401, 5099, 3731, 395, 288, 1689, 87, 5379, 401, 29762, 14, 5172, 395, 288, 1689, 5474, 4301, 401, 29762, 14, 28570, 63, 4168, 395, 288, 1689, 10772, 10915, 4301, 2320, 401, 5099, 3731, 395, 267, 1622, 267, 347, 636, 495, 721, 277, 304, 288, 372, 25676, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 3171, 450, 334, 355, 291, 14, 10772, 2320, 14, 57, 12, 291, 14, 10772, 2320, 14, 56, 355, 2360, 291, 14, 10772, 32766, 14, 57, 12, 291, 14, 10772, 32766, 14, 56, 355, 2360, 291, 14, 87, 5379, 355, 2360, 291, 14, 5474, 4301, 14, 6105, 12, 291, 14, 5474, 4301, 14, 8185, 12, 291, 14, 5474, 4301, 14, 22886, 12, 291, 14, 5474, 4301, 14, 9121, 355, 2360, 291, 14, 10772, 10915, 4301, 2320, 14, 57, 12, 291, 14, 10772, 10915, 4301, 2320, 14, 56, 288, 776, 339, 485, 1002, 11976, 5940, 275, 22350, 14, 4989, 708, 14, 1002, 11976, 5940, 272, 485, 1002, 11976, 5940, 14, 10025, 275, 359, 267, 29762, 14, 24754, 12, 272, 1622, 272, 485, 1002, 11976, 5940, 14, 9990, 275, 29762, 14, 15885, 339, 485, 1002, 9270, 9616, 3299, 2354, 275, 22350, 14, 4989, 708, 14, 1002, 9270, 9616, 3299, 2354, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 6569, 8, 31774, 63, 25070, 63, 10960, 63, 4531, 395, 272, 1622, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 1872, 1646, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 1872, 1646, 272, 485, 1084, 9270, 1872, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 272, 1622, 272, 485, 1084, 9270, 1872, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 32766, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 32766, 272, 485, 1084, 9270, 32766, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 5099, 3731, 12, 272, 1622, 272, 485, 1084, 9270, 32766, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 14852, 33, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 14852, 33, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 286, 63, 1560, 12, 267, 29762, 14, 24754, 12, 267, 5099, 3731, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 1646, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 1646, 272, 485, 12914, 9270, 2959, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 267, 29762, 14, 24754, 12, 267, 5099, 3731, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 6888, 55, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 6888, 33, 272, 485, 1084, 9270, 6888, 55, 14, 10025, 275, 359, 267, 29762, 14, 44, 4222, 3027, 272, 1622, 272, 485, 1084, 9270, 6888, 55, 14, 9990, 275, 29762, 14, 16026, 339, 10022, 275, 469, 267, 4384, 12619, 26, 485, 1002, 11976, 5940, 8, 13850, 395, 267, 30118, 2666, 26, 485, 1002, 11976, 5940, 8, 18472, 2666, 395, 272, 789, 339, 347, 2372, 9270, 9616, 3299, 2354, 8, 1745, 63, 344, 29, 13850, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 7117, 4492, 275, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 342, 267, 3182, 275, 485, 1002, 9270, 9616, 3299, 2354, 8, 288, 2429, 12, 15968, 8, 1259, 4492, 430, 267, 372, 7117, 4492, 339, 347, 2494, 9270, 1872, 1646, 8, 1745, 63, 344, 12, 3290, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 2494, 9270, 32766, 8, 1745, 63, 344, 12, 3421, 12, 11311, 29, 549, 304, 267, 3421, 275, 5099, 3731, 2031, 3124, 9, 267, 327, 982, 314, 3421, 365, 734, 402, 1425, 12, 886, 6548, 14, 267, 340, 3421, 14, 57, 2695, 378, 503, 3421, 14, 56, 2695, 378, 26, 288, 372, 267, 327, 26412, 367, 5417, 7, 2494, 9270, 32766, 26, 267, 327, 259, 413, 14, 3769, 378, 13, 6788, 12, 1830, 25600, 365, 413, 13, 6788, 14, 267, 327, 259, 499, 14, 21055, 334, 88, 12, 89, 395, 1830, 25600, 4440, 334, 89, 12, 88, 680, 267, 19477, 63, 3124, 275, 5099, 3731, 8, 3124, 14, 57, 446, 413, 12, 3421, 14, 56, 446, 413, 9, 267, 340, 11311, 26, 288, 327, 26412, 367, 2455, 719, 1159, 13704, 3421, 288, 11483, 275, 2372, 9270, 9616, 3299, 2354, 8, 13850, 680, 5474, 4301, 288, 19477, 63, 3124, 14, 57, 847, 11483, 14, 6105, 288, 19477, 63, 3124, 14, 56, 847, 11483, 14, 8185, 267, 327, 3591, 940, 3293, 6661, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 32766, 8, 2479, 12, 19477, 63, 3124, 9, 339, 347, 24797, 9270, 2959, 14852, 8, 1745, 63, 344, 12, 1495, 12, 2582, 12, 1343, 304, 267, 2429, 275, 10022, 59, 1745, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
ilya-epifanov/ansible
lib/ansible/plugins/callback/hipchat.py
101
5867
# (C) 2014, Matt Martz <matt@sivel.net> # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import os import urllib import urllib2 try: import prettytable HAS_PRETTYTABLE = True except ImportError: HAS_PRETTYTABLE = False from ansible.plugins.callback import CallbackBase class CallbackModule(CallbackBase): """This is an example ansible callback plugin that sends status updates to a HipChat channel during playbook execution. This plugin makes use of the following environment variables: HIPCHAT_TOKEN (required): HipChat API token HIPCHAT_ROOM (optional): HipChat room to post in. Default: ansible HIPCHAT_FROM (optional): Name to post as. Default: ansible HIPCHAT_NOTIFY (optional): Add notify flag to important messages ("true" or "false"). Default: true Requires: prettytable """ CALLBACK_VERSION = 2.0 CALLBACK_VERSION = 2.0 CALLBACK_NAME = 'hipchat' def __init__(self, display): super(CallbackModule, self).__init__(display) if not HAS_PRETTYTABLE: self.disabled = True self.display.warning('The `prettytable` python module is not installed. ' 'Disabling the HipChat callback plugin.') self.msg_uri = 'https://api.hipchat.com/v1/rooms/message' self.token = os.getenv('HIPCHAT_TOKEN') self.room = os.getenv('HIPCHAT_ROOM', 'ansible') self.from_name = os.getenv('HIPCHAT_FROM', 'ansible') self.allow_notify = (os.getenv('HIPCHAT_NOTIFY') != 'false') if self.token is None: self.disabled = True self.display.warning('HipChat token could not be loaded. The HipChat ' 'token can be provided using the `HIPCHAT_TOKEN` ' 'environment variable.') self.printed_playbook = False self.playbook_name = None def send_msg(self, msg, msg_format='text', color='yellow', notify=False): """Method for sending a message to HipChat""" params = {} params['room_id'] = self.room params['from'] = self.from_name[:15] # max length is 15 params['message'] = msg params['message_format'] = msg_format params['color'] = color params['notify'] = int(self.allow_notify and notify) url = ('%s?auth_token=%s' % (self.msg_uri, self.token)) try: response = urllib2.urlopen(url, urllib.urlencode(params)) return response.read() except: self.display.warning('Could not submit message to hipchat') def playbook_on_play_start(self, name): """Display Playbook and play start messages""" # This block sends information about a playbook when it starts # The playbook object is not immediately available at # playbook_on_start so we grab it via the play # # Displays info about playbook being started by a person on an # inventory, as well as Tags, Skip Tags and Limits if not self.printed_playbook: self.playbook_name, _ = os.path.splitext( os.path.basename(self.play.playbook.filename)) host_list = self.play.playbook.inventory.host_list inventory = os.path.basename(os.path.realpath(host_list)) self.send_msg("%s: Playbook initiated by %s against %s" % (self.playbook_name, self.play.playbook.remote_user, inventory), notify=True) self.printed_playbook = True subset = self.play.playbook.inventory._subset skip_tags = self.play.playbook.skip_tags self.send_msg("%s:\nTags: %s\nSkip Tags: %s\nLimit: %s" % (self.playbook_name, ', '.join(self.play.playbook.only_tags), ', '.join(skip_tags) if skip_tags else None, ', '.join(subset) if subset else subset)) # This is where we actually say we are starting a play self.send_msg("%s: Starting play: %s" % (self.playbook_name, name)) def playbook_on_stats(self, stats): """Display info about playbook statistics""" hosts = sorted(stats.processed.keys()) t = prettytable.PrettyTable(['Host', 'Ok', 'Changed', 'Unreachable', 'Failures']) failures = False unreachable = False for h in hosts: s = stats.summarize(h) if s['failures'] > 0: failures = True if s['unreachable'] > 0: unreachable = True t.add_row([h] + [s[k] for k in ['ok', 'changed', 'unreachable', 'failures']]) self.send_msg("%s: Playbook complete" % self.playbook_name, notify=True) if failures or unreachable: color = 'red' self.send_msg("%s: Failures detected" % self.playbook_name, color=color, notify=True) else: color = 'green' self.send_msg("/code %s:\n%s" % (self.playbook_name, t), color=color)
gpl-3.0
[ 3, 334, 35, 9, 6927, 12, 31653, 603, 28124, 665, 569, 84, 32, 338, 1090, 14, 846, 30, 199, 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, 646, 747, 199, 646, 4011, 199, 646, 4011, 18, 199, 199, 893, 26, 272, 492, 7268, 1224, 272, 7509, 63, 3311, 775, 2099, 8723, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 3311, 775, 2099, 8723, 275, 756, 199, 199, 504, 3242, 14, 5265, 14, 3058, 492, 17555, 1563, 199, 199, 533, 17555, 2377, 8, 9822, 304, 272, 408, 2765, 365, 376, 2893, 3242, 3233, 3589, 626, 16178, 2004, 272, 7029, 370, 282, 869, 711, 21954, 3623, 5309, 15695, 6451, 14, 339, 961, 3589, 7704, 675, 402, 314, 2569, 3734, 2860, 26, 267, 869, 1772, 1244, 619, 63, 8803, 334, 2427, 304, 869, 711, 21954, 3261, 1526, 267, 869, 1772, 1244, 619, 63, 1092, 7474, 221, 334, 4144, 304, 869, 711, 21954, 14726, 370, 2963, 315, 14, 3758, 26, 3242, 267, 869, 1772, 1244, 619, 63, 12491, 221, 334, 4144, 304, 2812, 370, 2963, 465, 14, 3758, 26, 3242, 267, 869, 1772, 1244, 619, 63, 24972, 334, 4144, 304, 2654, 11705, 3305, 370, 11012, 3788, 1689, 2052, 2, 503, 298, 3910, 3471, 3758, 26, 2549, 339, 15127, 26, 267, 7268, 1224, 339, 408, 272, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 2339, 275, 283, 28951, 10289, 7, 339, 347, 636, 826, 721, 277, 12, 2929, 304, 398, 1613, 8, 2806, 2377, 12, 291, 2843, 826, 721, 2918, 9, 398, 340, 440, 7509, 63, 3311, 775, 2099, 8723, 26, 288, 291, 14, 7011, 275, 715, 288, 291, 14, 2918, 14, 3764, 360, 1918, 658, 9118, 1224, 64, 2366, 859, 365, 440, 4903, 14, 283, 2079, 283, 2825, 14744, 314, 869, 711, 21954, 3233, 3589, 2659, 398, 291, 14, 1328, 63, 2302, 275, 283, 2859, 921, 1246, 14, 28951, 10289, 14, 957, 15, 86, 17, 15, 29191, 15, 1188, 7, 267, 291, 14, 1418, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 8803, 358, 267, 291, 14, 11245, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 1092, 7474, 297, 283, 4853, 358, 267, 291, 14, 504, 63, 354, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 12491, 297, 283, 4853, 358, 267, 291, 14, 3306, 63, 6814, 275, 334, 736, 14, 12959, 360, 40, 1772, 1244, 619, 63, 24972, 358, 1137, 283, 3910, 358, 398, 340, 291, 14, 1418, 365, 488, 26, 288, 291, 14, 7011, 275, 715, 288, 291, 14, 2918, 14, 3764, 360, 40, 711, 21954, 1526, 4293, 440, 506, 6511, 14, 710, 869, 711, 21954, 283, 2079, 283, 1418, 883, 506, 2741, 1808, 314, 658, 40, 1772, 1244, 619, 63, 8803, 64, 283, 2079, 283, 5418, 1750, 2659, 398, 291, 14, 27131, 63, 14205, 275, 756, 267, 291, 14, 14205, 63, 354, 275, 488, 339, 347, 3222, 63, 1328, 8, 277, 12, 1499, 12, 1499, 63, 908, 534, 505, 297, 3164, 534, 14514, 297, 11705, 29, 797, 304, 267, 408, 3767, 367, 10209, 282, 1245, 370, 869, 711, 21954, 624, 398, 1862, 275, 1052, 267, 1862, 459, 11245, 63, 344, 418, 275, 291, 14, 11245, 267, 1862, 459, 504, 418, 275, 291, 14, 504, 63, 354, 1491, 1046, 61, 221, 327, 1390, 2582, 365, 4114, 267, 1862, 459, 1188, 418, 275, 1499, 267, 1862, 459, 1188, 63, 908, 418, 275, 1499, 63, 908, 267, 1862, 459, 2326, 418, 275, 3164, 267, 1862, 459, 6814, 418, 275, 1109, 8, 277, 14, 3306, 63, 6814, 436, 11705, 9, 398, 1166, 275, 16651, 83, 31, 1178, 63, 1418, 2458, 83, 7, 450, 334, 277, 14, 1328, 63, 2302, 12, 291, 14, 1418, 430, 267, 862, 26, 288, 1177, 275, 4011, 18, 14, 10890, 8, 633, 12, 4011, 14, 10738, 8, 1162, 430, 288, 372, 1177, 14, 739, 342, 267, 871, 26, 288, 291, 14, 2918, 14, 3764, 360, 6531, 440, 11482, 1245, 370, 394, 711, 10289, 358, 2378, 347, 15695, 63, 265, 63, 2802, 63, 928, 8, 277, 12, 536, 304, 267, 408, 7687, 16527, 2706, 436, 5232, 1343, 3788, 624, 398, 327, 961, 1853, 16178, 2556, 3595, 282, 15695, 1380, 652, 9174, 267, 327, 710, 15695, 909, 365, 440, 9939, 2808, 737, 267, 327, 15695, 63, 265, 63, 928, 880, 781, 18200, 652, 4799, 314, 5232, 267, 327, 267, 327, 28750, 2256, 3595, 15695, 3769, 8239, 701, 282, 4954, 641, 376, 267, 327, 8200, 12, 465, 5521, 465, 25204, 12, 8232, 25204, 436, 14620, 1405, 267, 340, 440, 291, 14, 27131, 63, 14205, 26, 288, 291, 14, 14205, 63, 354, 12, 485, 275, 747, 14, 515, 14, 7973, 8, 355, 747, 14, 515, 14, 4846, 8, 277, 14, 2802, 14, 14205, 14, 1501, 430, 288, 1591, 63, 513, 275, 291, 14, 2802, 14, 14205, 14, 7212, 14, 1102, 63, 513, 288, 8200, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 11091, 8, 1102, 63, 513, 430, 288, 291, 14, 2254, 63, 1328, 3647, 83, 26, 16527, 2706, 11023, 972, 701, 450, 83, 6169, 450, 83, 2, 450, 2079, 334, 277, 14, 14205, 63, 354, 12, 2574, 291, 14, 2802, 14, 14205, 14, 3846, 63, 751, 12, 2574, 8200, 395, 11705, 29, 549, 9, 288 ]
[ 334, 35, 9, 6927, 12, 31653, 603, 28124, 665, 569, 84, 32, 338, 1090, 14, 846, 30, 199, 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, 646, 747, 199, 646, 4011, 199, 646, 4011, 18, 199, 199, 893, 26, 272, 492, 7268, 1224, 272, 7509, 63, 3311, 775, 2099, 8723, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 3311, 775, 2099, 8723, 275, 756, 199, 199, 504, 3242, 14, 5265, 14, 3058, 492, 17555, 1563, 199, 199, 533, 17555, 2377, 8, 9822, 304, 272, 408, 2765, 365, 376, 2893, 3242, 3233, 3589, 626, 16178, 2004, 272, 7029, 370, 282, 869, 711, 21954, 3623, 5309, 15695, 6451, 14, 339, 961, 3589, 7704, 675, 402, 314, 2569, 3734, 2860, 26, 267, 869, 1772, 1244, 619, 63, 8803, 334, 2427, 304, 869, 711, 21954, 3261, 1526, 267, 869, 1772, 1244, 619, 63, 1092, 7474, 221, 334, 4144, 304, 869, 711, 21954, 14726, 370, 2963, 315, 14, 3758, 26, 3242, 267, 869, 1772, 1244, 619, 63, 12491, 221, 334, 4144, 304, 2812, 370, 2963, 465, 14, 3758, 26, 3242, 267, 869, 1772, 1244, 619, 63, 24972, 334, 4144, 304, 2654, 11705, 3305, 370, 11012, 3788, 1689, 2052, 2, 503, 298, 3910, 3471, 3758, 26, 2549, 339, 15127, 26, 267, 7268, 1224, 339, 408, 272, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 2339, 275, 283, 28951, 10289, 7, 339, 347, 636, 826, 721, 277, 12, 2929, 304, 398, 1613, 8, 2806, 2377, 12, 291, 2843, 826, 721, 2918, 9, 398, 340, 440, 7509, 63, 3311, 775, 2099, 8723, 26, 288, 291, 14, 7011, 275, 715, 288, 291, 14, 2918, 14, 3764, 360, 1918, 658, 9118, 1224, 64, 2366, 859, 365, 440, 4903, 14, 283, 2079, 283, 2825, 14744, 314, 869, 711, 21954, 3233, 3589, 2659, 398, 291, 14, 1328, 63, 2302, 275, 283, 2859, 921, 1246, 14, 28951, 10289, 14, 957, 15, 86, 17, 15, 29191, 15, 1188, 7, 267, 291, 14, 1418, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 8803, 358, 267, 291, 14, 11245, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 1092, 7474, 297, 283, 4853, 358, 267, 291, 14, 504, 63, 354, 275, 747, 14, 12959, 360, 40, 1772, 1244, 619, 63, 12491, 297, 283, 4853, 358, 267, 291, 14, 3306, 63, 6814, 275, 334, 736, 14, 12959, 360, 40, 1772, 1244, 619, 63, 24972, 358, 1137, 283, 3910, 358, 398, 340, 291, 14, 1418, 365, 488, 26, 288, 291, 14, 7011, 275, 715, 288, 291, 14, 2918, 14, 3764, 360, 40, 711, 21954, 1526, 4293, 440, 506, 6511, 14, 710, 869, 711, 21954, 283, 2079, 283, 1418, 883, 506, 2741, 1808, 314, 658, 40, 1772, 1244, 619, 63, 8803, 64, 283, 2079, 283, 5418, 1750, 2659, 398, 291, 14, 27131, 63, 14205, 275, 756, 267, 291, 14, 14205, 63, 354, 275, 488, 339, 347, 3222, 63, 1328, 8, 277, 12, 1499, 12, 1499, 63, 908, 534, 505, 297, 3164, 534, 14514, 297, 11705, 29, 797, 304, 267, 408, 3767, 367, 10209, 282, 1245, 370, 869, 711, 21954, 624, 398, 1862, 275, 1052, 267, 1862, 459, 11245, 63, 344, 418, 275, 291, 14, 11245, 267, 1862, 459, 504, 418, 275, 291, 14, 504, 63, 354, 1491, 1046, 61, 221, 327, 1390, 2582, 365, 4114, 267, 1862, 459, 1188, 418, 275, 1499, 267, 1862, 459, 1188, 63, 908, 418, 275, 1499, 63, 908, 267, 1862, 459, 2326, 418, 275, 3164, 267, 1862, 459, 6814, 418, 275, 1109, 8, 277, 14, 3306, 63, 6814, 436, 11705, 9, 398, 1166, 275, 16651, 83, 31, 1178, 63, 1418, 2458, 83, 7, 450, 334, 277, 14, 1328, 63, 2302, 12, 291, 14, 1418, 430, 267, 862, 26, 288, 1177, 275, 4011, 18, 14, 10890, 8, 633, 12, 4011, 14, 10738, 8, 1162, 430, 288, 372, 1177, 14, 739, 342, 267, 871, 26, 288, 291, 14, 2918, 14, 3764, 360, 6531, 440, 11482, 1245, 370, 394, 711, 10289, 358, 2378, 347, 15695, 63, 265, 63, 2802, 63, 928, 8, 277, 12, 536, 304, 267, 408, 7687, 16527, 2706, 436, 5232, 1343, 3788, 624, 398, 327, 961, 1853, 16178, 2556, 3595, 282, 15695, 1380, 652, 9174, 267, 327, 710, 15695, 909, 365, 440, 9939, 2808, 737, 267, 327, 15695, 63, 265, 63, 928, 880, 781, 18200, 652, 4799, 314, 5232, 267, 327, 267, 327, 28750, 2256, 3595, 15695, 3769, 8239, 701, 282, 4954, 641, 376, 267, 327, 8200, 12, 465, 5521, 465, 25204, 12, 8232, 25204, 436, 14620, 1405, 267, 340, 440, 291, 14, 27131, 63, 14205, 26, 288, 291, 14, 14205, 63, 354, 12, 485, 275, 747, 14, 515, 14, 7973, 8, 355, 747, 14, 515, 14, 4846, 8, 277, 14, 2802, 14, 14205, 14, 1501, 430, 288, 1591, 63, 513, 275, 291, 14, 2802, 14, 14205, 14, 7212, 14, 1102, 63, 513, 288, 8200, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 11091, 8, 1102, 63, 513, 430, 288, 291, 14, 2254, 63, 1328, 3647, 83, 26, 16527, 2706, 11023, 972, 701, 450, 83, 6169, 450, 83, 2, 450, 2079, 334, 277, 14, 14205, 63, 354, 12, 2574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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 ]
meabsence/python-for-android
python3-alpha/python3-src/Lib/distutils/tests/test_bdist_dumb.py
46
2555
"""Tests for distutils.command.bdist_dumb.""" import unittest import sys import os from test.support import run_unittest from distutils.core import Distribution from distutils.command.bdist_dumb import bdist_dumb from distutils.tests import support SETUP_PY = """\ from distutils.core import setup import foo setup(name='foo', version='0.1', py_modules=['foo'], url='xxx', author='xxx', author_email='xxx') """ try: import zlib ZLIB_SUPPORT = True except ImportError: ZLIB_SUPPORT = False class BuildDumbTestCase(support.TempdirManager, support.LoggingSilencer, support.EnvironGuard, unittest.TestCase): def setUp(self): super(BuildDumbTestCase, self).setUp() self.old_location = os.getcwd() self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) sys.argv = self.old_sys_argv[0] sys.argv[:] = self.old_sys_argv[1] super(BuildDumbTestCase, self).tearDown() @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_simple_built(self): # let's create a simple package tmp_dir = self.mkdtemp() pkg_dir = os.path.join(tmp_dir, 'foo') os.mkdir(pkg_dir) self.write_file((pkg_dir, 'setup.py'), SETUP_PY) self.write_file((pkg_dir, 'foo.py'), '#') self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py') self.write_file((pkg_dir, 'README'), '') dist = Distribution({'name': 'foo', 'version': '0.1', 'py_modules': ['foo'], 'url': 'xxx', 'author': 'xxx', 'author_email': 'xxx'}) dist.script_name = 'setup.py' os.chdir(pkg_dir) sys.argv = ['setup.py'] cmd = bdist_dumb(dist) # so the output is the same no matter # what is the platform cmd.format = 'zip' cmd.ensure_finalized() cmd.run() # see what we have dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) base = "%s.%s" % (dist.get_fullname(), cmd.plat_name) if os.name == 'os2': base = base.replace(':', '-') wanted = ['%s.zip' % base] self.assertEqual(dist_created, wanted) # now let's check what we have in the zip file # XXX to be done def test_suite(): return unittest.makeSuite(BuildDumbTestCase) if __name__ == '__main__': run_unittest(test_suite())
apache-2.0
[ 624, 2925, 367, 7065, 14, 1531, 14, 17403, 63, 29271, 1041, 199, 199, 646, 2882, 199, 646, 984, 199, 646, 747, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 199, 199, 504, 7065, 14, 1018, 492, 11839, 199, 504, 7065, 14, 1531, 14, 17403, 63, 29271, 492, 26308, 63, 29271, 199, 504, 7065, 14, 2219, 492, 2291, 199, 199, 20836, 63, 4521, 275, 9638, 199, 504, 7065, 14, 1018, 492, 3272, 199, 646, 3925, 199, 199, 2758, 8, 354, 534, 1421, 297, 1015, 534, 16, 14, 17, 297, 1134, 63, 3112, 2968, 1421, 995, 489, 1166, 534, 10013, 297, 4132, 534, 10013, 297, 4132, 63, 2123, 534, 10013, 358, 199, 199, 624, 199, 199, 893, 26, 272, 492, 12472, 272, 3107, 5617, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 3107, 5617, 63, 10640, 275, 756, 421, 199, 533, 6516, 36, 4295, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 717, 2291, 14, 14054, 51, 441, 78, 2247, 12, 717, 2291, 14, 23027, 18183, 12, 717, 2882, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 3425, 36, 4295, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 1753, 63, 1985, 275, 747, 14, 9458, 342, 267, 291, 14, 1753, 63, 1274, 63, 3020, 275, 984, 14, 3020, 12, 984, 14, 3020, 5873, 339, 347, 6766, 8, 277, 304, 267, 747, 14, 8563, 8, 277, 14, 1753, 63, 1985, 9, 267, 984, 14, 3020, 275, 291, 14, 1753, 63, 1274, 63, 3020, 59, 16, 61, 267, 984, 14, 3020, 5873, 275, 291, 14, 1753, 63, 1274, 63, 3020, 59, 17, 61, 267, 1613, 8, 3425, 36, 4295, 1746, 12, 291, 680, 12336, 342, 339, 768, 2796, 14, 11278, 8, 58, 5617, 63, 10640, 12, 283, 17809, 12472, 2291, 370, 1255, 358, 272, 347, 511, 63, 4129, 63, 11730, 8, 277, 304, 398, 327, 4691, 1159, 1218, 282, 3486, 2559, 267, 3529, 63, 694, 275, 291, 14, 11983, 342, 267, 5496, 63, 694, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 283, 1421, 358, 267, 747, 14, 8215, 8, 4600, 63, 694, 9, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 2758, 14, 647, 659, 11543, 2160, 63, 4521, 9, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 1421, 14, 647, 659, 3943, 358, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 24067, 14, 262, 659, 283, 2613, 3925, 14, 647, 358, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 18195, 659, 4074, 398, 2917, 275, 11839, 3252, 354, 356, 283, 1421, 297, 283, 1023, 356, 283, 16, 14, 17, 297, 2490, 283, 647, 63, 3112, 356, 788, 1421, 995, 2490, 283, 633, 356, 283, 10013, 297, 283, 2502, 356, 283, 10013, 297, 2490, 283, 2502, 63, 2123, 356, 283, 10013, 3071, 267, 2917, 14, 1579, 63, 354, 275, 283, 2758, 14, 647, 7, 267, 747, 14, 8563, 8, 4600, 63, 694, 9, 398, 984, 14, 3020, 275, 788, 2758, 14, 647, 418, 267, 2088, 275, 26308, 63, 29271, 8, 2686, 9, 398, 327, 880, 314, 1072, 365, 314, 2011, 949, 17247, 267, 327, 4052, 365, 314, 4298, 267, 2088, 14, 908, 275, 283, 3065, 7, 398, 2088, 14, 7505, 63, 19231, 342, 267, 2088, 14, 1065, 342, 398, 327, 1937, 4052, 781, 1172, 267, 2917, 63, 3966, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 4600, 63, 694, 12, 283, 2686, 1333, 267, 1300, 275, 2071, 83, 4111, 83, 2, 450, 334, 2686, 14, 362, 63, 9930, 1062, 2088, 14, 14156, 63, 354, 9, 267, 340, 747, 14, 354, 508, 283, 736, 18, 356, 288, 1300, 275, 1300, 14, 1814, 16451, 26942, 398, 13632, 275, 15926, 83, 14, 3065, 7, 450, 1300, 61, 267, 291, 14, 629, 8, 2686, 63, 3966, 12, 13632, 9, 398, 327, 3063, 4691, 1159, 1104, 4052, 781, 1172, 315, 314, 3482, 570, 267, 327, 5787, 370, 506, 4224, 199, 199, 318, 511, 63, 5768, 837, 272, 372, 2882, 14, 18275, 8, 3425, 36, 4295, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1255, 63, 2796, 8, 396, 63, 5768, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2925, 367, 7065, 14, 1531, 14, 17403, 63, 29271, 1041, 199, 199, 646, 2882, 199, 646, 984, 199, 646, 747, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 199, 199, 504, 7065, 14, 1018, 492, 11839, 199, 504, 7065, 14, 1531, 14, 17403, 63, 29271, 492, 26308, 63, 29271, 199, 504, 7065, 14, 2219, 492, 2291, 199, 199, 20836, 63, 4521, 275, 9638, 199, 504, 7065, 14, 1018, 492, 3272, 199, 646, 3925, 199, 199, 2758, 8, 354, 534, 1421, 297, 1015, 534, 16, 14, 17, 297, 1134, 63, 3112, 2968, 1421, 995, 489, 1166, 534, 10013, 297, 4132, 534, 10013, 297, 4132, 63, 2123, 534, 10013, 358, 199, 199, 624, 199, 199, 893, 26, 272, 492, 12472, 272, 3107, 5617, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 3107, 5617, 63, 10640, 275, 756, 421, 199, 533, 6516, 36, 4295, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 717, 2291, 14, 14054, 51, 441, 78, 2247, 12, 717, 2291, 14, 23027, 18183, 12, 717, 2882, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 3425, 36, 4295, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 1753, 63, 1985, 275, 747, 14, 9458, 342, 267, 291, 14, 1753, 63, 1274, 63, 3020, 275, 984, 14, 3020, 12, 984, 14, 3020, 5873, 339, 347, 6766, 8, 277, 304, 267, 747, 14, 8563, 8, 277, 14, 1753, 63, 1985, 9, 267, 984, 14, 3020, 275, 291, 14, 1753, 63, 1274, 63, 3020, 59, 16, 61, 267, 984, 14, 3020, 5873, 275, 291, 14, 1753, 63, 1274, 63, 3020, 59, 17, 61, 267, 1613, 8, 3425, 36, 4295, 1746, 12, 291, 680, 12336, 342, 339, 768, 2796, 14, 11278, 8, 58, 5617, 63, 10640, 12, 283, 17809, 12472, 2291, 370, 1255, 358, 272, 347, 511, 63, 4129, 63, 11730, 8, 277, 304, 398, 327, 4691, 1159, 1218, 282, 3486, 2559, 267, 3529, 63, 694, 275, 291, 14, 11983, 342, 267, 5496, 63, 694, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 283, 1421, 358, 267, 747, 14, 8215, 8, 4600, 63, 694, 9, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 2758, 14, 647, 659, 11543, 2160, 63, 4521, 9, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 1421, 14, 647, 659, 3943, 358, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 24067, 14, 262, 659, 283, 2613, 3925, 14, 647, 358, 267, 291, 14, 952, 63, 493, 1332, 4600, 63, 694, 12, 283, 18195, 659, 4074, 398, 2917, 275, 11839, 3252, 354, 356, 283, 1421, 297, 283, 1023, 356, 283, 16, 14, 17, 297, 2490, 283, 647, 63, 3112, 356, 788, 1421, 995, 2490, 283, 633, 356, 283, 10013, 297, 283, 2502, 356, 283, 10013, 297, 2490, 283, 2502, 63, 2123, 356, 283, 10013, 3071, 267, 2917, 14, 1579, 63, 354, 275, 283, 2758, 14, 647, 7, 267, 747, 14, 8563, 8, 4600, 63, 694, 9, 398, 984, 14, 3020, 275, 788, 2758, 14, 647, 418, 267, 2088, 275, 26308, 63, 29271, 8, 2686, 9, 398, 327, 880, 314, 1072, 365, 314, 2011, 949, 17247, 267, 327, 4052, 365, 314, 4298, 267, 2088, 14, 908, 275, 283, 3065, 7, 398, 2088, 14, 7505, 63, 19231, 342, 267, 2088, 14, 1065, 342, 398, 327, 1937, 4052, 781, 1172, 267, 2917, 63, 3966, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 4600, 63, 694, 12, 283, 2686, 1333, 267, 1300, 275, 2071, 83, 4111, 83, 2, 450, 334, 2686, 14, 362, 63, 9930, 1062, 2088, 14, 14156, 63, 354, 9, 267, 340, 747, 14, 354, 508, 283, 736, 18, 356, 288, 1300, 275, 1300, 14, 1814, 16451, 26942, 398, 13632, 275, 15926, 83, 14, 3065, 7, 450, 1300, 61, 267, 291, 14, 629, 8, 2686, 63, 3966, 12, 13632, 9, 398, 327, 3063, 4691, 1159, 1104, 4052, 781, 1172, 315, 314, 3482, 570, 267, 327, 5787, 370, 506, 4224, 199, 199, 318, 511, 63, 5768, 837, 272, 372, 2882, 14, 18275, 8, 3425, 36, 4295, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1255, 63, 2796, 8, 396, 63, 5768, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bettermirror/wget
testenv/Test-auth-digest.py
12
1568
#!/usr/bin/env python3 from sys import exit from test.http_test import HTTPTest from misc.wget_file import WgetFile """ This test ensures Wget's Digest Authorization Negotiation. """ ############# File Definitions ############################################### File1 = "Need a cookie?" File2 = "Want cookies with milk!" File1_rules = { "Authentication" : { "Type" : "Digest", "User" : "Pacman", "Pass" : "Omnomnom", "Parm" : { "qop" : "auth" } } } File2_rules = { "Authentication" : { "Type" : "Digest", "User" : "Pacman", "Pass" : "Omnomnom", "Parm" : { "qop" : None } } } A_File = WgetFile ("File1", File1, rules=File1_rules) B_File = WgetFile ("File2", File2, rules=File2_rules) WGET_OPTIONS = "--user=Pacman --password=Omnomnom" WGET_URLS = [["File1", "File2"]] Files = [[A_File, B_File]] ExpectedReturnCode = 0 ExpectedDownloadedFiles = [A_File, B_File] ################ Pre and Post Test Hooks ##################################### pre_test = { "ServerFiles" : Files } test_options = { "WgetCommands" : WGET_OPTIONS, "Urls" : WGET_URLS } post_test = { "ExpectedFiles" : ExpectedDownloadedFiles, "ExpectedRetcode" : ExpectedReturnCode } err = HTTPTest ( pre_hook=pre_test, test_params=test_options, post_hook=post_test ).begin () exit (err)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 504, 984, 492, 4458, 199, 504, 511, 14, 1014, 63, 396, 492, 3101, 774, 199, 504, 18576, 14, 87, 362, 63, 493, 492, 644, 362, 1173, 199, 199, 624, 272, 961, 511, 15620, 644, 362, 1159, 3757, 3199, 21527, 5612, 14727, 425, 14, 199, 624, 199, 516, 8776, 3814, 22659, 852, 26316, 14776, 199, 1173, 17, 275, 298, 17809, 282, 5494, 13472, 199, 1173, 18, 275, 298, 55, 867, 10049, 543, 333, 382, 75, 9539, 199, 199, 1173, 17, 63, 4423, 275, 469, 272, 298, 10348, 2, 259, 520, 469, 267, 298, 804, 2, 3515, 520, 298, 18541, 401, 267, 298, 1899, 2, 3515, 520, 298, 48, 645, 1237, 401, 267, 298, 4986, 2, 3515, 520, 298, 47, 10344, 676, 15998, 401, 267, 298, 1262, 77, 2, 3515, 520, 469, 288, 298, 81, 411, 2, 755, 520, 298, 1178, 2, 267, 789, 272, 789, 199, 93, 199, 199, 1173, 18, 63, 4423, 275, 469, 272, 298, 10348, 2, 259, 520, 469, 267, 298, 804, 2, 3515, 520, 298, 18541, 401, 267, 298, 1899, 2, 3515, 520, 298, 48, 645, 1237, 401, 267, 298, 4986, 2, 3515, 520, 298, 47, 10344, 676, 15998, 401, 267, 298, 1262, 77, 2, 3515, 520, 469, 288, 298, 81, 411, 2, 755, 520, 488, 267, 789, 272, 789, 199, 93, 199, 33, 63, 1173, 275, 644, 362, 1173, 1689, 1173, 17, 401, 3814, 17, 12, 4713, 29, 1173, 17, 63, 4423, 9, 199, 34, 63, 1173, 275, 644, 362, 1173, 1689, 1173, 18, 401, 3814, 18, 12, 4713, 29, 1173, 18, 63, 4423, 9, 199, 199, 55, 2970, 63, 8808, 275, 4320, 751, 29, 48, 645, 1237, 1553, 2060, 29, 47, 10344, 676, 15998, 2, 199, 55, 2970, 63, 31582, 275, 24212, 1173, 17, 401, 298, 1173, 18, 15261, 199, 199, 5535, 275, 3474, 33, 63, 1173, 12, 699, 63, 1173, 2677, 199, 199, 6964, 30212, 275, 378, 199, 6964, 3514, 4591, 5535, 275, 359, 33, 63, 1173, 12, 699, 63, 1173, 61, 199, 199, 749, 5543, 436, 7711, 1379, 24837, 83, 10371, 8776, 199, 657, 63, 396, 275, 469, 272, 298, 3120, 5535, 2, 755, 520, 16920, 199, 93, 199, 396, 63, 1419, 275, 469, 272, 298, 55, 362, 14680, 2, 420, 520, 644, 2970, 63, 8808, 12, 272, 298, 21867, 478, 2, 4519, 520, 644, 2970, 63, 31582, 199, 93, 199, 1932, 63, 396, 275, 469, 272, 298, 6964, 5535, 2, 258, 520, 13796, 3514, 4591, 5535, 12, 272, 298, 6964, 6816, 600, 2, 257, 520, 13796, 30212, 199, 93, 199, 199, 1508, 275, 3101, 774, 334, 355, 876, 63, 3664, 29, 657, 63, 396, 12, 355, 511, 63, 1162, 29, 396, 63, 1419, 12, 355, 2963, 63, 3664, 29, 1932, 63, 396, 199, 680, 5037, 6248, 199, 199, 2224, 334, 1508, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 504, 984, 492, 4458, 199, 504, 511, 14, 1014, 63, 396, 492, 3101, 774, 199, 504, 18576, 14, 87, 362, 63, 493, 492, 644, 362, 1173, 199, 199, 624, 272, 961, 511, 15620, 644, 362, 1159, 3757, 3199, 21527, 5612, 14727, 425, 14, 199, 624, 199, 516, 8776, 3814, 22659, 852, 26316, 14776, 199, 1173, 17, 275, 298, 17809, 282, 5494, 13472, 199, 1173, 18, 275, 298, 55, 867, 10049, 543, 333, 382, 75, 9539, 199, 199, 1173, 17, 63, 4423, 275, 469, 272, 298, 10348, 2, 259, 520, 469, 267, 298, 804, 2, 3515, 520, 298, 18541, 401, 267, 298, 1899, 2, 3515, 520, 298, 48, 645, 1237, 401, 267, 298, 4986, 2, 3515, 520, 298, 47, 10344, 676, 15998, 401, 267, 298, 1262, 77, 2, 3515, 520, 469, 288, 298, 81, 411, 2, 755, 520, 298, 1178, 2, 267, 789, 272, 789, 199, 93, 199, 199, 1173, 18, 63, 4423, 275, 469, 272, 298, 10348, 2, 259, 520, 469, 267, 298, 804, 2, 3515, 520, 298, 18541, 401, 267, 298, 1899, 2, 3515, 520, 298, 48, 645, 1237, 401, 267, 298, 4986, 2, 3515, 520, 298, 47, 10344, 676, 15998, 401, 267, 298, 1262, 77, 2, 3515, 520, 469, 288, 298, 81, 411, 2, 755, 520, 488, 267, 789, 272, 789, 199, 93, 199, 33, 63, 1173, 275, 644, 362, 1173, 1689, 1173, 17, 401, 3814, 17, 12, 4713, 29, 1173, 17, 63, 4423, 9, 199, 34, 63, 1173, 275, 644, 362, 1173, 1689, 1173, 18, 401, 3814, 18, 12, 4713, 29, 1173, 18, 63, 4423, 9, 199, 199, 55, 2970, 63, 8808, 275, 4320, 751, 29, 48, 645, 1237, 1553, 2060, 29, 47, 10344, 676, 15998, 2, 199, 55, 2970, 63, 31582, 275, 24212, 1173, 17, 401, 298, 1173, 18, 15261, 199, 199, 5535, 275, 3474, 33, 63, 1173, 12, 699, 63, 1173, 2677, 199, 199, 6964, 30212, 275, 378, 199, 6964, 3514, 4591, 5535, 275, 359, 33, 63, 1173, 12, 699, 63, 1173, 61, 199, 199, 749, 5543, 436, 7711, 1379, 24837, 83, 10371, 8776, 199, 657, 63, 396, 275, 469, 272, 298, 3120, 5535, 2, 755, 520, 16920, 199, 93, 199, 396, 63, 1419, 275, 469, 272, 298, 55, 362, 14680, 2, 420, 520, 644, 2970, 63, 8808, 12, 272, 298, 21867, 478, 2, 4519, 520, 644, 2970, 63, 31582, 199, 93, 199, 1932, 63, 396, 275, 469, 272, 298, 6964, 5535, 2, 258, 520, 13796, 3514, 4591, 5535, 12, 272, 298, 6964, 6816, 600, 2, 257, 520, 13796, 30212, 199, 93, 199, 199, 1508, 275, 3101, 774, 334, 355, 876, 63, 3664, 29, 657, 63, 396, 12, 355, 511, 63, 1162, 29, 396, 63, 1419, 12, 355, 2963, 63, 3664, 29, 1932, 63, 396, 199, 680, 5037, 6248, 199, 199, 2224, 334, 1508, 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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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 ]
ARM-software/mbed-beetle
tools/size.py
52
4111
""" mbed SDK Copyright (c) 2011-2013 ARM Limited 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 sys from os.path import join, abspath, dirname, exists, splitext from subprocess import Popen, PIPE import csv from collections import defaultdict ROOT = abspath(join(dirname(__file__), "..")) sys.path.insert(0, ROOT) from tools.paths import BUILD_DIR, TOOLS_DATA from tools.settings import GCC_ARM_PATH from tools.tests import TEST_MAP from tools.build_api import build_mbed_libs, build_project SIZE = join(GCC_ARM_PATH, 'arm-none-eabi-size') def get_size(path): out = Popen([SIZE, path], stdout=PIPE).communicate()[0] return map(int, out.splitlines()[1].split()[:4]) def get_percentage(before, after): if before == 0: return 0 if after == 0 else 100.0 return float(after - before) / float(before) * 100.0 def human_size(val): if val>1024: return "%.0fKb" % (float(val)/1024.0) return "%d" % val def print_diff(name, before, after): print "%s: (%s -> %s) %.2f%%" % (name, human_size(before) , human_size(after) , get_percentage(before , after)) BENCHMARKS = [ ("BENCHMARK_1", "CENV"), ("BENCHMARK_2", "PRINTF"), ("BENCHMARK_3", "FP"), ("BENCHMARK_4", "MBED"), ("BENCHMARK_5", "ALL"), ] BENCHMARK_DATA_PATH = join(TOOLS_DATA, 'benchmarks.csv') def benchmarks(): # CSV Data csv_data = csv.writer(open(BENCHMARK_DATA_PATH, 'wb')) csv_data.writerow(['Toolchain', "Target", "Benchmark", "code", "data", "bss", "flash"]) # Build for toolchain in ['ARM', 'uARM', 'GCC_CR', 'GCC_ARM']: for mcu in ["LPC1768", "LPC11U24"]: # Build Libraries build_mbed_libs(mcu, toolchain) # Build benchmarks build_dir = join(BUILD_DIR, "benchmarks", mcu, toolchain) for test_id, title in BENCHMARKS: # Build Benchmark try: test = TEST_MAP[test_id] path = build_project(test.source_dir, join(build_dir, test_id), mcu, toolchain, test.dependencies) base, ext = splitext(path) # Check Size code, data, bss, flash = get_size(base+'.elf') csv_data.writerow([toolchain, mcu, title, code, data, bss, flash]) except Exception, e: print "Unable to build %s for toolchain %s targeting %s" % (test_id, toolchain, mcu) print e def compare(t1, t2, target): if not exists(BENCHMARK_DATA_PATH): benchmarks() else: print "Loading: %s" % BENCHMARK_DATA_PATH data = csv.reader(open(BENCHMARK_DATA_PATH, 'rb')) benchmarks_data = defaultdict(dict) for (toolchain, mcu, name, code, data, bss, flash) in data: if target == mcu: for t in [t1, t2]: if toolchain == t: benchmarks_data[name][t] = map(int, (code, data, bss, flash)) print "%s vs %s for %s" % (t1, t2, target) for name, data in benchmarks_data.iteritems(): try: # Check Size code_a, data_a, bss_a, flash_a = data[t1] code_u, data_u, bss_u, flash_u = data[t2] print "\n=== %s ===" % name print_diff("code", code_a , code_u) print_diff("data", data_a , data_u) print_diff("bss", bss_a , bss_u) print_diff("flash", flash_a , flash_u) except Exception, e: print "No data for benchmark %s" % (name) print e if __name__ == '__main__': compare("GCC_CR", "LPC1768")
apache-2.0
[ 624, 199, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 6965, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 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, 624, 199, 646, 984, 199, 504, 747, 14, 515, 492, 4263, 12, 19529, 12, 9017, 12, 3495, 12, 2249, 7699, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 7392, 199, 504, 5055, 492, 10018, 199, 199, 5441, 275, 19529, 8, 904, 8, 3475, 3460, 493, 10139, 21777, 2237, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 16547, 9, 199, 199, 504, 7249, 14, 3771, 492, 22974, 63, 3022, 12, 2296, 2228, 51, 63, 3998, 199, 504, 7249, 14, 1751, 492, 598, 2571, 63, 12482, 63, 3243, 199, 504, 7249, 14, 2219, 492, 7393, 63, 5443, 199, 504, 7249, 14, 1506, 63, 1246, 492, 1900, 63, 3665, 63, 8450, 12, 1900, 63, 1715, 199, 199, 4305, 275, 4263, 8, 10566, 63, 12482, 63, 3243, 12, 283, 5362, 13, 3592, 13, 69, 14677, 13, 890, 358, 199, 199, 318, 664, 63, 890, 8, 515, 304, 272, 734, 275, 13995, 779, 4305, 12, 931, 467, 3839, 29, 6089, 680, 10664, 3430, 16, 61, 272, 372, 2341, 8, 442, 12, 734, 14, 7644, 3430, 17, 1055, 1294, 20523, 20, 566, 199, 199, 318, 664, 63, 14200, 8, 5182, 12, 2410, 304, 272, 340, 2544, 508, 378, 26, 267, 372, 378, 340, 2410, 508, 378, 587, 2948, 14, 16, 272, 372, 2069, 8, 4399, 446, 2544, 9, 1182, 2069, 8, 5182, 9, 627, 2948, 14, 16, 199, 199, 318, 11779, 63, 890, 8, 637, 304, 272, 340, 1139, 30, 7727, 26, 267, 372, 31681, 16, 70, 43, 66, 2, 450, 334, 1609, 8, 637, 2447, 7727, 14, 16, 9, 272, 372, 2071, 68, 2, 450, 1139, 199, 199, 318, 870, 63, 3028, 8, 354, 12, 2544, 12, 2410, 304, 272, 870, 2071, 83, 26, 4366, 83, 1035, 450, 83, 9, 10536, 18, 70, 8530, 2, 450, 334, 354, 12, 11779, 63, 890, 8, 5182, 9, 2360, 11779, 63, 890, 8, 4399, 9, 2360, 664, 63, 14200, 8, 5182, 2360, 2410, 430, 199, 199, 34, 742, 1244, 10520, 51, 275, 359, 272, 1689, 34, 742, 1244, 10520, 63, 17, 401, 298, 35, 9984, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 18, 401, 298, 21754, 38, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 19, 401, 298, 17095, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 20, 401, 298, 4567, 1149, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 21, 401, 298, 1761, 1288, 199, 61, 199, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 275, 4263, 8, 20261, 63, 3998, 12, 283, 11861, 83, 14, 4737, 358, 421, 199, 318, 12338, 83, 837, 272, 327, 14689, 3918, 272, 7392, 63, 576, 275, 7392, 14, 5491, 8, 1490, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 12, 283, 6603, 1333, 272, 7392, 63, 576, 14, 22686, 2941, 5157, 4429, 297, 298, 4277, 401, 298, 18644, 401, 298, 600, 401, 298, 576, 401, 298, 66, 385, 401, 298, 11331, 3135, 339, 327, 6516, 272, 367, 22689, 315, 788, 12482, 297, 283, 85, 12482, 297, 283, 10566, 63, 2944, 297, 283, 10566, 63, 12482, 2565, 267, 367, 333, 15140, 315, 2097, 44, 4222, 1196, 2333, 401, 298, 44, 4222, 845, 53, 1194, 6229, 288, 327, 6516, 31454, 288, 1900, 63, 3665, 63, 8450, 8, 5466, 85, 12, 22689, 9, 953, 327, 6516, 12338, 83, 288, 1900, 63, 694, 275, 4263, 8, 8248, 63, 3022, 12, 298, 11861, 83, 401, 333, 15140, 12, 22689, 9, 288, 367, 511, 63, 344, 12, 2538, 315, 699, 742, 1244, 10520, 51, 26, 355, 327, 6516, 27067, 355, 862, 26, 490, 511, 275, 7393, 63, 5443, 59, 396, 63, 344, 61, 490, 931, 275, 1900, 63, 1715, 8, 396, 14, 1365, 63, 694, 12, 4263, 8, 1506, 63, 694, 12, 511, 63, 344, 395, 639, 333, 15140, 12, 22689, 12, 511, 14, 5714, 9, 490, 1300, 12, 1599, 275, 2249, 7699, 8, 515, 9, 490, 327, 2670, 14579, 490, 1233, 12, 666, 12, 330, 385, 12, 14775, 275, 664, 63, 890, 8, 1095, 18098, 25371, 358, 490, 7392, 63, 576, 14, 22686, 779, 22572, 12, 333, 15140, 12, 2538, 12, 1233, 12, 666, 12, 330, 385, 12, 14775, 566, 355, 871, 2186, 12, 325, 26, 490, 870, 298, 6005, 370, 1900, 450, 83, 367, 22689, 450, 83, 1347, 316, 450, 83, 2, 450, 334, 396, 63, 344, 12, 22689, 12, 333, 15140, 9, 490, 870, 325, 421, 199, 318, 6540, 8, 84, 17, 12, 307, 18, 12, 1347, 304, 272, 340, 440, 3495, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 304, 267, 12338, 83, 342, 272, 587, 26, 267, 870, 298, 19236, 26, 450, 83, 2, 450, 699, 742, 1244, 10520, 63, 3998, 63, 3243, 339, 666, 275, 7392, 14, 5503, 8, 1490, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 12, 283, 4848, 1333, 339, 12338, 83, 63, 576, 275, 10018, 8, 807, 9, 272, 367, 334, 22572, 12, 333, 15140, 12, 536, 12, 1233, 12, 666, 12, 330, 385, 12, 14775, 9, 315, 666, 26, 267, 340, 1347, 508, 333, 15140, 26, 288, 367, 307, 315, 359, 84, 17, 12, 307, 18, 2189, 355, 340, 22689, 508, 307, 26, 490, 12338, 83, 63, 576, 59, 354, 1527, 84, 61, 275, 2341, 8, 442, 12, 334, 600, 12, 666, 12, 330, 385, 12, 14775, 430, 339, 870, 2071, 83, 8118, 450, 83, 367, 450, 83, 2, 450, 334, 84, 17, 12, 307, 18, 12, 1347, 9, 272 ]
[ 199, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 6965, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 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, 624, 199, 646, 984, 199, 504, 747, 14, 515, 492, 4263, 12, 19529, 12, 9017, 12, 3495, 12, 2249, 7699, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 7392, 199, 504, 5055, 492, 10018, 199, 199, 5441, 275, 19529, 8, 904, 8, 3475, 3460, 493, 10139, 21777, 2237, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 16547, 9, 199, 199, 504, 7249, 14, 3771, 492, 22974, 63, 3022, 12, 2296, 2228, 51, 63, 3998, 199, 504, 7249, 14, 1751, 492, 598, 2571, 63, 12482, 63, 3243, 199, 504, 7249, 14, 2219, 492, 7393, 63, 5443, 199, 504, 7249, 14, 1506, 63, 1246, 492, 1900, 63, 3665, 63, 8450, 12, 1900, 63, 1715, 199, 199, 4305, 275, 4263, 8, 10566, 63, 12482, 63, 3243, 12, 283, 5362, 13, 3592, 13, 69, 14677, 13, 890, 358, 199, 199, 318, 664, 63, 890, 8, 515, 304, 272, 734, 275, 13995, 779, 4305, 12, 931, 467, 3839, 29, 6089, 680, 10664, 3430, 16, 61, 272, 372, 2341, 8, 442, 12, 734, 14, 7644, 3430, 17, 1055, 1294, 20523, 20, 566, 199, 199, 318, 664, 63, 14200, 8, 5182, 12, 2410, 304, 272, 340, 2544, 508, 378, 26, 267, 372, 378, 340, 2410, 508, 378, 587, 2948, 14, 16, 272, 372, 2069, 8, 4399, 446, 2544, 9, 1182, 2069, 8, 5182, 9, 627, 2948, 14, 16, 199, 199, 318, 11779, 63, 890, 8, 637, 304, 272, 340, 1139, 30, 7727, 26, 267, 372, 31681, 16, 70, 43, 66, 2, 450, 334, 1609, 8, 637, 2447, 7727, 14, 16, 9, 272, 372, 2071, 68, 2, 450, 1139, 199, 199, 318, 870, 63, 3028, 8, 354, 12, 2544, 12, 2410, 304, 272, 870, 2071, 83, 26, 4366, 83, 1035, 450, 83, 9, 10536, 18, 70, 8530, 2, 450, 334, 354, 12, 11779, 63, 890, 8, 5182, 9, 2360, 11779, 63, 890, 8, 4399, 9, 2360, 664, 63, 14200, 8, 5182, 2360, 2410, 430, 199, 199, 34, 742, 1244, 10520, 51, 275, 359, 272, 1689, 34, 742, 1244, 10520, 63, 17, 401, 298, 35, 9984, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 18, 401, 298, 21754, 38, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 19, 401, 298, 17095, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 20, 401, 298, 4567, 1149, 1288, 272, 1689, 34, 742, 1244, 10520, 63, 21, 401, 298, 1761, 1288, 199, 61, 199, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 275, 4263, 8, 20261, 63, 3998, 12, 283, 11861, 83, 14, 4737, 358, 421, 199, 318, 12338, 83, 837, 272, 327, 14689, 3918, 272, 7392, 63, 576, 275, 7392, 14, 5491, 8, 1490, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 12, 283, 6603, 1333, 272, 7392, 63, 576, 14, 22686, 2941, 5157, 4429, 297, 298, 4277, 401, 298, 18644, 401, 298, 600, 401, 298, 576, 401, 298, 66, 385, 401, 298, 11331, 3135, 339, 327, 6516, 272, 367, 22689, 315, 788, 12482, 297, 283, 85, 12482, 297, 283, 10566, 63, 2944, 297, 283, 10566, 63, 12482, 2565, 267, 367, 333, 15140, 315, 2097, 44, 4222, 1196, 2333, 401, 298, 44, 4222, 845, 53, 1194, 6229, 288, 327, 6516, 31454, 288, 1900, 63, 3665, 63, 8450, 8, 5466, 85, 12, 22689, 9, 953, 327, 6516, 12338, 83, 288, 1900, 63, 694, 275, 4263, 8, 8248, 63, 3022, 12, 298, 11861, 83, 401, 333, 15140, 12, 22689, 9, 288, 367, 511, 63, 344, 12, 2538, 315, 699, 742, 1244, 10520, 51, 26, 355, 327, 6516, 27067, 355, 862, 26, 490, 511, 275, 7393, 63, 5443, 59, 396, 63, 344, 61, 490, 931, 275, 1900, 63, 1715, 8, 396, 14, 1365, 63, 694, 12, 4263, 8, 1506, 63, 694, 12, 511, 63, 344, 395, 639, 333, 15140, 12, 22689, 12, 511, 14, 5714, 9, 490, 1300, 12, 1599, 275, 2249, 7699, 8, 515, 9, 490, 327, 2670, 14579, 490, 1233, 12, 666, 12, 330, 385, 12, 14775, 275, 664, 63, 890, 8, 1095, 18098, 25371, 358, 490, 7392, 63, 576, 14, 22686, 779, 22572, 12, 333, 15140, 12, 2538, 12, 1233, 12, 666, 12, 330, 385, 12, 14775, 566, 355, 871, 2186, 12, 325, 26, 490, 870, 298, 6005, 370, 1900, 450, 83, 367, 22689, 450, 83, 1347, 316, 450, 83, 2, 450, 334, 396, 63, 344, 12, 22689, 12, 333, 15140, 9, 490, 870, 325, 421, 199, 318, 6540, 8, 84, 17, 12, 307, 18, 12, 1347, 304, 272, 340, 440, 3495, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 304, 267, 12338, 83, 342, 272, 587, 26, 267, 870, 298, 19236, 26, 450, 83, 2, 450, 699, 742, 1244, 10520, 63, 3998, 63, 3243, 339, 666, 275, 7392, 14, 5503, 8, 1490, 8, 34, 742, 1244, 10520, 63, 3998, 63, 3243, 12, 283, 4848, 1333, 339, 12338, 83, 63, 576, 275, 10018, 8, 807, 9, 272, 367, 334, 22572, 12, 333, 15140, 12, 536, 12, 1233, 12, 666, 12, 330, 385, 12, 14775, 9, 315, 666, 26, 267, 340, 1347, 508, 333, 15140, 26, 288, 367, 307, 315, 359, 84, 17, 12, 307, 18, 2189, 355, 340, 22689, 508, 307, 26, 490, 12338, 83, 63, 576, 59, 354, 1527, 84, 61, 275, 2341, 8, 442, 12, 334, 600, 12, 666, 12, 330, 385, 12, 14775, 430, 339, 870, 2071, 83, 8118, 450, 83, 367, 450, 83, 2, 450, 334, 84, 17, 12, 307, 18, 12, 1347, 9, 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,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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 ]
orione7/plugin.video.streamondemand-pureita
lib/elementtree/__init__.py
127
1491
# $Id: __init__.py 1821 2004-06-03 16:57:49Z fredrik $ # elementtree package # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2004 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # --------------------------------------------------------------------
gpl-3.0
[ 3, 2672, 1304, 26, 636, 826, 4343, 647, 6155, 2025, 8353, 13, 1690, 13, 1644, 3193, 26, 1641, 26, 1887, 58, 289, 581, 25844, 2672, 199, 3, 1819, 2350, 2559, 199, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 15431, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2672, 1304, 26, 636, 826, 4343, 647, 6155, 2025, 8353, 13, 1690, 13, 1644, 3193, 26, 1641, 26, 1887, 58, 289, 581, 25844, 2672, 199, 3, 1819, 2350, 2559, 199, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 15431, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
rtucker-mozilla/mozilla_inventory
mozdns/txt/migrations/0001_initial.py
3
5233
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'TXT' db.create_table('txt', ( ('domain', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['domain.Domain'])), ('label', self.gf('django.db.models.fields.CharField')(max_length=63, null=True, blank=True)), ('fqdn', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=255, null=True, blank=True)), ('ttl', self.gf('django.db.models.fields.PositiveIntegerField')(default=3600, null=True, blank=True)), ('description', self.gf('django.db.models.fields.CharField')(max_length=1000, null=True, blank=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('txt_data', self.gf('django.db.models.fields.TextField')()), )) db.send_create_signal('txt', ['TXT']) # Adding M2M table for field views on 'TXT' db.create_table('txt_views', ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('txt', models.ForeignKey(orm['txt.txt'], null=False)), ('view', models.ForeignKey(orm['view.view'], null=False)) )) db.create_unique('txt_views', ['txt_id', 'view_id']) def backwards(self, orm): # Deleting model 'TXT' db.delete_table('txt') # Removing M2M table for field views on 'TXT' db.delete_table('txt_views') models = { 'domain.domain': { 'Meta': {'object_name': 'Domain', 'db_table': "'domain'"}, 'delegated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'dirty': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_reverse': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'master_domain': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['domain.Domain']", 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'purgeable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'soa': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['soa.SOA']", 'null': 'True', 'blank': 'True'}) }, 'soa.soa': { 'Meta': {'unique_together': "(('primary', 'contact', 'description'),)", 'object_name': 'SOA', 'db_table': "'soa'"}, 'contact': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'dirty': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'expire': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1209600'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'minimum': ('django.db.models.fields.PositiveIntegerField', [], {'default': '180'}), 'primary': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'refresh': ('django.db.models.fields.PositiveIntegerField', [], {'default': '180'}), 'retry': ('django.db.models.fields.PositiveIntegerField', [], {'default': '86400'}), 'serial': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1360538205'}), 'ttl': ('django.db.models.fields.PositiveIntegerField', [], {'default': '3600', 'null': 'True', 'blank': 'True'}) }, 'txt.txt': { 'Meta': {'object_name': 'TXT', 'db_table': "'txt'"}, 'description': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'blank': 'True'}), 'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['domain.Domain']"}), 'fqdn': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'label': ('django.db.models.fields.CharField', [], {'max_length': '63', 'null': 'True', 'blank': 'True'}), 'ttl': ('django.db.models.fields.PositiveIntegerField', [], {'default': '3600', 'null': 'True', 'blank': 'True'}), 'txt_data': ('django.db.models.fields.TextField', [], {}), 'views': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['view.View']", 'symmetrical': 'False', 'blank': 'True'}) }, 'view.view': { 'Meta': {'unique_together': "(('name',),)", 'object_name': 'View', 'db_table': "'view'"}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}) } } complete_apps = ['txt']
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 17715, 7, 267, 1592, 14, 981, 63, 1224, 360, 2424, 297, 334, 288, 661, 2261, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 2261, 14, 7705, 16607, 288, 661, 1302, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2766, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 18364, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 697, 63, 1080, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 12130, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 7533, 885, 29, 11035, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 2424, 63, 576, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 4000, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 2424, 297, 788, 17715, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 6858, 641, 283, 17715, 7, 267, 1592, 14, 981, 63, 1224, 360, 2424, 63, 4196, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 2424, 297, 1709, 14, 3190, 8, 1025, 459, 2424, 14, 2424, 995, 2973, 29, 797, 1826, 288, 661, 1345, 297, 1709, 14, 3190, 8, 1025, 459, 1345, 14, 1345, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 2424, 63, 4196, 297, 788, 2424, 63, 344, 297, 283, 1345, 63, 344, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 17715, 7, 267, 1592, 14, 1807, 63, 1224, 360, 2424, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 6858, 641, 283, 17715, 7, 267, 1592, 14, 1807, 63, 1224, 360, 2424, 63, 4196, 358, 2378, 1709, 275, 469, 267, 283, 2261, 14, 2261, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 7705, 297, 283, 697, 63, 1224, 356, 3546, 2261, 15208, 288, 283, 23684, 972, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 8799, 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, 374, 63, 4471, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 4133, 63, 2261, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 885, 356, 283, 403, 297, 283, 475, 356, 298, 1025, 459, 2261, 14, 7705, 6256, 283, 2307, 356, 283, 549, 297, 283, 2500, 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, 2299, 1604, 288, 283, 18254, 461, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 1152, 65, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 885, 356, 283, 403, 297, 283, 475, 356, 298, 1025, 459, 1152, 65, 14, 4118, 33, 6256, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1152, 65, 14, 1152, 65, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 3327, 297, 283, 7811, 297, 283, 1802, 9878, 283, 785, 63, 354, 356, 283, 4118, 33, 297, 283, 697, 63, 1224, 356, 3546, 1152, 65, 15208, 288, 283, 7811, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 8799, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 14691, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 713, 1643, 6683, 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, 10700, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 7663, 1604, 288, 283, 3327, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 6635, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 7663, 1604, 288, 283, 7154, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 24, 20543, 1604, 288, 283, 2171, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 8138, 1717, 1703, 10629, 1604, 288, 283, 12130, 356, 661, 1176, 14, 697, 14, 992, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 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, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 17715, 7, 267, 1592, 14, 981, 63, 1224, 360, 2424, 297, 334, 288, 661, 2261, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 2261, 14, 7705, 16607, 288, 661, 1302, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2766, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 18364, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 697, 63, 1080, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 12130, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 7533, 885, 29, 11035, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 2424, 63, 576, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 4000, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 2424, 297, 788, 17715, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 6858, 641, 283, 17715, 7, 267, 1592, 14, 981, 63, 1224, 360, 2424, 63, 4196, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 2424, 297, 1709, 14, 3190, 8, 1025, 459, 2424, 14, 2424, 995, 2973, 29, 797, 1826, 288, 661, 1345, 297, 1709, 14, 3190, 8, 1025, 459, 1345, 14, 1345, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 2424, 63, 4196, 297, 788, 2424, 63, 344, 297, 283, 1345, 63, 344, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 17715, 7, 267, 1592, 14, 1807, 63, 1224, 360, 2424, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 6858, 641, 283, 17715, 7, 267, 1592, 14, 1807, 63, 1224, 360, 2424, 63, 4196, 358, 2378, 1709, 275, 469, 267, 283, 2261, 14, 2261, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 7705, 297, 283, 697, 63, 1224, 356, 3546, 2261, 15208, 288, 283, 23684, 972, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 8799, 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, 374, 63, 4471, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 4133, 63, 2261, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 885, 356, 283, 403, 297, 283, 475, 356, 298, 1025, 459, 2261, 14, 7705, 6256, 283, 2307, 356, 283, 549, 297, 283, 2500, 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, 2299, 1604, 288, 283, 18254, 461, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 1152, 65, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 885, 356, 283, 403, 297, 283, 475, 356, 298, 1025, 459, 1152, 65, 14, 4118, 33, 6256, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1152, 65, 14, 1152, 65, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 3327, 297, 283, 7811, 297, 283, 1802, 9878, 283, 785, 63, 354, 356, 283, 4118, 33, 297, 283, 697, 63, 1224, 356, 3546, 1152, 65, 15208, 288, 283, 7811, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 8799, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 14691, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 713, 1643, 6683, 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, 10700, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 7663, 1604, 288, 283, 3327, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 6635, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 7663, 1604, 288, 283, 7154, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 24, 20543, 1604, 288, 283, 2171, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 8138, 1717, 1703, 10629, 1604, 288, 283, 12130, 356, 661, 1176, 14, 697, 14, 992, 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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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 ]
SEL-Columbia/commcare-hq
custom/openlmis/api.py
2
19029
from datetime import datetime import json import feedparser import time import requests from corehq.apps.commtrack.const import REQUISITION_CASE_TYPE from corehq.apps.commtrack.models import RequisitionCase from custom.api.utils import EndpointMixin from custom.openlmis.exceptions import OpenLMISAPIException REQUISITION_APPROVED = "Requisition approved successfully" class RssMetadata(object): def __init__(self, id, updated, metadata): self.id = id self.updated = updated self.metadata = metadata @classmethod def from_entry(cls, entry): id = entry['id'] updated = datetime.fromtimestamp(time.mktime(entry['updated_parsed'])) [content] = entry['content'] metadata = json.loads(content['value']) return cls(id, updated, metadata) class RssWrapper(object): def __init__(self, rss_meta): self.rss_meta = rss_meta @property def metadata(self): return self.rss_meta.metadata class Facility(RssWrapper): @property def code(self): return self.metadata['code'] @property def name(self): return self.metadata['name'] @property def type(self): return self.metadata['facilityType'] @property def latitude(self): return self.metadata.get('latitude', None) @property def longitude(self): return self.metadata.get('longitude', None) @property def parent_id(self): return self.metadata.get('parentFacility', None) class FacilityProgramLink(RssWrapper): pass class Product(object): def __init__(self, code, name, description, unit, category): self.code = code self.name = name self.description = description self.unit = unit self.category = category @classmethod def from_json(cls, json_rep): return cls( code=json_rep['productCode'], name=json_rep['productName'], description=json_rep['description'], unit=json_rep['unit'], category=json_rep['category'], ) class RequisitionStatus(RssWrapper): @property def requisition_id(self): return self.metadata['requisitionId'] @property def requisition_status(self): return self.metadata['requisitionStatus'] @property def order_id(self): return self.metadata.get('orderId', None) @property def order_status(self): return self.metadata.get('orderStatus', None) @property def emergency(self): return self.metadata.get('emergency', None) @property def start_date(self): return self.metadata.get('startDate', None) @property def end_date(self): return self.metadata.get('endDate', None) class Program(object): def __init__(self, code, name, products=None): self.code = code self.name = name self.products = products or [] @classmethod def from_metadata(cls, metadata): ret = cls(metadata['programCode'], metadata['programName']) return ret @classmethod def from_json(cls, json_rep): product_list = json_rep['programProductList'] if not product_list: return None name = product_list[0]['programName'] code = product_list[0]['programCode'] products = [] for p in product_list: if p['programName'] != name or p['programCode'] != code: raise OpenLMISAPIException('Product list was inconsistent') products.append(Product.from_json(p)) return cls(code=code, name=name, products=products) def get_facilities(uri_or_text): parsed = feedparser.parse(uri_or_text) for entry in parsed.entries: yield Facility(RssMetadata.from_entry(entry)) def get_facility_programs(uri_or_text): parsed = feedparser.parse(uri_or_text) for entry in parsed.entries: yield FacilityProgramLink(RssMetadata.from_entry(entry)) def get_programs_and_products(uri_or_text): parsed = feedparser.parse(uri_or_text) for entry in parsed.entries: yield Program.from_metadata(RssMetadata.from_entry(entry).metadata) def get_requisition_statuses(uri_or_text): parsed = feedparser.parse(uri_or_text) for entry in parsed.entries: yield RequisitionStatus(RssMetadata.from_entry(entry)) class OpenLMISEndpoint(EndpointMixin): """ Endpoint for interfacing with the OpenLMIS APIs """ def __init__(self, base_uri, username, password): self.base_uri = base_uri.rstrip('/') self.username = username self.password = password # feeds self._feed_uri = self._urlcombine(self.base_uri, '/feeds') self.facility_master_feed_uri = self._urlcombine(self._feed_uri, '/facilities') self.facility_program_feed_uri = self._urlcombine(self._feed_uri, '/programs-supported') self.program_catalog_feed_uri = self._urlcombine(self._feed_uri, '/program-catalog-changes') self.requisition_status_feed_uri = self._urlcombine(self._feed_uri, '/requisition-status') # rest apis self._rest_uri = self._urlcombine(self.base_uri, '/rest-api') self.create_virtual_facility_url = self._urlcombine(self._rest_uri, '/agents.json') self.update_virtual_facility_base_url = self._urlcombine(self._rest_uri, '/agents') self.program_product_url = self._urlcombine(self._rest_uri, '/program-products.json') self.requisition_details_url = self._urlcombine(self._rest_uri, '/requisitions') self.confirm_delivery_base_url = self._urlcombine(self._rest_uri, '/orders') def _page(self, base, page): return '{base}/{page}'.format(base=base, page=page) def _iter_feed(self, uri, item_wrapper): results = True page = 1 while results: next = self._page(uri, page) results = list(item_wrapper(next)) for r in results: yield r page += 1 def _response(self, response): # todo: error handling and such res = response.json() if res.get('success', False) or res == ("%s" % REQUISITION_APPROVED): return True elif res.get('requisitionId', False): return res else: raise OpenLMISAPIException(res['error']) def get_all_facilities(self): return (fac for fac in self._iter_feed(self.facility_master_feed_uri, get_facilities)) def get_all_requisition_statuses(self): return (fac for fac in self._iter_feed(self.requisition_status_feed_uri, get_requisition_statuses)) def get_all_programs(self, include_products=True): programs = (p for p in self._iter_feed(self.program_catalog_feed_uri, get_programs_and_products)) if include_products: return (self.get_program_products(p.code) for p in programs) else: return programs def get_program_products(self, program_code): response = requests.get(self.program_product_url, params={'programCode': program_code}, auth=self._auth()) return Program.from_json(response.json()) def get_requisition_details(self, id): response = requests.get(self.update_requisition_details_url(id), auth=self._auth()) if response.json().get('requisition'): return RequisitionDetails.from_json(response.json()) else: return None def create_virtual_facility(self, facility_data): response = requests.post(self.create_virtual_facility_url, data=json.dumps(facility_data), headers={'content-type': 'application/json'}, auth=self._auth()) return self._response(response) def update_virtual_facility_url(self, id): return self._urlcombine(self.update_virtual_facility_base_url, '/{id}.json'.format(id=id)) def update_requisition_details_url(self, id): return self._urlcombine(self.requisition_details_url, '/{id}.json'.format(id=id)) def update_virtual_facility(self, id, facility_data): facility_data['agentCode'] = id response = requests.put(self.update_virtual_facility_url(id), data=json.dumps(facility_data), headers={'content-type': 'application/json'}, auth=self._auth()) return self._response(response) def submit_requisition(self, requisition_data): response = requests.post(self.requisition_details_url, data=json.dumps(requisition_data), headers={'content-type': 'application/json'}, auth=self._auth()) return self._response(response) def update_confirm_delivery_url(self, order_id): return self._urlcombine(self.confirm_delivery_base_url, '/{orderId}/pod.json'.format(orderId=order_id)) def confirm_delivery(self, order_id, delivery_data): response = requests.post(self.update_confirm_delivery_url(order_id), data=json.dumps(delivery_data), headers={'content-type': 'application/json'}, auth=self._auth()) return self._response(response) def approve_requisition_url(self, requisition_id): return self._urlcombine(self.requisition_details_url, '/{requisitionId}/approve'.format(requisitionId=requisition_id)) def approve_requisition(self, approve_requisition, requisition_id): response = requests.put(self.approve_requisition_url(requisition_id), data=json.dumps(approve_requisition), headers={'content-type': 'application/json'}, auth=self._auth()) return self._response(response) class Requisition(object): def __init__(self, agent_code, program_id, products, period_id=None): self.agent_code = agent_code self.program_id = program_id self.period_id = period_id self.products = products @classmethod def from_json(cls, json_rep): product_list = json_rep['products'] if not product_list: return None agent_code = json_rep['agentCode'] program_id = json_rep['programId'] period_id = json_rep['periodId'] products = [] for p in product_list: products.append(RequisitionProduct.from_json(p)) return cls(agent_code=agent_code, program_id=program_id, products=products, period_id=period_id) class RequisitionProduct(Product): def __init__(self, code, name=None, description=None, unit=None, category=None, beginning_balance=None, quantity_received=None, quantity_dispensed=None, losses_and_adjustments=None, new_patient_count=None, stock_in_hand=None, stock_out_days=None, quantity_requested=None, reason_for_requested_quantity=None, remarks=None): self.beginning_balance = beginning_balance self.quantity_received = quantity_received self.quantity_dispensed = quantity_dispensed self.losses_and_adjustments = losses_and_adjustments self.new_patient_count = new_patient_count self.stock_in_hand = stock_in_hand self.stock_out_days = stock_out_days self.quantity_requested = quantity_requested self.reason_for_requested_quantity = reason_for_requested_quantity self.remarks = remarks super(RequisitionProduct, self).__init__(code, name, description, unit, category) @classmethod def from_json(cls, json_rep): code = json_rep['productCode'] beginning_balance = json_rep.get('beginningBalance', None) quantity_received = json_rep.get('quantityReceived', None) quantity_dispensed = json_rep.get('quantityDispensed', None) losses_and_adjustments = json_rep.get('lossesAndAdjustments', None) new_patient_count = json_rep.get('newPatientCount', None) stock_in_hand = json_rep.get('stockInHand', None) stock_out_days = json_rep.get('stockOutDays', None) quantity_requested = json_rep.get('quantityRequested', None) reason_for_requested_quantity = json_rep.get('reasonForRequestedQuantity', None) remarks = json_rep.get('remarks', None) return cls(code=code, beginning_balance=beginning_balance, quantity_received=quantity_received, quantity_dispensed=quantity_dispensed, losses_and_adjustments=losses_and_adjustments, new_patient_count=new_patient_count, stock_in_hand=stock_in_hand, stock_out_days=stock_out_days, quantity_requested=quantity_requested, reason_for_requested_quantity=reason_for_requested_quantity, remarks=remarks) class RequisitionDetails(Requisition): def __init__(self, id, agent_code, program_code, emergency, period_start_date, period_end_date, requisition_status, products, supplying_facility_code=None, order_id=None, order_status=None): super(RequisitionDetails, self).__init__(agent_code=agent_code, program_id=program_code, products=products) self.id = id self.emergency = emergency self.period_start_date = period_start_date self.period_end_date = period_end_date self.requisition_status = requisition_status self.order_id = order_id self.order_status = order_status self.supplying_facility_code = supplying_facility_code @classmethod def from_json(cls, json_rep): json_rep = json_rep["requisition"] product_list = json_rep['products'] if not product_list: return None id = json_rep['id'] agent_code = json_rep['agentCode'] program_code = json_rep['programCode'] emergency = json_rep['emergency'] period_start_date = json_rep['stringPeriodStartDate'] period_end_date = json_rep['stringPeriodEndDate'] requisition_status = json_rep['requisitionStatus'] order_id = json_rep.get('orderId', None) order_status = json_rep.get('orderStatus', None) supplying_facility_code = json_rep.get('supplyingFacilityCode', None) products = [] for p in product_list: products.append(RequisitionProductDetails.from_json(p)) return cls(id, agent_code, program_code, emergency, period_start_date, period_end_date, requisition_status, products, supplying_facility_code, order_id, order_status) def to_requisition_case(self, product_id, case_id=None, case_rev=None): req_case = RequisitionCase() req_case.type = REQUISITION_CASE_TYPE req_case.user_id = self.agent_code req_case.set_case_property("program_id", self.program_id) req_case.set_case_property("period_id", self.period_id) req_case.product_id = product_id req_case.external_id = self.id req_case.requisition_status = self.requisition_status req_case.set_case_property("order_id", self.order_id) req_case.set_case_property("order_status", self.order_status) req_case.set_case_property("emergency", self.emergency) req_case.set_case_property("start_date", self.period_start_date) req_case.set_case_property("end_date", self.period_end_date) if case_id: req_case._id = case_id if case_rev: req_case._rev = case_rev return req_case def to_dict(self, product_id): dictionary = { 'product_id': product_id, 'program_id': self.program_id, 'order_id': self.order_id, 'agent_code': self.agent_code, 'order_status': self.order_status, 'emergency': self.emergency, 'start_date': self.period_start_date, 'end_date': self.period_end_date, 'supplyingFacilityCode': self.supplying_facility_code } return dictionary class RequisitionProductDetails(RequisitionProduct): def __init__(self, code, beginning_balance, quantity_received, quantity_dispensed=None, losses_and_adjustments=None, new_patient_count=None, stock_in_hand=None, stock_out_days=None, quantity_requested=None, reason_for_requested_quantity=None, remarks=None, skipped=None, total_losses_and_adjustments=None, calculated_order_quantity=None, quantity_approved=None): self.total_losses_and_adjustments = total_losses_and_adjustments self.calculated_order_quantity = calculated_order_quantity self.quantity_approved = quantity_approved self.skipped = skipped super(RequisitionProductDetails, self).__init__(code=code, beginning_balance=beginning_balance, quantity_received=quantity_received, quantity_dispensed=quantity_dispensed, losses_and_adjustments=losses_and_adjustments, new_patient_count=new_patient_count, stock_in_hand=stock_in_hand, stock_out_days=stock_out_days, quantity_requested=quantity_requested, reason_for_requested_quantity=reason_for_requested_quantity, remarks=remarks) @classmethod def from_json(cls, json_rep): code = json_rep['productCode'] beginning_balance = json_rep.get('beginningBalance', None) quantity_received = json_rep.get('quantityReceived', None) quantity_dispensed = json_rep.get('quantityDispensed', None) losses_and_adjustments = json_rep.get('lossesAndAdjustments', None) new_patient_count = json_rep.get('newPatientCount', None) stock_in_hand = json_rep.get('stockInHand', None) stock_out_days = json_rep.get('stockOutDays', None) quantity_requested = json_rep.get('quantityRequested', None) reason_for_requested_quantity =json_rep.get('reasonForRequestedQuantity', None) remarks = json_rep.get('remarks', None) skipped = json_rep.get('skipped', None) total_losses_and_adjustments = json_rep.get('totalLossesAndAdjustments', None) calculated_order_quantity = json_rep.get('calculatedOrderQuantity', None) quantity_approved = json_rep.get('quantityApproved', None) return cls(code=code, beginning_balance=beginning_balance, quantity_received=quantity_received, quantity_dispensed=quantity_dispensed, losses_and_adjustments=losses_and_adjustments, new_patient_count=new_patient_count, stock_in_hand=stock_in_hand, stock_out_days=stock_out_days, quantity_requested=quantity_requested, reason_for_requested_quantity=reason_for_requested_quantity, remarks=remarks, skipped=skipped, total_losses_and_adjustments=total_losses_and_adjustments, calculated_order_quantity=calculated_order_quantity, quantity_approved=quantity_approved)
bsd-3-clause
[ 504, 2197, 492, 2197, 199, 646, 2022, 199, 646, 4733, 2087, 199, 646, 900, 199, 646, 4145, 199, 504, 6170, 21550, 14, 5181, 14, 1404, 3885, 14, 1297, 492, 17023, 1311, 12039, 63, 11320, 63, 2711, 199, 504, 6170, 21550, 14, 5181, 14, 1404, 3885, 14, 992, 492, 799, 21523, 1538, 199, 504, 3537, 14, 1246, 14, 1208, 492, 9599, 1403, 4256, 199, 504, 3537, 14, 1490, 76, 1292, 14, 3924, 492, 3232, 44, 9674, 29388, 199, 199, 5255, 1311, 12039, 63, 1282, 2514, 14112, 275, 298, 497, 21523, 30055, 8792, 2, 421, 199, 533, 820, 385, 5142, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1305, 12, 4588, 12, 3341, 304, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 5334, 275, 4588, 267, 291, 14, 2343, 275, 3341, 339, 768, 3744, 272, 347, 687, 63, 2373, 8, 1886, 12, 2397, 304, 267, 1305, 275, 2397, 459, 344, 418, 267, 4588, 275, 2197, 14, 18531, 8, 521, 14, 23456, 8, 2373, 459, 5334, 63, 6751, 5156, 267, 359, 1317, 61, 275, 2397, 459, 1317, 418, 267, 3341, 275, 2022, 14, 3640, 8, 1317, 459, 585, 1105, 267, 372, 843, 8, 344, 12, 4588, 12, 3341, 9, 421, 199, 533, 820, 385, 4590, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 32291, 63, 2024, 304, 267, 291, 14, 13614, 63, 2024, 275, 32291, 63, 2024, 339, 768, 1829, 272, 347, 3341, 8, 277, 304, 267, 372, 291, 14, 13614, 63, 2024, 14, 2343, 421, 199, 533, 10859, 12498, 8, 50, 385, 4590, 304, 339, 768, 1829, 272, 347, 1233, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 600, 418, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 354, 418, 339, 768, 1829, 272, 347, 730, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 22354, 804, 418, 339, 768, 1829, 272, 347, 18896, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 13331, 297, 488, 9, 339, 768, 1829, 272, 347, 18154, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 13803, 297, 488, 9, 339, 768, 1829, 272, 347, 1676, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1708, 1906, 12498, 297, 488, 9, 421, 199, 533, 10859, 12498, 9184, 3834, 8, 50, 385, 4590, 304, 272, 986, 421, 199, 533, 12705, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 536, 12, 1369, 12, 4137, 12, 4637, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 3248, 275, 4137, 267, 291, 14, 3710, 275, 4637, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 1155, 304, 267, 372, 843, 8, 288, 1233, 29, 1001, 63, 1155, 459, 2558, 3034, 995, 288, 536, 29, 1001, 63, 1155, 459, 2558, 985, 995, 288, 1369, 29, 1001, 63, 1155, 459, 1802, 995, 288, 4137, 29, 1001, 63, 1155, 459, 3248, 995, 288, 4637, 29, 1001, 63, 1155, 459, 3710, 995, 267, 776, 199, 199, 533, 799, 21523, 3694, 8, 50, 385, 4590, 304, 339, 768, 1829, 272, 347, 295, 21523, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 14668, 1588, 1304, 418, 339, 768, 1829, 272, 347, 295, 21523, 63, 1205, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 14668, 1588, 3694, 418, 339, 768, 1829, 272, 347, 1865, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1648, 1304, 297, 488, 9, 339, 768, 1829, 272, 347, 1865, 63, 1205, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1648, 3694, 297, 488, 9, 339, 768, 1829, 272, 347, 325, 2626, 27798, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 69, 2626, 27798, 297, 488, 9, 339, 768, 1829, 272, 347, 1343, 63, 602, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 928, 2506, 297, 488, 9, 339, 768, 1829, 272, 347, 1284, 63, 602, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 500, 2506, 297, 488, 9, 421, 199, 533, 18841, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 536, 12, 7585, 29, 403, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 354, 275, 536, 267, 291, 14, 13336, 275, 7585, 503, 942, 339, 768, 3744, 272, 347, 687, 63, 2343, 8, 1886, 12, 3341, 304, 267, 2203, 275, 843, 8, 2343, 459, 6815, 3034, 995, 3341, 459, 6815, 985, 1105, 267, 372, 2203, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 1155, 304, 267, 3336, 63, 513, 275, 2022, 63, 1155, 459, 6815, 5884, 1296, 418, 267, 340, 440, 3336, 63, 513, 26, 288, 372, 488, 398, 536, 275, 3336, 63, 513, 59, 16, 2733, 6815, 985, 418, 267, 1233, 275, 3336, 63, 513, 59, 16, 2733, 6815, 3034, 418, 267, 7585, 275, 942, 267, 367, 299, 315, 3336, 63, 513, 26, 288, 340, 299, 459, 6815, 985, 418, 1137, 536, 503, 299, 459, 6815, 3034, 418, 1137, 1233, 26, 355, 746, 3232, 44, 9674, 29388, 360, 5884, 769, 1990, 27253, 358, 288, 7585, 14, 740, 8, 5884, 14, 504, 63, 1001, 8, 80, 430, 398, 372, 843, 8, 600, 29, 600, 12, 536, 29, 354, 12, 7585, 29, 13336, 9, 421, 199, 318, 664, 63, 667, 559, 7999, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122, 8, 2302, 63, 269, 63, 505, 9, 272, 367, 2397, 315, 4565, 14, 3189, 26, 267, 1995, 10859, 12498, 8, 50, 385, 5142, 14, 504, 63, 2373, 8, 2373, 430, 421, 199, 318, 664, 63, 22354, 63, 28464, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122, 8, 2302, 63, 269, 63, 505, 9, 272, 367, 2397, 315, 4565, 14, 3189, 26, 267, 1995, 10859, 12498, 9184, 3834, 8, 50, 385, 5142, 14, 504, 63, 2373, 8, 2373, 430, 421, 199, 318, 664, 63, 28464, 63, 460, 63, 13336, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122 ]
[ 2197, 492, 2197, 199, 646, 2022, 199, 646, 4733, 2087, 199, 646, 900, 199, 646, 4145, 199, 504, 6170, 21550, 14, 5181, 14, 1404, 3885, 14, 1297, 492, 17023, 1311, 12039, 63, 11320, 63, 2711, 199, 504, 6170, 21550, 14, 5181, 14, 1404, 3885, 14, 992, 492, 799, 21523, 1538, 199, 504, 3537, 14, 1246, 14, 1208, 492, 9599, 1403, 4256, 199, 504, 3537, 14, 1490, 76, 1292, 14, 3924, 492, 3232, 44, 9674, 29388, 199, 199, 5255, 1311, 12039, 63, 1282, 2514, 14112, 275, 298, 497, 21523, 30055, 8792, 2, 421, 199, 533, 820, 385, 5142, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1305, 12, 4588, 12, 3341, 304, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 5334, 275, 4588, 267, 291, 14, 2343, 275, 3341, 339, 768, 3744, 272, 347, 687, 63, 2373, 8, 1886, 12, 2397, 304, 267, 1305, 275, 2397, 459, 344, 418, 267, 4588, 275, 2197, 14, 18531, 8, 521, 14, 23456, 8, 2373, 459, 5334, 63, 6751, 5156, 267, 359, 1317, 61, 275, 2397, 459, 1317, 418, 267, 3341, 275, 2022, 14, 3640, 8, 1317, 459, 585, 1105, 267, 372, 843, 8, 344, 12, 4588, 12, 3341, 9, 421, 199, 533, 820, 385, 4590, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 32291, 63, 2024, 304, 267, 291, 14, 13614, 63, 2024, 275, 32291, 63, 2024, 339, 768, 1829, 272, 347, 3341, 8, 277, 304, 267, 372, 291, 14, 13614, 63, 2024, 14, 2343, 421, 199, 533, 10859, 12498, 8, 50, 385, 4590, 304, 339, 768, 1829, 272, 347, 1233, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 600, 418, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 354, 418, 339, 768, 1829, 272, 347, 730, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 22354, 804, 418, 339, 768, 1829, 272, 347, 18896, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 13331, 297, 488, 9, 339, 768, 1829, 272, 347, 18154, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 13803, 297, 488, 9, 339, 768, 1829, 272, 347, 1676, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1708, 1906, 12498, 297, 488, 9, 421, 199, 533, 10859, 12498, 9184, 3834, 8, 50, 385, 4590, 304, 272, 986, 421, 199, 533, 12705, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 536, 12, 1369, 12, 4137, 12, 4637, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 3248, 275, 4137, 267, 291, 14, 3710, 275, 4637, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 1155, 304, 267, 372, 843, 8, 288, 1233, 29, 1001, 63, 1155, 459, 2558, 3034, 995, 288, 536, 29, 1001, 63, 1155, 459, 2558, 985, 995, 288, 1369, 29, 1001, 63, 1155, 459, 1802, 995, 288, 4137, 29, 1001, 63, 1155, 459, 3248, 995, 288, 4637, 29, 1001, 63, 1155, 459, 3710, 995, 267, 776, 199, 199, 533, 799, 21523, 3694, 8, 50, 385, 4590, 304, 339, 768, 1829, 272, 347, 295, 21523, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 14668, 1588, 1304, 418, 339, 768, 1829, 272, 347, 295, 21523, 63, 1205, 8, 277, 304, 267, 372, 291, 14, 2343, 459, 14668, 1588, 3694, 418, 339, 768, 1829, 272, 347, 1865, 63, 344, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1648, 1304, 297, 488, 9, 339, 768, 1829, 272, 347, 1865, 63, 1205, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 1648, 3694, 297, 488, 9, 339, 768, 1829, 272, 347, 325, 2626, 27798, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 69, 2626, 27798, 297, 488, 9, 339, 768, 1829, 272, 347, 1343, 63, 602, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 928, 2506, 297, 488, 9, 339, 768, 1829, 272, 347, 1284, 63, 602, 8, 277, 304, 267, 372, 291, 14, 2343, 14, 362, 360, 500, 2506, 297, 488, 9, 421, 199, 533, 18841, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 536, 12, 7585, 29, 403, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 354, 275, 536, 267, 291, 14, 13336, 275, 7585, 503, 942, 339, 768, 3744, 272, 347, 687, 63, 2343, 8, 1886, 12, 3341, 304, 267, 2203, 275, 843, 8, 2343, 459, 6815, 3034, 995, 3341, 459, 6815, 985, 1105, 267, 372, 2203, 339, 768, 3744, 272, 347, 687, 63, 1001, 8, 1886, 12, 2022, 63, 1155, 304, 267, 3336, 63, 513, 275, 2022, 63, 1155, 459, 6815, 5884, 1296, 418, 267, 340, 440, 3336, 63, 513, 26, 288, 372, 488, 398, 536, 275, 3336, 63, 513, 59, 16, 2733, 6815, 985, 418, 267, 1233, 275, 3336, 63, 513, 59, 16, 2733, 6815, 3034, 418, 267, 7585, 275, 942, 267, 367, 299, 315, 3336, 63, 513, 26, 288, 340, 299, 459, 6815, 985, 418, 1137, 536, 503, 299, 459, 6815, 3034, 418, 1137, 1233, 26, 355, 746, 3232, 44, 9674, 29388, 360, 5884, 769, 1990, 27253, 358, 288, 7585, 14, 740, 8, 5884, 14, 504, 63, 1001, 8, 80, 430, 398, 372, 843, 8, 600, 29, 600, 12, 536, 29, 354, 12, 7585, 29, 13336, 9, 421, 199, 318, 664, 63, 667, 559, 7999, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122, 8, 2302, 63, 269, 63, 505, 9, 272, 367, 2397, 315, 4565, 14, 3189, 26, 267, 1995, 10859, 12498, 8, 50, 385, 5142, 14, 504, 63, 2373, 8, 2373, 430, 421, 199, 318, 664, 63, 22354, 63, 28464, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122, 8, 2302, 63, 269, 63, 505, 9, 272, 367, 2397, 315, 4565, 14, 3189, 26, 267, 1995, 10859, 12498, 9184, 3834, 8, 50, 385, 5142, 14, 504, 63, 2373, 8, 2373, 430, 421, 199, 318, 664, 63, 28464, 63, 460, 63, 13336, 8, 2302, 63, 269, 63, 505, 304, 272, 4565, 275, 4733, 2087, 14, 1122, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dyoung418/tensorflow
tensorflow/contrib/session_bundle/exporter.py
35
12771
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Export a TensorFlow model. See: go/tf-exporter """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import re import six from google.protobuf.any_pb2 import Any from tensorflow.contrib.session_bundle import constants from tensorflow.contrib.session_bundle import gc from tensorflow.contrib.session_bundle import manifest_pb2 from tensorflow.core.framework import graph_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.platform import gfile from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training import saver as tf_saver from tensorflow.python.training import training_util from tensorflow.python.util import compat from tensorflow.python.util.deprecation import deprecated @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def gfile_copy_callback(files_to_copy, export_dir_path): """Callback to copy files using `gfile.Copy` to an export directory. This method is used as the default `assets_callback` in `Exporter.init` to copy assets from the `assets_collection`. It can also be invoked directly to copy additional supplementary files into the export directory (in which case it is not a callback). Args: files_to_copy: A dictionary that maps original file paths to desired basename in the export directory. export_dir_path: Directory to copy the files to. """ logging.info("Write assets into: %s using gfile_copy.", export_dir_path) gfile.MakeDirs(export_dir_path) for source_filepath, basename in files_to_copy.items(): new_path = os.path.join( compat.as_bytes(export_dir_path), compat.as_bytes(basename)) logging.info("Copying asset %s to path %s.", source_filepath, new_path) if gfile.Exists(new_path): # Guard against being restarted while copying assets, and the file # existing and being in an unknown state. # TODO(b/28676216): Do some file checks before deleting. logging.info("Removing file %s.", new_path) gfile.Remove(new_path) gfile.Copy(source_filepath, new_path) @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def regression_signature(input_tensor, output_tensor): """Creates a regression signature. Args: input_tensor: Tensor specifying the input to a graph. output_tensor: Tensor specifying the output of a graph. Returns: A Signature message. """ signature = manifest_pb2.Signature() signature.regression_signature.input.tensor_name = input_tensor.name signature.regression_signature.output.tensor_name = output_tensor.name return signature @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def classification_signature(input_tensor, classes_tensor=None, scores_tensor=None): """Creates a classification signature. Args: input_tensor: Tensor specifying the input to a graph. classes_tensor: Tensor specifying the output classes of a graph. scores_tensor: Tensor specifying the scores of the output classes. Returns: A Signature message. """ signature = manifest_pb2.Signature() signature.classification_signature.input.tensor_name = input_tensor.name if classes_tensor is not None: signature.classification_signature.classes.tensor_name = classes_tensor.name if scores_tensor is not None: signature.classification_signature.scores.tensor_name = scores_tensor.name return signature @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def generic_signature(name_tensor_map): """Creates a generic signature of name to Tensor name. Args: name_tensor_map: Map from logical name to Tensor. Returns: A Signature message. """ signature = manifest_pb2.Signature() for name, tensor in six.iteritems(name_tensor_map): signature.generic_signature.map[name].tensor_name = tensor.name return signature class Exporter(object): """Exporter helps package a TensorFlow model for serving. Args: saver: Saver object. """ def __init__(self, saver): # Makes a copy of the saver-def and disables garbage-collection, since the # exporter enforces garbage-collection independently. Specifically, since # the exporter performs atomic copies of the saver output, it is required # that garbage-collection via the underlying saver be disabled. saver_def = saver.as_saver_def() saver_def.ClearField("max_to_keep") self._saver = tf_saver.Saver(saver_def=saver_def) self._has_init = False self._assets_to_copy = {} @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def init(self, graph_def=None, init_op=None, clear_devices=False, default_graph_signature=None, named_graph_signatures=None, assets_collection=None, assets_callback=gfile_copy_callback): """Initialization. Args: graph_def: A GraphDef message of the graph to be used in inference. GraphDef of default graph is used when None. init_op: Op to be used in initialization. clear_devices: If device info of the graph should be cleared upon export. default_graph_signature: Default signature of the graph. named_graph_signatures: Map of named input/output signatures of the graph. assets_collection: A collection of constant asset filepath tensors. If set the assets will be exported into the asset directory. assets_callback: callback with two argument called during export with the list of files to copy and the asset path. Raises: RuntimeError: if init is called more than once. TypeError: if init_op is not an Operation or None. ValueError: if asset file path tensors are not non-empty constant string scalar tensors. """ # Avoid Dangerous default value [] if named_graph_signatures is None: named_graph_signatures = {} assets = [] if assets_collection: for asset_tensor in assets_collection: asset_filepath = self._file_path_value(asset_tensor) if not asset_filepath: raise ValueError("invalid asset filepath tensor %s" % asset_tensor) basename = os.path.basename(asset_filepath) assets.append((basename, asset_tensor)) self._assets_to_copy[asset_filepath] = basename if self._has_init: raise RuntimeError("init should be called only once") self._has_init = True if graph_def or clear_devices: copy = graph_pb2.GraphDef() if graph_def: copy.CopyFrom(graph_def) else: copy.CopyFrom(ops.get_default_graph().as_graph_def()) if clear_devices: for node in copy.node: node.device = "" graph_any_buf = Any() graph_any_buf.Pack(copy) ops.add_to_collection(constants.GRAPH_KEY, graph_any_buf) if init_op: if not isinstance(init_op, ops.Operation): raise TypeError("init_op needs to be an Operation: %s" % init_op) ops.add_to_collection(constants.INIT_OP_KEY, init_op) signatures_proto = manifest_pb2.Signatures() if default_graph_signature: signatures_proto.default_signature.CopyFrom(default_graph_signature) for signature_name, signature in six.iteritems(named_graph_signatures): signatures_proto.named_signatures[signature_name].CopyFrom(signature) signatures_any_buf = Any() signatures_any_buf.Pack(signatures_proto) ops.add_to_collection(constants.SIGNATURES_KEY, signatures_any_buf) for filename, tensor in assets: asset = manifest_pb2.AssetFile() asset.filename = filename asset.tensor_binding.tensor_name = tensor.name asset_any_buf = Any() asset_any_buf.Pack(asset) ops.add_to_collection(constants.ASSETS_KEY, asset_any_buf) self._assets_callback = assets_callback @deprecated("2017-06-30", "No longer supported. Switch to SavedModel immediately.") def export(self, export_dir_base, global_step_tensor, sess=None, exports_to_keep=None): """Exports the model. Args: export_dir_base: A string path to the base export dir. global_step_tensor: An Tensor or tensor name providing the global step counter to append to the export directory path and set in the manifest version. sess: A Session to use to save the parameters. exports_to_keep: a gc.Path filter function used to determine the set of exports to keep. If set to None, all versions will be kept. Returns: The string path to the exported directory. Raises: RuntimeError: if init is not called. RuntimeError: if the export would overwrite an existing directory. """ if not self._has_init: raise RuntimeError("init must be called first") # Export dir must not end with / or it will break exports to keep. Strip /. if export_dir_base.endswith("/"): export_dir_base = export_dir_base[:-1] global_step = training_util.global_step(sess, global_step_tensor) export_dir = os.path.join( compat.as_bytes(export_dir_base), compat.as_bytes(constants.VERSION_FORMAT_SPECIFIER % global_step)) # Prevent overwriting on existing exports which could lead to bad/corrupt # storage and loading of models. This is an important check that must be # done before any output files or directories are created. if gfile.Exists(export_dir): raise RuntimeError("Overwriting exports can cause corruption and are " "not allowed. Duplicate export dir: %s" % export_dir) # Output to a temporary directory which is atomically renamed to the final # directory when complete. tmp_export_dir = compat.as_text(export_dir) + "-tmp" gfile.MakeDirs(tmp_export_dir) self._saver.save(sess, os.path.join( compat.as_text(tmp_export_dir), compat.as_text(constants.EXPORT_BASE_NAME)), meta_graph_suffix=constants.EXPORT_SUFFIX_NAME) # Run the asset callback. if self._assets_callback and self._assets_to_copy: assets_dir = os.path.join( compat.as_bytes(tmp_export_dir), compat.as_bytes(constants.ASSETS_DIRECTORY)) gfile.MakeDirs(assets_dir) self._assets_callback(self._assets_to_copy, assets_dir) # TODO(b/27794910): Delete *checkpoint* file before rename. gfile.Rename(tmp_export_dir, export_dir) if exports_to_keep: # create a simple parser that pulls the export_version from the directory. def parser(path): if os.name == 'nt': match = re.match("^" + export_dir_base.replace('\\','/') + "/(\\d{8})$", path.path.replace('\\','/')) else: match = re.match("^" + export_dir_base + "/(\\d{8})$", path.path) if not match: return None return path._replace(export_version=int(match.group(1))) paths_to_delete = gc.negation(exports_to_keep) for p in paths_to_delete(gc.get_paths(export_dir_base, parser=parser)): gfile.DeleteRecursively(p.path) return export_dir def _file_path_value(self, path_tensor): """Returns the filepath value stored in constant `path_tensor`.""" if not isinstance(path_tensor, ops.Tensor): raise TypeError("tensor is not a Tensor") if path_tensor.op.type != "Const": raise TypeError("Only constants tensor are supported") if path_tensor.dtype != dtypes.string: raise TypeError("File paths should be string") str_value = path_tensor.op.get_attr("value").string_val if len(str_value) != 1: raise TypeError("Only scalar tensors are supported") return str_value[0]
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 11399, 282, 9134, 1402, 14, 199, 199, 9295, 26, 2621, 15, 3249, 13, 30305, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 646, 295, 199, 646, 3816, 199, 199, 504, 6233, 14, 7204, 14, 1629, 63, 3317, 18, 492, 6184, 199, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 5262, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 9486, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 7712, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 4857, 492, 3343, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 2833, 63, 21166, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6093, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1974, 492, 8434, 199, 504, 3228, 14, 1548, 14, 1974, 14, 15383, 492, 5906, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 26532, 63, 1574, 63, 3058, 8, 1725, 63, 475, 63, 1574, 12, 4843, 63, 694, 63, 515, 304, 523, 408, 2806, 370, 1331, 1584, 1808, 658, 30325, 14, 5116, 64, 370, 376, 4843, 2082, 14, 819, 961, 1083, 365, 1202, 465, 314, 849, 658, 12186, 63, 3058, 64, 315, 658, 30341, 14, 826, 64, 370, 523, 1331, 17202, 687, 314, 658, 12186, 63, 3627, 2313, 2779, 883, 2597, 506, 10302, 5370, 370, 523, 1331, 4722, 4973, 968, 695, 1584, 1901, 314, 4843, 2082, 334, 262, 1314, 1930, 523, 652, 365, 440, 282, 3233, 680, 819, 3033, 26, 272, 1584, 63, 475, 63, 1574, 26, 437, 2600, 626, 9033, 3379, 570, 3792, 370, 6387, 489, 9593, 315, 314, 4843, 2082, 14, 272, 4843, 63, 694, 63, 515, 26, 15191, 370, 1331, 314, 1584, 370, 14, 523, 408, 523, 2050, 14, 815, 480, 3534, 17202, 1901, 26, 450, 83, 1808, 26532, 63, 1574, 4765, 4843, 63, 694, 63, 515, 9, 523, 26532, 14, 5483, 17051, 8, 3790, 63, 694, 63, 515, 9, 523, 367, 1350, 63, 7218, 12, 9593, 315, 1584, 63, 475, 63, 1574, 14, 1744, 837, 272, 892, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 8434, 14, 305, 63, 2394, 8, 3790, 63, 694, 63, 515, 395, 8434, 14, 305, 63, 2394, 8, 4846, 430, 272, 2050, 14, 815, 480, 32596, 8977, 450, 83, 370, 931, 450, 83, 4765, 1350, 63, 7218, 12, 892, 63, 515, 9, 339, 340, 26532, 14, 7965, 8, 1222, 63, 515, 304, 489, 327, 12436, 1005, 6169, 3769, 32277, 1830, 16743, 17202, 12, 436, 314, 570, 489, 327, 3411, 436, 3769, 315, 376, 5809, 1174, 14, 489, 327, 3254, 8, 66, 15, 11125, 2114, 9669, 304, 4226, 2005, 570, 5920, 2544, 13794, 14, 489, 2050, 14, 815, 480, 23420, 570, 450, 83, 4765, 892, 63, 515, 9, 489, 26532, 14, 5587, 8, 1222, 63, 515, 9, 272, 26532, 14, 5116, 8, 1365, 63, 7218, 12, 892, 63, 515, 9, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 10864, 63, 5233, 8, 1210, 63, 3128, 12, 1072, 63, 3128, 304, 523, 408, 10607, 282, 10864, 4955, 14, 819, 3033, 26, 272, 1324, 63, 3128, 26, 5878, 9176, 314, 1324, 370, 282, 3343, 14, 272, 1072, 63, 3128, 26, 5878, 9176, 314, 1072, 402, 282, 3343, 14, 819, 1803, 26, 272, 437, 18603, 1245, 14, 523, 408, 523, 4955, 275, 7712, 63, 3317, 18, 14, 10014, 342, 523, 4955, 14, 12513, 63, 5233, 14, 1210, 14, 3128, 63, 354, 275, 1324, 63, 3128, 14, 354, 523, 4955, 14, 12513, 63, 5233, 14, 1199, 14, 3128, 63, 354, 275, 1072, 63, 3128, 14, 354, 523, 372, 4955, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 12505, 63, 5233, 8, 1210, 63, 3128, 12, 2490, 3992, 63, 3128, 29, 403, 12, 2490, 9342, 63, 3128, 29, 403, 304, 523, 408, 10607, 282, 12505, 4955, 14, 819, 3033, 26, 272, 1324, 63, 3128, 26, 5878, 9176, 314, 1324, 370, 282, 3343, 14, 272, 3992, 63, 3128, 26, 5878, 9176, 314, 1072, 3992, 402, 282, 3343, 14, 272, 9342, 63, 3128, 26, 5878, 9176, 314, 9342, 402, 314, 1072, 3992, 14, 819, 1803, 26, 272, 437, 18603, 1245, 14, 523, 408, 523, 4955, 275, 7712, 63, 3317, 18, 14, 10014, 342, 523, 4955, 14, 14368, 63, 5233, 14, 1210, 14, 3128, 63, 354, 275, 1324, 63, 3128, 14, 354, 523, 340, 3992, 63, 3128, 365, 440, 488, 26, 272, 4955, 14, 14368, 63, 5233, 14, 2888, 14, 3128, 63, 354, 275, 3992, 63, 3128, 14, 354, 523, 340, 9342, 63, 3128, 365, 440, 488, 26, 272, 4955, 14, 14368, 63, 5233, 14, 7107, 14, 3128, 63, 354, 275, 9342, 63, 3128, 14, 354, 523, 372, 4955, 421, 199 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 11399, 282, 9134, 1402, 14, 199, 199, 9295, 26, 2621, 15, 3249, 13, 30305, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 646, 295, 199, 646, 3816, 199, 199, 504, 6233, 14, 7204, 14, 1629, 63, 3317, 18, 492, 6184, 199, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 5262, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 9486, 199, 504, 3228, 14, 2828, 14, 1730, 63, 6469, 492, 7712, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 4857, 492, 3343, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 2833, 63, 21166, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6093, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1974, 492, 8434, 199, 504, 3228, 14, 1548, 14, 1974, 14, 15383, 492, 5906, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 26532, 63, 1574, 63, 3058, 8, 1725, 63, 475, 63, 1574, 12, 4843, 63, 694, 63, 515, 304, 523, 408, 2806, 370, 1331, 1584, 1808, 658, 30325, 14, 5116, 64, 370, 376, 4843, 2082, 14, 819, 961, 1083, 365, 1202, 465, 314, 849, 658, 12186, 63, 3058, 64, 315, 658, 30341, 14, 826, 64, 370, 523, 1331, 17202, 687, 314, 658, 12186, 63, 3627, 2313, 2779, 883, 2597, 506, 10302, 5370, 370, 523, 1331, 4722, 4973, 968, 695, 1584, 1901, 314, 4843, 2082, 334, 262, 1314, 1930, 523, 652, 365, 440, 282, 3233, 680, 819, 3033, 26, 272, 1584, 63, 475, 63, 1574, 26, 437, 2600, 626, 9033, 3379, 570, 3792, 370, 6387, 489, 9593, 315, 314, 4843, 2082, 14, 272, 4843, 63, 694, 63, 515, 26, 15191, 370, 1331, 314, 1584, 370, 14, 523, 408, 523, 2050, 14, 815, 480, 3534, 17202, 1901, 26, 450, 83, 1808, 26532, 63, 1574, 4765, 4843, 63, 694, 63, 515, 9, 523, 26532, 14, 5483, 17051, 8, 3790, 63, 694, 63, 515, 9, 523, 367, 1350, 63, 7218, 12, 9593, 315, 1584, 63, 475, 63, 1574, 14, 1744, 837, 272, 892, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 8434, 14, 305, 63, 2394, 8, 3790, 63, 694, 63, 515, 395, 8434, 14, 305, 63, 2394, 8, 4846, 430, 272, 2050, 14, 815, 480, 32596, 8977, 450, 83, 370, 931, 450, 83, 4765, 1350, 63, 7218, 12, 892, 63, 515, 9, 339, 340, 26532, 14, 7965, 8, 1222, 63, 515, 304, 489, 327, 12436, 1005, 6169, 3769, 32277, 1830, 16743, 17202, 12, 436, 314, 570, 489, 327, 3411, 436, 3769, 315, 376, 5809, 1174, 14, 489, 327, 3254, 8, 66, 15, 11125, 2114, 9669, 304, 4226, 2005, 570, 5920, 2544, 13794, 14, 489, 2050, 14, 815, 480, 23420, 570, 450, 83, 4765, 892, 63, 515, 9, 489, 26532, 14, 5587, 8, 1222, 63, 515, 9, 272, 26532, 14, 5116, 8, 1365, 63, 7218, 12, 892, 63, 515, 9, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 10864, 63, 5233, 8, 1210, 63, 3128, 12, 1072, 63, 3128, 304, 523, 408, 10607, 282, 10864, 4955, 14, 819, 3033, 26, 272, 1324, 63, 3128, 26, 5878, 9176, 314, 1324, 370, 282, 3343, 14, 272, 1072, 63, 3128, 26, 5878, 9176, 314, 1072, 402, 282, 3343, 14, 819, 1803, 26, 272, 437, 18603, 1245, 14, 523, 408, 523, 4955, 275, 7712, 63, 3317, 18, 14, 10014, 342, 523, 4955, 14, 12513, 63, 5233, 14, 1210, 14, 3128, 63, 354, 275, 1324, 63, 3128, 14, 354, 523, 4955, 14, 12513, 63, 5233, 14, 1199, 14, 3128, 63, 354, 275, 1072, 63, 3128, 14, 354, 523, 372, 4955, 421, 199, 32, 6667, 480, 10680, 13, 1690, 13, 1216, 401, 288, 298, 1944, 8088, 3748, 14, 17711, 370, 29026, 1685, 9939, 2685, 199, 318, 12505, 63, 5233, 8, 1210, 63, 3128, 12, 2490, 3992, 63, 3128, 29, 403, 12, 2490, 9342, 63, 3128, 29, 403, 304, 523, 408, 10607, 282, 12505, 4955, 14, 819, 3033, 26, 272, 1324, 63, 3128, 26, 5878, 9176, 314, 1324, 370, 282, 3343, 14, 272, 3992, 63, 3128, 26, 5878, 9176, 314, 1072, 3992, 402, 282, 3343, 14, 272, 9342, 63, 3128, 26, 5878, 9176, 314, 9342, 402, 314, 1072, 3992, 14, 819, 1803, 26, 272, 437, 18603, 1245, 14, 523, 408, 523, 4955, 275, 7712, 63, 3317, 18, 14, 10014, 342, 523, 4955, 14, 14368, 63, 5233, 14, 1210, 14, 3128, 63, 354, 275, 1324, 63, 3128, 14, 354, 523, 340, 3992, 63, 3128, 365, 440, 488, 26, 272, 4955, 14, 14368, 63, 5233, 14, 2888, 14, 3128, 63, 354, 275, 3992, 63, 3128, 14, 354, 523, 340, 9342, 63, 3128, 365, 440, 488, 26, 272, 4955, 14, 14368, 63, 5233, 14, 7107, 14, 3128, 63, 354, 275, 9342, 63, 3128, 14, 354, 523, 372, 4955, 421, 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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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 ]
leesavide/pythonista-docs
Documentation/matplotlib/examples/old_animation/histogram_tkagg.py
3
1847
""" This example shows how to use a path patch to draw a bunch of rectangles for an animated histogram """ import numpy as np import matplotlib matplotlib.use('TkAgg') # do this before importing pylab import matplotlib.pyplot as plt import matplotlib.patches as patches import matplotlib.path as path fig, ax = plt.subplots() # histogram our data with numpy data = np.random.randn(1000) n, bins = np.histogram(data, 100) # get the corners of the rectangles for the histogram left = np.array(bins[:-1]) right = np.array(bins[1:]) bottom = np.zeros(len(left)) top = bottom + n nrects = len(left) # here comes the tricky part -- we have to set up the vertex and path # codes arrays using moveto, lineto and closepoly # for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the # CLOSEPOLY; the vert for the closepoly is ignored but we still need # it to keep the codes aligned with the vertices nverts = nrects*(1+3+1) verts = np.zeros((nverts, 2)) codes = np.ones(nverts, int) * path.Path.LINETO codes[0::5] = path.Path.MOVETO codes[4::5] = path.Path.CLOSEPOLY verts[0::5,0] = left verts[0::5,1] = bottom verts[1::5,0] = left verts[1::5,1] = top verts[2::5,0] = right verts[2::5,1] = top verts[3::5,0] = right verts[3::5,1] = bottom barpath = path.Path(verts, codes) patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5) ax.add_patch(patch) ax.set_xlim(left[0], right[-1]) ax.set_ylim(bottom.min(), top.max()) def animate(): if animate.cnt>=100: return animate.cnt += 1 # simulate new data coming in data = np.random.randn(1000) n, bins = np.histogram(data, 100) top = bottom + n verts[1::5,1] = top verts[2::5,1] = top fig.canvas.draw() fig.canvas.manager.window.after(100, animate) animate.cnt = 0 fig.canvas.manager.window.after(100, animate) plt.show()
apache-2.0
[ 624, 199, 2765, 2893, 13703, 4212, 370, 675, 282, 931, 3371, 370, 5954, 282, 22219, 402, 199, 1201, 13162, 367, 376, 376, 12754, 15379, 199, 624, 199, 646, 2680, 465, 980, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 327, 886, 642, 2544, 16306, 19199, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 8027, 14, 11350, 465, 12385, 199, 646, 8027, 14, 515, 465, 931, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 342, 199, 199, 3, 15379, 4154, 666, 543, 2680, 199, 576, 275, 980, 14, 2355, 14, 10843, 8, 5279, 9, 199, 78, 12, 13341, 275, 980, 14, 14805, 8, 576, 12, 2948, 9, 199, 199, 3, 664, 314, 31657, 402, 314, 8626, 13162, 367, 314, 15379, 199, 3039, 275, 980, 14, 1144, 8, 11329, 4439, 17, 566, 199, 1019, 275, 980, 14, 1144, 8, 11329, 59, 17, 5728, 199, 8305, 275, 980, 14, 4250, 8, 552, 8, 3039, 430, 199, 2119, 275, 9048, 435, 302, 199, 78, 23411, 275, 822, 8, 3039, 9, 199, 199, 3, 2348, 12477, 314, 32553, 1777, 1553, 781, 1172, 370, 663, 1536, 314, 12759, 436, 931, 199, 3, 9479, 6572, 1808, 26524, 16876, 12, 7403, 16876, 436, 4002, 6023, 199, 199, 3, 367, 1924, 8626, 26, 413, 367, 314, 10362, 54, 26614, 12, 650, 367, 314, 491, 11367, 47, 12, 413, 367, 314, 199, 3, 445, 1484, 899, 19869, 27, 314, 809, 84, 367, 314, 4002, 6023, 365, 5525, 1325, 781, 5139, 1929, 199, 3, 652, 370, 4215, 314, 9479, 22569, 543, 314, 14971, 199, 78, 21505, 275, 302, 23411, 5830, 17, 11, 19, 11, 17, 9, 199, 21505, 275, 980, 14, 4250, 1332, 78, 21505, 12, 499, 430, 199, 6021, 275, 980, 14, 4548, 8, 78, 21505, 12, 1109, 9, 627, 931, 14, 2042, 14, 6143, 26614, 199, 6021, 59, 16, 447, 21, 61, 275, 931, 14, 2042, 14, 24321, 26614, 199, 6021, 59, 20, 447, 21, 61, 275, 931, 14, 2042, 14, 18219, 19869, 199, 21505, 59, 16, 447, 21, 12, 16, 61, 275, 3602, 199, 21505, 59, 16, 447, 21, 12, 17, 61, 275, 9048, 199, 21505, 59, 17, 447, 21, 12, 16, 61, 275, 3602, 199, 21505, 59, 17, 447, 21, 12, 17, 61, 275, 2746, 199, 21505, 59, 18, 447, 21, 12, 16, 61, 275, 2451, 199, 21505, 59, 18, 447, 21, 12, 17, 61, 275, 2746, 199, 21505, 59, 19, 447, 21, 12, 16, 61, 275, 2451, 199, 21505, 59, 19, 447, 21, 12, 17, 61, 275, 9048, 199, 199, 1700, 515, 275, 931, 14, 2042, 8, 21505, 12, 9479, 9, 199, 2068, 275, 12385, 14, 2042, 11173, 8, 1700, 515, 12, 8870, 2326, 534, 7731, 297, 6275, 2326, 534, 14514, 297, 5131, 29, 16, 14, 21, 9, 199, 1219, 14, 525, 63, 2068, 8, 2068, 9, 199, 199, 1219, 14, 409, 63, 18512, 8, 3039, 59, 16, 467, 2451, 1988, 17, 566, 199, 1219, 14, 409, 63, 18123, 8, 8305, 14, 827, 1062, 2746, 14, 988, 1012, 199, 199, 318, 376, 6897, 837, 272, 340, 376, 6897, 14, 6507, 8119, 1960, 26, 267, 372, 339, 376, 6897, 14, 6507, 847, 413, 272, 327, 20577, 892, 666, 17262, 315, 272, 666, 275, 980, 14, 2355, 14, 10843, 8, 5279, 9, 272, 302, 12, 13341, 275, 980, 14, 14805, 8, 576, 12, 2948, 9, 272, 2746, 275, 9048, 435, 302, 272, 809, 1086, 59, 17, 447, 21, 12, 17, 61, 275, 2746, 272, 809, 1086, 59, 18, 447, 21, 12, 17, 61, 275, 2746, 272, 6085, 14, 7682, 14, 5485, 342, 272, 6085, 14, 7682, 14, 2609, 14, 3806, 14, 4399, 8, 1960, 12, 376, 6897, 9, 199, 27062, 14, 6507, 275, 378, 199, 592, 14, 7682, 14, 2609, 14, 3806, 14, 4399, 8, 1960, 12, 376, 6897, 9, 199, 6003, 14, 2384, 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 ]
[ 199, 2765, 2893, 13703, 4212, 370, 675, 282, 931, 3371, 370, 5954, 282, 22219, 402, 199, 1201, 13162, 367, 376, 376, 12754, 15379, 199, 624, 199, 646, 2680, 465, 980, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 327, 886, 642, 2544, 16306, 19199, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 8027, 14, 11350, 465, 12385, 199, 646, 8027, 14, 515, 465, 931, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 342, 199, 199, 3, 15379, 4154, 666, 543, 2680, 199, 576, 275, 980, 14, 2355, 14, 10843, 8, 5279, 9, 199, 78, 12, 13341, 275, 980, 14, 14805, 8, 576, 12, 2948, 9, 199, 199, 3, 664, 314, 31657, 402, 314, 8626, 13162, 367, 314, 15379, 199, 3039, 275, 980, 14, 1144, 8, 11329, 4439, 17, 566, 199, 1019, 275, 980, 14, 1144, 8, 11329, 59, 17, 5728, 199, 8305, 275, 980, 14, 4250, 8, 552, 8, 3039, 430, 199, 2119, 275, 9048, 435, 302, 199, 78, 23411, 275, 822, 8, 3039, 9, 199, 199, 3, 2348, 12477, 314, 32553, 1777, 1553, 781, 1172, 370, 663, 1536, 314, 12759, 436, 931, 199, 3, 9479, 6572, 1808, 26524, 16876, 12, 7403, 16876, 436, 4002, 6023, 199, 199, 3, 367, 1924, 8626, 26, 413, 367, 314, 10362, 54, 26614, 12, 650, 367, 314, 491, 11367, 47, 12, 413, 367, 314, 199, 3, 445, 1484, 899, 19869, 27, 314, 809, 84, 367, 314, 4002, 6023, 365, 5525, 1325, 781, 5139, 1929, 199, 3, 652, 370, 4215, 314, 9479, 22569, 543, 314, 14971, 199, 78, 21505, 275, 302, 23411, 5830, 17, 11, 19, 11, 17, 9, 199, 21505, 275, 980, 14, 4250, 1332, 78, 21505, 12, 499, 430, 199, 6021, 275, 980, 14, 4548, 8, 78, 21505, 12, 1109, 9, 627, 931, 14, 2042, 14, 6143, 26614, 199, 6021, 59, 16, 447, 21, 61, 275, 931, 14, 2042, 14, 24321, 26614, 199, 6021, 59, 20, 447, 21, 61, 275, 931, 14, 2042, 14, 18219, 19869, 199, 21505, 59, 16, 447, 21, 12, 16, 61, 275, 3602, 199, 21505, 59, 16, 447, 21, 12, 17, 61, 275, 9048, 199, 21505, 59, 17, 447, 21, 12, 16, 61, 275, 3602, 199, 21505, 59, 17, 447, 21, 12, 17, 61, 275, 2746, 199, 21505, 59, 18, 447, 21, 12, 16, 61, 275, 2451, 199, 21505, 59, 18, 447, 21, 12, 17, 61, 275, 2746, 199, 21505, 59, 19, 447, 21, 12, 16, 61, 275, 2451, 199, 21505, 59, 19, 447, 21, 12, 17, 61, 275, 9048, 199, 199, 1700, 515, 275, 931, 14, 2042, 8, 21505, 12, 9479, 9, 199, 2068, 275, 12385, 14, 2042, 11173, 8, 1700, 515, 12, 8870, 2326, 534, 7731, 297, 6275, 2326, 534, 14514, 297, 5131, 29, 16, 14, 21, 9, 199, 1219, 14, 525, 63, 2068, 8, 2068, 9, 199, 199, 1219, 14, 409, 63, 18512, 8, 3039, 59, 16, 467, 2451, 1988, 17, 566, 199, 1219, 14, 409, 63, 18123, 8, 8305, 14, 827, 1062, 2746, 14, 988, 1012, 199, 199, 318, 376, 6897, 837, 272, 340, 376, 6897, 14, 6507, 8119, 1960, 26, 267, 372, 339, 376, 6897, 14, 6507, 847, 413, 272, 327, 20577, 892, 666, 17262, 315, 272, 666, 275, 980, 14, 2355, 14, 10843, 8, 5279, 9, 272, 302, 12, 13341, 275, 980, 14, 14805, 8, 576, 12, 2948, 9, 272, 2746, 275, 9048, 435, 302, 272, 809, 1086, 59, 17, 447, 21, 12, 17, 61, 275, 2746, 272, 809, 1086, 59, 18, 447, 21, 12, 17, 61, 275, 2746, 272, 6085, 14, 7682, 14, 5485, 342, 272, 6085, 14, 7682, 14, 2609, 14, 3806, 14, 4399, 8, 1960, 12, 376, 6897, 9, 199, 27062, 14, 6507, 275, 378, 199, 592, 14, 7682, 14, 2609, 14, 3806, 14, 4399, 8, 1960, 12, 376, 6897, 9, 199, 6003, 14, 2384, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RodrigoDev/Django-todo
todo/settings.py
1
2707
""" Django settings for todo project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'u%h0i!)2=b8h5!c_vh#n0(wpgl^i^8(*yzp^&jssckq7vj%)to' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['localhost'] # Application definition INSTALLED_APPS = ( 'django_admin_bootstrapped.bootstrap3', 'django_admin_bootstrapped', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'core', 'accounts', 'bootstrap3', 'inplaceeditform', 'debug_toolbar', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'todo.urls' WSGI_APPLICATION = 'todo.wsgi.application' SSO_URL = 'http://localhost:8021' SSO_APP_KEY = '54b80e13a72bd33d834d3d04' SSO_APP_SECRET = 'AI16496WSHCOyibdext3eeDA4RnMUzS52wm52RfdXnUU6OKD/yyeq' # Database # https://docs.djangoproject.com/en/1.7/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.to-do'), } } TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.request', ) CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } # Internationalization # https://docs.djangoproject.com/en/1.7/topics/i18n/ LANGUAGE_CODE = 'pt-BR' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.7/howto/static-files/ STATIC_URL = '/static/' AUTHENTICATION_BACKENDS = ('accounts.auth.SSOModelBackend',)
mit
[ 624, 199, 9323, 2202, 367, 11386, 2199, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 283, 85, 5, 72, 16, 73, 21866, 18, 29, 66, 24, 72, 21, 1, 67, 63, 20369, 3, 78, 16, 8, 14649, 3528, 62, 73, 62, 24, 2031, 19873, 80, 62, 6, 74, 385, 346, 81, 23, 86, 74, 5, 9, 475, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 7433, 63, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 788, 5967, 418, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 63, 2113, 63, 11146, 1915, 14, 11146, 19, 297, 272, 283, 1176, 63, 2113, 63, 11146, 1915, 297, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 1018, 297, 272, 283, 8370, 297, 272, 283, 11146, 19, 297, 272, 283, 15008, 3773, 964, 297, 272, 283, 1757, 63, 13951, 297, 199, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 11396, 14, 3603, 7, 199, 199, 16828, 63, 24051, 275, 283, 11396, 14, 6508, 14, 3578, 7, 199, 199, 2300, 47, 63, 2632, 275, 283, 1014, 921, 5967, 26, 11366, 17, 7, 199, 2300, 47, 63, 7121, 63, 3078, 275, 283, 1477, 66, 1257, 69, 969, 65, 2819, 3691, 1153, 68, 31230, 68, 19, 68, 966, 7, 199, 2300, 47, 63, 7121, 63, 12961, 275, 283, 7730, 8982, 2534, 55, 3234, 1439, 89, 1892, 271, 400, 19, 1024, 8980, 20, 50, 78, 45, 53, 90, 51, 2528, 16240, 2528, 50, 2592, 56, 78, 4622, 22, 3593, 36, 15, 7566, 4077, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 1121, 15, 1751, 12645, 17439, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 475, 13, 1117, 659, 272, 789, 199, 93, 199, 199, 7433, 63, 9059, 63, 10494, 4149, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 272, 283, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1069, 297, 199, 9, 199, 199, 3263, 1244, 654, 275, 469, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 32567, 14, 14169, 5245, 4437, 297, 267, 283, 16575, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 26, 6094, 845, 297, 272, 789, 199, 93, 421, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 541, 13, 7184, 7, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 29599, 63, 28988, 275, 661, 8370, 14, 1178, 14, 2300, 47, 1685, 8447, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9323, 2202, 367, 11386, 2199, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 283, 85, 5, 72, 16, 73, 21866, 18, 29, 66, 24, 72, 21, 1, 67, 63, 20369, 3, 78, 16, 8, 14649, 3528, 62, 73, 62, 24, 2031, 19873, 80, 62, 6, 74, 385, 346, 81, 23, 86, 74, 5, 9, 475, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 7433, 63, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 788, 5967, 418, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 63, 2113, 63, 11146, 1915, 14, 11146, 19, 297, 272, 283, 1176, 63, 2113, 63, 11146, 1915, 297, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 1018, 297, 272, 283, 8370, 297, 272, 283, 11146, 19, 297, 272, 283, 15008, 3773, 964, 297, 272, 283, 1757, 63, 13951, 297, 199, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 11396, 14, 3603, 7, 199, 199, 16828, 63, 24051, 275, 283, 11396, 14, 6508, 14, 3578, 7, 199, 199, 2300, 47, 63, 2632, 275, 283, 1014, 921, 5967, 26, 11366, 17, 7, 199, 2300, 47, 63, 7121, 63, 3078, 275, 283, 1477, 66, 1257, 69, 969, 65, 2819, 3691, 1153, 68, 31230, 68, 19, 68, 966, 7, 199, 2300, 47, 63, 7121, 63, 12961, 275, 283, 7730, 8982, 2534, 55, 3234, 1439, 89, 1892, 271, 400, 19, 1024, 8980, 20, 50, 78, 45, 53, 90, 51, 2528, 16240, 2528, 50, 2592, 56, 78, 4622, 22, 3593, 36, 15, 7566, 4077, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 1121, 15, 1751, 12645, 17439, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 475, 13, 1117, 659, 272, 789, 199, 93, 199, 199, 7433, 63, 9059, 63, 10494, 4149, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 272, 283, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1069, 297, 199, 9, 199, 199, 3263, 1244, 654, 275, 469, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 32567, 14, 14169, 5245, 4437, 297, 267, 283, 16575, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 26, 6094, 845, 297, 272, 789, 199, 93, 421, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 541, 13, 7184, 7, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 23, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 29599, 63, 28988, 275, 661, 8370, 14, 1178, 14, 2300, 47, 1685, 8447, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
dkarakats/edx-platform
lms/envs/sauce.py
116
2389
""" This config file extends the test environment configuration so that we can run the lettuce acceptance tests on SauceLabs. """ # We intentionally define lots of variables that aren't used, and # want to import all variables from base settings files # pylint: disable=wildcard-import, unused-wildcard-import from selenium.webdriver.common.desired_capabilities import DesiredCapabilities import os PORTS = [ 2000, 2001, 2020, 2109, 2222, 2310, 3000, 3001, 3030, 3210, 3333, 4000, 4001, 4040, 4321, 4502, 4503, 5050, 5555, 5432, 6060, 6666, 6543, 7000, 7070, 7774, 7777, 8003, 8031, 8080, 8081, 8765, 8888, 9080, 9090, 9876, 9999, 49221, 55001 ] DESIRED_CAPABILITIES = { 'chrome': DesiredCapabilities.CHROME, 'internetexplorer': DesiredCapabilities.INTERNETEXPLORER, 'firefox': DesiredCapabilities.FIREFOX, 'opera': DesiredCapabilities.OPERA, 'iphone': DesiredCapabilities.IPHONE, 'ipad': DesiredCapabilities.IPAD, 'safari': DesiredCapabilities.SAFARI, 'android': DesiredCapabilities.ANDROID } # All keys must be URL and JSON encodable # PLATFORM-BROWSER-VERSION_NUM-DEVICE ALL_CONFIG = { 'Linux-chrome--': ['Linux', 'chrome', '', ''], 'Windows 8-chrome--': ['Windows 8', 'chrome', '', ''], 'Windows 7-chrome--': ['Windows 7', 'chrome', '', ''], 'Windows XP-chrome--': ['Windows XP', 'chrome', '', ''], 'OS X 10.8-chrome--': ['OS X 10.8', 'chrome', '', ''], 'OS X 10.6-chrome--': ['OS X 10.6', 'chrome', '', ''], 'Linux-firefox-23-': ['Linux', 'firefox', '23', ''], 'Windows 8-firefox-23-': ['Windows 8', 'firefox', '23', ''], 'Windows 7-firefox-23-': ['Windows 7', 'firefox', '23', ''], 'Windows XP-firefox-23-': ['Windows XP', 'firefox', '23', ''], 'OS X 10.8-safari-6-': ['OS X 10.8', 'safari', '6', ''], 'Windows 8-internetexplorer-10-': ['Windows 8', 'internetexplorer', '10', ''], } SAUCE_INFO = ALL_CONFIG.get(os.environ.get('SAUCE_INFO', 'Linux-chrome--')) # Information needed to utilize Sauce Labs. SAUCE = { 'USERNAME': os.environ.get('SAUCE_USER_NAME'), 'ACCESS_ID': os.environ.get('SAUCE_API_KEY'), 'PLATFORM': SAUCE_INFO[0], 'BROWSER': DESIRED_CAPABILITIES.get(SAUCE_INFO[1]), 'VERSION': SAUCE_INFO[2], 'DEVICE': SAUCE_INFO[3], 'SESSION': 'Jenkins Acceptance Tests', 'BUILD': os.environ.get('BUILD_DISPLAY_NAME', 'LETTUCE TESTS'), }
agpl-3.0
[ 624, 199, 2765, 1101, 570, 16879, 314, 511, 3734, 2897, 199, 1152, 626, 781, 883, 1255, 314, 4691, 84, 3683, 4729, 554, 2295, 641, 428, 65, 3683, 44, 2101, 14, 199, 624, 199, 199, 3, 2136, 32005, 5627, 24213, 402, 2860, 626, 10621, 1133, 1202, 12, 436, 199, 3, 2934, 370, 492, 1006, 2860, 687, 1300, 2202, 1584, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 12, 9563, 13, 16692, 13, 646, 199, 199, 504, 19481, 14, 17946, 14, 2330, 14, 16035, 63, 10732, 492, 1487, 5381, 17006, 199, 646, 747, 199, 199, 3657, 51, 275, 359, 272, 12293, 12, 12521, 12, 25455, 12, 499, 6996, 12, 499, 9485, 12, 6546, 709, 12, 29664, 12, 650, 4587, 12, 272, 4233, 1216, 12, 4337, 709, 12, 650, 11769, 12, 31092, 12, 841, 4587, 12, 7901, 16, 12, 841, 12638, 12, 10416, 996, 12, 841, 15773, 12, 272, 5238, 1400, 12, 959, 15722, 12, 959, 10657, 12, 1227, 18857, 12, 1227, 11829, 12, 1227, 20103, 12, 1520, 1493, 12, 1520, 19235, 12, 8375, 1342, 12, 272, 8375, 1138, 12, 1695, 8262, 12, 5939, 2192, 12, 30220, 12, 5939, 2835, 12, 10513, 2182, 12, 10523, 1299, 12, 272, 9137, 1257, 12, 1749, 18526, 12, 1749, 14690, 12, 221, 5008, 12, 12260, 11564, 12, 12766, 4587, 199, 61, 199, 199, 4448, 10322, 63, 8549, 21545, 19144, 275, 469, 272, 283, 9887, 356, 1487, 5381, 17006, 14, 1244, 31364, 12, 272, 283, 1058, 685, 3858, 80, 22732, 356, 1487, 5381, 17006, 14, 3843, 7278, 1438, 2749, 726, 540, 12, 272, 283, 15394, 356, 1487, 5381, 17006, 14, 1976, 907, 3230, 56, 12, 272, 283, 2262, 65, 356, 1487, 5381, 17006, 14, 15598, 33, 12, 272, 283, 28303, 356, 1487, 5381, 17006, 14, 1772, 40, 4817, 12, 272, 283, 711, 350, 356, 1487, 5381, 17006, 14, 1772, 1554, 12, 272, 283, 2231, 70, 759, 356, 1487, 5381, 17006, 14, 4251, 38, 689, 41, 12, 272, 283, 6238, 356, 1487, 5381, 17006, 14, 25658, 199, 93, 199, 199, 3, 2900, 2883, 1471, 506, 2851, 436, 4840, 655, 7889, 461, 199, 3, 21966, 13, 31956, 3279, 13, 4612, 63, 7125, 13, 10555, 199, 1761, 63, 5569, 275, 469, 272, 283, 14091, 13, 9887, 306, 356, 788, 14091, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1695, 13, 9887, 306, 356, 788, 8647, 1695, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1520, 13, 9887, 306, 356, 788, 8647, 1520, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1323, 48, 13, 9887, 306, 356, 788, 8647, 1323, 48, 297, 283, 9887, 297, 3260, 28175, 272, 283, 3100, 1323, 1616, 14, 24, 13, 9887, 306, 356, 788, 3100, 1323, 1616, 14, 24, 297, 283, 9887, 297, 3260, 28175, 272, 283, 3100, 1323, 1616, 14, 22, 13, 9887, 306, 356, 788, 3100, 1323, 1616, 14, 22, 297, 283, 9887, 297, 3260, 28175, 339, 283, 14091, 13, 15394, 13, 1789, 13, 356, 788, 14091, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1695, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1695, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1520, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1520, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1323, 48, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1323, 48, 297, 283, 15394, 297, 283, 1789, 297, 28175, 339, 283, 3100, 1323, 1616, 14, 24, 13, 2231, 70, 759, 13, 22, 13, 356, 788, 3100, 1323, 1616, 14, 24, 297, 283, 2231, 70, 759, 297, 283, 22, 297, 28175, 339, 283, 8647, 1695, 13, 1058, 685, 3858, 80, 22732, 13, 709, 13, 356, 788, 8647, 1695, 297, 283, 1058, 685, 3858, 80, 22732, 297, 283, 709, 297, 28175, 199, 93, 199, 199, 4251, 53, 2089, 63, 4531, 275, 11727, 63, 5569, 14, 362, 8, 736, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 4531, 297, 283, 14091, 13, 9887, 306, 1333, 199, 199, 3, 17064, 4346, 370, 7678, 13559, 428, 65, 3683, 491, 2101, 14, 199, 4251, 53, 2089, 275, 469, 272, 283, 11958, 356, 747, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 3791, 63, 2339, 659, 272, 283, 11074, 63, 998, 356, 747, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 3735, 63, 3078, 659, 272, 283, 17805, 356, 428, 9331, 2089, 63, 4531, 59, 16, 467, 272, 283, 31956, 3279, 356, 11758, 10322, 63, 8549, 21545, 19144, 14, 362, 8, 4251, 53, 2089, 63, 4531, 59, 17, 2522, 272, 283, 4612, 356, 428, 9331, 2089, 63, 4531, 59, 18, 467, 272, 283, 10555, 356, 428, 9331, 2089, 63, 4531, 59, 19, 467, 272, 283, 12763, 356, 283, 42, 14758, 15506, 554, 6496, 297, 272, 283, 8248, 356, 747, 14, 2314, 14, 362, 360, 8248, 63, 20993, 63, 2339, 297, 283, 44, 775, 21364, 2089, 7393, 51, 659, 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 ]
[ 199, 2765, 1101, 570, 16879, 314, 511, 3734, 2897, 199, 1152, 626, 781, 883, 1255, 314, 4691, 84, 3683, 4729, 554, 2295, 641, 428, 65, 3683, 44, 2101, 14, 199, 624, 199, 199, 3, 2136, 32005, 5627, 24213, 402, 2860, 626, 10621, 1133, 1202, 12, 436, 199, 3, 2934, 370, 492, 1006, 2860, 687, 1300, 2202, 1584, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 12, 9563, 13, 16692, 13, 646, 199, 199, 504, 19481, 14, 17946, 14, 2330, 14, 16035, 63, 10732, 492, 1487, 5381, 17006, 199, 646, 747, 199, 199, 3657, 51, 275, 359, 272, 12293, 12, 12521, 12, 25455, 12, 499, 6996, 12, 499, 9485, 12, 6546, 709, 12, 29664, 12, 650, 4587, 12, 272, 4233, 1216, 12, 4337, 709, 12, 650, 11769, 12, 31092, 12, 841, 4587, 12, 7901, 16, 12, 841, 12638, 12, 10416, 996, 12, 841, 15773, 12, 272, 5238, 1400, 12, 959, 15722, 12, 959, 10657, 12, 1227, 18857, 12, 1227, 11829, 12, 1227, 20103, 12, 1520, 1493, 12, 1520, 19235, 12, 8375, 1342, 12, 272, 8375, 1138, 12, 1695, 8262, 12, 5939, 2192, 12, 30220, 12, 5939, 2835, 12, 10513, 2182, 12, 10523, 1299, 12, 272, 9137, 1257, 12, 1749, 18526, 12, 1749, 14690, 12, 221, 5008, 12, 12260, 11564, 12, 12766, 4587, 199, 61, 199, 199, 4448, 10322, 63, 8549, 21545, 19144, 275, 469, 272, 283, 9887, 356, 1487, 5381, 17006, 14, 1244, 31364, 12, 272, 283, 1058, 685, 3858, 80, 22732, 356, 1487, 5381, 17006, 14, 3843, 7278, 1438, 2749, 726, 540, 12, 272, 283, 15394, 356, 1487, 5381, 17006, 14, 1976, 907, 3230, 56, 12, 272, 283, 2262, 65, 356, 1487, 5381, 17006, 14, 15598, 33, 12, 272, 283, 28303, 356, 1487, 5381, 17006, 14, 1772, 40, 4817, 12, 272, 283, 711, 350, 356, 1487, 5381, 17006, 14, 1772, 1554, 12, 272, 283, 2231, 70, 759, 356, 1487, 5381, 17006, 14, 4251, 38, 689, 41, 12, 272, 283, 6238, 356, 1487, 5381, 17006, 14, 25658, 199, 93, 199, 199, 3, 2900, 2883, 1471, 506, 2851, 436, 4840, 655, 7889, 461, 199, 3, 21966, 13, 31956, 3279, 13, 4612, 63, 7125, 13, 10555, 199, 1761, 63, 5569, 275, 469, 272, 283, 14091, 13, 9887, 306, 356, 788, 14091, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1695, 13, 9887, 306, 356, 788, 8647, 1695, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1520, 13, 9887, 306, 356, 788, 8647, 1520, 297, 283, 9887, 297, 3260, 28175, 272, 283, 8647, 1323, 48, 13, 9887, 306, 356, 788, 8647, 1323, 48, 297, 283, 9887, 297, 3260, 28175, 272, 283, 3100, 1323, 1616, 14, 24, 13, 9887, 306, 356, 788, 3100, 1323, 1616, 14, 24, 297, 283, 9887, 297, 3260, 28175, 272, 283, 3100, 1323, 1616, 14, 22, 13, 9887, 306, 356, 788, 3100, 1323, 1616, 14, 22, 297, 283, 9887, 297, 3260, 28175, 339, 283, 14091, 13, 15394, 13, 1789, 13, 356, 788, 14091, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1695, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1695, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1520, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1520, 297, 283, 15394, 297, 283, 1789, 297, 28175, 272, 283, 8647, 1323, 48, 13, 15394, 13, 1789, 13, 356, 788, 8647, 1323, 48, 297, 283, 15394, 297, 283, 1789, 297, 28175, 339, 283, 3100, 1323, 1616, 14, 24, 13, 2231, 70, 759, 13, 22, 13, 356, 788, 3100, 1323, 1616, 14, 24, 297, 283, 2231, 70, 759, 297, 283, 22, 297, 28175, 339, 283, 8647, 1695, 13, 1058, 685, 3858, 80, 22732, 13, 709, 13, 356, 788, 8647, 1695, 297, 283, 1058, 685, 3858, 80, 22732, 297, 283, 709, 297, 28175, 199, 93, 199, 199, 4251, 53, 2089, 63, 4531, 275, 11727, 63, 5569, 14, 362, 8, 736, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 4531, 297, 283, 14091, 13, 9887, 306, 1333, 199, 199, 3, 17064, 4346, 370, 7678, 13559, 428, 65, 3683, 491, 2101, 14, 199, 4251, 53, 2089, 275, 469, 272, 283, 11958, 356, 747, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 3791, 63, 2339, 659, 272, 283, 11074, 63, 998, 356, 747, 14, 2314, 14, 362, 360, 4251, 53, 2089, 63, 3735, 63, 3078, 659, 272, 283, 17805, 356, 428, 9331, 2089, 63, 4531, 59, 16, 467, 272, 283, 31956, 3279, 356, 11758, 10322, 63, 8549, 21545, 19144, 14, 362, 8, 4251, 53, 2089, 63, 4531, 59, 17, 2522, 272, 283, 4612, 356, 428, 9331, 2089, 63, 4531, 59, 18, 467, 272, 283, 10555, 356, 428, 9331, 2089, 63, 4531, 59, 19, 467, 272, 283, 12763, 356, 283, 42, 14758, 15506, 554, 6496, 297, 272, 283, 8248, 356, 747, 14, 2314, 14, 362, 360, 8248, 63, 20993, 63, 2339, 297, 283, 44, 775, 21364, 2089, 7393, 51, 659, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ntiufalara/openerp7
openerp/addons/l10n_pt/__openerp__.py
51
1844
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2012 Thinkopen Solutions, Lda. All Rights Reserved # http://www.thinkopensolutions.com. # $Id$ # # 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': 'Portugal - Chart of Accounts', 'version': '0.011', 'author': 'ThinkOpen Solutions', 'website': 'http://www.thinkopensolutions.com/', 'category': 'Localization/Account Charts', 'description': 'Plano de contas SNC para Portugal', 'depends': ['base', 'base_vat', 'account', 'account_chart', ], 'init_xml': [], 'update_xml': ['account_types.xml', 'account_chart.xml', 'account_tax_code_template.xml', 'account_chart_template.xml', 'fiscal_position_templates.xml', 'account_taxes.xml', 'l10n_chart_pt_wizard.xml', ], 'demo_xml': [], 'installable': True, }
mit
[ 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, 6029, 3868, 2292, 1490, 17991, 8653, 12, 491, 983, 14, 2900, 5924, 5702, 199, 3, 259, 1455, 921, 1544, 14, 29727, 1490, 27313, 14, 957, 14, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 4313, 1518, 279, 446, 24874, 402, 4473, 6851, 297, 272, 283, 1023, 356, 283, 16, 14, 13059, 297, 272, 283, 2502, 356, 283, 2719, 2292, 4299, 17991, 8653, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 29727, 1490, 27313, 14, 957, 3678, 272, 283, 3710, 356, 283, 5339, 2072, 15, 6009, 24874, 83, 297, 272, 283, 1802, 356, 283, 13375, 79, 477, 13770, 305, 428, 6389, 12665, 10977, 1518, 279, 297, 272, 283, 8912, 356, 788, 1095, 297, 355, 283, 1095, 63, 16305, 297, 355, 283, 2048, 297, 355, 283, 2048, 63, 9019, 297, 355, 2156, 272, 283, 826, 63, 1652, 356, 990, 272, 283, 873, 63, 1652, 356, 788, 2048, 63, 1313, 14, 1652, 297, 673, 283, 2048, 63, 9019, 14, 1652, 297, 673, 283, 2048, 63, 5530, 63, 600, 63, 1160, 14, 1652, 297, 673, 283, 2048, 63, 9019, 63, 1160, 14, 1652, 297, 673, 283, 18646, 63, 3124, 63, 5876, 14, 1652, 297, 673, 283, 2048, 63, 22272, 14, 1652, 297, 673, 283, 76, 709, 78, 63, 9019, 63, 541, 63, 9819, 14, 1652, 297, 673, 2156, 272, 283, 8768, 63, 1652, 356, 990, 272, 283, 21762, 356, 715, 12, 199, 93, 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 ]
[ 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, 6029, 3868, 2292, 1490, 17991, 8653, 12, 491, 983, 14, 2900, 5924, 5702, 199, 3, 259, 1455, 921, 1544, 14, 29727, 1490, 27313, 14, 957, 14, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 4313, 1518, 279, 446, 24874, 402, 4473, 6851, 297, 272, 283, 1023, 356, 283, 16, 14, 13059, 297, 272, 283, 2502, 356, 283, 2719, 2292, 4299, 17991, 8653, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 29727, 1490, 27313, 14, 957, 3678, 272, 283, 3710, 356, 283, 5339, 2072, 15, 6009, 24874, 83, 297, 272, 283, 1802, 356, 283, 13375, 79, 477, 13770, 305, 428, 6389, 12665, 10977, 1518, 279, 297, 272, 283, 8912, 356, 788, 1095, 297, 355, 283, 1095, 63, 16305, 297, 355, 283, 2048, 297, 355, 283, 2048, 63, 9019, 297, 355, 2156, 272, 283, 826, 63, 1652, 356, 990, 272, 283, 873, 63, 1652, 356, 788, 2048, 63, 1313, 14, 1652, 297, 673, 283, 2048, 63, 9019, 14, 1652, 297, 673, 283, 2048, 63, 5530, 63, 600, 63, 1160, 14, 1652, 297, 673, 283, 2048, 63, 9019, 63, 1160, 14, 1652, 297, 673, 283, 18646, 63, 3124, 63, 5876, 14, 1652, 297, 673, 283, 2048, 63, 22272, 14, 1652, 297, 673, 283, 76, 709, 78, 63, 9019, 63, 541, 63, 9819, 14, 1652, 297, 673, 2156, 272, 283, 8768, 63, 1652, 356, 990, 272, 283, 21762, 356, 715, 12, 199, 93, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Hazelsuko07/17WarmingUp
py3.6/lib/python3.6/site-packages/flask_wtf/recaptcha/widgets.py
91
1267
# -*- coding: utf-8 -*- from flask import current_app, Markup from flask import json from werkzeug import url_encode JSONEncoder = json.JSONEncoder RECAPTCHA_SCRIPT = u'https://www.google.com/recaptcha/api.js' RECAPTCHA_TEMPLATE = u''' <script src='%s' async defer></script> <div class="g-recaptcha" %s></div> ''' __all__ = ["RecaptchaWidget"] class RecaptchaWidget(object): def recaptcha_html(self, public_key): html = current_app.config.get('RECAPTCHA_HTML') if html: return Markup(html) params = current_app.config.get('RECAPTCHA_PARAMETERS') script = RECAPTCHA_SCRIPT if params: script += u'?' + url_encode(params) attrs = current_app.config.get('RECAPTCHA_DATA_ATTRS', {}) attrs['sitekey'] = public_key snippet = u' '.join([u'data-%s="%s"' % (k, attrs[k]) for k in attrs]) return Markup(RECAPTCHA_TEMPLATE % (script, snippet)) def __call__(self, field, error=None, **kwargs): """Returns the recaptcha input HTML.""" try: public_key = current_app.config['RECAPTCHA_PUBLIC_KEY'] except KeyError: raise RuntimeError("RECAPTCHA_PUBLIC_KEY config not set") return self.recaptcha_html(public_key)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 7209, 492, 1453, 63, 571, 12, 17504, 199, 504, 7209, 492, 2022, 199, 504, 10380, 492, 1166, 63, 2143, 199, 23069, 275, 2022, 14, 23069, 199, 199, 907, 28342, 26363, 63, 10484, 275, 399, 7, 2859, 921, 1544, 14, 3098, 14, 957, 15, 2761, 6182, 9518, 15, 1246, 14, 3596, 7, 199, 199, 907, 28342, 26363, 63, 7433, 275, 399, 2344, 199, 28, 1579, 2928, 9569, 83, 7, 5316, 10133, 2957, 1579, 30, 199, 28, 3015, 1021, 628, 71, 13, 2761, 6182, 9518, 2, 450, 83, 2957, 3015, 30, 199, 2344, 199, 199, 363, 452, 363, 275, 2097, 497, 20559, 3339, 937, 421, 199, 533, 799, 20559, 3339, 8, 785, 304, 339, 347, 295, 20559, 63, 1360, 8, 277, 12, 4575, 63, 498, 304, 267, 3517, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 4943, 358, 267, 340, 3517, 26, 288, 372, 17504, 8, 1360, 9, 267, 1862, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 24014, 358, 267, 2884, 275, 19461, 26086, 26363, 63, 10484, 267, 340, 1862, 26, 288, 2884, 847, 399, 7, 14069, 435, 1166, 63, 2143, 8, 1162, 9, 398, 3290, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 3998, 63, 27356, 297, 5009, 267, 3290, 459, 2124, 498, 418, 275, 4575, 63, 498, 267, 17440, 275, 399, 7, 1987, 904, 779, 85, 5121, 419, 3295, 83, 5961, 83, 4507, 450, 334, 75, 12, 3290, 59, 75, 566, 367, 1022, 315, 3290, 566, 267, 372, 17504, 8, 907, 28342, 26363, 63, 7433, 450, 334, 1579, 12, 17440, 430, 339, 347, 636, 1250, 721, 277, 12, 901, 12, 1125, 29, 403, 12, 1011, 958, 304, 267, 408, 3407, 314, 295, 20559, 1324, 4163, 1041, 398, 862, 26, 288, 4575, 63, 498, 275, 1453, 63, 571, 14, 888, 459, 907, 28342, 26363, 63, 19476, 63, 3078, 418, 267, 871, 4067, 26, 288, 746, 6064, 480, 907, 28342, 26363, 63, 19476, 63, 3078, 1101, 440, 663, 531, 398, 372, 291, 14, 2761, 6182, 9518, 63, 1360, 8, 3455, 63, 498, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 7209, 492, 1453, 63, 571, 12, 17504, 199, 504, 7209, 492, 2022, 199, 504, 10380, 492, 1166, 63, 2143, 199, 23069, 275, 2022, 14, 23069, 199, 199, 907, 28342, 26363, 63, 10484, 275, 399, 7, 2859, 921, 1544, 14, 3098, 14, 957, 15, 2761, 6182, 9518, 15, 1246, 14, 3596, 7, 199, 199, 907, 28342, 26363, 63, 7433, 275, 399, 2344, 199, 28, 1579, 2928, 9569, 83, 7, 5316, 10133, 2957, 1579, 30, 199, 28, 3015, 1021, 628, 71, 13, 2761, 6182, 9518, 2, 450, 83, 2957, 3015, 30, 199, 2344, 199, 199, 363, 452, 363, 275, 2097, 497, 20559, 3339, 937, 421, 199, 533, 799, 20559, 3339, 8, 785, 304, 339, 347, 295, 20559, 63, 1360, 8, 277, 12, 4575, 63, 498, 304, 267, 3517, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 4943, 358, 267, 340, 3517, 26, 288, 372, 17504, 8, 1360, 9, 267, 1862, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 24014, 358, 267, 2884, 275, 19461, 26086, 26363, 63, 10484, 267, 340, 1862, 26, 288, 2884, 847, 399, 7, 14069, 435, 1166, 63, 2143, 8, 1162, 9, 398, 3290, 275, 1453, 63, 571, 14, 888, 14, 362, 360, 907, 28342, 26363, 63, 3998, 63, 27356, 297, 5009, 267, 3290, 459, 2124, 498, 418, 275, 4575, 63, 498, 267, 17440, 275, 399, 7, 1987, 904, 779, 85, 5121, 419, 3295, 83, 5961, 83, 4507, 450, 334, 75, 12, 3290, 59, 75, 566, 367, 1022, 315, 3290, 566, 267, 372, 17504, 8, 907, 28342, 26363, 63, 7433, 450, 334, 1579, 12, 17440, 430, 339, 347, 636, 1250, 721, 277, 12, 901, 12, 1125, 29, 403, 12, 1011, 958, 304, 267, 408, 3407, 314, 295, 20559, 1324, 4163, 1041, 398, 862, 26, 288, 4575, 63, 498, 275, 1453, 63, 571, 14, 888, 459, 907, 28342, 26363, 63, 19476, 63, 3078, 418, 267, 871, 4067, 26, 288, 746, 6064, 480, 907, 28342, 26363, 63, 19476, 63, 3078, 1101, 440, 663, 531, 398, 372, 291, 14, 2761, 6182, 9518, 63, 1360, 8, 3455, 63, 498, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
perryjrandall/arsenalsuite
cpp/lib/PyQt4/examples/widgets/screenshot.py
22
5860
#!/usr/bin/env python ############################################################################# ## ## Copyright (C) 2005-2005 Trolltech AS. All rights reserved. ## ## This file is part of the example classes of the Qt Toolkit. ## ## This file may be used under the terms of the GNU General Public ## License version 2.0 as published by the Free Software Foundation ## and appearing in the file LICENSE.GPL included in the packaging of ## this file. Please review the following information to ensure GNU ## General Public Licensing requirements will be met: ## http://www.trolltech.com/products/qt/opensource.html ## ## If you are unsure which license is appropriate for your use, please ## review the following information: ## http://www.trolltech.com/products/qt/licensing.html or contact the ## sales department at sales@trolltech.com. ## ## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ## ############################################################################# import sys from PyQt4 import QtCore, QtGui class Screenshot(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.screenshotLabel = QtGui.QLabel() self.screenshotLabel.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.screenshotLabel.setAlignment(QtCore.Qt.AlignCenter) self.screenshotLabel.setMinimumSize(240, 160) self.createOptionsGroupBox() self.createButtonsLayout() self.mainLayout = QtGui.QVBoxLayout() self.mainLayout.addWidget(self.screenshotLabel) self.mainLayout.addWidget(self.optionsGroupBox) self.mainLayout.addLayout(self.buttonsLayout) self.setLayout(self.mainLayout) self.shootScreen() self.delaySpinBox.setValue(5) self.setWindowTitle(self.tr("Screenshot")) self.resize(300, 200) def resizeEvent(self, event): scaledSize = self.originalPixmap.size() scaledSize.scale(self.screenshotLabel.size(), QtCore.Qt.KeepAspectRatio) if not self.screenshotLabel.pixmap() or scaledSize != self.screenshotLabel.pixmap().size(): self.updateScreenshotLabel() def newScreenshot(self): if self.hideThisWindowCheckBox.isChecked(): self.hide() self.newScreenshotButton.setDisabled(True) QtCore.QTimer.singleShot(self.delaySpinBox.value() * 1000, self.shootScreen) def saveScreenshot(self): format = QtCore.QString("png") initialPath = QtCore.QDir.currentPath() + self.tr("/untitled.") + format fileName = QtGui.QFileDialog.getSaveFileName(self, self.tr("Save As"), initialPath, self.tr("%1 Files (*.%2);;All Files (*)") .arg(format.toUpper()) .arg(format)) if not fileName.isEmpty(): self.originalPixmap.save(fileName, str(format)) def shootScreen(self): if self.delaySpinBox.value() != 0: QtGui.qApp.beep() self.originalPixmap = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId()) self.updateScreenshotLabel() self.newScreenshotButton.setDisabled(False) if self.hideThisWindowCheckBox.isChecked(): self.show() def updateCheckBox(self): if self.delaySpinBox.value() == 0: self.hideThisWindowCheckBox.setDisabled(True) else: self.hideThisWindowCheckBox.setDisabled(False) def createOptionsGroupBox(self): self.optionsGroupBox = QtGui.QGroupBox(self.tr("Options")) self.delaySpinBox = QtGui.QSpinBox() self.delaySpinBox.setSuffix(self.tr(" s")) self.delaySpinBox.setMaximum(60) self.connect(self.delaySpinBox, QtCore.SIGNAL("valueChanged(int)"), self.updateCheckBox) self.delaySpinBoxLabel = QtGui.QLabel(self.tr("Screenshot Delay:")) self.hideThisWindowCheckBox = QtGui.QCheckBox(self.tr("Hide This Window")) self.optionsGroupBoxLayout = QtGui.QGridLayout() self.optionsGroupBoxLayout.addWidget(self.delaySpinBoxLabel, 0, 0) self.optionsGroupBoxLayout.addWidget(self.delaySpinBox, 0, 1) self.optionsGroupBoxLayout.addWidget(self.hideThisWindowCheckBox, 1, 0, 1, 2) self.optionsGroupBox.setLayout(self.optionsGroupBoxLayout) def createButtonsLayout(self): self.newScreenshotButton = self.createButton(self.tr("New Screenshot"), self.newScreenshot) self.saveScreenshotButton = self.createButton(self.tr("Save Screenshot"), self.saveScreenshot) self.quitScreenshotButton = self.createButton(self.tr("Quit"), self.close) self.buttonsLayout = QtGui.QHBoxLayout() self.buttonsLayout.addStretch() self.buttonsLayout.addWidget(self.newScreenshotButton) self.buttonsLayout.addWidget(self.saveScreenshotButton) self.buttonsLayout.addWidget(self.quitScreenshotButton) def createButton(self, text, member): button = QtGui.QPushButton(text) button.connect(button, QtCore.SIGNAL("clicked()"), member) return button def updateScreenshotLabel(self): self.screenshotLabel.setPixmap(self.originalPixmap.scaled( self.screenshotLabel.size(), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) screenshot = Screenshot() screenshot.show() sys.exit(app.exec_())
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 11811, 13, 9397, 377, 2827, 15970, 4319, 14, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 2893, 3992, 402, 314, 3959, 15650, 6065, 14, 199, 309, 199, 309, 961, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 309, 844, 1015, 499, 14, 16, 465, 3267, 701, 314, 2868, 2290, 2752, 199, 309, 436, 7468, 316, 315, 314, 570, 5113, 14, 12006, 5120, 315, 314, 27369, 402, 199, 309, 642, 570, 14, 221, 7754, 11248, 314, 2569, 2556, 370, 4868, 1664, 199, 309, 1696, 1684, 491, 530, 25843, 9760, 911, 506, 7647, 26, 199, 309, 1455, 921, 1544, 14, 1374, 914, 15970, 14, 957, 15, 13336, 15, 8440, 15, 16374, 14, 1360, 199, 309, 199, 309, 982, 1265, 787, 625, 3253, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 199, 309, 11248, 314, 2569, 2556, 26, 199, 309, 1455, 921, 1544, 14, 1374, 914, 15970, 14, 957, 15, 13336, 15, 8440, 15, 606, 25843, 14, 1360, 503, 8966, 314, 199, 309, 21702, 27669, 737, 21702, 32, 1374, 914, 15970, 14, 957, 14, 199, 309, 199, 309, 961, 570, 365, 2741, 4319, 2281, 543, 4825, 3408, 1634, 1821, 3826, 12, 6931, 2334, 199, 309, 3408, 1634, 11758, 3203, 12, 3169, 2401, 3092, 2381, 437, 3115, 3104, 14, 199, 309, 199, 31635, 199, 199, 646, 984, 199, 504, 14084, 20, 492, 10565, 12, 5928, 421, 199, 533, 17804, 2782, 8, 10604, 14, 23894, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 275, 488, 304, 267, 5928, 14, 23894, 855, 826, 721, 277, 12, 1676, 9, 398, 291, 14, 23269, 4314, 275, 5928, 14, 19890, 342, 267, 291, 14, 23269, 4314, 14, 21735, 4845, 8, 10604, 14, 19934, 14, 12839, 316, 12, 5644, 5928, 14, 19934, 14, 12839, 316, 9, 267, 291, 14, 23269, 4314, 14, 409, 16613, 8, 10901, 14, 4238, 14, 9497, 13551, 9, 267, 291, 14, 23269, 4314, 14, 32608, 2320, 8, 9873, 12, 21235, 9, 398, 291, 14, 981, 4558, 2448, 3532, 342, 267, 291, 14, 981, 24021, 4798, 342, 398, 291, 14, 973, 4798, 275, 5928, 14, 25527, 18536, 342, 267, 291, 14, 973, 4798, 14, 9475, 8, 277, 14, 23269, 4314, 9, 267, 291, 14, 973, 4798, 14, 9475, 8, 277, 14, 1419, 2448, 3532, 9, 267, 291, 14, 973, 4798, 14, 30571, 8, 277, 14, 15687, 4798, 9, 267, 291, 14, 409, 4798, 8, 277, 14, 973, 4798, 9, 398, 291, 14, 13927, 357, 9616, 342, 267, 291, 14, 5814, 27806, 14, 14733, 8, 21, 9, 398, 291, 14, 30601, 8, 277, 14, 454, 480, 9616, 2782, 2237, 267, 291, 14, 8709, 8, 5863, 12, 1926, 9, 339, 347, 15210, 2390, 8, 277, 12, 1566, 304, 267, 17923, 2320, 275, 291, 14, 5043, 16049, 14, 890, 342, 267, 17923, 2320, 14, 3467, 8, 277, 14, 23269, 4314, 14, 890, 1062, 10565, 14, 4238, 14, 18567, 2822, 1764, 13971, 9, 267, 340, 440, 291, 14, 23269, 4314, 14, 6644, 1130, 342, 503, 17923, 2320, 1137, 291, 14, 23269, 4314, 14, 6644, 1130, 1252, 890, 837, 288, 291, 14, 873, 9616, 2782, 4314, 342, 339, 347, 892, 9616, 2782, 8, 277, 304, 267, 340, 291, 14, 8191, 2765, 4301, 20530, 14, 25374, 837, 288, 291, 14, 8191, 342, 267, 291, 14, 1222, 9616, 2782, 4259, 14, 409, 15049, 8, 549, 9, 398, 10565, 14, 49, 7929, 14, 4780, 2662, 357, 8, 277, 14, 5814, 27806, 14, 585, 342, 627, 5198, 12, 291, 14, 13927, 357, 9616, 9, 339, 347, 3354, 9616, 2782, 8, 277, 304, 267, 1475, 275, 10565, 14, 49, 1558, 480, 4524, 531, 267, 2536, 2042, 275, 10565, 14, 49, 3567, 14, 1818, 2042, 342, 435, 291, 14, 454, 4769, 324, 1213, 68, 2685, 435, 1475, 398, 18305, 275, 5928, 14, 49, 25213, 14, 362, 8229, 7733, 8, 277, 12, 291, 14, 454, 480, 8229, 3709, 1288, 3044, 2536, 2042, 12, 3044, 291, 14, 454, 3647, 17, 16920, 19943, 4111, 18, 2736, 27, 2422, 16920, 19943, 6320, 3521, 1275, 1273, 8, 908, 14, 475, 19316, 1012, 3521, 1275, 1273, 8, 908, 430, 267, 340, 440, 18305, 14, 374, 4699, 837, 288, 291, 14, 5043, 16049, 14, 2117, 8, 15450, 12, 620, 8, 908, 430, 339, 347, 930, 357, 9616, 8, 277, 304, 267, 340, 291, 14, 5814, 27806, 14, 585, 342, 1137, 378, 26, 288, 5928, 14, 81, 2640, 14, 66, 7840, 342, 398, 291, 14, 5043, 16049, 275, 5928, 14, 49, 16049, 14, 22090, 4301, 8, 10604, 14, 12757, 14, 14487, 1252, 2676, 1304, 1012, 267, 291, 14, 873, 9616, 2782, 4314, 342, 398, 291, 14, 1222, 9616, 2782, 4259, 14, 409, 15049, 8, 797, 9, 267, 340, 291, 14, 8191, 2765, 4301, 20530, 14, 25374, 837, 288, 291, 14, 2384, 342, 339, 347, 1678, 20530, 8, 277, 304, 267, 340, 291, 14, 5814, 27806, 14, 585, 342, 508, 378, 26, 288, 291, 14, 8191, 2765, 4301, 20530, 14, 409, 15049, 8, 549, 9, 267, 587, 26, 288, 291, 14, 8191, 2765, 4301, 20530, 14, 409, 15049, 8, 797, 9, 339, 347, 1218, 4558, 2448, 3532, 8, 277, 304, 267, 291, 14, 1419, 2448, 3532, 275, 5928, 14, 49, 2448, 3532, 8, 277, 14, 454, 480, 4558, 2237, 398, 291, 14, 5814, 27806, 275, 5928, 14, 49, 27806, 342, 267, 291, 14, 5814, 27806, 14, 409, 20126, 8, 277, 14, 454, 480, 308, 2237, 267, 291, 14, 5814, 27806, 14, 409, 10915, 8, 2259, 9, 267, 291, 14, 2242, 8, 277, 14, 5814, 27806, 12, 10565, 14, 16496, 480, 585, 6970, 8, 442, 13185, 2151, 291, 14, 873, 20530, 9, 398, 291, 14, 5814, 27806, 4314, 275, 5928, 14, 19890, 8, 277, 14, 454, 480, 9616, 2782, 18464, 1187, 26, 2237, 398, 291, 14, 8191, 2765, 4301, 20530, 275, 5928, 14, 49, 20530, 8, 277, 14, 454, 480, 18224, 961, 15689, 2237, 398, 291, 14, 1419, 2448, 18536, 275, 5928, 14, 49, 7900, 4798, 342, 267, 291, 14, 1419, 2448, 18536, 14, 9475, 8, 277, 14, 5814, 27806, 4314, 12, 378, 12, 378, 9, 267, 291, 14, 1419, 2448 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 11811, 13, 9397, 377, 2827, 15970, 4319, 14, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 2893, 3992, 402, 314, 3959, 15650, 6065, 14, 199, 309, 199, 309, 961, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 309, 844, 1015, 499, 14, 16, 465, 3267, 701, 314, 2868, 2290, 2752, 199, 309, 436, 7468, 316, 315, 314, 570, 5113, 14, 12006, 5120, 315, 314, 27369, 402, 199, 309, 642, 570, 14, 221, 7754, 11248, 314, 2569, 2556, 370, 4868, 1664, 199, 309, 1696, 1684, 491, 530, 25843, 9760, 911, 506, 7647, 26, 199, 309, 1455, 921, 1544, 14, 1374, 914, 15970, 14, 957, 15, 13336, 15, 8440, 15, 16374, 14, 1360, 199, 309, 199, 309, 982, 1265, 787, 625, 3253, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 199, 309, 11248, 314, 2569, 2556, 26, 199, 309, 1455, 921, 1544, 14, 1374, 914, 15970, 14, 957, 15, 13336, 15, 8440, 15, 606, 25843, 14, 1360, 503, 8966, 314, 199, 309, 21702, 27669, 737, 21702, 32, 1374, 914, 15970, 14, 957, 14, 199, 309, 199, 309, 961, 570, 365, 2741, 4319, 2281, 543, 4825, 3408, 1634, 1821, 3826, 12, 6931, 2334, 199, 309, 3408, 1634, 11758, 3203, 12, 3169, 2401, 3092, 2381, 437, 3115, 3104, 14, 199, 309, 199, 31635, 199, 199, 646, 984, 199, 504, 14084, 20, 492, 10565, 12, 5928, 421, 199, 533, 17804, 2782, 8, 10604, 14, 23894, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 275, 488, 304, 267, 5928, 14, 23894, 855, 826, 721, 277, 12, 1676, 9, 398, 291, 14, 23269, 4314, 275, 5928, 14, 19890, 342, 267, 291, 14, 23269, 4314, 14, 21735, 4845, 8, 10604, 14, 19934, 14, 12839, 316, 12, 5644, 5928, 14, 19934, 14, 12839, 316, 9, 267, 291, 14, 23269, 4314, 14, 409, 16613, 8, 10901, 14, 4238, 14, 9497, 13551, 9, 267, 291, 14, 23269, 4314, 14, 32608, 2320, 8, 9873, 12, 21235, 9, 398, 291, 14, 981, 4558, 2448, 3532, 342, 267, 291, 14, 981, 24021, 4798, 342, 398, 291, 14, 973, 4798, 275, 5928, 14, 25527, 18536, 342, 267, 291, 14, 973, 4798, 14, 9475, 8, 277, 14, 23269, 4314, 9, 267, 291, 14, 973, 4798, 14, 9475, 8, 277, 14, 1419, 2448, 3532, 9, 267, 291, 14, 973, 4798, 14, 30571, 8, 277, 14, 15687, 4798, 9, 267, 291, 14, 409, 4798, 8, 277, 14, 973, 4798, 9, 398, 291, 14, 13927, 357, 9616, 342, 267, 291, 14, 5814, 27806, 14, 14733, 8, 21, 9, 398, 291, 14, 30601, 8, 277, 14, 454, 480, 9616, 2782, 2237, 267, 291, 14, 8709, 8, 5863, 12, 1926, 9, 339, 347, 15210, 2390, 8, 277, 12, 1566, 304, 267, 17923, 2320, 275, 291, 14, 5043, 16049, 14, 890, 342, 267, 17923, 2320, 14, 3467, 8, 277, 14, 23269, 4314, 14, 890, 1062, 10565, 14, 4238, 14, 18567, 2822, 1764, 13971, 9, 267, 340, 440, 291, 14, 23269, 4314, 14, 6644, 1130, 342, 503, 17923, 2320, 1137, 291, 14, 23269, 4314, 14, 6644, 1130, 1252, 890, 837, 288, 291, 14, 873, 9616, 2782, 4314, 342, 339, 347, 892, 9616, 2782, 8, 277, 304, 267, 340, 291, 14, 8191, 2765, 4301, 20530, 14, 25374, 837, 288, 291, 14, 8191, 342, 267, 291, 14, 1222, 9616, 2782, 4259, 14, 409, 15049, 8, 549, 9, 398, 10565, 14, 49, 7929, 14, 4780, 2662, 357, 8, 277, 14, 5814, 27806, 14, 585, 342, 627, 5198, 12, 291, 14, 13927, 357, 9616, 9, 339, 347, 3354, 9616, 2782, 8, 277, 304, 267, 1475, 275, 10565, 14, 49, 1558, 480, 4524, 531, 267, 2536, 2042, 275, 10565, 14, 49, 3567, 14, 1818, 2042, 342, 435, 291, 14, 454, 4769, 324, 1213, 68, 2685, 435, 1475, 398, 18305, 275, 5928, 14, 49, 25213, 14, 362, 8229, 7733, 8, 277, 12, 291, 14, 454, 480, 8229, 3709, 1288, 3044, 2536, 2042, 12, 3044, 291, 14, 454, 3647, 17, 16920, 19943, 4111, 18, 2736, 27, 2422, 16920, 19943, 6320, 3521, 1275, 1273, 8, 908, 14, 475, 19316, 1012, 3521, 1275, 1273, 8, 908, 430, 267, 340, 440, 18305, 14, 374, 4699, 837, 288, 291, 14, 5043, 16049, 14, 2117, 8, 15450, 12, 620, 8, 908, 430, 339, 347, 930, 357, 9616, 8, 277, 304, 267, 340, 291, 14, 5814, 27806, 14, 585, 342, 1137, 378, 26, 288, 5928, 14, 81, 2640, 14, 66, 7840, 342, 398, 291, 14, 5043, 16049, 275, 5928, 14, 49, 16049, 14, 22090, 4301, 8, 10604, 14, 12757, 14, 14487, 1252, 2676, 1304, 1012, 267, 291, 14, 873, 9616, 2782, 4314, 342, 398, 291, 14, 1222, 9616, 2782, 4259, 14, 409, 15049, 8, 797, 9, 267, 340, 291, 14, 8191, 2765, 4301, 20530, 14, 25374, 837, 288, 291, 14, 2384, 342, 339, 347, 1678, 20530, 8, 277, 304, 267, 340, 291, 14, 5814, 27806, 14, 585, 342, 508, 378, 26, 288, 291, 14, 8191, 2765, 4301, 20530, 14, 409, 15049, 8, 549, 9, 267, 587, 26, 288, 291, 14, 8191, 2765, 4301, 20530, 14, 409, 15049, 8, 797, 9, 339, 347, 1218, 4558, 2448, 3532, 8, 277, 304, 267, 291, 14, 1419, 2448, 3532, 275, 5928, 14, 49, 2448, 3532, 8, 277, 14, 454, 480, 4558, 2237, 398, 291, 14, 5814, 27806, 275, 5928, 14, 49, 27806, 342, 267, 291, 14, 5814, 27806, 14, 409, 20126, 8, 277, 14, 454, 480, 308, 2237, 267, 291, 14, 5814, 27806, 14, 409, 10915, 8, 2259, 9, 267, 291, 14, 2242, 8, 277, 14, 5814, 27806, 12, 10565, 14, 16496, 480, 585, 6970, 8, 442, 13185, 2151, 291, 14, 873, 20530, 9, 398, 291, 14, 5814, 27806, 4314, 275, 5928, 14, 19890, 8, 277, 14, 454, 480, 9616, 2782, 18464, 1187, 26, 2237, 398, 291, 14, 8191, 2765, 4301, 20530, 275, 5928, 14, 49, 20530, 8, 277, 14, 454, 480, 18224, 961, 15689, 2237, 398, 291, 14, 1419, 2448, 18536, 275, 5928, 14, 49, 7900, 4798, 342, 267, 291, 14, 1419, 2448, 18536, 14, 9475, 8, 277, 14, 5814, 27806, 4314, 12, 378, 12, 378, 9, 267, 291, 14, 1419, 2448, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thresholdsoftware/asylum-v2.0
openerp/addons/crm_profiling/crm_profiling.py
52
10442
# -*- 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/>. # ############################################################################## from openerp.osv import fields,osv from openerp.osv import orm from openerp.tools.translate import _ def _get_answers(cr, uid, ids): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm profiling’s IDs """ query = """ select distinct(answer) from profile_question_yes_rel where profile IN %s""" cr.execute(query, (tuple(ids),)) ans_yes = [x[0] for x in cr.fetchall()] query = """ select distinct(answer) from profile_question_no_rel where profile IN %s""" cr.execute(query, (tuple(ids),)) ans_no = [x[0] for x in cr.fetchall()] return [ans_yes, ans_no] def _get_parents(cr, uid, ids): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm profiling’s IDs @return: Get parents's Id """ ids_to_check = ids cr.execute(""" select distinct(parent_id) from crm_segmentation where parent_id is not null and id IN %s""",(tuple(ids),)) parent_ids = [x[0] for x in cr.fetchall()] trigger = False for x in parent_ids: if x not in ids_to_check: ids_to_check.append(x) trigger = True if trigger: ids_to_check = _get_parents(cr, uid, ids_to_check) return ids_to_check def test_prof(cr, uid, seg_id, pid, answers_ids=None): """ return True if the partner pid fetch the segmentation rule seg_id @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param seg_id: Segmentaion's ID @param pid: partner's ID @param answers_ids: Answers's IDs """ ids_to_check = _get_parents(cr, uid, [seg_id]) [yes_answers, no_answers] = _get_answers(cr, uid, ids_to_check) temp = True for y_ans in yes_answers: if y_ans not in answers_ids: temp = False break if temp: for ans in answers_ids: if ans in no_answers: temp = False break if temp: return True return False def _recompute_categ(self, cr, uid, pid, answers_ids): """ Recompute category @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param pid: partner's ID @param answers_ids: Answers's IDs """ ok = [] cr.execute(''' select r.category_id from res_partner_res_partner_category_rel r left join crm_segmentation s on (r.category_id = s.categ_id) where r.partner_id = %s and (s.exclusif = false or s.exclusif is null) ''', (pid,)) for x in cr.fetchall(): ok.append(x[0]) query = ''' select id, categ_id from crm_segmentation where profiling_active = true''' if ok != []: query = query +''' and categ_id not in(%s)'''% ','.join([str(i) for i in ok ]) query = query + ''' order by id ''' cr.execute(query) segm_cat_ids = cr.fetchall() for (segm_id, cat_id) in segm_cat_ids: if test_prof(cr, uid, segm_id, pid, answers_ids): ok.append(cat_id) return ok class question(osv.osv): """ Question """ _name="crm_profiling.question" _description= "Question" _columns={ 'name': fields.char("Question",size=128, required=True), 'answers_ids': fields.one2many("crm_profiling.answer","question_id","Avalaible Answers",), } question() class questionnaire(osv.osv): """ Questionnaire """ _name="crm_profiling.questionnaire" _description= "Questionnaire" _columns = { 'name': fields.char("Questionnaire",size=128, required=True), 'description':fields.text("Description", required=True), 'questions_ids': fields.many2many('crm_profiling.question','profile_questionnaire_quest_rel',\ 'questionnaire', 'question', "Questions"), } questionnaire() class answer(osv.osv): _name="crm_profiling.answer" _description="Answer" _columns={ "name": fields.char("Answer",size=128, required=True), "question_id": fields.many2one('crm_profiling.question',"Question"), } answer() class partner(osv.osv): _inherit="res.partner" _columns={ "answers_ids": fields.many2many("crm_profiling.answer","partner_question_rel",\ "partner","answer","Answers"), } def _questionnaire_compute(self, cr, uid, answers, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param data: Get Data @param context: A standard dictionary for contextual values """ partner_id = context.get('active_id') query = "select answer from partner_question_rel where partner=%s" cr.execute(query, (partner_id,)) for x in cr.fetchall(): answers.append(x[0]) self.write(cr, uid, [partner_id], {'answers_ids': [[6, 0, answers]]}, context=context) return {} def write(self, cr, uid, ids, vals, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm profiling’s IDs @param context: A standard dictionary for contextual values """ if 'answers_ids' in vals: vals['category_id']=[[6, 0, _recompute_categ(self, cr, uid, ids[0], vals['answers_ids'][0][2])]] return super(partner, self).write(cr, uid, ids, vals, context=context) partner() class crm_segmentation(osv.osv): """ CRM Segmentation """ _inherit="crm.segmentation" _columns={ "answer_yes": fields.many2many("crm_profiling.answer","profile_question_yes_rel",\ "profile","answer","Included Answers"), "answer_no": fields.many2many("crm_profiling.answer","profile_question_no_rel",\ "profile","answer","Excluded Answers"), 'parent_id': fields.many2one('crm.segmentation', 'Parent Profile'), 'child_ids': fields.one2many('crm.segmentation', 'parent_id', 'Child Profiles'), 'profiling_active': fields.boolean('Use The Profiling Rules', help='Check\ this box if you want to use this tab as part of the \ segmentation rule. If not checked, the criteria beneath will be ignored') } _constraints = [ (osv.osv._check_recursion, 'Error ! You cannot create recursive profiles.', ['parent_id']) ] def process_continue(self, cr, uid, ids, start=False): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm segmentation’s IDs """ partner_obj = self.pool.get('res.partner') categs = self.read(cr,uid,ids,['categ_id','exclusif','partner_id', \ 'sales_purchase_active', 'profiling_active']) for categ in categs: if start: if categ['exclusif']: cr.execute('delete from res_partner_res_partner_category_rel where \ category_id=%s', (categ['categ_id'][0],)) id = categ['id'] cr.execute('select id from res_partner order by id ') partners = [x[0] for x in cr.fetchall()] if categ['sales_purchase_active']: to_remove_list=[] cr.execute('select id from crm_segmentation_line where segmentation_id=%s', (id,)) line_ids = [x[0] for x in cr.fetchall()] for pid in partners: if (not self.pool.get('crm.segmentation.line').test(cr, uid, line_ids, pid)): to_remove_list.append(pid) for pid in to_remove_list: partners.remove(pid) if categ['profiling_active']: to_remove_list = [] for pid in partners: cr.execute('select distinct(answer) from partner_question_rel where partner=%s',(pid,)) answers_ids = [x[0] for x in cr.fetchall()] if (not test_prof(cr, uid, id, pid, answers_ids)): to_remove_list.append(pid) for pid in to_remove_list: partners.remove(pid) for partner in partner_obj.browse(cr, uid, partners): category_ids = [categ_id.id for categ_id in partner.category_id] if categ['categ_id'][0] not in category_ids: cr.execute('insert into res_partner_res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner.id)) self.write(cr, uid, [id], {'state':'not running', 'partner_id':0}) return True crm_segmentation() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 14, 4795, 492, 9813, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 318, 485, 362, 63, 13379, 8, 1556, 12, 1747, 12, 2762, 304, 272, 408, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 2762, 26, 3820, 402, 2467, 77, 30238, 21045, 83, 11449, 408, 339, 1827, 275, 408, 272, 3504, 15392, 8, 5934, 9, 272, 687, 4690, 63, 4790, 63, 5066, 63, 3369, 272, 2382, 4690, 1621, 450, 83, 624, 339, 2467, 14, 2526, 8, 1131, 12, 334, 2960, 8, 1580, 18399, 272, 4987, 63, 5066, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 1827, 275, 408, 272, 3504, 15392, 8, 5934, 9, 272, 687, 4690, 63, 4790, 63, 889, 63, 3369, 272, 2382, 4690, 1621, 450, 83, 624, 339, 2467, 14, 2526, 8, 1131, 12, 334, 2960, 8, 1580, 18399, 272, 4987, 63, 889, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 372, 359, 796, 63, 5066, 12, 4987, 63, 889, 61, 421, 199, 318, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 2762, 304, 272, 408, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 2762, 26, 3820, 402, 2467, 77, 30238, 21045, 83, 11449, 267, 768, 1107, 26, 2372, 8623, 1159, 15418, 408, 339, 2762, 63, 475, 63, 1074, 275, 2762, 272, 2467, 14, 2526, 4852, 1362, 3504, 15392, 8, 1708, 63, 344, 9, 1362, 687, 2467, 77, 63, 26926, 1362, 2382, 1676, 63, 344, 365, 440, 2973, 1362, 436, 1305, 1621, 450, 83, 7208, 8, 2960, 8, 1580, 18399, 339, 1676, 63, 1580, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 6804, 275, 756, 272, 367, 671, 315, 1676, 63, 1580, 26, 267, 340, 671, 440, 315, 2762, 63, 475, 63, 1074, 26, 288, 2762, 63, 475, 63, 1074, 14, 740, 8, 88, 9, 288, 6804, 275, 715, 339, 340, 6804, 26, 267, 2762, 63, 475, 63, 1074, 275, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 2762, 63, 475, 63, 1074, 9, 339, 372, 2762, 63, 475, 63, 1074, 421, 199, 318, 511, 63, 14979, 8, 1556, 12, 1747, 12, 8812, 63, 344, 12, 4422, 12, 17133, 63, 1580, 29, 403, 304, 339, 408, 372, 715, 340, 314, 5854, 4422, 5267, 314, 27315, 2332, 8812, 63, 344, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 8812, 63, 344, 26, 29858, 65, 1636, 1159, 2870, 267, 768, 635, 4422, 26, 5854, 1159, 2870, 267, 768, 635, 17133, 63, 1580, 26, 437, 561, 12203, 1159, 11449, 272, 408, 339, 2762, 63, 475, 63, 1074, 275, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 359, 8359, 63, 344, 566, 272, 359, 5066, 63, 13379, 12, 949, 63, 13379, 61, 275, 485, 362, 63, 13379, 8, 1556, 12, 1747, 12, 2762, 63, 475, 63, 1074, 9, 272, 2388, 275, 715, 272, 367, 612, 63, 796, 315, 9456, 63, 13379, 26, 267, 340, 612, 63, 796, 440, 315, 17133, 63, 1580, 26, 288, 2388, 275, 756, 288, 2059, 272, 340, 2388, 26, 267, 367, 4987, 315, 17133, 63, 1580, 26, 288, 340, 4987, 315, 949, 63, 13379, 26, 355, 2388, 275, 756, 355, 2059, 272, 340, 2388, 26, 267, 372, 715, 272, 372, 756, 421, 199, 318, 485, 264, 3357, 63, 3533, 8, 277, 12, 2467, 12, 1747, 12, 4422, 12, 17133, 63, 1580, 304, 272, 408, 799, 3357, 4637, 267, 768, 635, 291, 26, 710, 909, 7849, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 4422, 26, 5854, 1159, 2870, 267, 768, 635, 17133, 63, 1580, 26, 437, 561, 12203, 1159, 11449, 272, 408, 339, 4112, 275, 221, 942, 272, 2467, 14, 2526, 10505, 267, 3504, 519, 14, 3710, 63, 344, 267, 687, 522, 63, 3899, 63, 470, 63, 3899, 63, 3710, 63, 3369, 519, 3602, 4263, 2467, 77, 63, 26926, 308, 641, 334, 82, 14, 3710, 63, 344, 275, 308, 14, 3533, 63, 344, 9, 267, 2382, 519, 14, 3899, 63, 344, 275, 450, 83, 436, 334, 83, 14, 476, 1016, 338, 70, 275, 3055, 503, 308, 14, 476, 1016, 338, 70, 365, 2973, 9, 267, 21281, 334, 3150, 4641, 272, 367, 671, 315, 2467, 14, 10174, 837, 267, 4112, 14, 740, 8, 88, 59, 16, 566, 339, 1827, 275 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 14, 4795, 492, 9813, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 318, 485, 362, 63, 13379, 8, 1556, 12, 1747, 12, 2762, 304, 272, 408, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 2762, 26, 3820, 402, 2467, 77, 30238, 21045, 83, 11449, 408, 339, 1827, 275, 408, 272, 3504, 15392, 8, 5934, 9, 272, 687, 4690, 63, 4790, 63, 5066, 63, 3369, 272, 2382, 4690, 1621, 450, 83, 624, 339, 2467, 14, 2526, 8, 1131, 12, 334, 2960, 8, 1580, 18399, 272, 4987, 63, 5066, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 1827, 275, 408, 272, 3504, 15392, 8, 5934, 9, 272, 687, 4690, 63, 4790, 63, 889, 63, 3369, 272, 2382, 4690, 1621, 450, 83, 624, 339, 2467, 14, 2526, 8, 1131, 12, 334, 2960, 8, 1580, 18399, 272, 4987, 63, 889, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 372, 359, 796, 63, 5066, 12, 4987, 63, 889, 61, 421, 199, 318, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 2762, 304, 272, 408, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 2762, 26, 3820, 402, 2467, 77, 30238, 21045, 83, 11449, 267, 768, 1107, 26, 2372, 8623, 1159, 15418, 408, 339, 2762, 63, 475, 63, 1074, 275, 2762, 272, 2467, 14, 2526, 4852, 1362, 3504, 15392, 8, 1708, 63, 344, 9, 1362, 687, 2467, 77, 63, 26926, 1362, 2382, 1676, 63, 344, 365, 440, 2973, 1362, 436, 1305, 1621, 450, 83, 7208, 8, 2960, 8, 1580, 18399, 339, 1676, 63, 1580, 275, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 6804, 275, 756, 272, 367, 671, 315, 1676, 63, 1580, 26, 267, 340, 671, 440, 315, 2762, 63, 475, 63, 1074, 26, 288, 2762, 63, 475, 63, 1074, 14, 740, 8, 88, 9, 288, 6804, 275, 715, 339, 340, 6804, 26, 267, 2762, 63, 475, 63, 1074, 275, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 2762, 63, 475, 63, 1074, 9, 339, 372, 2762, 63, 475, 63, 1074, 421, 199, 318, 511, 63, 14979, 8, 1556, 12, 1747, 12, 8812, 63, 344, 12, 4422, 12, 17133, 63, 1580, 29, 403, 304, 339, 408, 372, 715, 340, 314, 5854, 4422, 5267, 314, 27315, 2332, 8812, 63, 344, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 8812, 63, 344, 26, 29858, 65, 1636, 1159, 2870, 267, 768, 635, 4422, 26, 5854, 1159, 2870, 267, 768, 635, 17133, 63, 1580, 26, 437, 561, 12203, 1159, 11449, 272, 408, 339, 2762, 63, 475, 63, 1074, 275, 485, 362, 63, 8859, 8, 1556, 12, 1747, 12, 359, 8359, 63, 344, 566, 272, 359, 5066, 63, 13379, 12, 949, 63, 13379, 61, 275, 485, 362, 63, 13379, 8, 1556, 12, 1747, 12, 2762, 63, 475, 63, 1074, 9, 272, 2388, 275, 715, 272, 367, 612, 63, 796, 315, 9456, 63, 13379, 26, 267, 340, 612, 63, 796, 440, 315, 17133, 63, 1580, 26, 288, 2388, 275, 756, 288, 2059, 272, 340, 2388, 26, 267, 367, 4987, 315, 17133, 63, 1580, 26, 288, 340, 4987, 315, 949, 63, 13379, 26, 355, 2388, 275, 756, 355, 2059, 272, 340, 2388, 26, 267, 372, 715, 272, 372, 756, 421, 199, 318, 485, 264, 3357, 63, 3533, 8, 277, 12, 2467, 12, 1747, 12, 4422, 12, 17133, 63, 1580, 304, 272, 408, 799, 3357, 4637, 267, 768, 635, 291, 26, 710, 909, 7849, 267, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 768, 635, 1747, 26, 314, 1453, 922, 21045, 83, 2870, 367, 6391, 5920, 12, 267, 768, 635, 4422, 26, 5854, 1159, 2870, 267, 768, 635, 17133, 63, 1580, 26, 437, 561, 12203, 1159, 11449, 272, 408, 339, 4112, 275, 221, 942, 272, 2467, 14, 2526, 10505, 267, 3504, 519, 14, 3710, 63, 344, 267, 687, 522, 63, 3899, 63, 470, 63, 3899, 63, 3710, 63, 3369, 519, 3602, 4263, 2467, 77, 63, 26926, 308, 641, 334, 82, 14, 3710, 63, 344, 275, 308, 14, 3533, 63, 344, 9, 267, 2382, 519, 14, 3899, 63, 344, 275, 450, 83, 436, 334, 83, 14, 476, 1016, 338, 70, 275, 3055, 503, 308, 14, 476, 1016, 338, 70, 365, 2973, 9, 267, 21281, 334, 3150, 4641, 272, 367, 671, 315, 2467, 14, 10174, 837, 267, 4112, 14, 740, 8, 88, 59, 16, 566, 339, 1827, 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,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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 ]
jianglu/mojo
third_party/android_platform/development/scripts/stack_core.py
49
10687
#!/usr/bin/env python # # Copyright (C) 2013 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """stack symbolizes native crash dumps.""" import re import symbol def PrintTraceLines(trace_lines): """Print back trace.""" maxlen = max(map(lambda tl: len(tl[1]), trace_lines)) print print "Stack Trace:" print " RELADDR " + "FUNCTION".ljust(maxlen) + " FILE:LINE" for tl in trace_lines: (addr, symbol_with_offset, location) = tl print " %8s %s %s" % (addr, symbol_with_offset.ljust(maxlen), location) return def PrintValueLines(value_lines): """Print stack data values.""" maxlen = max(map(lambda tl: len(tl[2]), value_lines)) print print "Stack Data:" print " ADDR VALUE " + "FUNCTION".ljust(maxlen) + " FILE:LINE" for vl in value_lines: (addr, value, symbol_with_offset, location) = vl print " %8s %8s %s %s" % (addr, value, symbol_with_offset.ljust(maxlen), location) return UNKNOWN = "<unknown>" HEAP = "[heap]" STACK = "[stack]" def PrintOutput(trace_lines, value_lines, more_info): if trace_lines: PrintTraceLines(trace_lines) if value_lines: # TODO(cjhopman): it seems that symbol.SymbolInformation always fails to # find information for addresses in value_lines in chrome libraries, and so # value_lines have little value to us and merely clutter the output. # Since information is sometimes contained in these lines (from system # libraries), don't completely disable them. if more_info: PrintValueLines(value_lines) def PrintDivider(): print print "-----------------------------------------------------\n" def ConvertTrace(lines, more_info): """Convert strings containing native crash to a stack.""" process_info_line = re.compile("(pid: [0-9]+, tid: [0-9]+.*)") signal_line = re.compile("(signal [0-9]+ \(.*\).*)") register_line = re.compile("(([ ]*[0-9a-z]{2} [0-9a-f]{8}){4})") thread_line = re.compile("(.*)(\-\-\- ){15}\-\-\-") dalvik_jni_thread_line = re.compile("(\".*\" prio=[0-9]+ tid=[0-9]+ NATIVE.*)") dalvik_native_thread_line = re.compile("(\".*\" sysTid=[0-9]+ nice=[0-9]+.*)") width = "{8}" if symbol.ARCH == "arm64" or symbol.ARCH == "x86_64": width = "{16}" # Matches LOG(FATAL) lines, like the following example: # [FATAL:source_file.cc(33)] Check failed: !instances_.empty() log_fatal_line = re.compile("(\[FATAL\:.*\].*)$") # Note that both trace and value line matching allow for variable amounts of # whitespace (e.g. \t). This is because the we want to allow for the stack # tool to operate on AndroidFeedback provided system logs. AndroidFeedback # strips out double spaces that are found in tombsone files and logcat output. # # Examples of matched trace lines include lines from tombstone files like: # #00 pc 001cf42e /data/data/com.my.project/lib/libmyproject.so # #00 pc 001cf42e /data/data/com.my.project/lib/libmyproject.so (symbol) # Or lines from AndroidFeedback crash report system logs like: # 03-25 00:51:05.520 I/DEBUG ( 65): #00 pc 001cf42e /data/data/com.my.project/lib/libmyproject.so # Please note the spacing differences. trace_line = re.compile("(.*)\#(?P<frame>[0-9]+)[ \t]+(..)[ \t]+(0x)?(?P<address>[0-9a-f]{0,16})[ \t]+(?P<lib>[^\r\n \t]*)(?P<symbol_present> \((?P<symbol_name>.*)\))?") # pylint: disable-msg=C6310 # Matches lines emitted by src/base/debug/stack_trace_android.cc, like: # #00 0x7324d92d /data/app-lib/org.chromium.native_test-1/libbase.cr.so+0x0006992d # This pattern includes the unused named capture groups <symbol_present> and # <symbol_name> so that it can interoperate with the |trace_line| regex. debug_trace_line = re.compile( '(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]' + width + ') ' '(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]' + width + ')' '(?P<symbol_present>)(?P<symbol_name>)') # Examples of matched value lines include: # bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so # bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so (symbol) # 03-25 00:51:05.530 I/DEBUG ( 65): bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so # Again, note the spacing differences. value_line = re.compile("(.*)([0-9a-f]" + width + ")[ \t]+([0-9a-f]" + width + ")[ \t]+([^\r\n \t]*)( \((.*)\))?") # Lines from 'code around' sections of the output will be matched before # value lines because otheriwse the 'code around' sections will be confused as # value lines. # # Examples include: # 801cf40c ffffc4cc 00b2f2c5 00b2f1c7 00c1e1a8 # 03-25 00:51:05.530 I/DEBUG ( 65): 801cf40c ffffc4cc 00b2f2c5 00b2f1c7 00c1e1a8 code_line = re.compile("(.*)[ \t]*[a-f0-9]" + width + "[ \t]*[a-f0-9]" + width + "[ \t]*[a-f0-9]" + width + "[ \t]*[a-f0-9]" + width + "[ \t]*[a-f0-9]" + width + "[ \t]*[ \r\n]") # pylint: disable-msg=C6310 trace_lines = [] value_lines = [] last_frame = -1 # It is faster to get symbol information with a single call rather than with # separate calls for each line. Since symbol.SymbolInformation caches results, # we can extract all the addresses that we will want symbol information for # from the log and call symbol.SymbolInformation so that the results are # cached in the following lookups. code_addresses = {} for ln in lines: line = unicode(ln, errors='ignore') lib, address = None, None match = trace_line.match(line) or debug_trace_line.match(line) if match: address, lib = match.group('address', 'lib') match = value_line.match(line) if match and not code_line.match(line): (_0, _1, address, lib, _2, _3) = match.groups() if lib: code_addresses.setdefault(lib, set()).add(address) for lib in code_addresses: symbol.SymbolInformationForSet( symbol.TranslateLibPath(lib), code_addresses[lib], more_info) for ln in lines: # AndroidFeedback adds zero width spaces into its crash reports. These # should be removed or the regular expresssions will fail to match. line = unicode(ln, errors='ignore') process_header = process_info_line.search(line) signal_header = signal_line.search(line) register_header = register_line.search(line) thread_header = thread_line.search(line) dalvik_jni_thread_header = dalvik_jni_thread_line.search(line) dalvik_native_thread_header = dalvik_native_thread_line.search(line) log_fatal_header = log_fatal_line.search(line) if (process_header or signal_header or register_header or thread_header or dalvik_jni_thread_header or dalvik_native_thread_header or log_fatal_header) : if trace_lines or value_lines: PrintOutput(trace_lines, value_lines, more_info) PrintDivider() trace_lines = [] value_lines = [] last_frame = -1 if process_header: print process_header.group(1) if signal_header: print signal_header.group(1) if register_header: print register_header.group(1) if thread_header: print thread_header.group(1) if dalvik_jni_thread_header: print dalvik_jni_thread_header.group(1) if dalvik_native_thread_header: print dalvik_native_thread_header.group(1) if log_fatal_header: print log_fatal_header.group(1) continue match = trace_line.match(line) or debug_trace_line.match(line) if match: frame, code_addr, area, symbol_present, symbol_name = match.group( 'frame', 'address', 'lib', 'symbol_present', 'symbol_name') if frame <= last_frame and (trace_lines or value_lines): PrintOutput(trace_lines, value_lines, more_info) PrintDivider() trace_lines = [] value_lines = [] last_frame = frame if area == UNKNOWN or area == HEAP or area == STACK: trace_lines.append((code_addr, "", area)) else: # If a calls b which further calls c and c is inlined to b, we want to # display "a -> b -> c" in the stack trace instead of just "a -> c" info = symbol.SymbolInformation(area, code_addr, more_info) nest_count = len(info) - 1 for (source_symbol, source_location, object_symbol_with_offset) in info: if not source_symbol: if symbol_present: source_symbol = symbol.CallCppFilt(symbol_name) else: source_symbol = UNKNOWN if not source_location: source_location = area if nest_count > 0: nest_count = nest_count - 1 trace_lines.append(("v------>", source_symbol, source_location)) else: if not object_symbol_with_offset: object_symbol_with_offset = source_symbol trace_lines.append((code_addr, object_symbol_with_offset, source_location)) if code_line.match(line): # Code lines should be ignored. If this were exluded the 'code around' # sections would trigger value_line matches. continue; match = value_line.match(line) if match: (unused_, addr, value, area, symbol_present, symbol_name) = match.groups() if area == UNKNOWN or area == HEAP or area == STACK or not area: value_lines.append((addr, value, "", area)) else: info = symbol.SymbolInformation(area, value, more_info) (source_symbol, source_location, object_symbol_with_offset) = info.pop() if not source_symbol: if symbol_present: source_symbol = symbol.CallCppFilt(symbol_name) else: source_symbol = UNKNOWN if not source_location: source_location = area if not object_symbol_with_offset: object_symbol_with_offset = source_symbol value_lines.append((addr, value, object_symbol_with_offset, source_location)) PrintOutput(trace_lines, value_lines, more_info)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2340, 4678, 656, 19030, 397, 5438, 12420, 16864, 1041, 199, 199, 646, 295, 199, 199, 646, 5272, 199, 199, 318, 9101, 3921, 9863, 8, 3446, 63, 1278, 304, 523, 408, 5375, 1771, 3307, 1041, 523, 21037, 275, 1390, 8, 1130, 8, 2734, 25168, 26, 822, 8, 5019, 59, 17, 2522, 3307, 63, 1278, 430, 523, 870, 523, 870, 298, 4851, 11680, 5424, 523, 870, 298, 221, 820, 2901, 7803, 257, 298, 435, 298, 15476, 1674, 19996, 8, 29078, 9, 435, 298, 221, 13024, 26, 6174, 2, 523, 367, 25168, 315, 3307, 63, 1278, 26, 272, 334, 2697, 12, 5272, 63, 1045, 63, 2743, 12, 2909, 9, 275, 25168, 272, 870, 298, 221, 450, 24, 83, 221, 450, 83, 221, 450, 83, 2, 450, 334, 2697, 12, 5272, 63, 1045, 63, 2743, 14, 19996, 8, 29078, 395, 2909, 9, 523, 372, 421, 199, 318, 9101, 1110, 9863, 8, 585, 63, 1278, 304, 523, 408, 5375, 3464, 666, 1338, 1041, 523, 21037, 275, 1390, 8, 1130, 8, 2734, 25168, 26, 822, 8, 5019, 59, 18, 2522, 574, 63, 1278, 430, 523, 870, 523, 870, 298, 4851, 3918, 5424, 523, 870, 298, 221, 16271, 4564, 420, 21170, 258, 298, 435, 298, 15476, 1674, 19996, 8, 29078, 9, 435, 298, 221, 13024, 26, 6174, 2, 523, 367, 17876, 315, 574, 63, 1278, 26, 272, 334, 2697, 12, 574, 12, 5272, 63, 1045, 63, 2743, 12, 2909, 9, 275, 17876, 272, 870, 298, 221, 450, 24, 83, 221, 450, 24, 83, 221, 450, 83, 221, 450, 83, 2, 450, 334, 2697, 12, 574, 12, 5272, 63, 1045, 63, 2743, 14, 19996, 8, 29078, 395, 2909, 9, 523, 372, 199, 199, 11588, 275, 3886, 5187, 4335, 199, 23707, 275, 7369, 12492, 8480, 199, 17014, 275, 7369, 2340, 8480, 421, 199, 318, 9101, 2959, 8, 3446, 63, 1278, 12, 574, 63, 1278, 12, 1655, 63, 815, 304, 523, 340, 3307, 63, 1278, 26, 272, 9101, 3921, 9863, 8, 3446, 63, 1278, 9, 523, 340, 574, 63, 1278, 26, 272, 327, 3254, 8, 24862, 13376, 1237, 304, 652, 12237, 626, 5272, 14, 8169, 4935, 3544, 6918, 370, 272, 327, 2342, 2556, 367, 7149, 315, 574, 63, 1278, 315, 18221, 8363, 12, 436, 880, 272, 327, 574, 63, 1278, 1172, 12050, 574, 370, 2739, 436, 562, 264, 590, 824, 18404, 314, 1072, 14, 272, 327, 9336, 2556, 365, 15026, 10470, 315, 3520, 2385, 334, 504, 2656, 272, 327, 8363, 395, 2793, 1133, 14793, 3507, 3062, 14, 272, 340, 1655, 63, 815, 26, 489, 9101, 1110, 9863, 8, 585, 63, 1278, 9, 199, 199, 318, 9101, 1341, 2922, 837, 523, 870, 523, 870, 298, 6489, 375, 2696, 78, 2, 199, 199, 318, 7905, 3921, 8, 1278, 12, 1655, 63, 815, 304, 523, 408, 7306, 3326, 3035, 5438, 12420, 370, 282, 3464, 1041, 523, 2112, 63, 815, 63, 604, 275, 295, 14, 2014, 18353, 3150, 26, 359, 16, 13, 25, 2807, 12, 11559, 26, 359, 16, 13, 25, 2807, 2795, 6320, 523, 4673, 63, 604, 275, 295, 14, 2014, 18353, 4653, 359, 16, 13, 25, 2807, 25445, 17910, 680, 10, 6320, 523, 2274, 63, 604, 275, 295, 14, 2014, 18353, 779, 1622, 23033, 16, 13, 25, 65, 13, 90, 8194, 18, 93, 359, 16, 13, 25, 65, 13, 70, 8194, 24, 1552, 91, 20, 1552, 531, 523, 2462, 63, 604, 275, 295, 14, 2014, 18353, 2795, 10127, 2696, 2696, 13, 776, 91, 1046, 4988, 2696, 2696, 13, 531, 523, 366, 279, 433, 75, 63, 74, 8445, 63, 2671, 63, 604, 275, 295, 14, 2014, 480, 2961, 1674, 10, 4451, 20449, 1524, 16, 13, 25, 2807, 11559, 1524, 16, 13, 25, 2807, 653, 14277, 2795, 6320, 523, 366, 279, 433, 75, 63, 6106, 63, 2671, 63, 604, 275, 295, 14, 2014, 480, 2961, 1674, 10, 4451, 984, 32487, 1524, 16, 13, 25, 2807, 14213, 1524, 16, 13, 25, 2807, 2795, 6320, 819, 3462, 275, 5310, 24, 7063, 523, 340, 5272, 14, 7762, 508, 298, 5362, 772, 2, 503, 5272, 14, 7762, 508, 298, 88, 1184, 63, 772, 582, 272, 3462, 275, 5310, 975, 7063, 819, 327, 21682, 5051, 8, 29086, 9, 2385, 12, 2839, 314, 2569, 2893, 26, 523, 327, 257, 359, 29086, 26, 1365, 63, 493, 14, 2055, 8, 1153, 1874, 2670, 3405, 26, 8546, 5990, 3754, 1667, 342, 523, 943, 63, 16208, 63, 604, 275, 295, 14, 2014, 480, 2961, 59, 29086, 60, 26, 17910, 1055, 13278, 22550, 819, 327, 3390, 626, 3865, 3307, 436, 574, 1004, 4877, 2040, 367, 1750, 32247, 402, 523, 327, 8139, 334, 69, 14, 71, 14, 971, 84, 680, 961, 365, 2952, 314, 781, 2934, 370, 2040, 367, 314, 3464, 523, 327, 4744, 370, 19218, 641, 14694, 28687, 2741, 2656, 9610, 14, 14694, 28687, 523, 327, 32384, 734, 4270, 7883, 626, 787, 1911, 315, 370, 887, 83, 368, 1584, 436, 943, 3385, 1072, 14, 523, 327, 523, 327, 6058, 402, 7838, 3307, 2385, 2387, 2385, 687, 370, 887, 8361, 1584, 2839, 26, 523, 327, 257, 327, 383, 221, 13171, 378, 614, 2177, 2260, 69, 221, 1182, 576, 15, 576, 15, 957, 14, 1662, 14, 1715, 15, 773, 15, 773, 1662, 1715, 14, 1152, 523, 327, 257, 327, 383, 221, 13171, 378, 614, 2177, 2260, 69, 221, 1182, 576, 15, 576, 15, 957, 14, 1662 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2340, 4678, 656, 19030, 397, 5438, 12420, 16864, 1041, 199, 199, 646, 295, 199, 199, 646, 5272, 199, 199, 318, 9101, 3921, 9863, 8, 3446, 63, 1278, 304, 523, 408, 5375, 1771, 3307, 1041, 523, 21037, 275, 1390, 8, 1130, 8, 2734, 25168, 26, 822, 8, 5019, 59, 17, 2522, 3307, 63, 1278, 430, 523, 870, 523, 870, 298, 4851, 11680, 5424, 523, 870, 298, 221, 820, 2901, 7803, 257, 298, 435, 298, 15476, 1674, 19996, 8, 29078, 9, 435, 298, 221, 13024, 26, 6174, 2, 523, 367, 25168, 315, 3307, 63, 1278, 26, 272, 334, 2697, 12, 5272, 63, 1045, 63, 2743, 12, 2909, 9, 275, 25168, 272, 870, 298, 221, 450, 24, 83, 221, 450, 83, 221, 450, 83, 2, 450, 334, 2697, 12, 5272, 63, 1045, 63, 2743, 14, 19996, 8, 29078, 395, 2909, 9, 523, 372, 421, 199, 318, 9101, 1110, 9863, 8, 585, 63, 1278, 304, 523, 408, 5375, 3464, 666, 1338, 1041, 523, 21037, 275, 1390, 8, 1130, 8, 2734, 25168, 26, 822, 8, 5019, 59, 18, 2522, 574, 63, 1278, 430, 523, 870, 523, 870, 298, 4851, 3918, 5424, 523, 870, 298, 221, 16271, 4564, 420, 21170, 258, 298, 435, 298, 15476, 1674, 19996, 8, 29078, 9, 435, 298, 221, 13024, 26, 6174, 2, 523, 367, 17876, 315, 574, 63, 1278, 26, 272, 334, 2697, 12, 574, 12, 5272, 63, 1045, 63, 2743, 12, 2909, 9, 275, 17876, 272, 870, 298, 221, 450, 24, 83, 221, 450, 24, 83, 221, 450, 83, 221, 450, 83, 2, 450, 334, 2697, 12, 574, 12, 5272, 63, 1045, 63, 2743, 14, 19996, 8, 29078, 395, 2909, 9, 523, 372, 199, 199, 11588, 275, 3886, 5187, 4335, 199, 23707, 275, 7369, 12492, 8480, 199, 17014, 275, 7369, 2340, 8480, 421, 199, 318, 9101, 2959, 8, 3446, 63, 1278, 12, 574, 63, 1278, 12, 1655, 63, 815, 304, 523, 340, 3307, 63, 1278, 26, 272, 9101, 3921, 9863, 8, 3446, 63, 1278, 9, 523, 340, 574, 63, 1278, 26, 272, 327, 3254, 8, 24862, 13376, 1237, 304, 652, 12237, 626, 5272, 14, 8169, 4935, 3544, 6918, 370, 272, 327, 2342, 2556, 367, 7149, 315, 574, 63, 1278, 315, 18221, 8363, 12, 436, 880, 272, 327, 574, 63, 1278, 1172, 12050, 574, 370, 2739, 436, 562, 264, 590, 824, 18404, 314, 1072, 14, 272, 327, 9336, 2556, 365, 15026, 10470, 315, 3520, 2385, 334, 504, 2656, 272, 327, 8363, 395, 2793, 1133, 14793, 3507, 3062, 14, 272, 340, 1655, 63, 815, 26, 489, 9101, 1110, 9863, 8, 585, 63, 1278, 9, 199, 199, 318, 9101, 1341, 2922, 837, 523, 870, 523, 870, 298, 6489, 375, 2696, 78, 2, 199, 199, 318, 7905, 3921, 8, 1278, 12, 1655, 63, 815, 304, 523, 408, 7306, 3326, 3035, 5438, 12420, 370, 282, 3464, 1041, 523, 2112, 63, 815, 63, 604, 275, 295, 14, 2014, 18353, 3150, 26, 359, 16, 13, 25, 2807, 12, 11559, 26, 359, 16, 13, 25, 2807, 2795, 6320, 523, 4673, 63, 604, 275, 295, 14, 2014, 18353, 4653, 359, 16, 13, 25, 2807, 25445, 17910, 680, 10, 6320, 523, 2274, 63, 604, 275, 295, 14, 2014, 18353, 779, 1622, 23033, 16, 13, 25, 65, 13, 90, 8194, 18, 93, 359, 16, 13, 25, 65, 13, 70, 8194, 24, 1552, 91, 20, 1552, 531, 523, 2462, 63, 604, 275, 295, 14, 2014, 18353, 2795, 10127, 2696, 2696, 13, 776, 91, 1046, 4988, 2696, 2696, 13, 531, 523, 366, 279, 433, 75, 63, 74, 8445, 63, 2671, 63, 604, 275, 295, 14, 2014, 480, 2961, 1674, 10, 4451, 20449, 1524, 16, 13, 25, 2807, 11559, 1524, 16, 13, 25, 2807, 653, 14277, 2795, 6320, 523, 366, 279, 433, 75, 63, 6106, 63, 2671, 63, 604, 275, 295, 14, 2014, 480, 2961, 1674, 10, 4451, 984, 32487, 1524, 16, 13, 25, 2807, 14213, 1524, 16, 13, 25, 2807, 2795, 6320, 819, 3462, 275, 5310, 24, 7063, 523, 340, 5272, 14, 7762, 508, 298, 5362, 772, 2, 503, 5272, 14, 7762, 508, 298, 88, 1184, 63, 772, 582, 272, 3462, 275, 5310, 975, 7063, 819, 327, 21682, 5051, 8, 29086, 9, 2385, 12, 2839, 314, 2569, 2893, 26, 523, 327, 257, 359, 29086, 26, 1365, 63, 493, 14, 2055, 8, 1153, 1874, 2670, 3405, 26, 8546, 5990, 3754, 1667, 342, 523, 943, 63, 16208, 63, 604, 275, 295, 14, 2014, 480, 2961, 59, 29086, 60, 26, 17910, 1055, 13278, 22550, 819, 327, 3390, 626, 3865, 3307, 436, 574, 1004, 4877, 2040, 367, 1750, 32247, 402, 523, 327, 8139, 334, 69, 14, 71, 14, 971, 84, 680, 961, 365, 2952, 314, 781, 2934, 370, 2040, 367, 314, 3464, 523, 327, 4744, 370, 19218, 641, 14694, 28687, 2741, 2656, 9610, 14, 14694, 28687, 523, 327, 32384, 734, 4270, 7883, 626, 787, 1911, 315, 370, 887, 83, 368, 1584, 436, 943, 3385, 1072, 14, 523, 327, 523, 327, 6058, 402, 7838, 3307, 2385, 2387, 2385, 687, 370, 887, 8361, 1584, 2839, 26, 523, 327, 257, 327, 383, 221, 13171, 378, 614, 2177, 2260, 69, 221, 1182, 576, 15, 576, 15, 957, 14, 1662, 14, 1715, 15, 773, 15, 773, 1662, 1715, 14, 1152, 523, 327, 257, 327, 383, 221, 13171, 378, 614, 2177, 2260, 69, 221, 1182, 576, 15, 576, 15, 957, 14, 1662, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rbarlow/pulp_docker
plugins/pulp_docker/plugins/importers/sync.py
1
16753
""" This module contains the primary sync entry point for Docker v2 registries. """ from gettext import gettext as _ import errno import httplib import itertools import logging import os from pulp.common.plugins import importer_constants from pulp.plugins.util import nectar_config, publish_step from pulp.server.controllers import repository from pulp.server.exceptions import MissingValue, PulpCodedException from pulp_docker.common import constants, error_codes from pulp_docker.plugins import models, registry, token_util from pulp_docker.plugins.importers import v1_sync _logger = logging.getLogger(__name__) class SyncStep(publish_step.PluginStep): """ This PluginStep is the primary entry point into a repository sync against a Docker v2 registry. """ # The sync will fail if these settings are not provided in the config required_settings = (constants.CONFIG_KEY_UPSTREAM_NAME, importer_constants.KEY_FEED) def __init__(self, repo=None, conduit=None, config=None): """ This method initializes the SyncStep. It first validates the config to ensure that the required keys are present. It then constructs some needed items (such as a download config), and determines whether the feed URL is a Docker v2 registry or not. If it is, it instantiates child tasks that are appropriate for syncing a v2 registry, and if it is not it raises a NotImplementedError. :param repo: repository to sync :type repo: pulp.plugins.model.Repository :param conduit: sync conduit to use :type conduit: pulp.plugins.conduits.repo_sync.RepoSyncConduit :param config: config object for the sync :type config: pulp.plugins.config.PluginCallConfiguration """ super(SyncStep, self).__init__( step_type=constants.SYNC_STEP_MAIN, repo=repo, conduit=conduit, config=config, plugin_type=constants.IMPORTER_TYPE_ID) self.description = _('Syncing Docker Repository') self._validate(config) download_config = nectar_config.importer_config_to_nectar_config(config.flatten()) upstream_name = config.get(constants.CONFIG_KEY_UPSTREAM_NAME) url = config.get(importer_constants.KEY_FEED) # The DownloadMetadataSteps will set these to a list of Manifests and Blobs self.available_manifests = [] self.available_blobs = [] # Unit keys, populated by v1_sync.GetMetadataStep self.v1_available_units = [] # populated by v1_sync.GetMetadataStep self.v1_tags = {} # Create a Repository object to interact with. self.index_repository = registry.V2Repository( upstream_name, download_config, url, self.get_working_dir()) self.v1_index_repository = registry.V1Repository(upstream_name, download_config, url, self.get_working_dir()) # determine which API versions are supported and add corresponding steps v2_enabled = config.get(constants.CONFIG_KEY_ENABLE_V2, default=True) v1_enabled = config.get(constants.CONFIG_KEY_ENABLE_V1, default=False) if not v2_enabled: _logger.debug(_('v2 API skipped due to config')) if not v1_enabled: _logger.debug(_('v1 API skipped due to config')) v2_found = v2_enabled and self.index_repository.api_version_check() v1_found = v1_enabled and self.v1_index_repository.api_version_check() if v2_found: _logger.debug(_('v2 API found')) self.add_v2_steps(repo, conduit, config) if v1_found: _logger.debug(_('v1 API found')) self.add_v1_steps(repo, config) if not any((v1_found, v2_found)): raise PulpCodedException(error_code=error_codes.DKR1008, registry=url) def add_v2_steps(self, repo, conduit, config): """ Add v2 sync steps. :param repo: repository to sync :type repo: pulp.plugins.model.Repository :param conduit: sync conduit to use :type conduit: pulp.plugins.conduits.repo_sync.RepoSyncConduit :param config: config object for the sync :type config: pulp.plugins.config.PluginCallConfiguration """ self.add_child(DownloadManifestsStep(repo=repo, conduit=conduit, config=config)) # save these steps so their "units_to_download" attributes can be accessed later. We want # them to be separate steps because we have already downloaded all the Manifests but should # only save the new ones, while needing to go download the missing Blobs. Thus they must be # handled separately. self.step_get_local_manifests = publish_step.GetLocalUnitsStep( importer_type=constants.IMPORTER_TYPE_ID, available_units=self.available_manifests) self.step_get_local_blobs = publish_step.GetLocalUnitsStep( importer_type=constants.IMPORTER_TYPE_ID, available_units=self.available_blobs) self.add_child(self.step_get_local_manifests) self.add_child(self.step_get_local_blobs) self.add_child( TokenAuthDownloadStep( step_type=constants.SYNC_STEP_DOWNLOAD, downloads=self.generate_download_requests(), repo=self.repo, config=self.config, description=_('Downloading remote files'))) self.add_child(SaveUnitsStep()) self.save_tags_step = SaveTagsStep() self.add_child(self.save_tags_step) def add_v1_steps(self, repo, config): """ Add v1 sync steps. :param repo: repository to sync :type repo: pulp.plugins.model.Repository :param config: config object for the sync :type config: pulp.plugins.config.PluginCallConfiguration """ self.add_child(v1_sync.GetMetadataStep()) # save this step so its "units_to_download" attribute can be accessed later self.v1_step_get_local_units = publish_step.GetLocalUnitsStep( constants.IMPORTER_TYPE_ID, available_units=self.v1_available_units) self.v1_step_get_local_units.step_id = constants.SYNC_STEP_GET_LOCAL_V1 self.add_child(self.v1_step_get_local_units) self.add_child(publish_step.DownloadStep( constants.SYNC_STEP_DOWNLOAD_V1, downloads=self.v1_generate_download_requests(), repo=repo, config=config, description=_('Downloading remote files'))) self.add_child(v1_sync.SaveImages()) def generate_download_requests(self): """ a generator that yields DownloadRequest objects based on which units were determined to be needed. This looks at the GetLocalUnits step's output, which includes a list of units that need their files downloaded. :return: generator of DownloadRequest instances :rtype: types.GeneratorType """ for unit in self.step_get_local_blobs.units_to_download: yield self.index_repository.create_blob_download_request(unit.digest) def v1_generate_download_requests(self): """ a generator that yields DownloadRequest objects based on which units were determined to be needed. This looks at the GetLocalUnits step's output, which includes a list of units that need their files downloaded. :return: generator of DownloadRequest instances :rtype: types.GeneratorType """ for unit in self.v1_step_get_local_units.units_to_download: destination_dir = os.path.join(self.get_working_dir(), unit.image_id) try: os.makedirs(destination_dir, mode=0755) except OSError, e: # it's ok if the directory exists if e.errno != errno.EEXIST: raise # we already retrieved the ancestry files for the tagged images, so # some of these will already exist if not os.path.exists(os.path.join(destination_dir, 'ancestry')): yield self.v1_index_repository.create_download_request(unit.image_id, 'ancestry', destination_dir) yield self.v1_index_repository.create_download_request(unit.image_id, 'json', destination_dir) yield self.v1_index_repository.create_download_request(unit.image_id, 'layer', destination_dir) @classmethod def _validate(cls, config): """ Ensure that any required settings have non-empty values. :param config: config object for the sync :type config: pulp.plugins.config.PluginCallConfiguration :raises MissingValue: if any required sync setting is missing """ missing = [] for key in cls.required_settings: if not config.get(key): missing.append(key) if missing: raise MissingValue(missing) class DownloadManifestsStep(publish_step.PluginStep): def __init__(self, repo=None, conduit=None, config=None): """ :param repo: repository to sync :type repo: pulp.plugins.model.Repository :param conduit: sync conduit to use :type conduit: pulp.plugins.conduits.repo_sync.RepoSyncConduit :param config: config object for the sync :type config: pulp.plugins.config.PluginCallConfiguration """ super(DownloadManifestsStep, self).__init__( step_type=constants.SYNC_STEP_METADATA, repo=repo, conduit=conduit, config=config, plugin_type=constants.IMPORTER_TYPE_ID) self.description = _('Downloading manifests') def process_main(self): """ Determine which manifests and blobs are available upstream, get the upstream tags, and save a list of available unit keys and manifests on the SyncStep. """ super(DownloadManifestsStep, self).process_main() _logger.debug(self.description) try: available_tags = self.parent.index_repository.get_tags() except IOError: _logger.info(_('Could not get tags through v2 API')) return # This will be a set of Blob digests. The set is used because they can be repeated and we # only want to download each layer once. available_blobs = set() self.total_units = len(available_tags) for tag in available_tags: digest, manifest = self.parent.index_repository.get_manifest(tag) # Save the manifest to the working directory with open(os.path.join(self.get_working_dir(), digest), 'w') as manifest_file: manifest_file.write(manifest) manifest = models.Manifest.from_json(manifest, digest) self.parent.available_manifests.append(manifest) for layer in manifest.fs_layers: available_blobs.add(layer.blob_sum) # Remember this tag for the SaveTagsStep. self.parent.save_tags_step.tagged_manifests[tag] = manifest self.progress_successes += 1 # Update the available units with the Manifests and Blobs we learned about available_blobs = [models.Blob(digest=d) for d in available_blobs] self.parent.available_blobs.extend(available_blobs) class SaveUnitsStep(publish_step.SaveUnitsStep): """ Save the Units that need to be added to the repository and move them to the content folder. """ def __init__(self): """ Initialize the step, setting its description. """ super(SaveUnitsStep, self).__init__(step_type=constants.SYNC_STEP_SAVE) self.description = _('Saving Manifests and Blobs') def get_iterator(self): """ Return an iterator that will traverse the list of Units that were downloaded. :return: An iterable containing the Blobs and Manifests that were downloaded and are new to Pulp. :rtype: iterator """ return iter(itertools.chain(self.parent.step_get_local_blobs.units_to_download, self.parent.step_get_local_manifests.units_to_download)) def process_main(self, item): """ This method gets called with each Unit that was downloaded from the parent step. It moves each Unit's files into permanent storage, and saves each Unit into the database and into the repository. :param item: The Unit to save in Pulp. :type item: pulp.server.db.model.FileContentUnit """ item.set_storage_path(item.digest) item.save_and_import_content(os.path.join(self.get_working_dir(), item.digest)) repository.associate_single_unit(self.get_repo().repo_obj, item) class SaveTagsStep(publish_step.SaveUnitsStep): """ Create or update Tag objects to reflect the tags that we found during the sync. """ def __init__(self): """ Initialize the step, setting its description. """ super(SaveTagsStep, self).__init__(step_type=constants.SYNC_STEP_SAVE) self.description = _('Saving Tags') # This dictionary maps tag named to Manifests that have the tag in the remote repository self.tagged_manifests = {} def process_main(self): """ For each tag found in the remote repository, if a Tag object exists in this repository we need to make sure its manifest_digest attribute points at this Manifest. If not, we need to create one. We'll rely on the uniqueness constraint in MongoDB to allow us to try to create it, and if that fails we'll fall back to updating the existing one. """ tagged_manifest_items = self.tagged_manifests.items() self.total_units = len(tagged_manifest_items) for tag, manifest in tagged_manifest_items: new_tag = models.Tag.objects.tag_manifest(repo_id=self.get_repo().repo_obj.repo_id, tag_name=tag, manifest_digest=manifest.digest) if new_tag: repository.associate_single_unit(self.get_repo().repo_obj, new_tag) self.progress_successes += 1 class TokenAuthDownloadStep(publish_step.DownloadStep): """ Download remote files. For v2, this may require a bearer token to be used. This step attempts to download files, and if it fails due to a 401, it will retrieve the auth token and retry the download. """ def __init__(self, step_type, downloads=None, repo=None, conduit=None, config=None, working_dir=None, plugin_type=None, description=''): """ Initialize the step, setting its description. """ super(TokenAuthDownloadStep, self).__init__( step_type, downloads=downloads, repo=repo, conduit=conduit, config=config, working_dir=working_dir, plugin_type=plugin_type) self.description = _('Downloading remote files') self.token = None self._requests_map = {} def process_main(self, item=None): """ Overrides the parent method to get a new token and try again if response is a 401. """ # Allow the original request to be retrieved from the url. for request in self.downloads: self._requests_map[request.url] = request for request in self.downloads: if self.token: token_util.add_auth_header(request, self.token) self.downloader.download_one(request, events=True) def download_failed(self, report): """ If the download fails due to a 401, attempt to retreive a token and try again. :param report: download report :type report: nectar.report.DownloadReport """ if report.error_report.get('response_code') == httplib.UNAUTHORIZED: _logger.debug(_('Download unauthorized, attempting to retrieve a token.')) request = self._requests_map[report.url] token = token_util.request_token(self.downloader, request, report.headers) token_util.add_auth_header(request, token) _logger.debug("Trying download again with new bearer token.") report = self.downloader.download_one(request, events=True) if report.state == report.DOWNLOAD_FAILED: super(TokenAuthDownloadStep, self).download_failed(report)
gpl-2.0
[ 624, 199, 2765, 859, 3509, 314, 5062, 7604, 2397, 2376, 367, 22067, 373, 18, 25483, 1996, 14, 199, 624, 199, 504, 9796, 492, 9796, 465, 485, 199, 646, 7554, 199, 646, 8809, 199, 646, 7975, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 299, 15513, 14, 2330, 14, 5265, 492, 13479, 63, 5559, 199, 504, 299, 15513, 14, 5265, 14, 1974, 492, 302, 449, 285, 63, 888, 12, 2780, 63, 2926, 199, 504, 299, 15513, 14, 1000, 14, 20531, 492, 7611, 199, 504, 299, 15513, 14, 1000, 14, 3924, 492, 15626, 1110, 12, 510, 15513, 3034, 68, 1726, 199, 199, 504, 299, 15513, 63, 9991, 14, 2330, 492, 5262, 12, 1125, 63, 6021, 199, 504, 299, 15513, 63, 9991, 14, 5265, 492, 1709, 12, 7086, 12, 1526, 63, 1974, 199, 504, 299, 15513, 63, 9991, 14, 5265, 14, 3236, 27568, 492, 373, 17, 63, 5186, 421, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 22407, 7801, 8, 4763, 63, 2926, 14, 5061, 7801, 304, 272, 408, 272, 961, 11349, 7801, 365, 314, 5062, 2397, 2376, 1901, 282, 7611, 7604, 6169, 282, 22067, 373, 18, 7086, 14, 272, 408, 272, 327, 710, 7604, 911, 2449, 340, 3520, 2202, 787, 440, 2741, 315, 314, 1101, 272, 1415, 63, 1751, 275, 334, 5559, 14, 5569, 63, 3078, 63, 2160, 9484, 63, 2339, 12, 13479, 63, 5559, 14, 3078, 63, 18068, 9, 339, 347, 636, 826, 721, 277, 12, 3831, 29, 403, 12, 406, 2033, 390, 29, 403, 12, 1101, 29, 403, 304, 267, 408, 267, 961, 1083, 2536, 6491, 314, 22407, 7801, 14, 2779, 1642, 29280, 314, 1101, 370, 4868, 626, 314, 267, 1415, 2883, 787, 3451, 14, 2779, 2066, 21638, 2005, 4346, 2974, 334, 10180, 465, 282, 5235, 1101, 395, 267, 436, 16756, 3775, 314, 4733, 2851, 365, 282, 22067, 373, 18, 7086, 503, 440, 14, 982, 652, 365, 12, 652, 267, 9034, 2335, 1982, 6527, 626, 787, 5827, 367, 7604, 316, 282, 373, 18, 7086, 12, 436, 340, 652, 365, 440, 652, 267, 6534, 282, 4279, 14, 398, 520, 635, 3831, 26, 263, 7611, 370, 7604, 267, 520, 466, 221, 3831, 26, 263, 299, 15513, 14, 5265, 14, 1238, 14, 15614, 267, 520, 635, 406, 2033, 390, 26, 258, 7604, 406, 2033, 390, 370, 675, 267, 520, 466, 221, 406, 2033, 390, 26, 258, 299, 15513, 14, 5265, 14, 388, 2033, 1405, 14, 3417, 63, 5186, 14, 11334, 10878, 714, 2033, 390, 267, 520, 635, 1101, 26, 420, 1101, 909, 367, 314, 7604, 267, 520, 466, 221, 1101, 26, 420, 299, 15513, 14, 5265, 14, 888, 14, 5061, 2176, 5688, 267, 408, 267, 1613, 8, 10878, 7801, 12, 291, 2843, 826, 721, 288, 3650, 63, 466, 29, 5559, 14, 22012, 63, 17988, 63, 5848, 12, 3831, 29, 3417, 12, 406, 2033, 390, 29, 388, 2033, 390, 12, 1101, 29, 888, 12, 288, 3589, 63, 466, 29, 5559, 14, 8947, 726, 1157, 63, 2711, 63, 998, 9, 267, 291, 14, 1802, 275, 4018, 10878, 316, 22067, 24426, 358, 398, 291, 423, 3502, 8, 888, 9, 267, 5235, 63, 888, 275, 302, 449, 285, 63, 888, 14, 12138, 63, 888, 63, 475, 63, 78, 449, 285, 63, 888, 8, 888, 14, 8487, 1012, 267, 18932, 63, 354, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 2160, 9484, 63, 2339, 9, 267, 1166, 275, 1101, 14, 362, 8, 12138, 63, 5559, 14, 3078, 63, 18068, 9, 267, 327, 710, 17955, 5142, 20960, 911, 663, 3520, 370, 282, 769, 402, 4688, 3944, 83, 436, 31745, 83, 267, 291, 14, 4561, 63, 6418, 83, 275, 942, 267, 291, 14, 4561, 63, 21893, 275, 942, 398, 327, 12008, 2883, 12, 16460, 701, 373, 17, 63, 5186, 14, 1002, 5142, 7801, 267, 291, 14, 86, 17, 63, 4561, 63, 5260, 275, 942, 267, 327, 16460, 701, 373, 17, 63, 5186, 14, 1002, 5142, 7801, 267, 291, 14, 86, 17, 63, 2969, 275, 1052, 398, 327, 2790, 282, 24426, 909, 370, 17232, 543, 14, 267, 291, 14, 1080, 63, 8421, 275, 7086, 14, 54, 18, 15614, 8, 288, 18932, 63, 354, 12, 5235, 63, 888, 12, 1166, 12, 291, 14, 362, 63, 9818, 63, 694, 1012, 267, 291, 14, 86, 17, 63, 1080, 63, 8421, 275, 7086, 14, 54, 17, 15614, 8, 20099, 63, 354, 12, 5235, 63, 888, 12, 1166, 12, 12740, 291, 14, 362, 63, 9818, 63, 694, 1012, 398, 327, 6705, 1314, 3261, 5459, 787, 3748, 436, 1050, 5226, 7124, 267, 373, 18, 63, 3827, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 8898, 63, 54, 18, 12, 849, 29, 549, 9, 267, 373, 17, 63, 3827, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 8898, 63, 54, 17, 12, 849, 29, 797, 9, 267, 340, 440, 373, 18, 63, 3827, 26, 288, 485, 2921, 14, 1757, 6723, 86, 18, 3261, 9645, 7037, 370, 1101, 1333, 267, 340, 440, 373, 17, 63, 3827, 26, 288, 485, 2921, 14, 1757, 6723, 86, 17, 3261, 9645, 7037, 370, 1101, 1333, 267, 373, 18, 63, 4214, 275, 373, 18, 63, 3827, 436, 291, 14, 1080, 63, 8421, 14, 1246, 63, 1023, 63, 1074, 342, 267, 373, 17, 63, 4214, 275, 373, 17, 63, 3827, 436, 291, 14, 86, 17, 63, 1080, 63, 8421, 14, 1246, 63, 1023, 63, 1074, 342, 267, 340, 373, 18, 63, 4214, 26, 288, 485, 2921, 14, 1757, 6723, 86, 18, 3261, 1911, 1333, 288, 291, 14, 525, 63, 86, 18, 63, 5895, 8, 3417, 12, 406, 2033, 390, 12, 1101, 9, 267, 340, 373, 17, 63, 4214, 26, 288, 485, 2921, 14, 1757, 6723, 86, 17, 3261, 1911, 1333, 288, 291, 14, 525, 63, 86, 17, 63, 5895, 8, 3417, 12, 1101, 9, 267, 340, 440, 1263, 1332, 86, 17, 63, 4214, 12, 373, 18, 63, 4214, 2298, 288, 746, 510, 15513, 3034, 68, 1726, 8, 705, 63, 600, 29, 705, 63, 6021, 14, 10892, 50, 1960, 24, 12, 7086, 29, 633, 9, 339, 347, 1050, 63, 86, 18, 63, 5895, 8, 277, 12, 3831, 12, 406, 2033, 390, 12, 1101, 304, 267, 408, 267, 2654, 373, 18, 7604, 7124, 14, 398, 520 ]
[ 199, 2765, 859, 3509, 314, 5062, 7604, 2397, 2376, 367, 22067, 373, 18, 25483, 1996, 14, 199, 624, 199, 504, 9796, 492, 9796, 465, 485, 199, 646, 7554, 199, 646, 8809, 199, 646, 7975, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 299, 15513, 14, 2330, 14, 5265, 492, 13479, 63, 5559, 199, 504, 299, 15513, 14, 5265, 14, 1974, 492, 302, 449, 285, 63, 888, 12, 2780, 63, 2926, 199, 504, 299, 15513, 14, 1000, 14, 20531, 492, 7611, 199, 504, 299, 15513, 14, 1000, 14, 3924, 492, 15626, 1110, 12, 510, 15513, 3034, 68, 1726, 199, 199, 504, 299, 15513, 63, 9991, 14, 2330, 492, 5262, 12, 1125, 63, 6021, 199, 504, 299, 15513, 63, 9991, 14, 5265, 492, 1709, 12, 7086, 12, 1526, 63, 1974, 199, 504, 299, 15513, 63, 9991, 14, 5265, 14, 3236, 27568, 492, 373, 17, 63, 5186, 421, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 22407, 7801, 8, 4763, 63, 2926, 14, 5061, 7801, 304, 272, 408, 272, 961, 11349, 7801, 365, 314, 5062, 2397, 2376, 1901, 282, 7611, 7604, 6169, 282, 22067, 373, 18, 7086, 14, 272, 408, 272, 327, 710, 7604, 911, 2449, 340, 3520, 2202, 787, 440, 2741, 315, 314, 1101, 272, 1415, 63, 1751, 275, 334, 5559, 14, 5569, 63, 3078, 63, 2160, 9484, 63, 2339, 12, 13479, 63, 5559, 14, 3078, 63, 18068, 9, 339, 347, 636, 826, 721, 277, 12, 3831, 29, 403, 12, 406, 2033, 390, 29, 403, 12, 1101, 29, 403, 304, 267, 408, 267, 961, 1083, 2536, 6491, 314, 22407, 7801, 14, 2779, 1642, 29280, 314, 1101, 370, 4868, 626, 314, 267, 1415, 2883, 787, 3451, 14, 2779, 2066, 21638, 2005, 4346, 2974, 334, 10180, 465, 282, 5235, 1101, 395, 267, 436, 16756, 3775, 314, 4733, 2851, 365, 282, 22067, 373, 18, 7086, 503, 440, 14, 982, 652, 365, 12, 652, 267, 9034, 2335, 1982, 6527, 626, 787, 5827, 367, 7604, 316, 282, 373, 18, 7086, 12, 436, 340, 652, 365, 440, 652, 267, 6534, 282, 4279, 14, 398, 520, 635, 3831, 26, 263, 7611, 370, 7604, 267, 520, 466, 221, 3831, 26, 263, 299, 15513, 14, 5265, 14, 1238, 14, 15614, 267, 520, 635, 406, 2033, 390, 26, 258, 7604, 406, 2033, 390, 370, 675, 267, 520, 466, 221, 406, 2033, 390, 26, 258, 299, 15513, 14, 5265, 14, 388, 2033, 1405, 14, 3417, 63, 5186, 14, 11334, 10878, 714, 2033, 390, 267, 520, 635, 1101, 26, 420, 1101, 909, 367, 314, 7604, 267, 520, 466, 221, 1101, 26, 420, 299, 15513, 14, 5265, 14, 888, 14, 5061, 2176, 5688, 267, 408, 267, 1613, 8, 10878, 7801, 12, 291, 2843, 826, 721, 288, 3650, 63, 466, 29, 5559, 14, 22012, 63, 17988, 63, 5848, 12, 3831, 29, 3417, 12, 406, 2033, 390, 29, 388, 2033, 390, 12, 1101, 29, 888, 12, 288, 3589, 63, 466, 29, 5559, 14, 8947, 726, 1157, 63, 2711, 63, 998, 9, 267, 291, 14, 1802, 275, 4018, 10878, 316, 22067, 24426, 358, 398, 291, 423, 3502, 8, 888, 9, 267, 5235, 63, 888, 275, 302, 449, 285, 63, 888, 14, 12138, 63, 888, 63, 475, 63, 78, 449, 285, 63, 888, 8, 888, 14, 8487, 1012, 267, 18932, 63, 354, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 2160, 9484, 63, 2339, 9, 267, 1166, 275, 1101, 14, 362, 8, 12138, 63, 5559, 14, 3078, 63, 18068, 9, 267, 327, 710, 17955, 5142, 20960, 911, 663, 3520, 370, 282, 769, 402, 4688, 3944, 83, 436, 31745, 83, 267, 291, 14, 4561, 63, 6418, 83, 275, 942, 267, 291, 14, 4561, 63, 21893, 275, 942, 398, 327, 12008, 2883, 12, 16460, 701, 373, 17, 63, 5186, 14, 1002, 5142, 7801, 267, 291, 14, 86, 17, 63, 4561, 63, 5260, 275, 942, 267, 327, 16460, 701, 373, 17, 63, 5186, 14, 1002, 5142, 7801, 267, 291, 14, 86, 17, 63, 2969, 275, 1052, 398, 327, 2790, 282, 24426, 909, 370, 17232, 543, 14, 267, 291, 14, 1080, 63, 8421, 275, 7086, 14, 54, 18, 15614, 8, 288, 18932, 63, 354, 12, 5235, 63, 888, 12, 1166, 12, 291, 14, 362, 63, 9818, 63, 694, 1012, 267, 291, 14, 86, 17, 63, 1080, 63, 8421, 275, 7086, 14, 54, 17, 15614, 8, 20099, 63, 354, 12, 5235, 63, 888, 12, 1166, 12, 12740, 291, 14, 362, 63, 9818, 63, 694, 1012, 398, 327, 6705, 1314, 3261, 5459, 787, 3748, 436, 1050, 5226, 7124, 267, 373, 18, 63, 3827, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 8898, 63, 54, 18, 12, 849, 29, 549, 9, 267, 373, 17, 63, 3827, 275, 1101, 14, 362, 8, 5559, 14, 5569, 63, 3078, 63, 8898, 63, 54, 17, 12, 849, 29, 797, 9, 267, 340, 440, 373, 18, 63, 3827, 26, 288, 485, 2921, 14, 1757, 6723, 86, 18, 3261, 9645, 7037, 370, 1101, 1333, 267, 340, 440, 373, 17, 63, 3827, 26, 288, 485, 2921, 14, 1757, 6723, 86, 17, 3261, 9645, 7037, 370, 1101, 1333, 267, 373, 18, 63, 4214, 275, 373, 18, 63, 3827, 436, 291, 14, 1080, 63, 8421, 14, 1246, 63, 1023, 63, 1074, 342, 267, 373, 17, 63, 4214, 275, 373, 17, 63, 3827, 436, 291, 14, 86, 17, 63, 1080, 63, 8421, 14, 1246, 63, 1023, 63, 1074, 342, 267, 340, 373, 18, 63, 4214, 26, 288, 485, 2921, 14, 1757, 6723, 86, 18, 3261, 1911, 1333, 288, 291, 14, 525, 63, 86, 18, 63, 5895, 8, 3417, 12, 406, 2033, 390, 12, 1101, 9, 267, 340, 373, 17, 63, 4214, 26, 288, 485, 2921, 14, 1757, 6723, 86, 17, 3261, 1911, 1333, 288, 291, 14, 525, 63, 86, 17, 63, 5895, 8, 3417, 12, 1101, 9, 267, 340, 440, 1263, 1332, 86, 17, 63, 4214, 12, 373, 18, 63, 4214, 2298, 288, 746, 510, 15513, 3034, 68, 1726, 8, 705, 63, 600, 29, 705, 63, 6021, 14, 10892, 50, 1960, 24, 12, 7086, 29, 633, 9, 339, 347, 1050, 63, 86, 18, 63, 5895, 8, 277, 12, 3831, 12, 406, 2033, 390, 12, 1101, 304, 267, 408, 267, 2654, 373, 18, 7604, 7124, 14, 398, 520, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ganeti/ganeti-doc
roles/ganeti-doc/files/srv/ganeti-vcs/hooks/ciabot.py
1
7112
#!/usr/bin/env python # Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com> # Distributed under BSD terms. # # Google changes (iustin): # - taken from upstream git repo, contrib/ciabot/ciabot.py # - disabled cgit.cgi and use gitweb as we use it on git.ganeti.org # (url tweaked) # - to not use tinyurl # - remove the url from the log # - hardcode hostname # # This script contains porcelain and porcelain byproducts. # It's Python because the Python standard libraries avoid portability/security # issues raised by callouts in the ancestral Perl and sh scripts. It should # be compatible back to Python 2.1.5 # # usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]] # # This script is meant to be run either in a post-commit hook or in an # update hook. If there's nothing unusual about your hosting setup, # you can specify the project name with a -p option and avoid having # to modify this script. Try it with -n to see the notification mail # dumped to stdout and verify that it looks sane. With -V it dumps its # version and exits. # # In post-commit, run it without arguments (other than possibly a -p # option). It will query for current HEAD and the latest commit ID to # get the information it needs. # # In update, call it with a refname followed by a list of commits: # You want to reverse the order git rev-list emits becxause it lists # from most recent to oldest. # # /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac) # # Note: this script uses mail, not XML-RPC, in order to avoid stalling # until timeout when the CIA XML-RPC server is down. # # # The project as known to CIA. You will either want to change this # or invoke the script with a -p option to set it. # project=None # # You may not need to change these: # import os, sys, commands, socket, urllib # Name of the repository. # You can hardwire this to make the script faster. repo = os.path.basename(os.getcwd()) # Fully-qualified domain name of this host. # You can hardwire this to make the script faster. #host = socket.getfqdn() host = "git.ganeti.org" # Changeset URL prefix for your repo: when the commit ID is appended # to this, it should point at a CGI that will display the commit # through gitweb or something similar. The defaults will probably # work if you have a typical gitweb/cgit setup. # urlprefix="http://%(host)s/?p=%(repo)s;a=commit;h=" #urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id=" # The service used to turn your gitwebbish URL into a tinyurl so it # will take up less space on the IRC notification line. tinyifier = "http://tinyurl.com/api-create.php?url=" # The template used to generate the XML messages to CIA. You can make # visible changes to the IRC-bot notification lines by hacking this. # The default will produce a notfication line that looks like this: # # ${project}: ${author} ${repo}:${branch} * ${rev} ${files}: ${logmsg} ${url} # # By omitting $files you can collapse the files part to a single slash. xml = '''\ <message> <generator> <name>CIA Python client for Git</name> <version>%(gitver)s</version> <url>%(generator)s</url> </generator> <source> <project>%(project)s</project> <branch>%(repo)s:%(branch)s</branch> </source> <timestamp>%(ts)s</timestamp> <body> <commit> <author>%(author)s</author> <revision>%(rev)s</revision> <files> %(files)s </files> <log>%(logmsg)s</log> <url>%(url)s</url> </commit> </body> </message> ''' # # No user-serviceable parts below this line: # # Addresses for the e-mail. The from address is a dummy, since CIA # will never reply to this mail. fromaddr = "CIABOT-NOREPLY@" + host toaddr = "cia@cia.navi.cx" # Identify the generator script. # Should only change when the script itself gets a new home and maintainer. generator="http://www.catb.org/~esr/ciabot.py" def do(command): return commands.getstatusoutput(command)[1] def report(refname, merged): "Generate a commit notification to be reported to CIA" # Try to tinyfy a reference to a web view for this commit. #try: # url = open(urllib.urlretrieve(tinyifier + urlprefix + merged)[0]).read() #except: # url = urlprefix + merged # tinyurl disabled url = urlprefix + merged branch = os.path.basename(refname) # Compute a shortnane for the revision rev = do("git describe ${merged} 2>/dev/null") or merged[:12] # Extract the neta-information for the commit rawcommit = do("git cat-file commit " + merged) files=do("git diff-tree -r --name-only '"+ merged +"' | sed -e '1d' -e 's-.*-<file>&</file>-'") inheader = True headers = {} logmsg = "" for line in rawcommit.split("\n"): if inheader: if line: fields = line.split() headers[fields[0]] = " ".join(fields[1:]) else: inheader = False else: logmsg = line break (author, ts) = headers["author"].split(">") # This discards the part of the authors addrsss after @. # Might be bnicece to ship the full email address, if not # for spammers' address harvesters - getting this wrong # would make the freenode #commits channel into harvester heaven. author = author.replace("<", "").split("@")[0].split()[-1] # This ignores the timezone. Not clear what to do with it... ts = ts.strip().split()[0] context = locals() context.update(globals()) out = xml % context message = '''\ Message-ID: <%(merged)s.%(author)s@%(project)s> From: %(fromaddr)s To: %(toaddr)s Content-type: text/xml Subject: DeliverXML %(out)s''' % locals() return message if __name__ == "__main__": import getopt try: (options, arguments) = getopt.getopt(sys.argv[1:], "np:V") except getopt.GetoptError, msg: print "ciabot.py: " + str(msg) raise SystemExit, 1 mailit = True for (switch, val) in options: if switch == '-p': project = val elif switch == '-n': mailit = False elif switch == '-V': print "ciabot.py: version 3.2" sys.exit(0) # Cough and die if user has not specified a project if not project: sys.stderr.write("ciabot.py: no project specified, bailing out.\n") sys.exit(1) # We'll need the git version number. gitver = do("git --version").split()[0] urlprefix = urlprefix % globals() # The script wants a reference to head followed by the list of # commit ID to report about. if len(arguments) == 0: refname = do("git symbolic-ref HEAD 2>/dev/null") merges = [do("git rev-parse HEAD")] else: refname = arguments[0] merges = arguments[1:] if mailit: import smtplib server = smtplib.SMTP('localhost') for merged in merges: message = report(refname, merged) if mailit: server.sendmail(fromaddr, [toaddr], message) else: print message if mailit: server.quit() #End
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7129, 662, 1567, 428, 14, 30703, 2106, 68, 665, 397, 82, 32, 273, 89, 2393, 527, 14, 957, 30, 199, 3, 17484, 1334, 6289, 2895, 14, 199, 3, 199, 3, 4475, 4493, 334, 73, 833, 262, 304, 199, 3, 446, 9394, 687, 18932, 6135, 3831, 12, 5914, 15, 559, 371, 357, 15, 559, 371, 357, 14, 647, 199, 3, 446, 6980, 286, 3187, 14, 13814, 436, 675, 6135, 2520, 465, 781, 675, 652, 641, 6135, 14, 71, 5865, 280, 14, 1308, 199, 3, 257, 334, 633, 32464, 379, 9, 199, 3, 446, 370, 440, 675, 29128, 633, 199, 3, 446, 2813, 314, 1166, 687, 314, 943, 199, 3, 446, 7508, 600, 6246, 199, 3, 199, 3, 961, 2884, 3509, 8706, 301, 3993, 436, 8706, 301, 3993, 701, 13336, 14, 199, 3, 2779, 1159, 2018, 2952, 314, 2018, 4465, 8363, 5126, 1844, 3616, 15, 4416, 199, 3, 10876, 4915, 701, 3213, 320, 14608, 315, 314, 12294, 31943, 3492, 76, 436, 1033, 10554, 14, 221, 2779, 1077, 199, 3, 506, 9025, 1771, 370, 2018, 499, 14, 17, 14, 21, 199, 3, 199, 3, 4503, 26, 16279, 371, 357, 14, 647, 5243, 54, 61, 5243, 78, 61, 5243, 80, 2199, 354, 61, 221, 359, 29124, 359, 18679, 1396, 2677, 199, 3, 199, 3, 961, 2884, 365, 18329, 370, 506, 1255, 1902, 315, 282, 2963, 13, 3543, 5759, 503, 315, 376, 199, 3, 1678, 5759, 14, 221, 982, 2337, 1159, 6548, 625, 527, 1061, 3595, 2195, 1591, 316, 3272, 12, 199, 3, 1265, 883, 4165, 314, 2199, 536, 543, 282, 446, 80, 945, 436, 5126, 9445, 199, 3, 370, 2811, 642, 2884, 14, 221, 7649, 652, 543, 446, 78, 370, 1937, 314, 6955, 6016, 199, 3, 31374, 370, 3839, 436, 4911, 626, 652, 10734, 31648, 14, 8777, 446, 54, 652, 16864, 2399, 199, 3, 1015, 436, 20100, 14, 199, 3, 199, 3, 1010, 2963, 13, 3543, 12, 1255, 652, 1928, 2368, 334, 1848, 2419, 12570, 282, 446, 80, 199, 3, 945, 680, 2779, 911, 1827, 367, 1453, 13053, 436, 314, 8839, 5532, 2870, 370, 199, 3, 664, 314, 2556, 652, 4839, 14, 199, 3, 199, 3, 1010, 1678, 12, 1240, 652, 543, 282, 2984, 354, 9437, 701, 282, 769, 402, 20835, 26, 199, 3, 2047, 2934, 370, 3837, 314, 1865, 6135, 6822, 13, 513, 8689, 83, 506, 67, 1800, 1180, 652, 5548, 199, 3, 687, 4750, 8058, 370, 29493, 14, 199, 3, 199, 3, 1182, 515, 15, 475, 15, 559, 371, 357, 14, 647, 10839, 29124, 93, 7714, 3187, 6822, 13, 513, 10839, 1753, 2993, 93, 703, 10545, 1222, 2993, 93, 1204, 307, 645, 9, 199, 3, 199, 3, 3390, 26, 642, 2884, 4440, 6016, 12, 440, 4692, 13, 8171, 12, 315, 1865, 370, 5126, 410, 26039, 199, 3, 5133, 2653, 1380, 314, 445, 13033, 4692, 13, 8171, 1654, 365, 3224, 14, 199, 3, 199, 199, 3, 199, 3, 710, 2199, 465, 6040, 370, 445, 13033, 14, 2047, 911, 1902, 2934, 370, 1570, 642, 199, 3, 503, 12677, 314, 2884, 543, 282, 446, 80, 945, 370, 663, 652, 14, 199, 3, 199, 1715, 29, 403, 199, 199, 3, 199, 3, 2047, 1443, 440, 1929, 370, 1570, 3520, 26, 199, 3, 199, 646, 747, 12, 984, 12, 3718, 12, 2838, 12, 4011, 199, 199, 3, 2812, 402, 314, 7611, 14, 199, 3, 2047, 883, 7508, 11239, 642, 370, 1852, 314, 2884, 12930, 14, 199, 3417, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 9458, 1012, 199, 199, 3, 481, 8525, 13, 11661, 2881, 536, 402, 642, 1591, 14, 199, 3, 2047, 883, 7508, 11239, 642, 370, 1852, 314, 2884, 12930, 14, 199, 3, 1102, 275, 2838, 14, 362, 18364, 342, 199, 1102, 275, 298, 3187, 14, 71, 5865, 280, 14, 1308, 2, 199, 199, 3, 7743, 409, 2851, 2403, 367, 2195, 3831, 26, 1380, 314, 5532, 2870, 365, 11544, 199, 3, 370, 642, 12, 652, 1077, 2376, 737, 282, 28716, 626, 911, 2929, 314, 5532, 199, 3, 4012, 6135, 2520, 503, 6020, 8545, 14, 710, 4243, 911, 8646, 199, 3, 1736, 340, 1265, 1172, 282, 25780, 6135, 2520, 15, 67, 3187, 3272, 14, 199, 3, 199, 633, 1861, 628, 1014, 921, 2840, 1102, 9, 83, 10197, 80, 15438, 3417, 9, 83, 27, 65, 29, 3543, 27, 72, 628, 199, 3, 633, 1861, 628, 1014, 921, 2840, 1102, 9, 83, 15, 13814, 13, 1393, 15, 67, 3187, 14, 13814, 21275, 3417, 9, 83, 15, 3543, 10197, 344, 628, 199, 199, 3, 710, 2435, 1202, 370, 7485, 2195, 6135, 1129, 2501, 2453, 2851, 1901, 282, 29128, 633, 880, 652, 199, 3, 911, 5452, 1536, 6656, 4601, 641, 314, 473, 8205, 6955, 1004, 14, 199, 9864, 9893, 275, 298, 1014, 921, 9864, 633, 14, 957, 15, 1246, 13, 981, 14, 8624, 31, 633, 628, 199, 199, 3, 710, 1978, 1202, 370, 3550, 314, 4692, 3788, 370, 445, 13033, 14, 221, 2047, 883, 1852, 199, 3, 8917, 4493, 370, 314, 473, 8205, 13, 3018, 6955, 2385, 701, 11176, 316, 642, 14, 199, 3, 710, 849, 911, 7389, 282, 440, 3477, 1004, 626, 10734, 2839, 642, 26, 199, 3, 199, 3, 10839, 1715, 9160, 10839, 2502, 93, 10839, 3417, 9160, 10545, 4694, 93, 627, 10839, 4964, 93, 10839, 1725, 9160, 10839, 793, 1328, 93, 10839, 633, 93, 199, 3, 199, 3, 4885, 19413, 1337, 2672, 1725, 1265, 883, 24311, 314, 1584, 1777, 370, 282, 2849, 14457, 14, 199, 1652, 275, 18087, 199, 28, 1188, 30, 523, 665, 4679, 30, 272, 665, 354, 30, 3553, 33, 2018, 1890, 367, 12579, 1108, 354, 30, 272, 665, 1023, 19418, 3187, 422, 9, 83, 1108, 1023, 30, 272, 665, 633, 19418, 4679, 9, 83, 1108, 633, 30, 523, 3068, 4679, 30, 523, 665, 1365, 30, 272, 665, 1715, 19418, 1715, 9, 83, 1108, 1715, 30, 272, 665, 4694, 19418, 3417, 9, 83, 19648, 4694, 9, 83, 1108, 4694, 30, 523, 3068, 1365, 30, 523, 665, 3954, 19418, 1086, 9, 83, 1108, 3954, 30, 523, 665, 2030, 30, 272, 665, 3543, 30, 489, 665, 2502, 19418, 2502, 9, 83, 1108, 2502, 30, 489, 665, 5792, 19418, 4964, 9, 83, 1108, 5792, 30, 489, 665, 1725 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7129, 662, 1567, 428, 14, 30703, 2106, 68, 665, 397, 82, 32, 273, 89, 2393, 527, 14, 957, 30, 199, 3, 17484, 1334, 6289, 2895, 14, 199, 3, 199, 3, 4475, 4493, 334, 73, 833, 262, 304, 199, 3, 446, 9394, 687, 18932, 6135, 3831, 12, 5914, 15, 559, 371, 357, 15, 559, 371, 357, 14, 647, 199, 3, 446, 6980, 286, 3187, 14, 13814, 436, 675, 6135, 2520, 465, 781, 675, 652, 641, 6135, 14, 71, 5865, 280, 14, 1308, 199, 3, 257, 334, 633, 32464, 379, 9, 199, 3, 446, 370, 440, 675, 29128, 633, 199, 3, 446, 2813, 314, 1166, 687, 314, 943, 199, 3, 446, 7508, 600, 6246, 199, 3, 199, 3, 961, 2884, 3509, 8706, 301, 3993, 436, 8706, 301, 3993, 701, 13336, 14, 199, 3, 2779, 1159, 2018, 2952, 314, 2018, 4465, 8363, 5126, 1844, 3616, 15, 4416, 199, 3, 10876, 4915, 701, 3213, 320, 14608, 315, 314, 12294, 31943, 3492, 76, 436, 1033, 10554, 14, 221, 2779, 1077, 199, 3, 506, 9025, 1771, 370, 2018, 499, 14, 17, 14, 21, 199, 3, 199, 3, 4503, 26, 16279, 371, 357, 14, 647, 5243, 54, 61, 5243, 78, 61, 5243, 80, 2199, 354, 61, 221, 359, 29124, 359, 18679, 1396, 2677, 199, 3, 199, 3, 961, 2884, 365, 18329, 370, 506, 1255, 1902, 315, 282, 2963, 13, 3543, 5759, 503, 315, 376, 199, 3, 1678, 5759, 14, 221, 982, 2337, 1159, 6548, 625, 527, 1061, 3595, 2195, 1591, 316, 3272, 12, 199, 3, 1265, 883, 4165, 314, 2199, 536, 543, 282, 446, 80, 945, 436, 5126, 9445, 199, 3, 370, 2811, 642, 2884, 14, 221, 7649, 652, 543, 446, 78, 370, 1937, 314, 6955, 6016, 199, 3, 31374, 370, 3839, 436, 4911, 626, 652, 10734, 31648, 14, 8777, 446, 54, 652, 16864, 2399, 199, 3, 1015, 436, 20100, 14, 199, 3, 199, 3, 1010, 2963, 13, 3543, 12, 1255, 652, 1928, 2368, 334, 1848, 2419, 12570, 282, 446, 80, 199, 3, 945, 680, 2779, 911, 1827, 367, 1453, 13053, 436, 314, 8839, 5532, 2870, 370, 199, 3, 664, 314, 2556, 652, 4839, 14, 199, 3, 199, 3, 1010, 1678, 12, 1240, 652, 543, 282, 2984, 354, 9437, 701, 282, 769, 402, 20835, 26, 199, 3, 2047, 2934, 370, 3837, 314, 1865, 6135, 6822, 13, 513, 8689, 83, 506, 67, 1800, 1180, 652, 5548, 199, 3, 687, 4750, 8058, 370, 29493, 14, 199, 3, 199, 3, 1182, 515, 15, 475, 15, 559, 371, 357, 14, 647, 10839, 29124, 93, 7714, 3187, 6822, 13, 513, 10839, 1753, 2993, 93, 703, 10545, 1222, 2993, 93, 1204, 307, 645, 9, 199, 3, 199, 3, 3390, 26, 642, 2884, 4440, 6016, 12, 440, 4692, 13, 8171, 12, 315, 1865, 370, 5126, 410, 26039, 199, 3, 5133, 2653, 1380, 314, 445, 13033, 4692, 13, 8171, 1654, 365, 3224, 14, 199, 3, 199, 199, 3, 199, 3, 710, 2199, 465, 6040, 370, 445, 13033, 14, 2047, 911, 1902, 2934, 370, 1570, 642, 199, 3, 503, 12677, 314, 2884, 543, 282, 446, 80, 945, 370, 663, 652, 14, 199, 3, 199, 1715, 29, 403, 199, 199, 3, 199, 3, 2047, 1443, 440, 1929, 370, 1570, 3520, 26, 199, 3, 199, 646, 747, 12, 984, 12, 3718, 12, 2838, 12, 4011, 199, 199, 3, 2812, 402, 314, 7611, 14, 199, 3, 2047, 883, 7508, 11239, 642, 370, 1852, 314, 2884, 12930, 14, 199, 3417, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 9458, 1012, 199, 199, 3, 481, 8525, 13, 11661, 2881, 536, 402, 642, 1591, 14, 199, 3, 2047, 883, 7508, 11239, 642, 370, 1852, 314, 2884, 12930, 14, 199, 3, 1102, 275, 2838, 14, 362, 18364, 342, 199, 1102, 275, 298, 3187, 14, 71, 5865, 280, 14, 1308, 2, 199, 199, 3, 7743, 409, 2851, 2403, 367, 2195, 3831, 26, 1380, 314, 5532, 2870, 365, 11544, 199, 3, 370, 642, 12, 652, 1077, 2376, 737, 282, 28716, 626, 911, 2929, 314, 5532, 199, 3, 4012, 6135, 2520, 503, 6020, 8545, 14, 710, 4243, 911, 8646, 199, 3, 1736, 340, 1265, 1172, 282, 25780, 6135, 2520, 15, 67, 3187, 3272, 14, 199, 3, 199, 633, 1861, 628, 1014, 921, 2840, 1102, 9, 83, 10197, 80, 15438, 3417, 9, 83, 27, 65, 29, 3543, 27, 72, 628, 199, 3, 633, 1861, 628, 1014, 921, 2840, 1102, 9, 83, 15, 13814, 13, 1393, 15, 67, 3187, 14, 13814, 21275, 3417, 9, 83, 15, 3543, 10197, 344, 628, 199, 199, 3, 710, 2435, 1202, 370, 7485, 2195, 6135, 1129, 2501, 2453, 2851, 1901, 282, 29128, 633, 880, 652, 199, 3, 911, 5452, 1536, 6656, 4601, 641, 314, 473, 8205, 6955, 1004, 14, 199, 9864, 9893, 275, 298, 1014, 921, 9864, 633, 14, 957, 15, 1246, 13, 981, 14, 8624, 31, 633, 628, 199, 199, 3, 710, 1978, 1202, 370, 3550, 314, 4692, 3788, 370, 445, 13033, 14, 221, 2047, 883, 1852, 199, 3, 8917, 4493, 370, 314, 473, 8205, 13, 3018, 6955, 2385, 701, 11176, 316, 642, 14, 199, 3, 710, 849, 911, 7389, 282, 440, 3477, 1004, 626, 10734, 2839, 642, 26, 199, 3, 199, 3, 10839, 1715, 9160, 10839, 2502, 93, 10839, 3417, 9160, 10545, 4694, 93, 627, 10839, 4964, 93, 10839, 1725, 9160, 10839, 793, 1328, 93, 10839, 633, 93, 199, 3, 199, 3, 4885, 19413, 1337, 2672, 1725, 1265, 883, 24311, 314, 1584, 1777, 370, 282, 2849, 14457, 14, 199, 1652, 275, 18087, 199, 28, 1188, 30, 523, 665, 4679, 30, 272, 665, 354, 30, 3553, 33, 2018, 1890, 367, 12579, 1108, 354, 30, 272, 665, 1023, 19418, 3187, 422, 9, 83, 1108, 1023, 30, 272, 665, 633, 19418, 4679, 9, 83, 1108, 633, 30, 523, 3068, 4679, 30, 523, 665, 1365, 30, 272, 665, 1715, 19418, 1715, 9, 83, 1108, 1715, 30, 272, 665, 4694, 19418, 3417, 9, 83, 19648, 4694, 9, 83, 1108, 4694, 30, 523, 3068, 1365, 30, 523, 665, 3954, 19418, 1086, 9, 83, 1108, 3954, 30, 523, 665, 2030, 30, 272, 665, 3543, 30, 489, 665, 2502, 19418, 2502, 9, 83, 1108, 2502, 30, 489, 665, 5792, 19418, 4964, 9, 83, 1108, 5792, 30, 489, 665, 1725, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ATIX-AG/ansible
contrib/inventory/openvz.py
196
2818
#!/usr/bin/env python # -*- coding: utf-8 -*- # # openvz.py # # Copyright 2014 jordonr <jordon@beamsyn.net> # # 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/>. # # Inspired by libvirt_lxc.py inventory script # https://github.com/ansible/ansible/blob/e5ef0eca03cbb6c8950c06dc50d0ca22aa8902f4/plugins/inventory/libvirt_lxc.py # # Groups are determined by the description field of openvz guests # multiple groups can be separated by commas: webserver,dbserver from subprocess import Popen, PIPE import sys import json # List openvz hosts vzhosts = ['vzhost1', 'vzhost2', 'vzhost3'] # Add openvz hosts to the inventory and Add "_meta" trick inventory = {'vzhosts': {'hosts': vzhosts}, '_meta': {'hostvars': {}}} # default group, when description not defined default_group = ['vzguest'] def get_guests(): # Loop through vzhosts for h in vzhosts: # SSH to vzhost and get the list of guests in json pipe = Popen(['ssh', h, 'vzlist', '-j'], stdout=PIPE, universal_newlines=True) # Load Json info of guests json_data = json.loads(pipe.stdout.read()) # loop through guests for j in json_data: # Add information to host vars inventory['_meta']['hostvars'][j['hostname']] = { 'ctid': j['ctid'], 'veid': j['veid'], 'vpsid': j['vpsid'], 'private_path': j['private'], 'root_path': j['root'], 'ip': j['ip'] } # determine group from guest description if j['description'] is not None: groups = j['description'].split(",") else: groups = default_group # add guest to inventory for g in groups: if g not in inventory: inventory[g] = {'hosts': []} inventory[g]['hosts'].append(j['hostname']) return inventory if len(sys.argv) == 2 and sys.argv[1] == '--list': inv_json = get_guests() print(json.dumps(inv_json, sort_keys=True)) elif len(sys.argv) == 3 and sys.argv[1] == '--host': print(json.dumps({})) else: print("Need an argument, either --list or --host <host>")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1551, 31007, 14, 647, 199, 3, 199, 3, 1898, 6927, 1335, 2181, 265, 82, 665, 74, 2181, 265, 32, 14529, 9466, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 14, 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, 3, 12062, 1038, 581, 701, 13108, 63, 29357, 14, 647, 8200, 2884, 199, 3, 4178, 921, 5031, 14, 957, 15, 4853, 15, 4853, 15, 6582, 15, 69, 21, 2829, 16, 69, 696, 1644, 21933, 22, 67, 1407, 1400, 67, 1690, 3833, 1400, 68, 16, 696, 1081, 2158, 1407, 996, 70, 20, 15, 5265, 15, 7212, 15, 11877, 63, 29357, 14, 647, 199, 3, 199, 3, 25031, 787, 12037, 701, 314, 1369, 901, 402, 1551, 31007, 13980, 83, 199, 3, 3663, 4652, 883, 506, 11673, 701, 24476, 26, 3330, 1000, 12, 697, 1000, 199, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 984, 199, 646, 2022, 421, 199, 3, 3820, 1551, 31007, 7057, 199, 31007, 5146, 275, 788, 31007, 1102, 17, 297, 283, 31007, 1102, 18, 297, 283, 31007, 1102, 19, 418, 199, 3, 2654, 1551, 31007, 7057, 370, 314, 8200, 436, 2654, 2668, 2024, 2, 20907, 199, 7212, 275, 791, 31007, 5146, 356, 791, 5146, 356, 373, 90, 5146, 1386, 2513, 2024, 356, 791, 23265, 356, 1052, 4863, 199, 3, 849, 1572, 12, 1380, 1369, 440, 3247, 199, 885, 63, 923, 275, 788, 31007, 10409, 418, 421, 199, 318, 664, 63, 10409, 83, 837, 272, 327, 18175, 4012, 373, 90, 5146, 272, 367, 394, 315, 373, 90, 5146, 26, 267, 327, 12027, 370, 373, 90, 1102, 436, 664, 314, 769, 402, 13980, 83, 315, 2022, 267, 5200, 275, 13995, 2941, 5510, 297, 394, 12, 283, 31007, 513, 297, 2475, 74, 995, 3839, 29, 6089, 12, 17508, 63, 13839, 29, 549, 9, 398, 327, 7190, 14587, 2256, 402, 13980, 83, 267, 2022, 63, 576, 275, 2022, 14, 3640, 8, 4990, 14, 2703, 14, 739, 1012, 398, 327, 4438, 4012, 13980, 83, 267, 367, 1335, 315, 2022, 63, 576, 26, 288, 327, 2654, 2556, 370, 1591, 6802, 288, 8200, 8680, 2024, 2545, 23265, 3488, 74, 459, 4269, 6538, 275, 469, 355, 283, 67, 5700, 356, 1335, 459, 67, 5700, 995, 355, 283, 432, 344, 356, 1335, 459, 432, 344, 995, 355, 283, 11702, 4148, 356, 1335, 459, 11702, 4148, 995, 355, 283, 4239, 63, 515, 356, 1335, 459, 4239, 995, 355, 283, 1231, 63, 515, 356, 1335, 459, 1231, 995, 355, 283, 711, 356, 1335, 459, 711, 418, 288, 789, 953, 327, 6705, 1572, 687, 13980, 1369, 288, 340, 1335, 459, 1802, 418, 365, 440, 488, 26, 355, 4652, 275, 1335, 459, 1802, 2278, 1294, 20324, 288, 587, 26, 355, 4652, 275, 849, 63, 923, 953, 327, 1050, 13980, 370, 8200, 288, 367, 486, 315, 4652, 26, 355, 340, 486, 440, 315, 8200, 26, 490, 8200, 59, 71, 61, 275, 791, 5146, 356, 23455, 2234, 8200, 59, 71, 2733, 5146, 2278, 740, 8, 74, 459, 4269, 1105, 398, 372, 8200, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 508, 499, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 513, 356, 272, 4572, 63, 1001, 275, 664, 63, 10409, 83, 342, 272, 870, 8, 1001, 14, 4180, 8, 5350, 63, 1001, 12, 4069, 63, 1612, 29, 549, 430, 199, 4164, 822, 8, 1274, 14, 3020, 9, 508, 650, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 1102, 356, 272, 870, 8, 1001, 14, 4180, 24692, 430, 199, 2836, 26, 272, 870, 480, 17809, 376, 1423, 12, 1902, 1553, 513, 503, 1553, 1102, 665, 1102, 9579, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1551, 31007, 14, 647, 199, 3, 199, 3, 1898, 6927, 1335, 2181, 265, 82, 665, 74, 2181, 265, 32, 14529, 9466, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 14, 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, 3, 12062, 1038, 581, 701, 13108, 63, 29357, 14, 647, 8200, 2884, 199, 3, 4178, 921, 5031, 14, 957, 15, 4853, 15, 4853, 15, 6582, 15, 69, 21, 2829, 16, 69, 696, 1644, 21933, 22, 67, 1407, 1400, 67, 1690, 3833, 1400, 68, 16, 696, 1081, 2158, 1407, 996, 70, 20, 15, 5265, 15, 7212, 15, 11877, 63, 29357, 14, 647, 199, 3, 199, 3, 25031, 787, 12037, 701, 314, 1369, 901, 402, 1551, 31007, 13980, 83, 199, 3, 3663, 4652, 883, 506, 11673, 701, 24476, 26, 3330, 1000, 12, 697, 1000, 199, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 984, 199, 646, 2022, 421, 199, 3, 3820, 1551, 31007, 7057, 199, 31007, 5146, 275, 788, 31007, 1102, 17, 297, 283, 31007, 1102, 18, 297, 283, 31007, 1102, 19, 418, 199, 3, 2654, 1551, 31007, 7057, 370, 314, 8200, 436, 2654, 2668, 2024, 2, 20907, 199, 7212, 275, 791, 31007, 5146, 356, 791, 5146, 356, 373, 90, 5146, 1386, 2513, 2024, 356, 791, 23265, 356, 1052, 4863, 199, 3, 849, 1572, 12, 1380, 1369, 440, 3247, 199, 885, 63, 923, 275, 788, 31007, 10409, 418, 421, 199, 318, 664, 63, 10409, 83, 837, 272, 327, 18175, 4012, 373, 90, 5146, 272, 367, 394, 315, 373, 90, 5146, 26, 267, 327, 12027, 370, 373, 90, 1102, 436, 664, 314, 769, 402, 13980, 83, 315, 2022, 267, 5200, 275, 13995, 2941, 5510, 297, 394, 12, 283, 31007, 513, 297, 2475, 74, 995, 3839, 29, 6089, 12, 17508, 63, 13839, 29, 549, 9, 398, 327, 7190, 14587, 2256, 402, 13980, 83, 267, 2022, 63, 576, 275, 2022, 14, 3640, 8, 4990, 14, 2703, 14, 739, 1012, 398, 327, 4438, 4012, 13980, 83, 267, 367, 1335, 315, 2022, 63, 576, 26, 288, 327, 2654, 2556, 370, 1591, 6802, 288, 8200, 8680, 2024, 2545, 23265, 3488, 74, 459, 4269, 6538, 275, 469, 355, 283, 67, 5700, 356, 1335, 459, 67, 5700, 995, 355, 283, 432, 344, 356, 1335, 459, 432, 344, 995, 355, 283, 11702, 4148, 356, 1335, 459, 11702, 4148, 995, 355, 283, 4239, 63, 515, 356, 1335, 459, 4239, 995, 355, 283, 1231, 63, 515, 356, 1335, 459, 1231, 995, 355, 283, 711, 356, 1335, 459, 711, 418, 288, 789, 953, 327, 6705, 1572, 687, 13980, 1369, 288, 340, 1335, 459, 1802, 418, 365, 440, 488, 26, 355, 4652, 275, 1335, 459, 1802, 2278, 1294, 20324, 288, 587, 26, 355, 4652, 275, 849, 63, 923, 953, 327, 1050, 13980, 370, 8200, 288, 367, 486, 315, 4652, 26, 355, 340, 486, 440, 315, 8200, 26, 490, 8200, 59, 71, 61, 275, 791, 5146, 356, 23455, 2234, 8200, 59, 71, 2733, 5146, 2278, 740, 8, 74, 459, 4269, 1105, 398, 372, 8200, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 508, 499, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 513, 356, 272, 4572, 63, 1001, 275, 664, 63, 10409, 83, 342, 272, 870, 8, 1001, 14, 4180, 8, 5350, 63, 1001, 12, 4069, 63, 1612, 29, 549, 430, 199, 4164, 822, 8, 1274, 14, 3020, 9, 508, 650, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 1102, 356, 272, 870, 8, 1001, 14, 4180, 24692, 430, 199, 2836, 26, 272, 870, 480, 17809, 376, 1423, 12, 1902, 1553, 513, 503, 1553, 1102, 665, 1102, 9579, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
Pragith/p8ste
src/app/user.py
2
1733
# Copyright 2008 Thomas Quemard # # Paste-It 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.0, or (at your option) # any later version. # # Paste-It 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. from google.appengine.api import users import hashlib import app import app.model class User: def refresh (self): guser = users.get_current_user() self.db_user = None self.id = None self.is_google_admin = False self.is_logged_in = False self.url = "" if guser: self.google_id = guser.user_id() self.google_email = guser.email() self.gravatar_id = hashlib.md5(self.google_email).hexdigest() self.is_logged_in_google = True self.is_google_admin = users.is_current_user_admin() else: self.google_id = "" self.google_email = "" self.gravatar_id = "" self.is_logged_in_google = False if self.google_id != "": qry_user = app.model.User.all() qry_user.filter("google_id =", self.google_id) self.db_user = qry_user.get() if self.db_user: self.is_logged_in = True self.id = self.db_user.id self.paste_count = self.db_user.paste_count self.url = app.url("users/%s", self.id) _user = User() def get_current_user (): return _user
gpl-3.0
[ 3, 1898, 9079, 27864, 1413, 310, 77, 1005, 199, 3, 199, 3, 510, 9209, 13, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 14, 16, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 510, 9209, 13, 7940, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 199, 3, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 1684, 199, 3, 844, 367, 1655, 2436, 14, 421, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 646, 8337, 199, 199, 646, 1145, 199, 646, 1145, 14, 1238, 421, 199, 533, 2876, 26, 272, 347, 9236, 334, 277, 304, 267, 486, 751, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 267, 291, 14, 697, 63, 751, 275, 488, 267, 291, 14, 344, 275, 488, 267, 291, 14, 374, 63, 3098, 63, 2113, 275, 756, 267, 291, 14, 374, 63, 12419, 63, 262, 275, 756, 267, 291, 14, 633, 275, 3087, 398, 340, 486, 751, 26, 288, 291, 14, 3098, 63, 344, 275, 486, 751, 14, 751, 63, 344, 342, 288, 291, 14, 3098, 63, 2123, 275, 486, 751, 14, 2123, 342, 288, 291, 14, 926, 28694, 63, 344, 275, 8337, 14, 1064, 21, 8, 277, 14, 3098, 63, 2123, 680, 11453, 342, 288, 291, 14, 374, 63, 12419, 63, 262, 63, 3098, 275, 715, 288, 291, 14, 374, 63, 3098, 63, 2113, 275, 4390, 14, 374, 63, 1818, 63, 751, 63, 2113, 342, 267, 587, 26, 288, 291, 14, 3098, 63, 344, 275, 3087, 288, 291, 14, 3098, 63, 2123, 275, 3087, 288, 291, 14, 926, 28694, 63, 344, 275, 3087, 288, 291, 14, 374, 63, 12419, 63, 262, 63, 3098, 275, 756, 398, 340, 291, 14, 3098, 63, 344, 1137, 10812, 288, 1894, 651, 63, 751, 275, 1145, 14, 1238, 14, 1899, 14, 452, 342, 288, 1894, 651, 63, 751, 14, 1541, 480, 3098, 63, 344, 20815, 291, 14, 3098, 63, 344, 9, 288, 291, 14, 697, 63, 751, 275, 1894, 651, 63, 751, 14, 362, 342, 288, 340, 291, 14, 697, 63, 751, 26, 355, 291, 14, 374, 63, 12419, 63, 262, 275, 715, 355, 291, 14, 344, 275, 291, 14, 697, 63, 751, 14, 344, 355, 291, 14, 16586, 63, 835, 275, 291, 14, 697, 63, 751, 14, 16586, 63, 835, 355, 291, 14, 633, 275, 1145, 14, 633, 480, 3707, 3149, 83, 401, 291, 14, 344, 9, 4388, 199, 63, 751, 275, 2876, 342, 199, 199, 318, 664, 63, 1818, 63, 751, 23390, 272, 372, 485, 751, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9079, 27864, 1413, 310, 77, 1005, 199, 3, 199, 3, 510, 9209, 13, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 14, 16, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 510, 9209, 13, 7940, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 199, 3, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 1684, 199, 3, 844, 367, 1655, 2436, 14, 421, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 646, 8337, 199, 199, 646, 1145, 199, 646, 1145, 14, 1238, 421, 199, 533, 2876, 26, 272, 347, 9236, 334, 277, 304, 267, 486, 751, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 267, 291, 14, 697, 63, 751, 275, 488, 267, 291, 14, 344, 275, 488, 267, 291, 14, 374, 63, 3098, 63, 2113, 275, 756, 267, 291, 14, 374, 63, 12419, 63, 262, 275, 756, 267, 291, 14, 633, 275, 3087, 398, 340, 486, 751, 26, 288, 291, 14, 3098, 63, 344, 275, 486, 751, 14, 751, 63, 344, 342, 288, 291, 14, 3098, 63, 2123, 275, 486, 751, 14, 2123, 342, 288, 291, 14, 926, 28694, 63, 344, 275, 8337, 14, 1064, 21, 8, 277, 14, 3098, 63, 2123, 680, 11453, 342, 288, 291, 14, 374, 63, 12419, 63, 262, 63, 3098, 275, 715, 288, 291, 14, 374, 63, 3098, 63, 2113, 275, 4390, 14, 374, 63, 1818, 63, 751, 63, 2113, 342, 267, 587, 26, 288, 291, 14, 3098, 63, 344, 275, 3087, 288, 291, 14, 3098, 63, 2123, 275, 3087, 288, 291, 14, 926, 28694, 63, 344, 275, 3087, 288, 291, 14, 374, 63, 12419, 63, 262, 63, 3098, 275, 756, 398, 340, 291, 14, 3098, 63, 344, 1137, 10812, 288, 1894, 651, 63, 751, 275, 1145, 14, 1238, 14, 1899, 14, 452, 342, 288, 1894, 651, 63, 751, 14, 1541, 480, 3098, 63, 344, 20815, 291, 14, 3098, 63, 344, 9, 288, 291, 14, 697, 63, 751, 275, 1894, 651, 63, 751, 14, 362, 342, 288, 340, 291, 14, 697, 63, 751, 26, 355, 291, 14, 374, 63, 12419, 63, 262, 275, 715, 355, 291, 14, 344, 275, 291, 14, 697, 63, 751, 14, 344, 355, 291, 14, 16586, 63, 835, 275, 291, 14, 697, 63, 751, 14, 16586, 63, 835, 355, 291, 14, 633, 275, 1145, 14, 633, 480, 3707, 3149, 83, 401, 291, 14, 344, 9, 4388, 199, 63, 751, 275, 2876, 342, 199, 199, 318, 664, 63, 1818, 63, 751, 23390, 272, 372, 485, 751, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
gylian/sickrage
lib/github/Commit.py
25
9927
# -*- coding: utf-8 -*- # ########################## Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # # Copyright 2012 Zearin <zearin@gonk.net> # # Copyright 2013 AKFish <akfish@gmail.com> # # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # # Copyright 2013 martinqt <m.ki2@laposte.net> # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # # # # PyGithub 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 3 of the License, or (at your option) # # any later version. # # # # PyGithub 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 PyGithub. If not, see <http://www.gnu.org/licenses/>. # # # # ############################################################################## import github.GithubObject import github.PaginatedList import github.GitCommit import github.NamedUser import github.CommitStatus import github.File import github.CommitStats import github.CommitComment class Commit(github.GithubObject.CompletableGithubObject): """ This class represents Commits. The reference can be found here http://developer.github.com/v3/git/commits/ """ @property def author(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._author) return self._author.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commit(self): """ :type: :class:`github.GitCommit.GitCommit` """ self._completeIfNotSet(self._commit) return self._commit.value @property def committer(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._committer) return self._committer.value @property def files(self): """ :type: list of :class:`github.File.File` """ self._completeIfNotSet(self._files) return self._files.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def parents(self): """ :type: list of :class:`github.Commit.Commit` """ self._completeIfNotSet(self._parents) return self._parents.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def stats(self): """ :type: :class:`github.CommitStats.CommitStats` """ self._completeIfNotSet(self._stats) return self._stats.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def create_comment(self, body, line=github.GithubObject.NotSet, path=github.GithubObject.NotSet, position=github.GithubObject.NotSet): """ :calls: `POST /repos/:owner/:repo/commits/:sha/comments <http://developer.github.com/v3/repos/comments>`_ :param body: string :param line: integer :param path: string :param position: integer :rtype: :class:`github.CommitComment.CommitComment` """ assert isinstance(body, (str, unicode)), body assert line is github.GithubObject.NotSet or isinstance(line, (int, long)), line assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path assert position is github.GithubObject.NotSet or isinstance(position, (int, long)), position post_parameters = { "body": body, } if line is not github.GithubObject.NotSet: post_parameters["line"] = line if path is not github.GithubObject.NotSet: post_parameters["path"] = path if position is not github.GithubObject.NotSet: post_parameters["position"] = position headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/comments", input=post_parameters ) return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet): """ :calls: `POST /repos/:owner/:repo/statuses/:sha <http://developer.github.com/v3/repos/statuses>`_ :param state: string :param target_url: string :param description: string :rtype: :class:`github.CommitStatus.CommitStatus` """ assert isinstance(state, (str, unicode)), state assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description post_parameters = { "state": state, } if target_url is not github.GithubObject.NotSet: post_parameters["target_url"] = target_url if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "POST", self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha, input=post_parameters ) return github.CommitStatus.CommitStatus(self._requester, headers, data, completed=True) def get_comments(self): """ :calls: `GET /repos/:owner/:repo/commits/:sha/comments <http://developer.github.com/v3/repos/comments>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CommitComment.CommitComment` """ return github.PaginatedList.PaginatedList( github.CommitComment.CommitComment, self._requester, self.url + "/comments", None ) def get_statuses(self): """ :calls: `GET /repos/:owner/:repo/statuses/:ref <http://developer.github.com/v3/repos/statuses>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CommitStatus.CommitStatus` """ return github.PaginatedList.PaginatedList( github.CommitStatus.CommitStatus, self._requester, self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha, None ) @property def _identity(self): return self.sha def _initAttributes(self): self._author = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commit = github.GithubObject.NotSet self._committer = github.GithubObject.NotSet self._files = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._parents = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._stats = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commit" in attributes: # pragma no branch self._commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["commit"]) if "committer" in attributes: # pragma no branch self._committer = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["committer"]) if "files" in attributes: # pragma no branch self._files = self._makeListOfClassesAttribute(github.File.File, attributes["files"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "parents" in attributes: # pragma no branch self._parents = self._makeListOfClassesAttribute(Commit, attributes["parents"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "stats" in attributes: # pragma no branch self._stats = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["stats"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"])
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 11945, 309, 1898, 83, 436, 4190, 11945, 381, 199, 3, 26209, 327, 199, 3, 1898, 6029, 28882, 2946, 1603, 645, 19658, 665, 11908, 2946, 32, 11908, 2946, 13, 9299, 19658, 14, 846, 30, 463, 327, 199, 3, 1898, 6029, 3107, 2210, 262, 665, 806, 285, 262, 32, 27719, 75, 14, 846, 30, 32543, 327, 199, 3, 1898, 6171, 437, 17706, 2453, 665, 1151, 16056, 32, 6799, 14, 957, 30, 32542, 327, 199, 3, 1898, 6171, 28882, 2946, 1603, 645, 19658, 665, 11908, 2946, 32, 11908, 2946, 13, 9299, 19658, 14, 846, 30, 463, 327, 199, 3, 1898, 6171, 333, 26788, 8440, 665, 77, 14, 8810, 18, 32, 416, 27706, 14, 846, 30, 22456, 327, 199, 3, 26209, 327, 199, 3, 961, 570, 365, 1777, 402, 1611, 14772, 14, 1455, 921, 9299, 544, 86, 22, 14, 5031, 14, 957, 15, 2713, 14772, 15, 3515, 327, 199, 3, 26209, 327, 199, 3, 1611, 14772, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 259, 327, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 221, 327, 199, 3, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 259, 327, 199, 3, 1263, 2945, 1015, 14, 2476, 13235, 327, 199, 3, 26209, 327, 199, 3, 1611, 14772, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 221, 327, 199, 3, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 259, 327, 199, 3, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 327, 199, 3, 2436, 14, 6208, 258, 327, 199, 3, 26209, 327, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 258, 327, 199, 3, 3180, 543, 1611, 14772, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 3777, 327, 199, 3, 26209, 327, 199, 3, 221, 4605, 199, 199, 646, 12869, 14, 20659, 199, 646, 12869, 14, 23862, 23831, 1296, 199, 199, 646, 12869, 14, 14686, 11421, 199, 646, 12869, 14, 7989, 1899, 199, 646, 12869, 14, 11421, 3694, 199, 646, 12869, 14, 1173, 199, 646, 12869, 14, 11421, 8257, 199, 646, 12869, 14, 11421, 7488, 421, 199, 533, 21447, 8, 5031, 14, 20659, 14, 6600, 1224, 20659, 304, 272, 408, 272, 961, 1021, 8469, 7046, 1405, 14, 710, 3659, 883, 506, 1911, 2348, 1455, 921, 11071, 14, 5031, 14, 957, 15, 86, 19, 15, 3187, 15, 18679, 15, 272, 408, 339, 768, 1829, 272, 347, 4132, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 7989, 1899, 14, 7989, 1899, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 2502, 9, 267, 372, 291, 423, 2502, 14, 585, 339, 768, 1829, 272, 347, 6786, 63, 633, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 6223, 63, 633, 9, 267, 372, 291, 423, 6223, 63, 633, 14, 585, 339, 768, 1829, 272, 347, 5532, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 14686, 11421, 14, 14686, 11421, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3543, 9, 267, 372, 291, 423, 3543, 14, 585, 339, 768, 1829, 272, 347, 5532, 351, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 7989, 1899, 14, 7989, 1899, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3543, 351, 9, 267, 372, 291, 423, 3543, 351, 14, 585, 339, 768, 1829, 272, 347, 1584, 8, 277, 304, 267, 408, 267, 520, 466, 26, 769, 402, 520, 533, 1705, 5031, 14, 1173, 14, 1173, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 1725, 9, 267, 372, 291, 423, 1725, 14, 585, 339, 768, 1829, 272, 347, 3517, 63, 633, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 1360, 63, 633, 9, 267, 372, 291, 423, 1360, 63, 633, 14, 585, 339, 768, 1829, 272, 347, 8623, 8, 277, 304, 267, 408, 267, 520, 466, 26, 769, 402, 520, 533, 1705, 5031, 14, 11421, 14, 11421, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 8859, 9, 267, 372, 291, 423, 8859, 14, 585, 339, 768, 1829, 272, 347, 7793, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 4835, 9, 267, 372, 291, 423, 4835, 14, 585, 339, 768, 1829, 272, 347, 5020, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 11421, 8257, 14, 11421, 8257, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3200, 9, 267, 372, 291, 423, 3200, 14, 585, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 633, 9, 267, 372, 291, 423, 633, 14, 585, 339, 347, 1218, 63, 3349, 8, 277, 12, 2396, 12, 1004, 29, 5031, 14, 20659, 14, 15953, 12, 931, 29, 5031, 14, 20659, 14, 15953, 12, 3421, 29, 5031, 14, 20659, 14, 15953, 304, 267, 408, 267, 520, 5352, 26, 658, 4030, 1182, 11857, 22075, 4597, 22075, 3417, 15, 18679, 22075, 4835, 15, 6223, 665, 1014, 921, 11071, 14, 5031, 14, 957, 15, 86, 19, 15, 11857, 15, 6223, 18740, 267, 520, 635, 2396, 26, 1059, 267, 520, 635, 1004, 26, 3000, 267, 520, 635, 931, 26, 1059, 267, 520, 635, 3421, 26, 3000, 267, 520, 4500, 26, 520, 533, 1705, 5031, 14, 11421, 7488, 14, 11421, 7488, 64, 267, 408, 267, 702, 1228, 8, 2030, 12, 334, 495, 12, 2649, 1826, 2396, 267, 702, 1004, 365, 12869, 14, 20659, 14, 15953, 503, 1228, 8, 604, 12, 334, 442, 12, 1846, 1826, 1004, 267, 702, 931, 365, 12869, 14, 20659, 14, 15953, 503 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 11945, 309, 1898, 83, 436, 4190, 11945, 381, 199, 3, 26209, 327, 199, 3, 1898, 6029, 28882, 2946, 1603, 645, 19658, 665, 11908, 2946, 32, 11908, 2946, 13, 9299, 19658, 14, 846, 30, 463, 327, 199, 3, 1898, 6029, 3107, 2210, 262, 665, 806, 285, 262, 32, 27719, 75, 14, 846, 30, 32543, 327, 199, 3, 1898, 6171, 437, 17706, 2453, 665, 1151, 16056, 32, 6799, 14, 957, 30, 32542, 327, 199, 3, 1898, 6171, 28882, 2946, 1603, 645, 19658, 665, 11908, 2946, 32, 11908, 2946, 13, 9299, 19658, 14, 846, 30, 463, 327, 199, 3, 1898, 6171, 333, 26788, 8440, 665, 77, 14, 8810, 18, 32, 416, 27706, 14, 846, 30, 22456, 327, 199, 3, 26209, 327, 199, 3, 961, 570, 365, 1777, 402, 1611, 14772, 14, 1455, 921, 9299, 544, 86, 22, 14, 5031, 14, 957, 15, 2713, 14772, 15, 3515, 327, 199, 3, 26209, 327, 199, 3, 1611, 14772, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 259, 327, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 221, 327, 199, 3, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 259, 327, 199, 3, 1263, 2945, 1015, 14, 2476, 13235, 327, 199, 3, 26209, 327, 199, 3, 1611, 14772, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 221, 327, 199, 3, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 259, 327, 199, 3, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 327, 199, 3, 2436, 14, 6208, 258, 327, 199, 3, 26209, 327, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 258, 327, 199, 3, 3180, 543, 1611, 14772, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 3777, 327, 199, 3, 26209, 327, 199, 3, 221, 4605, 199, 199, 646, 12869, 14, 20659, 199, 646, 12869, 14, 23862, 23831, 1296, 199, 199, 646, 12869, 14, 14686, 11421, 199, 646, 12869, 14, 7989, 1899, 199, 646, 12869, 14, 11421, 3694, 199, 646, 12869, 14, 1173, 199, 646, 12869, 14, 11421, 8257, 199, 646, 12869, 14, 11421, 7488, 421, 199, 533, 21447, 8, 5031, 14, 20659, 14, 6600, 1224, 20659, 304, 272, 408, 272, 961, 1021, 8469, 7046, 1405, 14, 710, 3659, 883, 506, 1911, 2348, 1455, 921, 11071, 14, 5031, 14, 957, 15, 86, 19, 15, 3187, 15, 18679, 15, 272, 408, 339, 768, 1829, 272, 347, 4132, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 7989, 1899, 14, 7989, 1899, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 2502, 9, 267, 372, 291, 423, 2502, 14, 585, 339, 768, 1829, 272, 347, 6786, 63, 633, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 6223, 63, 633, 9, 267, 372, 291, 423, 6223, 63, 633, 14, 585, 339, 768, 1829, 272, 347, 5532, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 14686, 11421, 14, 14686, 11421, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3543, 9, 267, 372, 291, 423, 3543, 14, 585, 339, 768, 1829, 272, 347, 5532, 351, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 7989, 1899, 14, 7989, 1899, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3543, 351, 9, 267, 372, 291, 423, 3543, 351, 14, 585, 339, 768, 1829, 272, 347, 1584, 8, 277, 304, 267, 408, 267, 520, 466, 26, 769, 402, 520, 533, 1705, 5031, 14, 1173, 14, 1173, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 1725, 9, 267, 372, 291, 423, 1725, 14, 585, 339, 768, 1829, 272, 347, 3517, 63, 633, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 1360, 63, 633, 9, 267, 372, 291, 423, 1360, 63, 633, 14, 585, 339, 768, 1829, 272, 347, 8623, 8, 277, 304, 267, 408, 267, 520, 466, 26, 769, 402, 520, 533, 1705, 5031, 14, 11421, 14, 11421, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 8859, 9, 267, 372, 291, 423, 8859, 14, 585, 339, 768, 1829, 272, 347, 7793, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 4835, 9, 267, 372, 291, 423, 4835, 14, 585, 339, 768, 1829, 272, 347, 5020, 8, 277, 304, 267, 408, 267, 520, 466, 26, 520, 533, 1705, 5031, 14, 11421, 8257, 14, 11421, 8257, 64, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 3200, 9, 267, 372, 291, 423, 3200, 14, 585, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 520, 466, 26, 1059, 267, 408, 267, 291, 423, 4883, 3917, 15953, 8, 277, 423, 633, 9, 267, 372, 291, 423, 633, 14, 585, 339, 347, 1218, 63, 3349, 8, 277, 12, 2396, 12, 1004, 29, 5031, 14, 20659, 14, 15953, 12, 931, 29, 5031, 14, 20659, 14, 15953, 12, 3421, 29, 5031, 14, 20659, 14, 15953, 304, 267, 408, 267, 520, 5352, 26, 658, 4030, 1182, 11857, 22075, 4597, 22075, 3417, 15, 18679, 22075, 4835, 15, 6223, 665, 1014, 921, 11071, 14, 5031, 14, 957, 15, 86, 19, 15, 11857, 15, 6223, 18740, 267, 520, 635, 2396, 26, 1059, 267, 520, 635, 1004, 26, 3000, 267, 520, 635, 931, 26, 1059, 267, 520, 635, 3421, 26, 3000, 267, 520, 4500, 26, 520, 533, 1705, 5031, 14, 11421, 7488, 14, 11421, 7488, 64, 267, 408, 267, 702, 1228,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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 ]
lin-credible/scikit-learn
examples/cluster/plot_kmeans_stability_low_dim_dense.py
338
4324
""" ============================================================ Empirical evaluation of the impact of k-means initialization ============================================================ Evaluate the ability of k-means initializations strategies to make the algorithm convergence robust as measured by the relative standard deviation of the inertia of the clustering (i.e. the sum of distances to the nearest cluster center). The first plot shows the best inertia reached for each combination of the model (``KMeans`` or ``MiniBatchKMeans``) and the init method (``init="random"`` or ``init="kmeans++"``) for increasing values of the ``n_init`` parameter that controls the number of initializations. The second plot demonstrate one single run of the ``MiniBatchKMeans`` estimator using a ``init="random"`` and ``n_init=1``. This run leads to a bad convergence (local optimum) with estimated centers stuck between ground truth clusters. The dataset used for evaluation is a 2D grid of isotropic Gaussian clusters widely spaced. """ print(__doc__) # Author: Olivier Grisel <olivier.grisel@ensta.org> # License: BSD 3 clause import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm from sklearn.utils import shuffle from sklearn.utils import check_random_state from sklearn.cluster import MiniBatchKMeans from sklearn.cluster import KMeans random_state = np.random.RandomState(0) # Number of run (with randomly generated dataset) for each strategy so as # to be able to compute an estimate of the standard deviation n_runs = 5 # k-means models can do several random inits so as to be able to trade # CPU time for convergence robustness n_init_range = np.array([1, 5, 10, 15, 20]) # Datasets generation parameters n_samples_per_center = 100 grid_size = 3 scale = 0.1 n_clusters = grid_size ** 2 def make_data(random_state, n_samples_per_center, grid_size, scale): random_state = check_random_state(random_state) centers = np.array([[i, j] for i in range(grid_size) for j in range(grid_size)]) n_clusters_true, n_features = centers.shape noise = random_state.normal( scale=scale, size=(n_samples_per_center, centers.shape[1])) X = np.concatenate([c + noise for c in centers]) y = np.concatenate([[i] * n_samples_per_center for i in range(n_clusters_true)]) return shuffle(X, y, random_state=random_state) # Part 1: Quantitative evaluation of various init methods fig = plt.figure() plots = [] legends = [] cases = [ (KMeans, 'k-means++', {}), (KMeans, 'random', {}), (MiniBatchKMeans, 'k-means++', {'max_no_improvement': 3}), (MiniBatchKMeans, 'random', {'max_no_improvement': 3, 'init_size': 500}), ] for factory, init, params in cases: print("Evaluation of %s with %s init" % (factory.__name__, init)) inertia = np.empty((len(n_init_range), n_runs)) for run_id in range(n_runs): X, y = make_data(run_id, n_samples_per_center, grid_size, scale) for i, n_init in enumerate(n_init_range): km = factory(n_clusters=n_clusters, init=init, random_state=run_id, n_init=n_init, **params).fit(X) inertia[i, run_id] = km.inertia_ p = plt.errorbar(n_init_range, inertia.mean(axis=1), inertia.std(axis=1)) plots.append(p[0]) legends.append("%s with %s init" % (factory.__name__, init)) plt.xlabel('n_init') plt.ylabel('inertia') plt.legend(plots, legends) plt.title("Mean inertia for various k-means init across %d runs" % n_runs) # Part 2: Qualitative visual inspection of the convergence X, y = make_data(random_state, n_samples_per_center, grid_size, scale) km = MiniBatchKMeans(n_clusters=n_clusters, init='random', n_init=1, random_state=random_state).fit(X) fig = plt.figure() for k in range(n_clusters): my_members = km.labels_ == k color = cm.spectral(float(k) / n_clusters, 1) plt.plot(X[my_members, 0], X[my_members, 1], 'o', marker='.', c=color) cluster_center = km.cluster_centers_[k] plt.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=color, markeredgecolor='k', markersize=6) plt.title("Example cluster allocation with a single random init\n" "with MiniBatchKMeans") plt.show()
bsd-3-clause
[ 624, 199, 12813, 5769, 199, 24949, 11735, 402, 314, 25568, 402, 1022, 13, 11579, 11097, 199, 12813, 5769, 199, 199, 25002, 314, 21255, 402, 1022, 13, 11579, 2536, 12270, 32647, 370, 1852, 199, 1589, 5563, 21346, 23399, 465, 27396, 701, 314, 3847, 4465, 199, 271, 12337, 402, 314, 315, 281, 14037, 402, 314, 19454, 334, 73, 14, 69, 14, 314, 3089, 402, 15108, 199, 475, 314, 17173, 4350, 8126, 680, 199, 199, 1918, 1642, 5137, 13703, 314, 5526, 315, 281, 14037, 13075, 367, 1924, 14665, 199, 1618, 314, 1402, 15693, 43, 21190, 1040, 503, 1124, 26822, 8842, 43, 21190, 16580, 436, 314, 4205, 1083, 199, 8, 1040, 826, 628, 2355, 31002, 503, 1124, 826, 628, 75, 11579, 4176, 2, 16580, 367, 22255, 1338, 402, 314, 199, 1040, 78, 63, 826, 1040, 2725, 626, 13467, 314, 1329, 402, 2536, 12270, 14, 199, 199, 1918, 3499, 5137, 23789, 18161, 1373, 2849, 1255, 402, 314, 1124, 26822, 8842, 43, 21190, 1040, 199, 8627, 1808, 282, 1124, 826, 628, 2355, 31002, 436, 1124, 78, 63, 826, 29, 17, 4345, 961, 1255, 27401, 370, 199, 65, 4875, 21346, 334, 1832, 5323, 453, 9, 543, 20077, 19190, 410, 10112, 199, 13007, 19252, 16865, 13865, 14, 199, 199, 1918, 4789, 1202, 367, 11735, 365, 282, 499, 36, 6068, 402, 365, 357, 2675, 530, 17131, 199, 9170, 20239, 590, 4601, 68, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 8027, 14, 4400, 465, 6904, 199, 199, 504, 6357, 14, 1208, 492, 13031, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 6357, 14, 4201, 492, 24954, 8842, 43, 21190, 199, 504, 6357, 14, 4201, 492, 1804, 21190, 199, 199, 2355, 63, 929, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 199, 3, 4860, 402, 1255, 334, 1045, 19311, 4046, 4789, 9, 367, 1924, 10054, 880, 465, 199, 3, 370, 506, 7688, 370, 4526, 376, 14497, 402, 314, 4465, 18458, 199, 78, 63, 10802, 275, 959, 199, 199, 3, 1022, 13, 11579, 1709, 883, 886, 9978, 2196, 315, 1405, 880, 465, 370, 506, 7688, 370, 21032, 199, 3, 11952, 900, 367, 21346, 23399, 4171, 199, 78, 63, 826, 63, 1842, 275, 980, 14, 1144, 779, 17, 12, 959, 12, 1616, 12, 4114, 12, 3388, 566, 199, 199, 3, 3918, 2193, 10152, 2633, 199, 78, 63, 3356, 63, 529, 63, 4218, 275, 2948, 199, 3825, 63, 890, 275, 650, 199, 3467, 275, 378, 14, 17, 199, 78, 63, 9170, 275, 6068, 63, 890, 1011, 499, 421, 199, 318, 1852, 63, 576, 8, 2355, 63, 929, 12, 302, 63, 3356, 63, 529, 63, 4218, 12, 6068, 63, 890, 12, 4666, 304, 272, 2196, 63, 929, 275, 1104, 63, 2355, 63, 929, 8, 2355, 63, 929, 9, 272, 19190, 275, 980, 14, 1144, 4038, 73, 12, 1335, 61, 717, 367, 284, 315, 1425, 8, 3825, 63, 890, 9, 717, 367, 1335, 315, 1425, 8, 3825, 63, 890, 3948, 272, 302, 63, 9170, 63, 2052, 12, 302, 63, 3179, 275, 19190, 14, 1392, 339, 11145, 275, 2196, 63, 929, 14, 3302, 8, 267, 4666, 29, 3467, 12, 1568, 2687, 78, 63, 3356, 63, 529, 63, 4218, 12, 19190, 14, 1392, 59, 17, 2459, 339, 1323, 275, 980, 14, 13433, 779, 67, 435, 11145, 367, 286, 315, 19190, 566, 272, 612, 275, 980, 14, 13433, 4038, 73, 61, 627, 302, 63, 3356, 63, 529, 63, 4218, 717, 367, 284, 315, 1425, 8, 78, 63, 9170, 63, 2052, 3948, 272, 372, 13031, 8, 56, 12, 612, 12, 2196, 63, 929, 29, 2355, 63, 929, 9, 199, 199, 3, 14320, 413, 26, 5843, 4466, 502, 857, 11735, 402, 7750, 4205, 3102, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 13701, 275, 942, 199, 4170, 3198, 275, 942, 199, 199, 9403, 275, 359, 272, 334, 43, 21190, 12, 283, 75, 13, 11579, 31249, 8613, 272, 334, 43, 21190, 12, 283, 2355, 297, 8613, 272, 334, 26822, 8842, 43, 21190, 12, 283, 75, 13, 11579, 31249, 791, 988, 63, 889, 63, 3236, 11750, 434, 356, 650, 8688, 272, 334, 26822, 8842, 43, 21190, 12, 283, 2355, 297, 791, 988, 63, 889, 63, 3236, 11750, 434, 356, 650, 12, 283, 826, 63, 890, 356, 6891, 8688, 199, 61, 199, 199, 509, 6434, 12, 4205, 12, 1862, 315, 5560, 26, 272, 870, 480, 29786, 402, 450, 83, 543, 450, 83, 4205, 2, 450, 334, 3702, 855, 354, 3108, 4205, 430, 272, 315, 281, 14037, 275, 980, 14, 1667, 1332, 552, 8, 78, 63, 826, 63, 1842, 395, 302, 63, 10802, 430, 339, 367, 1255, 63, 344, 315, 1425, 8, 78, 63, 10802, 304, 267, 1323, 12, 612, 275, 1852, 63, 576, 8, 1065, 63, 344, 12, 302, 63, 3356, 63, 529, 63, 4218, 12, 6068, 63, 890, 12, 4666, 9, 267, 367, 284, 12, 302, 63, 826, 315, 3874, 8, 78, 63, 826, 63, 1842, 304, 288, 16155, 275, 6434, 8, 78, 63, 9170, 29, 78, 63, 9170, 12, 4205, 29, 826, 12, 2196, 63, 929, 29, 1065, 63, 344, 12, 586, 302, 63, 826, 29, 78, 63, 826, 12, 1011, 1162, 680, 3269, 8, 56, 9, 288, 315, 281, 14037, 59, 73, 12, 1255, 63, 344, 61, 275, 16155, 14, 16187, 14037, 63, 272, 299, 275, 4488, 14, 705, 1700, 8, 78, 63, 826, 63, 1842, 12, 315, 281, 14037, 14, 3670, 8, 3127, 29, 17, 395, 315, 281, 14037, 14, 1516, 8, 3127, 29, 17, 430, 272, 19695, 14, 740, 8, 80, 59, 16, 566, 272, 6768, 3198, 14, 740, 3647, 83, 543, 450, 83, 4205, 2, 450, 334, 3702, 855, 354, 3108, 4205, 430, 199, 199, 6003, 14, 14168, 360, 78, 63, 826, 358, 199, 6003, 14, 13849, 360, 16187, 14037, 358, 199, 6003, 14, 10231, 8, 13701, 12, 6768, 3198, 9, 199, 6003, 14, 1213, 480, 14825, 315, 281, 14037, 367, 7750, 1022, 13, 11579, 4205, 9371, 450, 68, 7858, 2, 450, 302, 63, 10802, 9, 199, 199 ]
[ 199, 12813, 5769, 199, 24949, 11735, 402, 314, 25568, 402, 1022, 13, 11579, 11097, 199, 12813, 5769, 199, 199, 25002, 314, 21255, 402, 1022, 13, 11579, 2536, 12270, 32647, 370, 1852, 199, 1589, 5563, 21346, 23399, 465, 27396, 701, 314, 3847, 4465, 199, 271, 12337, 402, 314, 315, 281, 14037, 402, 314, 19454, 334, 73, 14, 69, 14, 314, 3089, 402, 15108, 199, 475, 314, 17173, 4350, 8126, 680, 199, 199, 1918, 1642, 5137, 13703, 314, 5526, 315, 281, 14037, 13075, 367, 1924, 14665, 199, 1618, 314, 1402, 15693, 43, 21190, 1040, 503, 1124, 26822, 8842, 43, 21190, 16580, 436, 314, 4205, 1083, 199, 8, 1040, 826, 628, 2355, 31002, 503, 1124, 826, 628, 75, 11579, 4176, 2, 16580, 367, 22255, 1338, 402, 314, 199, 1040, 78, 63, 826, 1040, 2725, 626, 13467, 314, 1329, 402, 2536, 12270, 14, 199, 199, 1918, 3499, 5137, 23789, 18161, 1373, 2849, 1255, 402, 314, 1124, 26822, 8842, 43, 21190, 1040, 199, 8627, 1808, 282, 1124, 826, 628, 2355, 31002, 436, 1124, 78, 63, 826, 29, 17, 4345, 961, 1255, 27401, 370, 199, 65, 4875, 21346, 334, 1832, 5323, 453, 9, 543, 20077, 19190, 410, 10112, 199, 13007, 19252, 16865, 13865, 14, 199, 199, 1918, 4789, 1202, 367, 11735, 365, 282, 499, 36, 6068, 402, 365, 357, 2675, 530, 17131, 199, 9170, 20239, 590, 4601, 68, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 8027, 14, 4400, 465, 6904, 199, 199, 504, 6357, 14, 1208, 492, 13031, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 6357, 14, 4201, 492, 24954, 8842, 43, 21190, 199, 504, 6357, 14, 4201, 492, 1804, 21190, 199, 199, 2355, 63, 929, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 199, 3, 4860, 402, 1255, 334, 1045, 19311, 4046, 4789, 9, 367, 1924, 10054, 880, 465, 199, 3, 370, 506, 7688, 370, 4526, 376, 14497, 402, 314, 4465, 18458, 199, 78, 63, 10802, 275, 959, 199, 199, 3, 1022, 13, 11579, 1709, 883, 886, 9978, 2196, 315, 1405, 880, 465, 370, 506, 7688, 370, 21032, 199, 3, 11952, 900, 367, 21346, 23399, 4171, 199, 78, 63, 826, 63, 1842, 275, 980, 14, 1144, 779, 17, 12, 959, 12, 1616, 12, 4114, 12, 3388, 566, 199, 199, 3, 3918, 2193, 10152, 2633, 199, 78, 63, 3356, 63, 529, 63, 4218, 275, 2948, 199, 3825, 63, 890, 275, 650, 199, 3467, 275, 378, 14, 17, 199, 78, 63, 9170, 275, 6068, 63, 890, 1011, 499, 421, 199, 318, 1852, 63, 576, 8, 2355, 63, 929, 12, 302, 63, 3356, 63, 529, 63, 4218, 12, 6068, 63, 890, 12, 4666, 304, 272, 2196, 63, 929, 275, 1104, 63, 2355, 63, 929, 8, 2355, 63, 929, 9, 272, 19190, 275, 980, 14, 1144, 4038, 73, 12, 1335, 61, 717, 367, 284, 315, 1425, 8, 3825, 63, 890, 9, 717, 367, 1335, 315, 1425, 8, 3825, 63, 890, 3948, 272, 302, 63, 9170, 63, 2052, 12, 302, 63, 3179, 275, 19190, 14, 1392, 339, 11145, 275, 2196, 63, 929, 14, 3302, 8, 267, 4666, 29, 3467, 12, 1568, 2687, 78, 63, 3356, 63, 529, 63, 4218, 12, 19190, 14, 1392, 59, 17, 2459, 339, 1323, 275, 980, 14, 13433, 779, 67, 435, 11145, 367, 286, 315, 19190, 566, 272, 612, 275, 980, 14, 13433, 4038, 73, 61, 627, 302, 63, 3356, 63, 529, 63, 4218, 717, 367, 284, 315, 1425, 8, 78, 63, 9170, 63, 2052, 3948, 272, 372, 13031, 8, 56, 12, 612, 12, 2196, 63, 929, 29, 2355, 63, 929, 9, 199, 199, 3, 14320, 413, 26, 5843, 4466, 502, 857, 11735, 402, 7750, 4205, 3102, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 13701, 275, 942, 199, 4170, 3198, 275, 942, 199, 199, 9403, 275, 359, 272, 334, 43, 21190, 12, 283, 75, 13, 11579, 31249, 8613, 272, 334, 43, 21190, 12, 283, 2355, 297, 8613, 272, 334, 26822, 8842, 43, 21190, 12, 283, 75, 13, 11579, 31249, 791, 988, 63, 889, 63, 3236, 11750, 434, 356, 650, 8688, 272, 334, 26822, 8842, 43, 21190, 12, 283, 2355, 297, 791, 988, 63, 889, 63, 3236, 11750, 434, 356, 650, 12, 283, 826, 63, 890, 356, 6891, 8688, 199, 61, 199, 199, 509, 6434, 12, 4205, 12, 1862, 315, 5560, 26, 272, 870, 480, 29786, 402, 450, 83, 543, 450, 83, 4205, 2, 450, 334, 3702, 855, 354, 3108, 4205, 430, 272, 315, 281, 14037, 275, 980, 14, 1667, 1332, 552, 8, 78, 63, 826, 63, 1842, 395, 302, 63, 10802, 430, 339, 367, 1255, 63, 344, 315, 1425, 8, 78, 63, 10802, 304, 267, 1323, 12, 612, 275, 1852, 63, 576, 8, 1065, 63, 344, 12, 302, 63, 3356, 63, 529, 63, 4218, 12, 6068, 63, 890, 12, 4666, 9, 267, 367, 284, 12, 302, 63, 826, 315, 3874, 8, 78, 63, 826, 63, 1842, 304, 288, 16155, 275, 6434, 8, 78, 63, 9170, 29, 78, 63, 9170, 12, 4205, 29, 826, 12, 2196, 63, 929, 29, 1065, 63, 344, 12, 586, 302, 63, 826, 29, 78, 63, 826, 12, 1011, 1162, 680, 3269, 8, 56, 9, 288, 315, 281, 14037, 59, 73, 12, 1255, 63, 344, 61, 275, 16155, 14, 16187, 14037, 63, 272, 299, 275, 4488, 14, 705, 1700, 8, 78, 63, 826, 63, 1842, 12, 315, 281, 14037, 14, 3670, 8, 3127, 29, 17, 395, 315, 281, 14037, 14, 1516, 8, 3127, 29, 17, 430, 272, 19695, 14, 740, 8, 80, 59, 16, 566, 272, 6768, 3198, 14, 740, 3647, 83, 543, 450, 83, 4205, 2, 450, 334, 3702, 855, 354, 3108, 4205, 430, 199, 199, 6003, 14, 14168, 360, 78, 63, 826, 358, 199, 6003, 14, 13849, 360, 16187, 14037, 358, 199, 6003, 14, 10231, 8, 13701, 12, 6768, 3198, 9, 199, 6003, 14, 1213, 480, 14825, 315, 281, 14037, 367, 7750, 1022, 13, 11579, 4205, 9371, 450, 68, 7858, 2, 450, 302, 63, 10802, 9, 199, 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,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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 ]
tyler6389/count_kernel_grand
scripts/rt-tester/rt-tester.py
11005
5307
#!/usr/bin/python # # rt-mutex tester # # (C) 2006 Thomas Gleixner <tglx@linutronix.de> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # import os import sys import getopt import shutil import string # Globals quiet = 0 test = 0 comments = 0 sysfsprefix = "/sys/devices/system/rttest/rttest" statusfile = "/status" commandfile = "/command" # Command opcodes cmd_opcodes = { "schedother" : "1", "schedfifo" : "2", "lock" : "3", "locknowait" : "4", "lockint" : "5", "lockintnowait" : "6", "lockcont" : "7", "unlock" : "8", "signal" : "11", "resetevent" : "98", "reset" : "99", } test_opcodes = { "prioeq" : ["P" , "eq" , None], "priolt" : ["P" , "lt" , None], "priogt" : ["P" , "gt" , None], "nprioeq" : ["N" , "eq" , None], "npriolt" : ["N" , "lt" , None], "npriogt" : ["N" , "gt" , None], "unlocked" : ["M" , "eq" , 0], "trylock" : ["M" , "eq" , 1], "blocked" : ["M" , "eq" , 2], "blockedwake" : ["M" , "eq" , 3], "locked" : ["M" , "eq" , 4], "opcodeeq" : ["O" , "eq" , None], "opcodelt" : ["O" , "lt" , None], "opcodegt" : ["O" , "gt" , None], "eventeq" : ["E" , "eq" , None], "eventlt" : ["E" , "lt" , None], "eventgt" : ["E" , "gt" , None], } # Print usage information def usage(): print "rt-tester.py <-c -h -q -t> <testfile>" print " -c display comments after first command" print " -h help" print " -q quiet mode" print " -t test mode (syntax check)" print " testfile: read test specification from testfile" print " otherwise from stdin" return # Print progress when not in quiet mode def progress(str): if not quiet: print str # Analyse a status value def analyse(val, top, arg): intval = int(val) if top[0] == "M": intval = intval / (10 ** int(arg)) intval = intval % 10 argval = top[2] elif top[0] == "O": argval = int(cmd_opcodes.get(arg, arg)) else: argval = int(arg) # progress("%d %s %d" %(intval, top[1], argval)) if top[1] == "eq" and intval == argval: return 1 if top[1] == "lt" and intval < argval: return 1 if top[1] == "gt" and intval > argval: return 1 return 0 # Parse the commandline try: (options, arguments) = getopt.getopt(sys.argv[1:],'chqt') except getopt.GetoptError, ex: usage() sys.exit(1) # Parse commandline options for option, value in options: if option == "-c": comments = 1 elif option == "-q": quiet = 1 elif option == "-t": test = 1 elif option == '-h': usage() sys.exit(0) # Select the input source if arguments: try: fd = open(arguments[0]) except Exception,ex: sys.stderr.write("File not found %s\n" %(arguments[0])) sys.exit(1) else: fd = sys.stdin linenr = 0 # Read the test patterns while 1: linenr = linenr + 1 line = fd.readline() if not len(line): break line = line.strip() parts = line.split(":") if not parts or len(parts) < 1: continue if len(parts[0]) == 0: continue if parts[0].startswith("#"): if comments > 1: progress(line) continue if comments == 1: comments = 2 progress(line) cmd = parts[0].strip().lower() opc = parts[1].strip().lower() tid = parts[2].strip() dat = parts[3].strip() try: # Test or wait for a status value if cmd == "t" or cmd == "w": testop = test_opcodes[opc] fname = "%s%s%s" %(sysfsprefix, tid, statusfile) if test: print fname continue while 1: query = 1 fsta = open(fname, 'r') status = fsta.readline().strip() fsta.close() stat = status.split(",") for s in stat: s = s.strip() if s.startswith(testop[0]): # Separate status value val = s[2:].strip() query = analyse(val, testop, dat) break if query or cmd == "t": break progress(" " + status) if not query: sys.stderr.write("Test failed in line %d\n" %(linenr)) sys.exit(1) # Issue a command to the tester elif cmd == "c": cmdnr = cmd_opcodes[opc] # Build command string and sys filename cmdstr = "%s:%s" %(cmdnr, dat) fname = "%s%s%s" %(sysfsprefix, tid, commandfile) if test: print fname continue fcmd = open(fname, 'w') fcmd.write(cmdstr) fcmd.close() except Exception,ex: sys.stderr.write(str(ex)) sys.stderr.write("\nSyntax error in line %d\n" %(linenr)) if not test: fd.close() sys.exit(1) # Normal exit pass print "Pass" sys.exit(0)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 14059, 13, 19078, 17570, 199, 3, 199, 3, 334, 35, 9, 8315, 27864, 598, 274, 1148, 1372, 665, 84, 18660, 32, 472, 5373, 1148, 14, 271, 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, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 5145, 199, 646, 1059, 199, 199, 3, 13641, 83, 199, 10243, 275, 378, 199, 396, 275, 378, 199, 6223, 275, 378, 199, 199, 1274, 2319, 1861, 275, 3286, 1274, 15, 6410, 15, 2253, 15, 2591, 396, 15, 2591, 396, 2, 199, 1205, 493, 275, 3286, 1205, 2, 199, 1531, 493, 275, 3286, 1531, 2, 199, 199, 3, 5817, 27388, 199, 1760, 63, 22022, 275, 469, 272, 298, 10487, 1848, 2, 259, 520, 298, 17, 401, 272, 298, 10487, 22976, 2, 258, 520, 298, 18, 401, 272, 298, 831, 2, 3515, 520, 298, 19, 401, 272, 298, 831, 20870, 2, 259, 520, 298, 20, 401, 272, 298, 831, 442, 2, 755, 520, 298, 21, 401, 272, 298, 831, 442, 20870, 2, 520, 298, 22, 401, 272, 298, 831, 11096, 2, 420, 520, 298, 23, 401, 272, 298, 17966, 2, 263, 520, 298, 24, 401, 272, 298, 4653, 2, 263, 520, 298, 845, 401, 272, 298, 264, 30563, 782, 2, 259, 520, 298, 2905, 401, 272, 298, 3958, 2, 260, 520, 298, 1020, 401, 272, 789, 199, 199, 396, 63, 22022, 275, 469, 272, 298, 20572, 4077, 2, 263, 520, 2097, 48, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1359, 28934, 2, 263, 520, 2097, 48, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1359, 974, 84, 2, 263, 520, 2097, 48, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 78, 20572, 4077, 2, 755, 520, 2097, 46, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 78, 1359, 28934, 2, 755, 520, 2097, 46, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 78, 1359, 974, 84, 2, 755, 520, 2097, 46, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 32489, 2, 420, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 378, 467, 272, 298, 893, 831, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 413, 467, 272, 298, 17726, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 499, 467, 272, 298, 17726, 15181, 2, 257, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 650, 467, 272, 298, 9325, 2, 263, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 841, 467, 272, 298, 14325, 4077, 2, 420, 520, 2097, 47, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 14325, 4116, 2, 420, 520, 2097, 47, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 14325, 3308, 2, 420, 520, 2097, 47, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 12056, 266, 81, 2, 755, 520, 2097, 37, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1430, 4116, 2, 755, 520, 2097, 37, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1430, 3308, 2, 755, 520, 2097, 37, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 789, 199, 199, 3, 9101, 4503, 2556, 199, 318, 4503, 837, 272, 870, 298, 2591, 13, 8234, 14, 647, 25549, 67, 446, 72, 446, 81, 446, 84, 30, 665, 21091, 4335, 272, 870, 298, 446, 67, 259, 2929, 6786, 2410, 1642, 1414, 2, 272, 870, 298, 446, 72, 259, 1720, 2, 272, 870, 298, 446, 81, 259, 11971, 818, 2, 272, 870, 298, 446, 84, 259, 511, 818, 334, 7093, 1104, 2924, 272, 870, 298, 30530, 26, 1586, 511, 8929, 687, 30530, 2, 272, 870, 298, 4257, 687, 9009, 2, 272, 372, 199, 199, 3, 9101, 6696, 1380, 440, 315, 11971, 818, 199, 318, 6696, 8, 495, 304, 272, 340, 440, 11971, 26, 267, 870, 620, 199, 199, 3, 14279, 261, 282, 2004, 574, 199, 318, 21297, 8, 637, 12, 2746, 12, 1680, 304, 339, 26111, 275, 1109, 8, 637, 9, 339, 340, 2746, 59, 16, 61, 508, 298, 45, 582, 267, 26111, 275, 26111, 1182, 334, 709, 1011, 1109, 8, 1273, 430, 199, 198, 442, 637, 275, 26111, 450, 1616, 267, 27610, 275, 2746, 59, 18, 61, 272, 916, 2746, 59, 16, 61, 508, 298, 47, 582, 267, 27610, 275, 1109, 8, 1760, 63, 22022, 14, 362, 8, 1273, 12, 1680, 430, 272, 587, 26, 267, 27610, 275, 1109, 8, 1273, 9, 339, 327, 6696, 3647, 68, 450, 83, 450, 68, 2, 2818, 442, 637, 12, 2746, 59, 17, 467, 27610, 430, 339, 340, 2746, 59, 17, 61, 508, 298, 4077, 2, 436, 26111, 508, 27610, 26, 199, 198, 1107, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 4116, 2, 436, 26111, 665, 27610, 26, 267, 372, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 3308, 2, 436, 26111, 690, 27610, 26, 199, 198, 1107, 413, 272, 372, 378, 199, 199, 3, 6077, 314, 28279, 199, 893, 26, 272, 334, 1419, 12, 2368, 9, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 7, 335, 8440, 358, 199, 2590, 12733, 14, 1002, 29368, 12, 444, 26, 272, 4503, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 6077, 28279, 1511, 199, 509, 945, 12, 574, 315, 1511, 26, 272, 340, 945, 508, 3905, 67, 582, 267, 6786, 275, 413, 272, 916, 945, 508, 3905, 81, 582, 267, 11971, 275, 413, 272, 916, 945, 508, 3905, 84, 582, 267, 511, 275, 413, 272, 916, 945, 508, 2475, 72, 356, 267, 4503, 342, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 9496, 314, 1324, 1350, 199, 692, 2368, 26, 272, 862, 26, 267, 6111, 275, 1551, 8, 4958, 59, 16, 566, 272, 871, 2186, 12, 476, 26, 267, 984, 14, 3083, 14, 952, 480, 1173, 440, 1911, 450, 83, 60, 78, 2, 2818, 4958, 59, 16, 2459, 267, 984, 14, 2224 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 14059, 13, 19078, 17570, 199, 3, 199, 3, 334, 35, 9, 8315, 27864, 598, 274, 1148, 1372, 665, 84, 18660, 32, 472, 5373, 1148, 14, 271, 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, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 5145, 199, 646, 1059, 199, 199, 3, 13641, 83, 199, 10243, 275, 378, 199, 396, 275, 378, 199, 6223, 275, 378, 199, 199, 1274, 2319, 1861, 275, 3286, 1274, 15, 6410, 15, 2253, 15, 2591, 396, 15, 2591, 396, 2, 199, 1205, 493, 275, 3286, 1205, 2, 199, 1531, 493, 275, 3286, 1531, 2, 199, 199, 3, 5817, 27388, 199, 1760, 63, 22022, 275, 469, 272, 298, 10487, 1848, 2, 259, 520, 298, 17, 401, 272, 298, 10487, 22976, 2, 258, 520, 298, 18, 401, 272, 298, 831, 2, 3515, 520, 298, 19, 401, 272, 298, 831, 20870, 2, 259, 520, 298, 20, 401, 272, 298, 831, 442, 2, 755, 520, 298, 21, 401, 272, 298, 831, 442, 20870, 2, 520, 298, 22, 401, 272, 298, 831, 11096, 2, 420, 520, 298, 23, 401, 272, 298, 17966, 2, 263, 520, 298, 24, 401, 272, 298, 4653, 2, 263, 520, 298, 845, 401, 272, 298, 264, 30563, 782, 2, 259, 520, 298, 2905, 401, 272, 298, 3958, 2, 260, 520, 298, 1020, 401, 272, 789, 199, 199, 396, 63, 22022, 275, 469, 272, 298, 20572, 4077, 2, 263, 520, 2097, 48, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1359, 28934, 2, 263, 520, 2097, 48, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1359, 974, 84, 2, 263, 520, 2097, 48, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 78, 20572, 4077, 2, 755, 520, 2097, 46, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 78, 1359, 28934, 2, 755, 520, 2097, 46, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 78, 1359, 974, 84, 2, 755, 520, 2097, 46, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 32489, 2, 420, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 378, 467, 272, 298, 893, 831, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 413, 467, 272, 298, 17726, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 499, 467, 272, 298, 17726, 15181, 2, 257, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 650, 467, 272, 298, 9325, 2, 263, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 841, 467, 272, 298, 14325, 4077, 2, 420, 520, 2097, 47, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 14325, 4116, 2, 420, 520, 2097, 47, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 14325, 3308, 2, 420, 520, 2097, 47, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 12056, 266, 81, 2, 755, 520, 2097, 37, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1430, 4116, 2, 755, 520, 2097, 37, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1430, 3308, 2, 755, 520, 2097, 37, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 789, 199, 199, 3, 9101, 4503, 2556, 199, 318, 4503, 837, 272, 870, 298, 2591, 13, 8234, 14, 647, 25549, 67, 446, 72, 446, 81, 446, 84, 30, 665, 21091, 4335, 272, 870, 298, 446, 67, 259, 2929, 6786, 2410, 1642, 1414, 2, 272, 870, 298, 446, 72, 259, 1720, 2, 272, 870, 298, 446, 81, 259, 11971, 818, 2, 272, 870, 298, 446, 84, 259, 511, 818, 334, 7093, 1104, 2924, 272, 870, 298, 30530, 26, 1586, 511, 8929, 687, 30530, 2, 272, 870, 298, 4257, 687, 9009, 2, 272, 372, 199, 199, 3, 9101, 6696, 1380, 440, 315, 11971, 818, 199, 318, 6696, 8, 495, 304, 272, 340, 440, 11971, 26, 267, 870, 620, 199, 199, 3, 14279, 261, 282, 2004, 574, 199, 318, 21297, 8, 637, 12, 2746, 12, 1680, 304, 339, 26111, 275, 1109, 8, 637, 9, 339, 340, 2746, 59, 16, 61, 508, 298, 45, 582, 267, 26111, 275, 26111, 1182, 334, 709, 1011, 1109, 8, 1273, 430, 199, 198, 442, 637, 275, 26111, 450, 1616, 267, 27610, 275, 2746, 59, 18, 61, 272, 916, 2746, 59, 16, 61, 508, 298, 47, 582, 267, 27610, 275, 1109, 8, 1760, 63, 22022, 14, 362, 8, 1273, 12, 1680, 430, 272, 587, 26, 267, 27610, 275, 1109, 8, 1273, 9, 339, 327, 6696, 3647, 68, 450, 83, 450, 68, 2, 2818, 442, 637, 12, 2746, 59, 17, 467, 27610, 430, 339, 340, 2746, 59, 17, 61, 508, 298, 4077, 2, 436, 26111, 508, 27610, 26, 199, 198, 1107, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 4116, 2, 436, 26111, 665, 27610, 26, 267, 372, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 3308, 2, 436, 26111, 690, 27610, 26, 199, 198, 1107, 413, 272, 372, 378, 199, 199, 3, 6077, 314, 28279, 199, 893, 26, 272, 334, 1419, 12, 2368, 9, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 7, 335, 8440, 358, 199, 2590, 12733, 14, 1002, 29368, 12, 444, 26, 272, 4503, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 6077, 28279, 1511, 199, 509, 945, 12, 574, 315, 1511, 26, 272, 340, 945, 508, 3905, 67, 582, 267, 6786, 275, 413, 272, 916, 945, 508, 3905, 81, 582, 267, 11971, 275, 413, 272, 916, 945, 508, 3905, 84, 582, 267, 511, 275, 413, 272, 916, 945, 508, 2475, 72, 356, 267, 4503, 342, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 9496, 314, 1324, 1350, 199, 692, 2368, 26, 272, 862, 26, 267, 6111, 275, 1551, 8, 4958, 59, 16, 566, 272, 871, 2186, 12, 476, 26, 267, 984, 14, 3083, 14, 952, 480, 1173, 440, 1911, 450, 83, 60, 78, 2, 2818, 4958, 59, 16, 2459, 267, 984, 14, 2224, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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SE for details. """ What I want it to look like: +- One | \- Two | |- Three | |- Four | +- Five | | \- Six | |- Seven +- Eight | \- Nine """ import os from Tkinter import END, Listbox, Tk, Scrollbar, LEFT, BOTH, RIGHT, Y class Node: def __init__(self): """ Do whatever you want here. """ self.item=None def getName(self): """ Return the name of this node in the tree. """ pass def isExpandable(self): """ Return true if this node is expandable. """ return len(self.getSubNodes())>0 def getSubNodes(self): """ Return the sub nodes of this node. """ return [] def gotDoubleClick(self): """ Called when we are double clicked. """ pass def updateMe(self): """ Call me when something about me changes, so that my representation changes. """ if self.item: self.item.update() class FileNode(Node): def __init__(self,name): Node.__init__(self) self.name=name def getName(self): return os.path.basename(self.name) def isExpandable(self): return os.path.isdir(self.name) def getSubNodes(self): names=map(lambda x,n=self.name:os.path.join(n,x),os.listdir(self.name)) return map(FileNode,names) class TreeItem: def __init__(self,widget,parent,node): self.widget=widget self.node=node node.item=self if self.node.isExpandable(): self.expand=0 else: self.expand=None self.parent=parent if parent: self.level=self.parent.level+1 else: self.level=0 self.first=0 # gets set in Tree.expand() self.subitems=[] def __del__(self): del self.node del self.widget def __repr__(self): return "<Item for Node %s at level %s>"%(self.node.getName(),self.level) def render(self): """ Override in a subclass. """ raise NotImplementedError def update(self): self.widget.update(self) class ListboxTreeItem(TreeItem): def render(self): start=self.level*"| " if self.expand==None and not self.first: start=start+"|" elif self.expand==0: start=start+"L" elif self.expand==1: start=start+"+" else: start=start+"\\" r=[start+"- "+self.node.getName()] if self.expand: for i in self.subitems: r.extend(i.render()) return r class ListboxTree: def __init__(self,parent=None,**options): self.box=apply(Listbox,[parent],options) self.box.bind("<Double-1>",self.flip) self.roots=[] self.items=[] def pack(self,*args,**kw): """ for packing. """ apply(self.box.pack,args,kw) def grid(self,*args,**kw): """ for gridding. """ apply(self.box.grid,args,kw) def yview(self,*args,**kw): """ for scrolling. """ apply(self.box.yview,args,kw) def addRoot(self,node): r=ListboxTreeItem(self,None,node) self.roots.append(r) self.items.append(r) self.box.insert(END,r.render()[0]) return r def curselection(self): c=self.box.curselection() if not c: return return self.items[int(c[0])] def flip(self,*foo): if not self.box.curselection(): return item=self.items[int(self.box.curselection()[0])] if item.expand==None: return if not item.expand: self.expand(item) else: self.close(item) item.node.gotDoubleClick() def expand(self,item): if item.expand or item.expand==None: return item.expand=1 item.subitems=map(lambda x,i=item,s=self:ListboxTreeItem(s,i,x),item.node.getSubNodes()) if item.subitems: item.subitems[0].first=1 i=self.items.index(item) self.items,after=self.items[:i+1],self.items[i+1:] self.items=self.items+item.subitems+after c=self.items.index(item) self.box.delete(c) r=item.render() for i in r: self.box.insert(c,i) c=c+1 def close(self,item): if not item.expand: return item.expand=0 length=len(item.subitems) for i in item.subitems: self.close(i) c=self.items.index(item) del self.items[c+1:c+1+length] for i in range(length+1): self.box.delete(c) self.box.insert(c,item.render()[0]) def remove(self,item): if item.expand: self.close(item) c=self.items.index(item) del self.items[c] if item.parent: item.parent.subitems.remove(item) self.box.delete(c) def update(self,item): if item.expand==None: c=self.items.index(item) self.box.delete(c) self.box.insert(c,item.render()[0]) elif item.expand: self.close(item) self.expand(item) if __name__=="__main__": tk=Tk() s=Scrollbar() t=ListboxTree(tk,yscrollcommand=s.set) t.pack(side=LEFT,fill=BOTH) s.config(command=t.yview) s.pack(side=RIGHT,fill=Y) t.addRoot(FileNode("C:/")) #mainloop()
mit
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 21015, 473, 2934, 652, 370, 3648, 2839, 26, 199, 199, 16341, 7309, 199, 92, 971, 13, 16853, 199, 92, 1204, 13, 30467, 199, 92, 1204, 13, 23843, 199, 92, 435, 13, 481, 1912, 199, 92, 1204, 971, 13, 428, 1148, 199, 92, 1204, 13, 3240, 1856, 199, 16341, 662, 1070, 199, 92, 971, 13, 653, 1132, 199, 624, 199, 199, 646, 747, 199, 504, 16826, 492, 7729, 12, 3820, 1977, 12, 12435, 12, 13916, 2827, 1700, 12, 6578, 12, 699, 22949, 12, 7052, 12, 1488, 199, 199, 533, 5013, 26, 272, 347, 636, 826, 721, 277, 304, 267, 408, 267, 4226, 15685, 1265, 2934, 2348, 14, 267, 408, 267, 291, 14, 1053, 29, 403, 272, 347, 664, 985, 8, 277, 304, 267, 408, 267, 1432, 314, 536, 402, 642, 1031, 315, 314, 3123, 14, 267, 408, 267, 986, 272, 347, 365, 12839, 461, 8, 277, 304, 267, 408, 267, 1432, 2549, 340, 642, 1031, 365, 6544, 461, 14, 267, 408, 267, 372, 822, 8, 277, 14, 362, 2610, 6300, 1012, 30, 16, 272, 347, 664, 2610, 6300, 8, 277, 304, 267, 408, 267, 1432, 314, 1007, 3380, 402, 642, 1031, 14, 267, 408, 267, 372, 942, 272, 347, 4788, 7281, 12040, 8, 277, 304, 267, 408, 267, 12295, 1380, 781, 787, 4270, 28614, 14, 267, 408, 267, 986, 272, 347, 1678, 1352, 8, 277, 304, 267, 408, 267, 6523, 562, 1380, 6020, 3595, 562, 4493, 12, 880, 626, 3002, 6025, 267, 4493, 14, 267, 408, 267, 340, 291, 14, 1053, 26, 288, 291, 14, 1053, 14, 873, 342, 199, 199, 533, 3814, 1716, 8, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 354, 304, 267, 5013, 855, 826, 721, 277, 9, 267, 291, 14, 354, 29, 354, 272, 347, 664, 985, 8, 277, 304, 267, 372, 747, 14, 515, 14, 4846, 8, 277, 14, 354, 9, 272, 347, 365, 12839, 461, 8, 277, 304, 267, 372, 747, 14, 515, 14, 6027, 8, 277, 14, 354, 9, 272, 347, 664, 2610, 6300, 8, 277, 304, 267, 1561, 29, 1130, 8, 2734, 671, 12, 78, 29, 277, 14, 354, 26, 736, 14, 515, 14, 904, 8, 78, 12, 88, 395, 736, 14, 7374, 8, 277, 14, 354, 430, 267, 372, 2341, 8, 1173, 1716, 12, 1247, 9, 199, 199, 533, 12178, 2081, 26, 272, 347, 636, 826, 721, 277, 12, 3440, 12, 1708, 12, 932, 304, 267, 291, 14, 3440, 29, 3440, 267, 291, 14, 932, 29, 932, 267, 1031, 14, 1053, 29, 277, 267, 340, 291, 14, 932, 14, 374, 12839, 461, 837, 288, 291, 14, 4441, 29, 16, 267, 587, 26, 288, 291, 14, 4441, 29, 403, 267, 291, 14, 1708, 29, 1708, 267, 340, 1676, 26, 288, 291, 14, 1896, 29, 277, 14, 1708, 14, 1896, 11, 17, 267, 587, 26, 288, 291, 14, 1896, 29, 16, 267, 291, 14, 2246, 29, 16, 327, 7545, 663, 315, 12178, 14, 4441, 342, 267, 291, 14, 954, 1744, 9811, 272, 347, 636, 2264, 721, 277, 304, 267, 2150, 291, 14, 932, 267, 2150, 291, 14, 3440, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 2081, 367, 5013, 450, 83, 737, 2166, 450, 83, 4335, 2840, 277, 14, 932, 14, 16405, 1062, 277, 14, 1896, 9, 272, 347, 3795, 8, 277, 304, 267, 408, 267, 11041, 315, 282, 5516, 14, 267, 408, 267, 746, 4279, 272, 347, 1678, 8, 277, 304, 267, 291, 14, 3440, 14, 873, 8, 277, 9, 199, 199, 533, 3820, 1977, 3987, 2081, 8, 3987, 2081, 304, 272, 347, 3795, 8, 277, 304, 267, 1343, 29, 277, 14, 1896, 12469, 92, 259, 298, 267, 340, 291, 14, 4441, 389, 403, 436, 440, 291, 14, 2246, 26, 288, 1343, 29, 928, 5207, 25576, 267, 916, 291, 14, 4441, 389, 16, 26, 288, 1343, 29, 928, 5207, 44, 2, 267, 916, 291, 14, 4441, 389, 17, 26, 288, 1343, 29, 928, 5207, 5207, 267, 587, 26, 288, 1343, 29, 928, 5207, 15022, 267, 519, 1524, 928, 14255, 7210, 277, 14, 932, 14, 16405, 5106, 267, 340, 291, 14, 4441, 26, 288, 367, 284, 315, 291, 14, 954, 1744, 26, 355, 519, 14, 2880, 8, 73, 14, 3352, 1012, 267, 372, 519, 199, 199, 533, 3820, 1977, 3987, 26, 272, 347, 636, 826, 721, 277, 12, 1708, 29, 403, 12663, 1419, 304, 267, 291, 14, 1977, 29, 4998, 8, 1296, 1977, 14343, 1708, 467, 1419, 9, 267, 291, 14, 1977, 14, 3409, 6757, 7281, 13, 17, 7166, 277, 14, 16114, 9, 267, 291, 14, 12065, 9811, 267, 291, 14, 1744, 9811, 272, 347, 1706, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 1706, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 1389, 12, 589, 12, 829, 9, 272, 347, 6068, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 27591, 617, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 3825, 12, 589, 12, 829, 9, 272, 347, 612, 1345, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 13704, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 89, 1345, 12, 589, 12, 829, 9, 272, 347, 1050, 6405, 8, 277, 12, 932, 304, 267, 519, 29, 1296, 1977, 3987, 2081, 8, 277, 12, 403, 12, 932, 9, 267, 291, 14, 12065, 14, 740, 8, 82, 9, 267, 291, 14, 1744, 14, 740, 8, 82, 9, 267, 291, 14, 1977, 14, 3176, 8, 3902, 12, 82, 14, 3352, 3430, 16, 566, 267, 372, 519, 272, 347, 1094, 5592, 8, 277, 304, 267, 286, 29, 277, 14, 1977, 14, 895, 5592, 342, 267, 340, 440, 286, 26, 372, 267, 372, 291, 14, 1744, 59, 442, 8, 67, 59, 16, 12457, 272, 347, 18761, 8, 277, 19166, 1421, 304, 267, 340, 440, 291, 14, 1977, 14, 895, 5592, 837, 372, 267, 1242, 29, 277, 14, 1744, 59, 442, 8, 277, 14, 1977, 14, 895, 5592, 3430, 16, 12457, 267, 340, 1242, 14, 4441, 389, 403, 26, 372, 267, 340, 440, 1242, 14, 4441, 26, 288, 291, 14, 4441, 8 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 21015, 473, 2934, 652, 370, 3648, 2839, 26, 199, 199, 16341, 7309, 199, 92, 971, 13, 16853, 199, 92, 1204, 13, 30467, 199, 92, 1204, 13, 23843, 199, 92, 435, 13, 481, 1912, 199, 92, 1204, 971, 13, 428, 1148, 199, 92, 1204, 13, 3240, 1856, 199, 16341, 662, 1070, 199, 92, 971, 13, 653, 1132, 199, 624, 199, 199, 646, 747, 199, 504, 16826, 492, 7729, 12, 3820, 1977, 12, 12435, 12, 13916, 2827, 1700, 12, 6578, 12, 699, 22949, 12, 7052, 12, 1488, 199, 199, 533, 5013, 26, 272, 347, 636, 826, 721, 277, 304, 267, 408, 267, 4226, 15685, 1265, 2934, 2348, 14, 267, 408, 267, 291, 14, 1053, 29, 403, 272, 347, 664, 985, 8, 277, 304, 267, 408, 267, 1432, 314, 536, 402, 642, 1031, 315, 314, 3123, 14, 267, 408, 267, 986, 272, 347, 365, 12839, 461, 8, 277, 304, 267, 408, 267, 1432, 2549, 340, 642, 1031, 365, 6544, 461, 14, 267, 408, 267, 372, 822, 8, 277, 14, 362, 2610, 6300, 1012, 30, 16, 272, 347, 664, 2610, 6300, 8, 277, 304, 267, 408, 267, 1432, 314, 1007, 3380, 402, 642, 1031, 14, 267, 408, 267, 372, 942, 272, 347, 4788, 7281, 12040, 8, 277, 304, 267, 408, 267, 12295, 1380, 781, 787, 4270, 28614, 14, 267, 408, 267, 986, 272, 347, 1678, 1352, 8, 277, 304, 267, 408, 267, 6523, 562, 1380, 6020, 3595, 562, 4493, 12, 880, 626, 3002, 6025, 267, 4493, 14, 267, 408, 267, 340, 291, 14, 1053, 26, 288, 291, 14, 1053, 14, 873, 342, 199, 199, 533, 3814, 1716, 8, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 354, 304, 267, 5013, 855, 826, 721, 277, 9, 267, 291, 14, 354, 29, 354, 272, 347, 664, 985, 8, 277, 304, 267, 372, 747, 14, 515, 14, 4846, 8, 277, 14, 354, 9, 272, 347, 365, 12839, 461, 8, 277, 304, 267, 372, 747, 14, 515, 14, 6027, 8, 277, 14, 354, 9, 272, 347, 664, 2610, 6300, 8, 277, 304, 267, 1561, 29, 1130, 8, 2734, 671, 12, 78, 29, 277, 14, 354, 26, 736, 14, 515, 14, 904, 8, 78, 12, 88, 395, 736, 14, 7374, 8, 277, 14, 354, 430, 267, 372, 2341, 8, 1173, 1716, 12, 1247, 9, 199, 199, 533, 12178, 2081, 26, 272, 347, 636, 826, 721, 277, 12, 3440, 12, 1708, 12, 932, 304, 267, 291, 14, 3440, 29, 3440, 267, 291, 14, 932, 29, 932, 267, 1031, 14, 1053, 29, 277, 267, 340, 291, 14, 932, 14, 374, 12839, 461, 837, 288, 291, 14, 4441, 29, 16, 267, 587, 26, 288, 291, 14, 4441, 29, 403, 267, 291, 14, 1708, 29, 1708, 267, 340, 1676, 26, 288, 291, 14, 1896, 29, 277, 14, 1708, 14, 1896, 11, 17, 267, 587, 26, 288, 291, 14, 1896, 29, 16, 267, 291, 14, 2246, 29, 16, 327, 7545, 663, 315, 12178, 14, 4441, 342, 267, 291, 14, 954, 1744, 9811, 272, 347, 636, 2264, 721, 277, 304, 267, 2150, 291, 14, 932, 267, 2150, 291, 14, 3440, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 2081, 367, 5013, 450, 83, 737, 2166, 450, 83, 4335, 2840, 277, 14, 932, 14, 16405, 1062, 277, 14, 1896, 9, 272, 347, 3795, 8, 277, 304, 267, 408, 267, 11041, 315, 282, 5516, 14, 267, 408, 267, 746, 4279, 272, 347, 1678, 8, 277, 304, 267, 291, 14, 3440, 14, 873, 8, 277, 9, 199, 199, 533, 3820, 1977, 3987, 2081, 8, 3987, 2081, 304, 272, 347, 3795, 8, 277, 304, 267, 1343, 29, 277, 14, 1896, 12469, 92, 259, 298, 267, 340, 291, 14, 4441, 389, 403, 436, 440, 291, 14, 2246, 26, 288, 1343, 29, 928, 5207, 25576, 267, 916, 291, 14, 4441, 389, 16, 26, 288, 1343, 29, 928, 5207, 44, 2, 267, 916, 291, 14, 4441, 389, 17, 26, 288, 1343, 29, 928, 5207, 5207, 267, 587, 26, 288, 1343, 29, 928, 5207, 15022, 267, 519, 1524, 928, 14255, 7210, 277, 14, 932, 14, 16405, 5106, 267, 340, 291, 14, 4441, 26, 288, 367, 284, 315, 291, 14, 954, 1744, 26, 355, 519, 14, 2880, 8, 73, 14, 3352, 1012, 267, 372, 519, 199, 199, 533, 3820, 1977, 3987, 26, 272, 347, 636, 826, 721, 277, 12, 1708, 29, 403, 12663, 1419, 304, 267, 291, 14, 1977, 29, 4998, 8, 1296, 1977, 14343, 1708, 467, 1419, 9, 267, 291, 14, 1977, 14, 3409, 6757, 7281, 13, 17, 7166, 277, 14, 16114, 9, 267, 291, 14, 12065, 9811, 267, 291, 14, 1744, 9811, 272, 347, 1706, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 1706, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 1389, 12, 589, 12, 829, 9, 272, 347, 6068, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 27591, 617, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 3825, 12, 589, 12, 829, 9, 272, 347, 612, 1345, 8, 277, 19166, 589, 12663, 829, 304, 267, 408, 267, 367, 13704, 316, 14, 267, 408, 267, 4838, 8, 277, 14, 1977, 14, 89, 1345, 12, 589, 12, 829, 9, 272, 347, 1050, 6405, 8, 277, 12, 932, 304, 267, 519, 29, 1296, 1977, 3987, 2081, 8, 277, 12, 403, 12, 932, 9, 267, 291, 14, 12065, 14, 740, 8, 82, 9, 267, 291, 14, 1744, 14, 740, 8, 82, 9, 267, 291, 14, 1977, 14, 3176, 8, 3902, 12, 82, 14, 3352, 3430, 16, 566, 267, 372, 519, 272, 347, 1094, 5592, 8, 277, 304, 267, 286, 29, 277, 14, 1977, 14, 895, 5592, 342, 267, 340, 440, 286, 26, 372, 267, 372, 291, 14, 1744, 59, 442, 8, 67, 59, 16, 12457, 272, 347, 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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 ]
resmo/cloudstack
scripts/vm/hypervisor/kvm/test_patchviasocket.py
4
4640
#!/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. import patchviasocket import getpass import os import socket import tempfile import time import threading import unittest KEY_DATA = "I luv\nCloudStack\n" CMD_DATA = "/run/this-for-me --please=TRUE! very%quickly" NON_EXISTING_FILE = "must-not-exist" def write_key_file(): _, tmpfile = tempfile.mkstemp(".sck") with open(tmpfile, "w") as f: f.write(KEY_DATA) return tmpfile class SocketThread(threading.Thread): def __init__(self): super(SocketThread, self).__init__() self._data = "" self._folder = tempfile.mkdtemp(".sck") self._file = os.path.join(self._folder, "socket") self._ready = False def data(self): return self._data def file(self): return self._file def wait_until_ready(self): while not self._ready: time.sleep(0.050) def run(self): TIMEOUT = 0.314 # Very short time for tests that don't write to socket. MAX_SIZE = 10 * 1024 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: s.bind(self._file) s.listen(1) s.settimeout(TIMEOUT) try: self._ready = True client, address = s.accept() self._data = client.recv(MAX_SIZE) client.close() except socket.timeout: pass finally: s.close() os.remove(self._file) os.rmdir(self._folder) class TestPatchViaSocket(unittest.TestCase): def setUp(self): self._key_file = write_key_file() self._unreadable = write_key_file() os.chmod(self._unreadable, 0) self.assertFalse(os.path.exists(NON_EXISTING_FILE)) self.assertNotEqual("root", getpass.getuser(), "must be non-root user (to test access denied errors)") def tearDown(self): os.remove(self._key_file) os.remove(self._unreadable) def test_write_to_socket(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(0, patchviasocket.send_to_socket(reader.file(), self._key_file, CMD_DATA)) reader.join() data = reader.data() self.assertIn(KEY_DATA, data) self.assertIn(CMD_DATA.replace("%", " "), data) self.assertNotIn("LUV", data) self.assertNotIn("very%quickly", data) # Testing substitution def test_host_key_error(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(1, patchviasocket.send_to_socket(reader.file(), NON_EXISTING_FILE, CMD_DATA)) reader.join() # timeout def test_host_key_access_denied(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(1, patchviasocket.send_to_socket(reader.file(), self._unreadable, CMD_DATA)) reader.join() # timeout def test_nonexistant_socket_error(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(1, patchviasocket.send_to_socket(NON_EXISTING_FILE, self._key_file, CMD_DATA)) reader.join() # timeout def test_invalid_socket_error(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(1, patchviasocket.send_to_socket(self._key_file, self._key_file, CMD_DATA)) reader.join() # timeout def test_access_denied_socket_error(self): reader = SocketThread() reader.start() reader.wait_until_ready() self.assertEquals(1, patchviasocket.send_to_socket(self._unreadable, self._key_file, CMD_DATA)) reader.join() # timeout if __name__ == '__main__': unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 3371, 433, 305, 1539, 199, 199, 646, 18354, 199, 646, 747, 199, 646, 2838, 199, 646, 5549, 199, 646, 900, 199, 646, 5796, 199, 646, 2882, 199, 199, 3078, 63, 3998, 275, 298, 41, 634, 9154, 60, 78, 24404, 60, 78, 2, 199, 9744, 63, 3998, 275, 3286, 1065, 15, 3749, 13, 509, 13, 278, 1553, 27567, 29, 15064, 1, 7437, 5, 13239, 590, 2, 199, 13887, 63, 13301, 1206, 63, 3817, 275, 298, 7790, 13, 1397, 13, 4494, 2, 421, 199, 318, 2218, 63, 498, 63, 493, 837, 272, 5501, 25137, 275, 5549, 14, 17721, 9520, 83, 346, 531, 272, 543, 1551, 8, 21930, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 3078, 63, 3998, 9, 272, 372, 25137, 421, 199, 533, 17766, 4436, 8, 12562, 14, 4436, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 3869, 4436, 12, 291, 2843, 826, 4533, 267, 291, 423, 576, 275, 3087, 267, 291, 423, 3741, 275, 5549, 14, 11983, 9520, 83, 346, 531, 267, 291, 423, 493, 275, 747, 14, 515, 14, 904, 8, 277, 423, 3741, 12, 298, 3450, 531, 267, 291, 423, 2179, 275, 756, 339, 347, 666, 8, 277, 304, 267, 372, 291, 423, 576, 339, 347, 570, 8, 277, 304, 267, 372, 291, 423, 493, 339, 347, 3618, 63, 8111, 63, 2179, 8, 277, 304, 267, 1830, 440, 291, 423, 2179, 26, 288, 900, 14, 4532, 8, 16, 14, 24742, 9, 339, 347, 1255, 8, 277, 304, 267, 29998, 275, 378, 14, 8988, 258, 327, 812, 994, 3974, 900, 367, 2295, 626, 2793, 1133, 2218, 370, 2838, 14, 267, 9141, 63, 4305, 275, 1616, 627, 6619, 398, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 267, 862, 26, 288, 308, 14, 3409, 8, 277, 423, 493, 9, 288, 308, 14, 5859, 8, 17, 9, 288, 308, 14, 24630, 8, 8899, 9, 288, 862, 26, 355, 291, 423, 2179, 275, 715, 355, 1890, 12, 2287, 275, 308, 14, 5694, 342, 355, 291, 423, 576, 275, 1890, 14, 7637, 8, 4283, 63, 4305, 9, 355, 1890, 14, 1600, 342, 288, 871, 2838, 14, 2593, 26, 355, 986, 267, 3753, 26, 288, 308, 14, 1600, 342, 288, 747, 14, 2168, 8, 277, 423, 493, 9, 288, 747, 14, 19405, 8, 277, 423, 3741, 9, 421, 199, 533, 1379, 11173, 2201, 65, 3869, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 498, 63, 493, 275, 2218, 63, 498, 63, 493, 342, 398, 291, 423, 324, 11875, 275, 2218, 63, 498, 63, 493, 342, 267, 747, 14, 11693, 8, 277, 423, 324, 11875, 12, 378, 9, 398, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 13887, 63, 13301, 1206, 63, 3817, 430, 267, 291, 14, 7418, 480, 1231, 401, 18354, 14, 362, 751, 1062, 298, 7790, 506, 2222, 13, 1231, 922, 334, 475, 511, 2879, 23355, 2552, 6320, 339, 347, 6766, 8, 277, 304, 267, 747, 14, 2168, 8, 277, 423, 498, 63, 493, 9, 267, 747, 14, 2168, 8, 277, 423, 324, 11875, 9, 339, 347, 511, 63, 952, 63, 475, 63, 3450, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 16, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 291, 423, 498, 63, 493, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 267, 666, 275, 7002, 14, 576, 342, 267, 291, 14, 4080, 8, 3078, 63, 3998, 12, 666, 9, 267, 291, 14, 4080, 8, 9744, 63, 3998, 14, 1814, 3647, 401, 298, 26261, 666, 9, 267, 291, 14, 8795, 480, 44, 15110, 401, 666, 9, 267, 291, 14, 8795, 480, 2588, 5, 13239, 590, 401, 666, 9, 221, 327, 11940, 20584, 339, 347, 511, 63, 1102, 63, 498, 63, 705, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 17, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 11214, 63, 13301, 1206, 63, 3817, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 257, 327, 2653, 339, 347, 511, 63, 1102, 63, 498, 63, 2732, 63, 28180, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 17, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 291, 423, 324, 11875, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 257, 327, 2653, 339, 347, 511, 63, 3592, 88, 631, 867, 63, 3450, 63, 705, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 3371, 433, 305, 1539, 199, 199, 646, 18354, 199, 646, 747, 199, 646, 2838, 199, 646, 5549, 199, 646, 900, 199, 646, 5796, 199, 646, 2882, 199, 199, 3078, 63, 3998, 275, 298, 41, 634, 9154, 60, 78, 24404, 60, 78, 2, 199, 9744, 63, 3998, 275, 3286, 1065, 15, 3749, 13, 509, 13, 278, 1553, 27567, 29, 15064, 1, 7437, 5, 13239, 590, 2, 199, 13887, 63, 13301, 1206, 63, 3817, 275, 298, 7790, 13, 1397, 13, 4494, 2, 421, 199, 318, 2218, 63, 498, 63, 493, 837, 272, 5501, 25137, 275, 5549, 14, 17721, 9520, 83, 346, 531, 272, 543, 1551, 8, 21930, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 3078, 63, 3998, 9, 272, 372, 25137, 421, 199, 533, 17766, 4436, 8, 12562, 14, 4436, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 3869, 4436, 12, 291, 2843, 826, 4533, 267, 291, 423, 576, 275, 3087, 267, 291, 423, 3741, 275, 5549, 14, 11983, 9520, 83, 346, 531, 267, 291, 423, 493, 275, 747, 14, 515, 14, 904, 8, 277, 423, 3741, 12, 298, 3450, 531, 267, 291, 423, 2179, 275, 756, 339, 347, 666, 8, 277, 304, 267, 372, 291, 423, 576, 339, 347, 570, 8, 277, 304, 267, 372, 291, 423, 493, 339, 347, 3618, 63, 8111, 63, 2179, 8, 277, 304, 267, 1830, 440, 291, 423, 2179, 26, 288, 900, 14, 4532, 8, 16, 14, 24742, 9, 339, 347, 1255, 8, 277, 304, 267, 29998, 275, 378, 14, 8988, 258, 327, 812, 994, 3974, 900, 367, 2295, 626, 2793, 1133, 2218, 370, 2838, 14, 267, 9141, 63, 4305, 275, 1616, 627, 6619, 398, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 267, 862, 26, 288, 308, 14, 3409, 8, 277, 423, 493, 9, 288, 308, 14, 5859, 8, 17, 9, 288, 308, 14, 24630, 8, 8899, 9, 288, 862, 26, 355, 291, 423, 2179, 275, 715, 355, 1890, 12, 2287, 275, 308, 14, 5694, 342, 355, 291, 423, 576, 275, 1890, 14, 7637, 8, 4283, 63, 4305, 9, 355, 1890, 14, 1600, 342, 288, 871, 2838, 14, 2593, 26, 355, 986, 267, 3753, 26, 288, 308, 14, 1600, 342, 288, 747, 14, 2168, 8, 277, 423, 493, 9, 288, 747, 14, 19405, 8, 277, 423, 3741, 9, 421, 199, 533, 1379, 11173, 2201, 65, 3869, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 498, 63, 493, 275, 2218, 63, 498, 63, 493, 342, 398, 291, 423, 324, 11875, 275, 2218, 63, 498, 63, 493, 342, 267, 747, 14, 11693, 8, 277, 423, 324, 11875, 12, 378, 9, 398, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 13887, 63, 13301, 1206, 63, 3817, 430, 267, 291, 14, 7418, 480, 1231, 401, 18354, 14, 362, 751, 1062, 298, 7790, 506, 2222, 13, 1231, 922, 334, 475, 511, 2879, 23355, 2552, 6320, 339, 347, 6766, 8, 277, 304, 267, 747, 14, 2168, 8, 277, 423, 498, 63, 493, 9, 267, 747, 14, 2168, 8, 277, 423, 324, 11875, 9, 339, 347, 511, 63, 952, 63, 475, 63, 3450, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 16, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 291, 423, 498, 63, 493, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 267, 666, 275, 7002, 14, 576, 342, 267, 291, 14, 4080, 8, 3078, 63, 3998, 12, 666, 9, 267, 291, 14, 4080, 8, 9744, 63, 3998, 14, 1814, 3647, 401, 298, 26261, 666, 9, 267, 291, 14, 8795, 480, 44, 15110, 401, 666, 9, 267, 291, 14, 8795, 480, 2588, 5, 13239, 590, 401, 666, 9, 221, 327, 11940, 20584, 339, 347, 511, 63, 1102, 63, 498, 63, 705, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 17, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 11214, 63, 13301, 1206, 63, 3817, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 257, 327, 2653, 339, 347, 511, 63, 1102, 63, 498, 63, 2732, 63, 28180, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 17, 12, 3371, 433, 305, 1539, 14, 2254, 63, 475, 63, 3450, 8, 5503, 14, 493, 1062, 291, 423, 324, 11875, 12, 25548, 63, 3998, 430, 267, 7002, 14, 904, 342, 257, 327, 2653, 339, 347, 511, 63, 3592, 88, 631, 867, 63, 3450, 63, 705, 8, 277, 304, 267, 7002, 275, 17766, 4436, 342, 267, 7002, 14, 928, 342, 267, 7002, 14, 2573, 63, 8111, 63, 2179, 342, 267, 291, 14, 2947, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
HackerEcology/SuggestU
suggestu/scrapers/views.py
1
1827
from django.template import RequestContext from django.core.context_processors import csrf from django.shortcuts import render_to_response from django.http import Http404, HttpResponse, HttpResponseRedirect import json from urllib import urlopen from subprocess import call def test(request): c = {} return render_to_response('test.html', c) def list_spiders(request): response = urlopen("http://127.0.0.1:6800/listspiders.json?project=default") return HttpResponse(response.read(), content_type="application/json") def list_jobs(request): response = urlopen("http://127.0.0.1:6800/listjobs.json?project=default") return HttpResponse(response.read(), content_type="application/json") def list_items(request, spider, dump): BASE = "http://127.0.0.1:6800/items/default" if spider == '': url = BASE else: print "spider: ", spider print "dump: ", dump url = BASE + '/' + spider + '/' + dump print "url: ", url response = urlopen(url) return HttpResponse(response.read()) def deploy(request, spider): url = "curl http://127.0.0.1:6800/schedule.json -d project=default -d spider=%s" % (spider) try: call(url.split()) return HttpResponse("Done!") except: return HttpResponse("Failed!") def render(request, spider, job): url = "http://127.0.0.1:6800/items/default/%s/%s.jl" % (spider, job) response = urlopen(url).read() if "404 - No Such Resource" in response: return HttpResponse(response) else: response = response.split('\n') try: while True: response.remove('') except: pass response = [json.loads(x) for x in response] return HttpResponse(json.dumps(response), content_type="application/json")
gpl-3.0
[ 504, 1639, 14, 1160, 492, 22538, 199, 504, 1639, 14, 1018, 14, 1100, 63, 10547, 492, 19213, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 6183, 12, 14935, 199, 646, 2022, 199, 504, 4011, 492, 18279, 199, 504, 3873, 492, 1240, 199, 199, 318, 511, 8, 1069, 304, 272, 286, 275, 1052, 272, 372, 3795, 63, 475, 63, 1310, 360, 396, 14, 1360, 297, 286, 9, 199, 199, 318, 769, 63, 8721, 7735, 8, 1069, 304, 272, 1177, 275, 18279, 480, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 513, 8721, 7735, 14, 1001, 31, 1715, 29, 885, 531, 272, 372, 6183, 8, 1310, 14, 739, 1062, 1564, 63, 466, 628, 3578, 15, 1001, 531, 199, 199, 318, 769, 63, 6920, 8, 1069, 304, 272, 1177, 275, 18279, 480, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 513, 6920, 14, 1001, 31, 1715, 29, 885, 531, 14821, 372, 6183, 8, 1310, 14, 739, 1062, 1564, 63, 466, 628, 3578, 15, 1001, 531, 199, 199, 318, 769, 63, 1744, 8, 1069, 12, 18094, 12, 5461, 304, 272, 19721, 275, 298, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 1744, 15, 885, 2, 272, 340, 18094, 508, 8061, 267, 1166, 275, 19721, 272, 587, 26, 267, 870, 298, 12856, 26, 3872, 18094, 267, 870, 298, 2724, 26, 3872, 5461, 267, 1166, 275, 19721, 435, 7324, 435, 18094, 435, 7324, 435, 5461, 267, 870, 298, 633, 26, 3872, 1166, 272, 1177, 275, 18279, 8, 633, 9, 272, 372, 6183, 8, 1310, 14, 739, 1012, 199, 199, 318, 12287, 8, 1069, 12, 18094, 304, 272, 1166, 275, 298, 17096, 1455, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 7211, 14, 1001, 446, 68, 2199, 29, 885, 446, 68, 18094, 2458, 83, 2, 450, 334, 12856, 9, 272, 862, 26, 267, 1240, 8, 633, 14, 1294, 1012, 267, 372, 6183, 480, 10759, 9124, 272, 871, 26, 267, 372, 6183, 480, 4276, 9124, 199, 199, 318, 3795, 8, 1069, 12, 18094, 12, 3906, 304, 272, 1166, 275, 298, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 1744, 15, 885, 3149, 83, 3149, 83, 14, 74, 76, 2, 450, 334, 12856, 12, 3906, 9, 272, 1177, 275, 18279, 8, 633, 680, 739, 342, 272, 340, 298, 5188, 446, 3091, 32753, 7337, 2, 315, 1177, 26, 267, 372, 6183, 8, 1310, 9, 272, 587, 26, 267, 1177, 275, 1177, 14, 1294, 2258, 78, 358, 267, 862, 26, 288, 1830, 715, 26, 355, 1177, 14, 2168, 8355, 267, 871, 26, 288, 986, 267, 1177, 275, 359, 1001, 14, 3640, 8, 88, 9, 367, 671, 315, 1177, 61, 267, 372, 6183, 8, 1001, 14, 4180, 8, 1310, 395, 1564, 63, 466, 628, 3578, 15, 1001, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1160, 492, 22538, 199, 504, 1639, 14, 1018, 14, 1100, 63, 10547, 492, 19213, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 6183, 12, 14935, 199, 646, 2022, 199, 504, 4011, 492, 18279, 199, 504, 3873, 492, 1240, 199, 199, 318, 511, 8, 1069, 304, 272, 286, 275, 1052, 272, 372, 3795, 63, 475, 63, 1310, 360, 396, 14, 1360, 297, 286, 9, 199, 199, 318, 769, 63, 8721, 7735, 8, 1069, 304, 272, 1177, 275, 18279, 480, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 513, 8721, 7735, 14, 1001, 31, 1715, 29, 885, 531, 272, 372, 6183, 8, 1310, 14, 739, 1062, 1564, 63, 466, 628, 3578, 15, 1001, 531, 199, 199, 318, 769, 63, 6920, 8, 1069, 304, 272, 1177, 275, 18279, 480, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 513, 6920, 14, 1001, 31, 1715, 29, 885, 531, 14821, 372, 6183, 8, 1310, 14, 739, 1062, 1564, 63, 466, 628, 3578, 15, 1001, 531, 199, 199, 318, 769, 63, 1744, 8, 1069, 12, 18094, 12, 5461, 304, 272, 19721, 275, 298, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 1744, 15, 885, 2, 272, 340, 18094, 508, 8061, 267, 1166, 275, 19721, 272, 587, 26, 267, 870, 298, 12856, 26, 3872, 18094, 267, 870, 298, 2724, 26, 3872, 5461, 267, 1166, 275, 19721, 435, 7324, 435, 18094, 435, 7324, 435, 5461, 267, 870, 298, 633, 26, 3872, 1166, 272, 1177, 275, 18279, 8, 633, 9, 272, 372, 6183, 8, 1310, 14, 739, 1012, 199, 199, 318, 12287, 8, 1069, 12, 18094, 304, 272, 1166, 275, 298, 17096, 1455, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 7211, 14, 1001, 446, 68, 2199, 29, 885, 446, 68, 18094, 2458, 83, 2, 450, 334, 12856, 9, 272, 862, 26, 267, 1240, 8, 633, 14, 1294, 1012, 267, 372, 6183, 480, 10759, 9124, 272, 871, 26, 267, 372, 6183, 480, 4276, 9124, 199, 199, 318, 3795, 8, 1069, 12, 18094, 12, 3906, 304, 272, 1166, 275, 298, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 2333, 383, 15, 1744, 15, 885, 3149, 83, 3149, 83, 14, 74, 76, 2, 450, 334, 12856, 12, 3906, 9, 272, 1177, 275, 18279, 8, 633, 680, 739, 342, 272, 340, 298, 5188, 446, 3091, 32753, 7337, 2, 315, 1177, 26, 267, 372, 6183, 8, 1310, 9, 272, 587, 26, 267, 1177, 275, 1177, 14, 1294, 2258, 78, 358, 267, 862, 26, 288, 1830, 715, 26, 355, 1177, 14, 2168, 8355, 267, 871, 26, 288, 986, 267, 1177, 275, 359, 1001, 14, 3640, 8, 88, 9, 367, 671, 315, 1177, 61, 267, 372, 6183, 8, 1001, 14, 4180, 8, 1310, 395, 1564, 63, 466, 628, 3578, 15, 1001, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
subailong/ns3-wireless-planning.ns-3
bindings/python/apidefs/gcc-LP64/ns3_module_radvd.py
8
21115
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers def register_types(module): root_module = module.get_root() ## simple-ref-count.h: ns3::SimpleRefCount<ns3::RadvdInterface, ns3::empty, ns3::DefaultDeleter<ns3::RadvdInterface> > [class] module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::RadvdInterface', 'ns3::empty', 'ns3::DefaultDeleter<ns3::RadvdInterface>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) ## simple-ref-count.h: ns3::SimpleRefCount<ns3::RadvdPrefix, ns3::empty, ns3::DefaultDeleter<ns3::RadvdPrefix> > [class] module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::RadvdPrefix', 'ns3::empty', 'ns3::DefaultDeleter<ns3::RadvdPrefix>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) ## radvd.h: ns3::Radvd [class] module.add_class('Radvd', parent=root_module['ns3::Application']) ## radvd-interface.h: ns3::RadvdInterface [class] module.add_class('RadvdInterface', parent=root_module['ns3::SimpleRefCount< ns3::RadvdInterface, ns3::empty, ns3::DefaultDeleter<ns3::RadvdInterface> >']) ## radvd-prefix.h: ns3::RadvdPrefix [class] module.add_class('RadvdPrefix', parent=root_module['ns3::SimpleRefCount< ns3::RadvdPrefix, ns3::empty, ns3::DefaultDeleter<ns3::RadvdPrefix> >']) ## Register a nested module for the namespace Config nested_module = module.add_cpp_namespace('Config') register_types_ns3_Config(nested_module) ## Register a nested module for the namespace TimeStepPrecision nested_module = module.add_cpp_namespace('TimeStepPrecision') register_types_ns3_TimeStepPrecision(nested_module) ## Register a nested module for the namespace addressUtils nested_module = module.add_cpp_namespace('addressUtils') register_types_ns3_addressUtils(nested_module) ## Register a nested module for the namespace aodv nested_module = module.add_cpp_namespace('aodv') register_types_ns3_aodv(nested_module) ## Register a nested module for the namespace dot11s nested_module = module.add_cpp_namespace('dot11s') register_types_ns3_dot11s(nested_module) ## Register a nested module for the namespace flame nested_module = module.add_cpp_namespace('flame') register_types_ns3_flame(nested_module) ## Register a nested module for the namespace internal nested_module = module.add_cpp_namespace('internal') register_types_ns3_internal(nested_module) ## Register a nested module for the namespace olsr nested_module = module.add_cpp_namespace('olsr') register_types_ns3_olsr(nested_module) def register_types_ns3_Config(module): root_module = module.get_root() def register_types_ns3_TimeStepPrecision(module): root_module = module.get_root() def register_types_ns3_addressUtils(module): root_module = module.get_root() def register_types_ns3_aodv(module): root_module = module.get_root() def register_types_ns3_dot11s(module): root_module = module.get_root() def register_types_ns3_flame(module): root_module = module.get_root() def register_types_ns3_internal(module): root_module = module.get_root() def register_types_ns3_olsr(module): root_module = module.get_root() def register_methods(root_module): register_Ns3Radvd_methods(root_module, root_module['ns3::Radvd']) register_Ns3RadvdInterface_methods(root_module, root_module['ns3::RadvdInterface']) register_Ns3RadvdPrefix_methods(root_module, root_module['ns3::RadvdPrefix']) return def register_Ns3Radvd_methods(root_module, cls): ## radvd.h: ns3::Radvd::Radvd(ns3::Radvd const & arg0) [copy constructor] cls.add_constructor([param('ns3::Radvd const &', 'arg0')]) ## radvd.h: ns3::Radvd::Radvd() [constructor] cls.add_constructor([]) ## radvd.h: void ns3::Radvd::AddConfiguration(ns3::Ptr<ns3::RadvdInterface> routerInterface) [member function] cls.add_method('AddConfiguration', 'void', [param('ns3::Ptr< ns3::RadvdInterface >', 'routerInterface')]) ## radvd.h: static ns3::TypeId ns3::Radvd::GetTypeId() [member function] cls.add_method('GetTypeId', 'ns3::TypeId', [], is_static=True) ## radvd.h: ns3::Radvd::MAX_RA_DELAY_TIME [variable] cls.add_static_attribute('MAX_RA_DELAY_TIME', 'uint32_t const', is_const=True) ## radvd.h: void ns3::Radvd::DoDispose() [member function] cls.add_method('DoDispose', 'void', [], visibility='protected', is_virtual=True) ## radvd.h: void ns3::Radvd::StartApplication() [member function] cls.add_method('StartApplication', 'void', [], visibility='private', is_virtual=True) ## radvd.h: void ns3::Radvd::StopApplication() [member function] cls.add_method('StopApplication', 'void', [], visibility='private', is_virtual=True) return def register_Ns3RadvdInterface_methods(root_module, cls): ## radvd-interface.h: ns3::RadvdInterface::RadvdInterface(ns3::RadvdInterface const & arg0) [copy constructor] cls.add_constructor([param('ns3::RadvdInterface const &', 'arg0')]) ## radvd-interface.h: ns3::RadvdInterface::RadvdInterface(uint32_t interface) [constructor] cls.add_constructor([param('uint32_t', 'interface')]) ## radvd-interface.h: ns3::RadvdInterface::RadvdInterface(uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval) [constructor] cls.add_constructor([param('uint32_t', 'interface'), param('uint32_t', 'maxRtrAdvInterval'), param('uint32_t', 'minRtrAdvInterval')]) ## radvd-interface.h: void ns3::RadvdInterface::AddPrefix(ns3::Ptr<ns3::RadvdPrefix> routerPrefix) [member function] cls.add_method('AddPrefix', 'void', [param('ns3::Ptr< ns3::RadvdPrefix >', 'routerPrefix')]) ## radvd-interface.h: uint8_t ns3::RadvdInterface::GetCurHopLimit() const [member function] cls.add_method('GetCurHopLimit', 'uint8_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetDefaultLifeTime() const [member function] cls.add_method('GetDefaultLifeTime', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint8_t ns3::RadvdInterface::GetDefaultPreference() const [member function] cls.add_method('GetDefaultPreference', 'uint8_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetHomeAgentLifeTime() const [member function] cls.add_method('GetHomeAgentLifeTime', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetHomeAgentPreference() const [member function] cls.add_method('GetHomeAgentPreference', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetInterface() const [member function] cls.add_method('GetInterface', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetLinkMtu() const [member function] cls.add_method('GetLinkMtu', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetMaxRtrAdvInterval() const [member function] cls.add_method('GetMaxRtrAdvInterval', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetMinDelayBetweenRAs() const [member function] cls.add_method('GetMinDelayBetweenRAs', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetMinRtrAdvInterval() const [member function] cls.add_method('GetMinRtrAdvInterval', 'uint32_t', [], is_const=True) ## radvd-interface.h: std::list<ns3::Ptr<ns3::RadvdPrefix>, std::allocator<ns3::Ptr<ns3::RadvdPrefix> > > ns3::RadvdInterface::GetPrefixes() const [member function] cls.add_method('GetPrefixes', 'std::list< ns3::Ptr< ns3::RadvdPrefix > >', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetReachableTime() const [member function] cls.add_method('GetReachableTime', 'uint32_t', [], is_const=True) ## radvd-interface.h: uint32_t ns3::RadvdInterface::GetRetransTimer() const [member function] cls.add_method('GetRetransTimer', 'uint32_t', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsHomeAgentFlag() const [member function] cls.add_method('IsHomeAgentFlag', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsHomeAgentInfo() const [member function] cls.add_method('IsHomeAgentInfo', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsIntervalOpt() const [member function] cls.add_method('IsIntervalOpt', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsManagedFlag() const [member function] cls.add_method('IsManagedFlag', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsMobRtrSupportFlag() const [member function] cls.add_method('IsMobRtrSupportFlag', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsOtherConfigFlag() const [member function] cls.add_method('IsOtherConfigFlag', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsSendAdvert() const [member function] cls.add_method('IsSendAdvert', 'bool', [], is_const=True) ## radvd-interface.h: bool ns3::RadvdInterface::IsSourceLLAddress() const [member function] cls.add_method('IsSourceLLAddress', 'bool', [], is_const=True) ## radvd-interface.h: void ns3::RadvdInterface::SetCurHopLimit(uint8_t curHopLimit) [member function] cls.add_method('SetCurHopLimit', 'void', [param('uint8_t', 'curHopLimit')]) ## radvd-interface.h: void ns3::RadvdInterface::SetDefaultLifeTime(uint32_t defaultLifeTime) [member function] cls.add_method('SetDefaultLifeTime', 'void', [param('uint32_t', 'defaultLifeTime')]) ## radvd-interface.h: void ns3::RadvdInterface::SetDefaultPreference(uint8_t defaultPreference) [member function] cls.add_method('SetDefaultPreference', 'void', [param('uint8_t', 'defaultPreference')]) ## radvd-interface.h: void ns3::RadvdInterface::SetHomeAgentFlag(bool homeAgentFlag) [member function] cls.add_method('SetHomeAgentFlag', 'void', [param('bool', 'homeAgentFlag')]) ## radvd-interface.h: void ns3::RadvdInterface::SetHomeAgentInfo(bool homeAgentFlag) [member function] cls.add_method('SetHomeAgentInfo', 'void', [param('bool', 'homeAgentFlag')]) ## radvd-interface.h: void ns3::RadvdInterface::SetHomeAgentLifeTime(uint32_t homeAgentLifeTime) [member function] cls.add_method('SetHomeAgentLifeTime', 'void', [param('uint32_t', 'homeAgentLifeTime')]) ## radvd-interface.h: void ns3::RadvdInterface::SetHomeAgentPreference(uint32_t homeAgentPreference) [member function] cls.add_method('SetHomeAgentPreference', 'void', [param('uint32_t', 'homeAgentPreference')]) ## radvd-interface.h: void ns3::RadvdInterface::SetIntervalOpt(bool intervalOpt) [member function] cls.add_method('SetIntervalOpt', 'void', [param('bool', 'intervalOpt')]) ## radvd-interface.h: void ns3::RadvdInterface::SetLinkMtu(uint32_t linkMtu) [member function] cls.add_method('SetLinkMtu', 'void', [param('uint32_t', 'linkMtu')]) ## radvd-interface.h: void ns3::RadvdInterface::SetManagedFlag(bool managedFlag) [member function] cls.add_method('SetManagedFlag', 'void', [param('bool', 'managedFlag')]) ## radvd-interface.h: void ns3::RadvdInterface::SetMaxRtrAdvInterval(uint32_t maxRtrAdvInterval) [member function] cls.add_method('SetMaxRtrAdvInterval', 'void', [param('uint32_t', 'maxRtrAdvInterval')]) ## radvd-interface.h: void ns3::RadvdInterface::SetMinDelayBetweenRAs(uint32_t minDelayBetweenRAs) [member function] cls.add_method('SetMinDelayBetweenRAs', 'void', [param('uint32_t', 'minDelayBetweenRAs')]) ## radvd-interface.h: void ns3::RadvdInterface::SetMinRtrAdvInterval(uint32_t minRtrAdvInterval) [member function] cls.add_method('SetMinRtrAdvInterval', 'void', [param('uint32_t', 'minRtrAdvInterval')]) ## radvd-interface.h: void ns3::RadvdInterface::SetMobRtrSupportFlag(bool mobRtrSupportFlag) [member function] cls.add_method('SetMobRtrSupportFlag', 'void', [param('bool', 'mobRtrSupportFlag')]) ## radvd-interface.h: void ns3::RadvdInterface::SetOtherConfigFlag(bool otherConfigFlag) [member function] cls.add_method('SetOtherConfigFlag', 'void', [param('bool', 'otherConfigFlag')]) ## radvd-interface.h: void ns3::RadvdInterface::SetReachableTime(uint32_t reachableTime) [member function] cls.add_method('SetReachableTime', 'void', [param('uint32_t', 'reachableTime')]) ## radvd-interface.h: void ns3::RadvdInterface::SetRetransTimer(uint32_t retransTimer) [member function] cls.add_method('SetRetransTimer', 'void', [param('uint32_t', 'retransTimer')]) ## radvd-interface.h: void ns3::RadvdInterface::SetSendAdvert(bool sendAdvert) [member function] cls.add_method('SetSendAdvert', 'void', [param('bool', 'sendAdvert')]) ## radvd-interface.h: void ns3::RadvdInterface::SetSourceLLAddress(bool sourceLLAddress) [member function] cls.add_method('SetSourceLLAddress', 'void', [param('bool', 'sourceLLAddress')]) return def register_Ns3RadvdPrefix_methods(root_module, cls): ## radvd-prefix.h: ns3::RadvdPrefix::RadvdPrefix(ns3::RadvdPrefix const & arg0) [copy constructor] cls.add_constructor([param('ns3::RadvdPrefix const &', 'arg0')]) ## radvd-prefix.h: ns3::RadvdPrefix::RadvdPrefix(ns3::Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime=604800, uint32_t validLifeTime=2592000, bool onLinkFlag=true, bool autonomousFlag=true, bool routerAddrFlag=false) [constructor] cls.add_constructor([param('ns3::Ipv6Address', 'network'), param('uint8_t', 'prefixLength'), param('uint32_t', 'preferredLifeTime', default_value='604800'), param('uint32_t', 'validLifeTime', default_value='2592000'), param('bool', 'onLinkFlag', default_value='true'), param('bool', 'autonomousFlag', default_value='true'), param('bool', 'routerAddrFlag', default_value='false')]) ## radvd-prefix.h: ns3::Ipv6Address ns3::RadvdPrefix::GetNetwork() const [member function] cls.add_method('GetNetwork', 'ns3::Ipv6Address', [], is_const=True) ## radvd-prefix.h: uint32_t ns3::RadvdPrefix::GetPreferredLifeTime() const [member function] cls.add_method('GetPreferredLifeTime', 'uint32_t', [], is_const=True) ## radvd-prefix.h: uint8_t ns3::RadvdPrefix::GetPrefixLength() const [member function] cls.add_method('GetPrefixLength', 'uint8_t', [], is_const=True) ## radvd-prefix.h: uint32_t ns3::RadvdPrefix::GetValidLifeTime() const [member function] cls.add_method('GetValidLifeTime', 'uint32_t', [], is_const=True) ## radvd-prefix.h: bool ns3::RadvdPrefix::IsAutonomousFlag() const [member function] cls.add_method('IsAutonomousFlag', 'bool', [], is_const=True) ## radvd-prefix.h: bool ns3::RadvdPrefix::IsOnLinkFlag() const [member function] cls.add_method('IsOnLinkFlag', 'bool', [], is_const=True) ## radvd-prefix.h: bool ns3::RadvdPrefix::IsRouterAddrFlag() const [member function] cls.add_method('IsRouterAddrFlag', 'bool', [], is_const=True) ## radvd-prefix.h: void ns3::RadvdPrefix::SetAutonomousFlag(bool autonomousFlag) [member function] cls.add_method('SetAutonomousFlag', 'void', [param('bool', 'autonomousFlag')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetNetwork(ns3::Ipv6Address network) [member function] cls.add_method('SetNetwork', 'void', [param('ns3::Ipv6Address', 'network')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetOnLinkFlag(bool onLinkFlag) [member function] cls.add_method('SetOnLinkFlag', 'void', [param('bool', 'onLinkFlag')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetPreferredLifeTime(uint32_t preferredLifeTime) [member function] cls.add_method('SetPreferredLifeTime', 'void', [param('uint32_t', 'preferredLifeTime')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetPrefixLength(uint8_t prefixLength) [member function] cls.add_method('SetPrefixLength', 'void', [param('uint8_t', 'prefixLength')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetRouterAddrFlag(bool routerAddrFlag) [member function] cls.add_method('SetRouterAddrFlag', 'void', [param('bool', 'routerAddrFlag')]) ## radvd-prefix.h: void ns3::RadvdPrefix::SetValidLifeTime(uint32_t validLifeTime) [member function] cls.add_method('SetValidLifeTime', 'void', [param('uint32_t', 'validLifeTime')]) return def register_functions(root_module): module = root_module register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) register_functions_ns3_aodv(module.get_submodule('aodv'), root_module) register_functions_ns3_dot11s(module.get_submodule('dot11s'), root_module) register_functions_ns3_flame(module.get_submodule('flame'), root_module) register_functions_ns3_internal(module.get_submodule('internal'), root_module) register_functions_ns3_olsr(module.get_submodule('olsr'), root_module) return def register_functions_ns3_Config(module, root_module): return def register_functions_ns3_TimeStepPrecision(module, root_module): return def register_functions_ns3_addressUtils(module, root_module): return def register_functions_ns3_aodv(module, root_module): return def register_functions_ns3_dot11s(module, root_module): return def register_functions_ns3_flame(module, root_module): return def register_functions_ns3_internal(module, root_module): return def register_functions_ns3_olsr(module, root_module): return
gpl-2.0
[ 504, 1134, 31297, 492, 5673, 12, 3814, 3034, 17111, 12, 1215, 12, 9151, 12, 7246, 533, 12, 14330, 199, 199, 318, 2274, 63, 1313, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 2286, 925, 3486, 13, 1121, 13, 835, 14, 72, 26, 700, 19, 447, 4447, 28, 561, 19, 447, 32573, 4267, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 30, 690, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 1978, 63, 3214, 2968, 561, 19, 447, 32573, 4267, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 16619, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 1667, 995, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 925, 3486, 13, 1121, 13, 835, 14, 72, 26, 700, 19, 447, 4447, 28, 561, 19, 447, 32573, 4793, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 30, 690, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 1978, 63, 3214, 2968, 561, 19, 447, 32573, 4793, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 16619, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 1667, 995, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 925, 660, 28502, 14, 72, 26, 700, 19, 447, 32573, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 5039, 1105, 272, 925, 660, 28502, 13, 3266, 14, 72, 26, 700, 19, 447, 32573, 4267, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 4267, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 32573, 4267, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 30, 12734, 272, 925, 660, 28502, 13, 1861, 14, 72, 26, 700, 19, 447, 32573, 4793, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 4793, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 32573, 4793, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 30, 12734, 2286, 925, 11828, 282, 6032, 859, 367, 314, 3231, 4094, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 2028, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 2028, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 4703, 7801, 28984, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 1366, 7801, 28984, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 1366, 7801, 28984, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 2287, 7535, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 1562, 7535, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 1562, 7535, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 20510, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 12721, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 12721, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 6308, 845, 83, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 3287, 845, 83, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 3287, 845, 83, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 2717, 313, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 2327, 313, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 2327, 313, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 5007, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 4672, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 4672, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 21990, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 11617, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 11617, 8, 6376, 63, 578, 9, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 2028, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 1366, 7801, 28984, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 1562, 7535, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 12721, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 3287, 845, 83, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 2327, 313, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 4672, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 11617, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 2474, 8, 1231, 63, 578, 304, 272, 2274, 63, 2438, 19, 32573, 63, 2474, 8, 1231, 63, 578, 12, 1738, 63, 578, 459, 561, 19, 447, 32573, 1105, 272, 2274, 63, 2438, 19, 32573, 4267, 63, 2474, 8, 1231, 63, 578, 12, 1738 ]
[ 1134, 31297, 492, 5673, 12, 3814, 3034, 17111, 12, 1215, 12, 9151, 12, 7246, 533, 12, 14330, 199, 199, 318, 2274, 63, 1313, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 2286, 925, 3486, 13, 1121, 13, 835, 14, 72, 26, 700, 19, 447, 4447, 28, 561, 19, 447, 32573, 4267, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 30, 690, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 1978, 63, 3214, 2968, 561, 19, 447, 32573, 4267, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 16619, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 1667, 995, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 925, 3486, 13, 1121, 13, 835, 14, 72, 26, 700, 19, 447, 4447, 28, 561, 19, 447, 32573, 4793, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 30, 690, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 1978, 63, 3214, 2968, 561, 19, 447, 32573, 4793, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 16619, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 1667, 995, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 925, 660, 28502, 14, 72, 26, 700, 19, 447, 32573, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 5039, 1105, 272, 925, 660, 28502, 13, 3266, 14, 72, 26, 700, 19, 447, 32573, 4267, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 4267, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 32573, 4267, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4267, 30, 12734, 272, 925, 660, 28502, 13, 1861, 14, 72, 26, 700, 19, 447, 32573, 4793, 359, 533, 61, 272, 859, 14, 525, 63, 533, 360, 32573, 4793, 297, 1676, 29, 1231, 63, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 32573, 4793, 12, 700, 19, 447, 1667, 12, 700, 19, 447, 5014, 28, 561, 19, 447, 32573, 4793, 30, 12734, 2286, 925, 11828, 282, 6032, 859, 367, 314, 3231, 4094, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 2028, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 2028, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 4703, 7801, 28984, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 1366, 7801, 28984, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 1366, 7801, 28984, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 2287, 7535, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 1562, 7535, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 1562, 7535, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 20510, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 12721, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 12721, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 6308, 845, 83, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 3287, 845, 83, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 3287, 845, 83, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 2717, 313, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 2327, 313, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 2327, 313, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 5007, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 4672, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 4672, 8, 6376, 63, 578, 9, 17635, 925, 11828, 282, 6032, 859, 367, 314, 3231, 21990, 2286, 6032, 63, 578, 275, 859, 14, 525, 63, 5910, 63, 3251, 360, 11617, 358, 272, 2274, 63, 1313, 63, 561, 19, 63, 11617, 8, 6376, 63, 578, 9, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 2028, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 1366, 7801, 28984, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 1562, 7535, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 12721, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 3287, 845, 83, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 2327, 313, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 4672, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 1313, 63, 561, 19, 63, 11617, 8, 578, 304, 272, 1738, 63, 578, 275, 859, 14, 362, 63, 1231, 342, 16872, 199, 318, 2274, 63, 2474, 8, 1231, 63, 578, 304, 272, 2274, 63, 2438, 19, 32573, 63, 2474, 8, 1231, 63, 578, 12, 1738, 63, 578, 459, 561, 19, 447, 32573, 1105, 272, 2274, 63, 2438, 19, 32573, 4267, 63, 2474, 8, 1231, 63, 578, 12, 1738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 1, 1, 1 ]
summerlight/anlp
src/dataset.py
1
1423
import glob import json from data_gen import segmentation def iter_segment(doc): text = doc['text'] for segment in doc['metadata']: yield segment['lang'], text[segment['begin']:segment['end']] def iter_sentences(doc): for lang, segment in iter_segment(doc): for st in segmentation.by_sentences(segment): yield lang, st def iter_words(doc): for lang, segment in iter_segment(doc): for word in segmentation.by_words(segment): yield lang, word def iter_words_from_st(st): for lang, segment in iter_segment(doc): for word in segmentation.by_words(st): yield lang, word def iter_words_by_st(doc): for lang, segment in iter_segment(doc): for st in segmentation.by_sentences(segment): yield lang, (word for word in segmentation.by_words(st)) def iter_chars(doc): for lang, segment in iter_segment(doc): for ch in segment: yield lang, ch def tagged_words(doc): for lang, word in iter_words(doc): if word.isspace(): continue if is_common(word): yield 'zz', word else: yield lang, word def read_dataset(name): for file_path in sorted(glob.glob('../data/{}/*.txt'.format(name))): with open(file_path, 'rt') as f: val = json.load(f) val['file_path'] = file_path yield val
apache-2.0
[ 646, 5739, 199, 646, 2022, 199, 504, 666, 63, 2268, 492, 27315, 421, 199, 318, 2740, 63, 9255, 8, 1301, 304, 272, 1318, 275, 1382, 459, 505, 418, 272, 367, 8135, 315, 1382, 459, 2343, 2565, 267, 1995, 8135, 459, 4159, 995, 1318, 59, 9255, 459, 5037, 2565, 9255, 459, 500, 6538, 421, 199, 318, 2740, 63, 25669, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 410, 315, 27315, 14, 991, 63, 25669, 8, 9255, 304, 288, 1995, 6339, 12, 410, 421, 199, 318, 2740, 63, 3148, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 9255, 304, 288, 1995, 6339, 12, 4349, 421, 199, 318, 2740, 63, 3148, 63, 504, 63, 270, 8, 270, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 270, 304, 288, 1995, 6339, 12, 4349, 421, 199, 318, 2740, 63, 3148, 63, 991, 63, 270, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 410, 315, 27315, 14, 991, 63, 25669, 8, 9255, 304, 288, 1995, 6339, 12, 334, 1027, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 270, 430, 421, 199, 318, 2740, 63, 6574, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 682, 315, 8135, 26, 288, 1995, 6339, 12, 682, 421, 199, 318, 20018, 63, 3148, 8, 1301, 304, 272, 367, 6339, 12, 4349, 315, 2740, 63, 3148, 8, 1301, 304, 267, 340, 4349, 14, 23360, 837, 288, 1980, 267, 340, 365, 63, 2330, 8, 1027, 304, 288, 1995, 283, 4348, 297, 4349, 267, 587, 26, 288, 1995, 6339, 12, 4349, 421, 199, 318, 1586, 63, 5214, 8, 354, 304, 272, 367, 570, 63, 515, 315, 3355, 8, 6463, 14, 6463, 24592, 576, 19655, 4856, 2424, 1370, 908, 8, 354, 15206, 267, 543, 1551, 8, 493, 63, 515, 12, 283, 2591, 358, 465, 289, 26, 288, 1139, 275, 2022, 14, 912, 8, 70, 9, 288, 1139, 459, 493, 63, 515, 418, 275, 570, 63, 515, 288, 1995, 1139, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5739, 199, 646, 2022, 199, 504, 666, 63, 2268, 492, 27315, 421, 199, 318, 2740, 63, 9255, 8, 1301, 304, 272, 1318, 275, 1382, 459, 505, 418, 272, 367, 8135, 315, 1382, 459, 2343, 2565, 267, 1995, 8135, 459, 4159, 995, 1318, 59, 9255, 459, 5037, 2565, 9255, 459, 500, 6538, 421, 199, 318, 2740, 63, 25669, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 410, 315, 27315, 14, 991, 63, 25669, 8, 9255, 304, 288, 1995, 6339, 12, 410, 421, 199, 318, 2740, 63, 3148, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 9255, 304, 288, 1995, 6339, 12, 4349, 421, 199, 318, 2740, 63, 3148, 63, 504, 63, 270, 8, 270, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 270, 304, 288, 1995, 6339, 12, 4349, 421, 199, 318, 2740, 63, 3148, 63, 991, 63, 270, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 410, 315, 27315, 14, 991, 63, 25669, 8, 9255, 304, 288, 1995, 6339, 12, 334, 1027, 367, 4349, 315, 27315, 14, 991, 63, 3148, 8, 270, 430, 421, 199, 318, 2740, 63, 6574, 8, 1301, 304, 272, 367, 6339, 12, 8135, 315, 2740, 63, 9255, 8, 1301, 304, 267, 367, 682, 315, 8135, 26, 288, 1995, 6339, 12, 682, 421, 199, 318, 20018, 63, 3148, 8, 1301, 304, 272, 367, 6339, 12, 4349, 315, 2740, 63, 3148, 8, 1301, 304, 267, 340, 4349, 14, 23360, 837, 288, 1980, 267, 340, 365, 63, 2330, 8, 1027, 304, 288, 1995, 283, 4348, 297, 4349, 267, 587, 26, 288, 1995, 6339, 12, 4349, 421, 199, 318, 1586, 63, 5214, 8, 354, 304, 272, 367, 570, 63, 515, 315, 3355, 8, 6463, 14, 6463, 24592, 576, 19655, 4856, 2424, 1370, 908, 8, 354, 15206, 267, 543, 1551, 8, 493, 63, 515, 12, 283, 2591, 358, 465, 289, 26, 288, 1139, 275, 2022, 14, 912, 8, 70, 9, 288, 1139, 459, 493, 63, 515, 418, 275, 570, 63, 515, 288, 1995, 1139, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
WarrenWeckesser/scipy
scipy/linalg/decomp_schur.py
17
10216
"""Schur decomposition functions.""" import numpy from numpy import asarray_chkfinite, single, asarray, array from numpy.linalg import norm # Local imports. from .misc import LinAlgError, _datacopied from .lapack import get_lapack_funcs from .decomp import eigvals __all__ = ['schur', 'rsf2csf'] _double_precision = ['i', 'l', 'd'] def schur(a, output='real', lwork=None, overwrite_a=False, sort=None, check_finite=True): """ Compute Schur decomposition of a matrix. The Schur decomposition is:: A = Z T Z^H where Z is unitary and T is either upper-triangular, or for real Schur decomposition (output='real'), quasi-upper triangular. In the quasi-triangular form, 2x2 blocks describing complex-valued eigenvalue pairs may extrude from the diagonal. Parameters ---------- a : (M, M) array_like Matrix to decompose output : {'real', 'complex'}, optional Construct the real or complex Schur decomposition (for real matrices). lwork : int, optional Work array size. If None or -1, it is automatically computed. overwrite_a : bool, optional Whether to overwrite data in a (may improve performance). sort : {None, callable, 'lhp', 'rhp', 'iuc', 'ouc'}, optional Specifies whether the upper eigenvalues should be sorted. A callable may be passed that, given a eigenvalue, returns a boolean denoting whether the eigenvalue should be sorted to the top-left (True). Alternatively, string parameters may be used:: 'lhp' Left-hand plane (x.real < 0.0) 'rhp' Right-hand plane (x.real > 0.0) 'iuc' Inside the unit circle (x*x.conjugate() <= 1.0) 'ouc' Outside the unit circle (x*x.conjugate() > 1.0) Defaults to None (no sorting). check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns ------- T : (M, M) ndarray Schur form of A. It is real-valued for the real Schur decomposition. Z : (M, M) ndarray An unitary Schur transformation matrix for A. It is real-valued for the real Schur decomposition. sdim : int If and only if sorting was requested, a third return value will contain the number of eigenvalues satisfying the sort condition. Raises ------ LinAlgError Error raised under three conditions: 1. The algorithm failed due to a failure of the QR algorithm to compute all eigenvalues. 2. If eigenvalue sorting was requested, the eigenvalues could not be reordered due to a failure to separate eigenvalues, usually because of poor conditioning. 3. If eigenvalue sorting was requested, roundoff errors caused the leading eigenvalues to no longer satisfy the sorting condition. See also -------- rsf2csf : Convert real Schur form to complex Schur form Examples -------- >>> from scipy.linalg import schur, eigvals >>> A = np.array([[0, 2, 2], [0, 1, 2], [1, 0, 1]]) >>> T, Z = schur(A) >>> T array([[ 2.65896708, 1.42440458, -1.92933439], [ 0. , -0.32948354, -0.49063704], [ 0. , 1.31178921, -0.32948354]]) >>> Z array([[0.72711591, -0.60156188, 0.33079564], [0.52839428, 0.79801892, 0.28976765], [0.43829436, 0.03590414, -0.89811411]]) >>> T2, Z2 = schur(A, output='complex') >>> T2 array([[ 2.65896708, -1.22839825+1.32378589j, 0.42590089+1.51937378j], [ 0. , -0.32948354+0.80225456j, -0.59877807+0.56192146j], [ 0. , 0. , -0.32948354-0.80225456j]]) >>> eigvals(T2) array([2.65896708, -0.32948354+0.80225456j, -0.32948354-0.80225456j]) An arbitrary custom eig-sorting condition, having positive imaginary part, which is satisfied by only one eigenvalue >>> T3, Z3, sdim = schur(A, output='complex', sort=lambda x: x.imag > 0) >>> sdim 1 """ if output not in ['real', 'complex', 'r', 'c']: raise ValueError("argument must be 'real', or 'complex'") if check_finite: a1 = asarray_chkfinite(a) else: a1 = asarray(a) if len(a1.shape) != 2 or (a1.shape[0] != a1.shape[1]): raise ValueError('expected square matrix') typ = a1.dtype.char if output in ['complex', 'c'] and typ not in ['F', 'D']: if typ in _double_precision: a1 = a1.astype('D') typ = 'D' else: a1 = a1.astype('F') typ = 'F' overwrite_a = overwrite_a or (_datacopied(a1, a)) gees, = get_lapack_funcs(('gees',), (a1,)) if lwork is None or lwork == -1: # get optimal work array result = gees(lambda x: None, a1, lwork=-1) lwork = result[-2][0].real.astype(numpy.int_) if sort is None: sort_t = 0 sfunction = lambda x: None else: sort_t = 1 if callable(sort): sfunction = sort elif sort == 'lhp': sfunction = lambda x: (x.real < 0.0) elif sort == 'rhp': sfunction = lambda x: (x.real >= 0.0) elif sort == 'iuc': sfunction = lambda x: (abs(x) <= 1.0) elif sort == 'ouc': sfunction = lambda x: (abs(x) > 1.0) else: raise ValueError("'sort' parameter must either be 'None', or a " "callable, or one of ('lhp','rhp','iuc','ouc')") result = gees(sfunction, a1, lwork=lwork, overwrite_a=overwrite_a, sort_t=sort_t) info = result[-1] if info < 0: raise ValueError('illegal value in {}-th argument of internal gees' ''.format(-info)) elif info == a1.shape[0] + 1: raise LinAlgError('Eigenvalues could not be separated for reordering.') elif info == a1.shape[0] + 2: raise LinAlgError('Leading eigenvalues do not satisfy sort condition.') elif info > 0: raise LinAlgError("Schur form not found. Possibly ill-conditioned.") if sort_t == 0: return result[0], result[-3] else: return result[0], result[-3], result[1] eps = numpy.finfo(float).eps feps = numpy.finfo(single).eps _array_kind = {'b': 0, 'h': 0, 'B': 0, 'i': 0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1} _array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1} _array_type = [['f', 'd'], ['F', 'D']] def _commonType(*arrays): kind = 0 precision = 0 for a in arrays: t = a.dtype.char kind = max(kind, _array_kind[t]) precision = max(precision, _array_precision[t]) return _array_type[kind][precision] def _castCopy(type, *arrays): cast_arrays = () for a in arrays: if a.dtype.char == type: cast_arrays = cast_arrays + (a.copy(),) else: cast_arrays = cast_arrays + (a.astype(type),) if len(cast_arrays) == 1: return cast_arrays[0] else: return cast_arrays def rsf2csf(T, Z, check_finite=True): """ Convert real Schur form to complex Schur form. Convert a quasi-diagonal real-valued Schur form to the upper-triangular complex-valued Schur form. Parameters ---------- T : (M, M) array_like Real Schur form of the original array Z : (M, M) array_like Schur transformation matrix check_finite : bool, optional Whether to check that the input arrays contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns ------- T : (M, M) ndarray Complex Schur form of the original array Z : (M, M) ndarray Schur transformation matrix corresponding to the complex form See Also -------- schur : Schur decomposition of an array Examples -------- >>> from scipy.linalg import schur, rsf2csf >>> A = np.array([[0, 2, 2], [0, 1, 2], [1, 0, 1]]) >>> T, Z = schur(A) >>> T array([[ 2.65896708, 1.42440458, -1.92933439], [ 0. , -0.32948354, -0.49063704], [ 0. , 1.31178921, -0.32948354]]) >>> Z array([[0.72711591, -0.60156188, 0.33079564], [0.52839428, 0.79801892, 0.28976765], [0.43829436, 0.03590414, -0.89811411]]) >>> T2 , Z2 = rsf2csf(T, Z) >>> T2 array([[2.65896708+0.j, -1.64592781+0.743164187j, -1.21516887+1.00660462j], [0.+0.j , -0.32948354+8.02254558e-01j, -0.82115218-2.77555756e-17j], [0.+0.j , 0.+0.j, -0.32948354-0.802254558j]]) >>> Z2 array([[0.72711591+0.j, 0.28220393-0.31385693j, 0.51319638-0.17258824j], [0.52839428+0.j, 0.24720268+0.41635578j, -0.68079517-0.15118243j], [0.43829436+0.j, -0.76618703+0.01873251j, -0.03063006+0.46857912j]]) """ if check_finite: Z, T = map(asarray_chkfinite, (Z, T)) else: Z, T = map(asarray, (Z, T)) for ind, X in enumerate([Z, T]): if X.ndim != 2 or X.shape[0] != X.shape[1]: raise ValueError("Input '{}' must be square.".format('ZT'[ind])) if T.shape[0] != Z.shape[0]: raise ValueError("Input array shapes must match: Z: {} vs. T: {}" "".format(Z.shape, T.shape)) N = T.shape[0] t = _commonType(Z, T, array([3.0], 'F')) Z, T = _castCopy(t, Z, T) for m in range(N-1, 0, -1): if abs(T[m, m-1]) > eps*(abs(T[m-1, m-1]) + abs(T[m, m])): mu = eigvals(T[m-1:m+1, m-1:m+1]) - T[m, m] r = norm([mu[0], T[m, m-1]]) c = mu[0] / r s = T[m, m-1] / r G = array([[c.conj(), s], [-s, c]], dtype=t) T[m-1:m+1, m-1:] = G.dot(T[m-1:m+1, m-1:]) T[:m+1, m-1:m+1] = T[:m+1, m-1:m+1].dot(G.conj().T) Z[:, m-1:m+1] = Z[:, m-1:m+1].dot(G.conj().T) T[m, m-1] = 0.0 return T, Z
bsd-3-clause
[ 624, 31936, 300, 22706, 3423, 1041, 199, 646, 2680, 199, 504, 2680, 492, 24144, 63, 14823, 8005, 12, 2849, 12, 24144, 12, 1625, 199, 504, 2680, 14, 10096, 492, 6316, 421, 199, 3, 10111, 8925, 14, 199, 504, 1275, 9923, 492, 29730, 28846, 547, 12, 485, 576, 23581, 199, 504, 1275, 26760, 492, 664, 63, 26760, 63, 9204, 199, 504, 1275, 271, 863, 492, 26547, 3643, 199, 199, 363, 452, 363, 275, 788, 15820, 300, 297, 283, 2393, 70, 18, 1259, 70, 418, 199, 199, 63, 3157, 63, 6833, 275, 788, 73, 297, 283, 76, 297, 283, 68, 418, 421, 199, 318, 308, 335, 300, 8, 65, 12, 1072, 534, 3093, 297, 634, 800, 29, 403, 12, 8970, 63, 65, 29, 797, 12, 4069, 29, 403, 12, 881, 1104, 63, 8005, 29, 549, 304, 272, 408, 272, 8354, 22985, 300, 22706, 402, 282, 3634, 14, 339, 710, 22985, 300, 22706, 365, 447, 398, 437, 275, 3107, 377, 3107, 62, 40, 339, 2382, 3107, 365, 4137, 695, 436, 377, 365, 1902, 7008, 13, 29663, 12, 503, 367, 3363, 272, 22985, 300, 22706, 334, 1199, 534, 3093, 659, 2173, 24950, 13, 4142, 3229, 11572, 14, 1010, 272, 314, 2173, 24950, 13, 29663, 1824, 12, 499, 88, 18, 5664, 13660, 6114, 13, 16611, 272, 11471, 585, 6342, 1443, 1599, 82, 3786, 687, 314, 16788, 14, 339, 3897, 272, 4143, 272, 282, 520, 334, 45, 12, 603, 9, 1625, 63, 2930, 267, 8449, 370, 477, 12607, 272, 1072, 520, 791, 3093, 297, 283, 5254, 2267, 2716, 267, 9215, 314, 3363, 503, 6114, 22985, 300, 22706, 334, 509, 3363, 12627, 680, 272, 634, 800, 520, 1109, 12, 2716, 267, 9361, 1625, 1568, 14, 982, 488, 503, 446, 17, 12, 652, 365, 5847, 9235, 14, 272, 8970, 63, 65, 520, 2155, 12, 2716, 267, 7480, 370, 8970, 666, 315, 282, 334, 7551, 19053, 10238, 680, 272, 4069, 520, 469, 403, 12, 4550, 12, 283, 76, 12025, 297, 283, 82, 12025, 297, 283, 73, 947, 297, 283, 810, 67, 2267, 2716, 267, 11015, 3775, 314, 7008, 22953, 1077, 506, 3355, 14, 437, 4550, 267, 1443, 506, 3032, 626, 12, 1627, 282, 11471, 585, 12, 2529, 282, 5046, 477, 1397, 316, 267, 3775, 314, 11471, 585, 1077, 506, 3355, 370, 314, 2746, 13, 3039, 334, 549, 680, 267, 26776, 12, 1059, 2633, 1443, 506, 1202, 447, 953, 283, 76, 12025, 7, 257, 29350, 13, 6868, 16388, 334, 88, 14, 3093, 665, 378, 14, 16, 9, 288, 283, 82, 12025, 7, 257, 20854, 13, 6868, 16388, 334, 88, 14, 3093, 690, 378, 14, 16, 9, 288, 283, 73, 947, 7, 257, 1010, 2441, 314, 4137, 17990, 334, 88, 10, 88, 14, 26000, 342, 2695, 413, 14, 16, 9, 288, 283, 810, 67, 7, 257, 6219, 2441, 314, 4137, 17990, 334, 88, 10, 88, 14, 26000, 342, 690, 413, 14, 16, 9, 398, 7827, 370, 488, 334, 889, 13351, 680, 272, 1104, 63, 8005, 520, 2155, 12, 2716, 267, 7480, 370, 1104, 626, 314, 1324, 3634, 3509, 1454, 21837, 5579, 14, 267, 5289, 14744, 1443, 8120, 282, 10238, 15334, 12, 1325, 1443, 754, 315, 8826, 267, 334, 1556, 9030, 12, 2222, 13, 20667, 9, 340, 314, 4153, 886, 1395, 315, 7295, 1417, 503, 31930, 14, 339, 1803, 272, 5514, 272, 377, 520, 334, 45, 12, 603, 9, 6800, 267, 22985, 300, 1824, 402, 437, 14, 2779, 365, 3363, 13, 16611, 367, 314, 3363, 22985, 300, 22706, 14, 272, 3107, 520, 334, 45, 12, 603, 9, 6800, 267, 1626, 4137, 695, 22985, 300, 13315, 3634, 367, 437, 14, 267, 2779, 365, 3363, 13, 16611, 367, 314, 3363, 22985, 300, 22706, 14, 272, 308, 3572, 520, 1109, 267, 982, 436, 1454, 340, 13351, 1990, 5839, 12, 282, 10919, 372, 574, 911, 267, 1395, 314, 1329, 402, 22953, 23082, 316, 314, 4069, 5558, 14, 339, 6218, 272, 21397, 272, 29730, 28846, 547, 267, 4520, 4915, 1334, 7795, 3704, 26, 398, 413, 14, 710, 5563, 3405, 7037, 370, 282, 5988, 402, 314, 1413, 50, 5563, 370, 1779, 4526, 1006, 22953, 14, 267, 499, 14, 982, 11471, 585, 13351, 1990, 5839, 12, 314, 22953, 4293, 440, 506, 1779, 295, 8235, 7037, 370, 282, 5988, 370, 7396, 22953, 12, 9987, 2952, 1779, 402, 1115, 269, 5558, 316, 14, 267, 650, 14, 982, 11471, 585, 13351, 1990, 5839, 12, 6168, 1997, 2552, 18104, 314, 1779, 9186, 22953, 370, 949, 8088, 23082, 314, 13351, 5558, 14, 339, 1666, 2597, 272, 3001, 272, 519, 7646, 18, 1259, 70, 520, 7905, 3363, 22985, 300, 1824, 370, 6114, 22985, 300, 1824, 339, 6058, 272, 3001, 272, 1306, 687, 7026, 14, 10096, 492, 308, 335, 300, 12, 26547, 3643, 272, 1306, 437, 275, 980, 14, 1144, 4038, 16, 12, 499, 12, 499, 467, 359, 16, 12, 413, 12, 499, 467, 359, 17, 12, 378, 12, 413, 3934, 272, 1306, 377, 12, 3107, 275, 308, 335, 300, 8, 33, 9, 272, 1306, 377, 272, 1625, 4038, 499, 14, 2182, 1407, 1822, 2036, 12, 221, 413, 14, 21089, 5188, 2010, 12, 446, 17, 14, 32340, 8425, 1355, 467, 1779, 359, 378, 14, 263, 2360, 446, 16, 14, 11685, 2006, 12967, 12, 446, 16, 14, 1887, 1690, 1401, 966, 467, 1779, 359, 378, 14, 263, 2360, 221, 413, 14, 19, 7362, 1407, 2025, 12, 446, 16, 14, 11685, 2006, 12967, 3934, 272, 1306, 3107, 272, 1625, 4038, 16, 14, 30624, 845, 17736, 12, 446, 16, 14, 24539, 1367, 11501, 12, 378, 14, 1153, 1780, 2720, 772, 467, 1779, 359, 16, 14, 28032, 13549, 1651, 12, 378, 14, 16564, 614, 15765, 12, 378, 14, 18, 8483, 1822, 2182, 467, 1779, 359, 16, 14, 31352, 10693, 1344, 12, 378, 14, 16, 11444, 966, 1079, 12, 446, 16, 14, 13176, 7636, 845, 3934, 339, 1306, 377, 18, 12, 3107, 18, 275, 308, 335, 300, 8, 33, 12, 1072, 534, 5254, 358, 272, 1306, 377, 18, 272, 1625, 4038, 499, 14, 2182, 1407, 1822, 2036, 12, 446, 17, 14, 12048, 13944, 821, 11, 17, 14, 708, 1401, 2426, 1407, 74, 12, 221, 378, 14, 20, 11990, 383, 1407, 11, 17, 14, 30432, 1401, 12046, 74, 467, 1779, 359, 378, 14, 263, 2360, 446, 16, 14, 11685, 2006, 12967, 11, 16, 14, 11366, 8306 ]
[ 31936, 300, 22706, 3423, 1041, 199, 646, 2680, 199, 504, 2680, 492, 24144, 63, 14823, 8005, 12, 2849, 12, 24144, 12, 1625, 199, 504, 2680, 14, 10096, 492, 6316, 421, 199, 3, 10111, 8925, 14, 199, 504, 1275, 9923, 492, 29730, 28846, 547, 12, 485, 576, 23581, 199, 504, 1275, 26760, 492, 664, 63, 26760, 63, 9204, 199, 504, 1275, 271, 863, 492, 26547, 3643, 199, 199, 363, 452, 363, 275, 788, 15820, 300, 297, 283, 2393, 70, 18, 1259, 70, 418, 199, 199, 63, 3157, 63, 6833, 275, 788, 73, 297, 283, 76, 297, 283, 68, 418, 421, 199, 318, 308, 335, 300, 8, 65, 12, 1072, 534, 3093, 297, 634, 800, 29, 403, 12, 8970, 63, 65, 29, 797, 12, 4069, 29, 403, 12, 881, 1104, 63, 8005, 29, 549, 304, 272, 408, 272, 8354, 22985, 300, 22706, 402, 282, 3634, 14, 339, 710, 22985, 300, 22706, 365, 447, 398, 437, 275, 3107, 377, 3107, 62, 40, 339, 2382, 3107, 365, 4137, 695, 436, 377, 365, 1902, 7008, 13, 29663, 12, 503, 367, 3363, 272, 22985, 300, 22706, 334, 1199, 534, 3093, 659, 2173, 24950, 13, 4142, 3229, 11572, 14, 1010, 272, 314, 2173, 24950, 13, 29663, 1824, 12, 499, 88, 18, 5664, 13660, 6114, 13, 16611, 272, 11471, 585, 6342, 1443, 1599, 82, 3786, 687, 314, 16788, 14, 339, 3897, 272, 4143, 272, 282, 520, 334, 45, 12, 603, 9, 1625, 63, 2930, 267, 8449, 370, 477, 12607, 272, 1072, 520, 791, 3093, 297, 283, 5254, 2267, 2716, 267, 9215, 314, 3363, 503, 6114, 22985, 300, 22706, 334, 509, 3363, 12627, 680, 272, 634, 800, 520, 1109, 12, 2716, 267, 9361, 1625, 1568, 14, 982, 488, 503, 446, 17, 12, 652, 365, 5847, 9235, 14, 272, 8970, 63, 65, 520, 2155, 12, 2716, 267, 7480, 370, 8970, 666, 315, 282, 334, 7551, 19053, 10238, 680, 272, 4069, 520, 469, 403, 12, 4550, 12, 283, 76, 12025, 297, 283, 82, 12025, 297, 283, 73, 947, 297, 283, 810, 67, 2267, 2716, 267, 11015, 3775, 314, 7008, 22953, 1077, 506, 3355, 14, 437, 4550, 267, 1443, 506, 3032, 626, 12, 1627, 282, 11471, 585, 12, 2529, 282, 5046, 477, 1397, 316, 267, 3775, 314, 11471, 585, 1077, 506, 3355, 370, 314, 2746, 13, 3039, 334, 549, 680, 267, 26776, 12, 1059, 2633, 1443, 506, 1202, 447, 953, 283, 76, 12025, 7, 257, 29350, 13, 6868, 16388, 334, 88, 14, 3093, 665, 378, 14, 16, 9, 288, 283, 82, 12025, 7, 257, 20854, 13, 6868, 16388, 334, 88, 14, 3093, 690, 378, 14, 16, 9, 288, 283, 73, 947, 7, 257, 1010, 2441, 314, 4137, 17990, 334, 88, 10, 88, 14, 26000, 342, 2695, 413, 14, 16, 9, 288, 283, 810, 67, 7, 257, 6219, 2441, 314, 4137, 17990, 334, 88, 10, 88, 14, 26000, 342, 690, 413, 14, 16, 9, 398, 7827, 370, 488, 334, 889, 13351, 680, 272, 1104, 63, 8005, 520, 2155, 12, 2716, 267, 7480, 370, 1104, 626, 314, 1324, 3634, 3509, 1454, 21837, 5579, 14, 267, 5289, 14744, 1443, 8120, 282, 10238, 15334, 12, 1325, 1443, 754, 315, 8826, 267, 334, 1556, 9030, 12, 2222, 13, 20667, 9, 340, 314, 4153, 886, 1395, 315, 7295, 1417, 503, 31930, 14, 339, 1803, 272, 5514, 272, 377, 520, 334, 45, 12, 603, 9, 6800, 267, 22985, 300, 1824, 402, 437, 14, 2779, 365, 3363, 13, 16611, 367, 314, 3363, 22985, 300, 22706, 14, 272, 3107, 520, 334, 45, 12, 603, 9, 6800, 267, 1626, 4137, 695, 22985, 300, 13315, 3634, 367, 437, 14, 267, 2779, 365, 3363, 13, 16611, 367, 314, 3363, 22985, 300, 22706, 14, 272, 308, 3572, 520, 1109, 267, 982, 436, 1454, 340, 13351, 1990, 5839, 12, 282, 10919, 372, 574, 911, 267, 1395, 314, 1329, 402, 22953, 23082, 316, 314, 4069, 5558, 14, 339, 6218, 272, 21397, 272, 29730, 28846, 547, 267, 4520, 4915, 1334, 7795, 3704, 26, 398, 413, 14, 710, 5563, 3405, 7037, 370, 282, 5988, 402, 314, 1413, 50, 5563, 370, 1779, 4526, 1006, 22953, 14, 267, 499, 14, 982, 11471, 585, 13351, 1990, 5839, 12, 314, 22953, 4293, 440, 506, 1779, 295, 8235, 7037, 370, 282, 5988, 370, 7396, 22953, 12, 9987, 2952, 1779, 402, 1115, 269, 5558, 316, 14, 267, 650, 14, 982, 11471, 585, 13351, 1990, 5839, 12, 6168, 1997, 2552, 18104, 314, 1779, 9186, 22953, 370, 949, 8088, 23082, 314, 13351, 5558, 14, 339, 1666, 2597, 272, 3001, 272, 519, 7646, 18, 1259, 70, 520, 7905, 3363, 22985, 300, 1824, 370, 6114, 22985, 300, 1824, 339, 6058, 272, 3001, 272, 1306, 687, 7026, 14, 10096, 492, 308, 335, 300, 12, 26547, 3643, 272, 1306, 437, 275, 980, 14, 1144, 4038, 16, 12, 499, 12, 499, 467, 359, 16, 12, 413, 12, 499, 467, 359, 17, 12, 378, 12, 413, 3934, 272, 1306, 377, 12, 3107, 275, 308, 335, 300, 8, 33, 9, 272, 1306, 377, 272, 1625, 4038, 499, 14, 2182, 1407, 1822, 2036, 12, 221, 413, 14, 21089, 5188, 2010, 12, 446, 17, 14, 32340, 8425, 1355, 467, 1779, 359, 378, 14, 263, 2360, 446, 16, 14, 11685, 2006, 12967, 12, 446, 16, 14, 1887, 1690, 1401, 966, 467, 1779, 359, 378, 14, 263, 2360, 221, 413, 14, 19, 7362, 1407, 2025, 12, 446, 16, 14, 11685, 2006, 12967, 3934, 272, 1306, 3107, 272, 1625, 4038, 16, 14, 30624, 845, 17736, 12, 446, 16, 14, 24539, 1367, 11501, 12, 378, 14, 1153, 1780, 2720, 772, 467, 1779, 359, 16, 14, 28032, 13549, 1651, 12, 378, 14, 16564, 614, 15765, 12, 378, 14, 18, 8483, 1822, 2182, 467, 1779, 359, 16, 14, 31352, 10693, 1344, 12, 378, 14, 16, 11444, 966, 1079, 12, 446, 16, 14, 13176, 7636, 845, 3934, 339, 1306, 377, 18, 12, 3107, 18, 275, 308, 335, 300, 8, 33, 12, 1072, 534, 5254, 358, 272, 1306, 377, 18, 272, 1625, 4038, 499, 14, 2182, 1407, 1822, 2036, 12, 446, 17, 14, 12048, 13944, 821, 11, 17, 14, 708, 1401, 2426, 1407, 74, 12, 221, 378, 14, 20, 11990, 383, 1407, 11, 17, 14, 30432, 1401, 12046, 74, 467, 1779, 359, 378, 14, 263, 2360, 446, 16, 14, 11685, 2006, 12967, 11, 16, 14, 11366, 8306, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
delmic/odemis
src/odemis/gui/dev/powermate.py
2
9666
# -*- coding: utf-8 -*- """ @author: Rinze de Laat Copyright © 2015 Rinze de Laat, Éric Piel, Delmic This file is part of Odemis. Odemis is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. Odemis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Odemis. If not, see http://www.gnu.org/licenses/. """ from __future__ import division import logging import os import struct import sys import threading import time import wx from odemis.acq.stream import StaticStream from odemis.gui.evt import KnobRotateEvent, KnobPressEvent class Powermate(threading.Thread): """ Interface to Griffin PowerMate It will translate the knob rotation movements into EVT_KNOB_ROTATE events It also automatically turn on/off the led based on the whether the current stream can focus. """ def __init__(self, main_data, **kwargs): """ Picks the first Powermate found, and main_data (MainGUIData) Raise: NotImplementedError: if the OS doesn't support it LookupError: if no Powermate is found """ # TODO: support other OS than Linux? if not sys.platform.startswith('linux'): raise NotImplementedError("Powermate only supported on Linux") # Find the Powermate device (will stop here if nothing is found) self.device = self._find_powermate_device() # The currently opened GUI tab, so we can keep track of tab switching self.current_tab = None # To keep track of ALL streams associated with the current tab (addition, removal etc.) self.tab_model_streams_va = None # .streams VA of the tab model # All streams belonging to the current tab self.current_tab_streams = () # Viewport to which we send our events self.target_viewport = None self.led_brightness = 255 # [0..255] self.led_pulse_speed = 0 # [0..510] self.keep_running = True # Track tab switching, so we know when to look for a new viewport main_data.tab.subscribe(self.on_tab_switch, init=True) # Start listening for Knob input threading.Thread.__init__(self, **kwargs) self.daemon = True self.start() # TODO: allow to terminate the thread? def on_tab_switch(self, tab): """ Subscribe to focussed view changes when the opened tab is changed """ # Clear old tab subscriptions if self.current_tab: if hasattr(self.current_tab.tab_data_model, 'focussedView'): # Clear the current subscription self.current_tab.tab_data_model.focussedView.unsubscribe(self._on_focussed_view) if self.tab_model_streams_va is not None: self.tab_model_streams_va.unsubscribe(self.on_tab_stream_change) self.current_tab = None # Set new subscriptions if hasattr(tab.tab_data_model, 'focussedView') and hasattr(tab, 'view_controller'): self.tab_model_streams_va = tab.tab_data_model.streams self.tab_model_streams_va.subscribe(self.on_tab_stream_change, init=True) self.current_tab = tab self.current_tab.tab_data_model.focussedView.subscribe(self._on_focussed_view, init=True) def on_tab_stream_change(self, streams): """ Set the subscription for the stream when the tab's stream set changes """ if self.current_tab_streams: for stream in self.current_tab_streams: stream.should_update.unsubscribe(self._on_stream_update) self.current_tab_streams = streams if self.current_tab_streams: for stream in self.current_tab_streams: stream.should_update.subscribe(self._on_stream_update, init=True) def _on_stream_update(self, _=None): """ Check all the streams of the currently focussed Viewport to see if the LED should be on. """ if self.current_tab is None: self.led_on(False) return view = self.current_tab.tab_data_model.focussedView.value if view is None: self.led_on(False) return for stream in view.stream_tree: static = isinstance(stream, StaticStream) updating = stream.should_update.value if hasattr(stream, "should_update") else False if updating and stream.focuser and not static: self.led_on(True) break else: self.led_on(False) def _on_focussed_view(self, view): """ Set or clear the Viewport where we should send events to """ if view: self.target_viewport = self.current_tab.view_controller.get_viewport_by_view(view) self._on_stream_update() logging.debug("New Viewport target set") else: self.target_viewport = None self.led_on(False) logging.debug("Viewport target cleared") def _find_powermate_device(self): try: import evdev except ImportError: raise LookupError("python-evdev is not present") # Look at all accessible /dev/input devices for fn in evdev.util.list_devices(): d = evdev.InputDevice(fn) # Check for PowerMate in the device name string if "PowerMate" in d.name: logging.info("Found Powermate device in %s", fn) return d else: raise LookupError("No Powermate device found") def run(self): """ Listen for knob events and translate them into wx.Python events """ from evdev import ecodes while self.keep_running: try: for evt in self.device.read_loop(): if self.target_viewport is not None: if evt.type == ecodes.EV_REL: knob_evt = KnobRotateEvent( self.target_viewport.canvas.GetId(), direction=(wx.RIGHT if evt.value > 0 else wx.LEFT), step_value=evt.value, device=self.device ) wx.PostEvent(self.target_viewport.canvas, knob_evt) elif evt.type == ecodes.EV_KEY and evt.value == 1: knob_evt = KnobPressEvent( self.target_viewport.canvas.GetId(), device=self.device ) wx.PostEvent(self.target_viewport.canvas, knob_evt) except IOError: logging.warn("Failed to communicate with the powermate, was unplugged?") # Sleep and after try and find the device again while True: time.sleep(5) try: self.device = self._find_powermate_device() break except LookupError: pass except Exception: logging.exception("Powermate listener failed") self.keep_running = False def led_on(self, on): self.led_brightness = 255 if on else 0 self._set_led_state() def led_pulse(self, pulse): self.led_pulse_speed = 255 if pulse else 0 self._set_led_state() def terminate(self): self.led_on(False) self.keep_running = False if self.device: self.device.close() self.device = None def _set_led_state(self, pulse_table=0, pulse_on_sleep=False): """ Changes the led state of the powermate pulse_table (0, 1, 2) pulse_on_sleep (bool): starting pulsing when the device is suspended """ # What do these magic values mean: # cf linux/drivers/input/misc/powermate.c: # bits 0- 7: 8 bits: LED brightness # bits 8-16: 9 bits: pulsing speed modifier (0 ... 510); # 0-254 = slower, 255 = standard, 256-510 = faster # bits 17-18: 2 bits: pulse table (0, 1, 2 valid) # bit 19: 1 bit : pulse whilst asleep? # bit 20: 1 bit : pulse constantly? static_brightness = self.led_brightness & 0xff pulse_speed = min(510, max(self.led_pulse_speed, 0)) pulse_table = min(2, max(pulse_table, 0)) pulse_on_sleep = not not pulse_on_sleep # not not = convert to 0/1 pulse_on_wake = 1 if pulse_speed else 0 magic = ( static_brightness | (pulse_speed << 8) | (pulse_table << 17) | (pulse_on_sleep << 19) | (pulse_on_wake << 20) ) input_event_struct = "@llHHi" data = struct.pack(input_event_struct, 0, 0, 0x04, 0x01, magic) if self.device is None: logging.debug("Powermate has disappeared, skipping led change") return try: os.write(self.device.fd, data) except OSError: logging.info("Failed to communicate with the powermate, was unplugged?", exc_info=True) self.device = None
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 32, 2502, 26, 820, 262, 806, 477, 7964, 292, 199, 199, 7384, 22405, 103, 6900, 820, 262, 806, 477, 7964, 292, 12, 13333, 232, 1567, 510, 14769, 12, 18464, 15003, 199, 199, 2765, 570, 365, 1777, 402, 593, 271, 1292, 14, 199, 199, 47, 271, 1292, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 199, 14109, 1684, 844, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 199, 47, 271, 1292, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 199, 1589, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 199, 9885, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 593, 271, 1292, 14, 982, 440, 12, 199, 3239, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 2702, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 4818, 199, 199, 504, 312, 271, 1292, 14, 645, 81, 14, 1745, 492, 13599, 3296, 199, 504, 312, 271, 1292, 14, 5885, 14, 19296, 492, 1804, 889, 66, 32638, 2390, 12, 1804, 889, 66, 14414, 2390, 421, 199, 533, 18879, 17684, 8, 12562, 14, 4436, 304, 272, 408, 14816, 370, 598, 322, 556, 262, 18879, 45, 323, 272, 2779, 911, 9028, 314, 1022, 889, 66, 13038, 4057, 1470, 1901, 662, 8156, 63, 43, 2826, 34, 63, 31075, 1951, 4474, 272, 2779, 2597, 5847, 7485, 641, 15, 1997, 314, 29239, 4079, 641, 314, 3775, 314, 1453, 272, 2547, 883, 16470, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2446, 63, 576, 12, 1011, 958, 304, 267, 408, 267, 16568, 83, 314, 1642, 18879, 17684, 1911, 12, 436, 267, 2446, 63, 576, 334, 6756, 17856, 419, 9, 267, 14771, 26, 288, 4279, 26, 340, 314, 4403, 3181, 1133, 2291, 652, 288, 19021, 26, 340, 949, 18879, 17684, 365, 1911, 267, 408, 267, 327, 3254, 26, 2291, 1163, 4403, 2419, 10130, 31, 267, 340, 440, 984, 14, 3246, 14, 2460, 360, 5135, 735, 288, 746, 4279, 480, 6921, 17684, 1454, 3748, 641, 10130, 531, 398, 327, 6668, 314, 18879, 17684, 2243, 334, 14117, 3631, 2348, 340, 6548, 365, 1911, 9, 267, 291, 14, 1782, 275, 291, 423, 1623, 63, 5652, 17684, 63, 1782, 342, 398, 327, 710, 5544, 12123, 17160, 5174, 12, 880, 781, 883, 4215, 4426, 402, 5174, 31620, 267, 291, 14, 1818, 63, 2902, 275, 488, 267, 327, 4005, 4215, 4426, 402, 11727, 13788, 4568, 543, 314, 1453, 5174, 334, 26799, 12, 20055, 5423, 4959, 267, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 275, 488, 221, 327, 1275, 11231, 812, 33, 402, 314, 5174, 1402, 267, 327, 2900, 13788, 30226, 370, 314, 1453, 5174, 267, 291, 14, 1818, 63, 2902, 63, 11231, 275, 6248, 267, 327, 10935, 719, 370, 1314, 781, 3222, 4154, 4474, 267, 291, 14, 1375, 63, 25484, 275, 488, 398, 291, 14, 1146, 63, 22298, 275, 5450, 221, 327, 359, 16, 703, 2299, 61, 267, 291, 14, 1146, 63, 19538, 63, 7625, 275, 378, 221, 327, 359, 16, 703, 27161, 61, 398, 291, 14, 3250, 63, 5720, 275, 715, 398, 327, 17507, 5174, 31620, 12, 880, 781, 5715, 1380, 370, 3648, 367, 282, 892, 2455, 719, 267, 2446, 63, 576, 14, 2902, 14, 10108, 8, 277, 14, 265, 63, 2902, 63, 5656, 12, 4205, 29, 549, 9, 398, 327, 7707, 22721, 367, 1804, 889, 66, 1324, 267, 5796, 14, 4436, 855, 826, 721, 277, 12, 1011, 958, 9, 267, 291, 14, 10824, 275, 715, 267, 291, 14, 928, 342, 339, 327, 3254, 26, 2040, 370, 15095, 314, 2462, 31, 339, 347, 641, 63, 2902, 63, 5656, 8, 277, 12, 5174, 304, 267, 408, 4804, 5355, 370, 16470, 939, 2455, 4493, 1380, 314, 12123, 5174, 365, 2896, 408, 398, 327, 14836, 2269, 5174, 25708, 267, 340, 291, 14, 1818, 63, 2902, 26, 288, 340, 2688, 8, 277, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 12, 283, 12283, 939, 2768, 735, 355, 327, 14836, 314, 1453, 9966, 355, 291, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 14, 12283, 939, 2768, 14, 25592, 8, 277, 423, 265, 63, 12283, 939, 63, 1345, 9, 288, 340, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 365, 440, 488, 26, 355, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 14, 25592, 8, 277, 14, 265, 63, 2902, 63, 1745, 63, 1461, 9, 288, 291, 14, 1818, 63, 2902, 275, 488, 398, 327, 2494, 892, 25708, 267, 340, 2688, 8, 2902, 14, 2902, 63, 576, 63, 1238, 12, 283, 12283, 939, 2768, 358, 436, 2688, 8, 2902, 12, 283, 1345, 63, 5538, 735, 288, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 275, 5174, 14, 2902, 63, 576, 63, 1238, 14, 11231, 288, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 14, 10108, 8, 277, 14, 265, 63, 2902, 63, 1745, 63, 1461, 12, 4205, 29, 549, 9, 953, 291, 14, 1818, 63, 2902, 275, 5174, 288, 291, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 14, 12283, 939, 2768, 14, 10108, 8, 277, 423, 265, 63, 12283, 939, 63, 1345, 12, 28095, 4205, 29, 549, 9, 339, 347, 641, 63, 2902, 63, 1745, 63, 1461, 8, 277, 12, 13788, 304, 267, 408, 2494, 314, 9966, 367, 314, 2547, 1380, 314, 5174, 1159, 2547, 663, 4493, 408, 398, 340, 291, 14, 1818, 63, 2902, 63, 11231, 26, 288, 367, 2547, 315, 291, 14, 1818, 63, 2902, 63, 11231, 26, 355, 2547, 14, 5626, 63, 873, 14, 25592, 8, 277, 423, 265, 63, 1745, 63, 873, 9, 398, 291, 14, 1818, 63, 2902, 63, 11231, 275, 13788, 398, 340, 291, 14, 1818, 63, 2902, 63, 11231, 26, 288, 367, 2547, 315, 291, 14, 1818, 63, 2902, 63, 11231, 26, 355, 2547, 14, 5626, 63, 873, 14, 10108, 8, 277, 423, 265 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 32, 2502, 26, 820, 262, 806, 477, 7964, 292, 199, 199, 7384, 22405, 103, 6900, 820, 262, 806, 477, 7964, 292, 12, 13333, 232, 1567, 510, 14769, 12, 18464, 15003, 199, 199, 2765, 570, 365, 1777, 402, 593, 271, 1292, 14, 199, 199, 47, 271, 1292, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 199, 14109, 1684, 844, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 199, 47, 271, 1292, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 199, 1589, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 199, 9885, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 593, 271, 1292, 14, 982, 440, 12, 199, 3239, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 2702, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 4818, 199, 199, 504, 312, 271, 1292, 14, 645, 81, 14, 1745, 492, 13599, 3296, 199, 504, 312, 271, 1292, 14, 5885, 14, 19296, 492, 1804, 889, 66, 32638, 2390, 12, 1804, 889, 66, 14414, 2390, 421, 199, 533, 18879, 17684, 8, 12562, 14, 4436, 304, 272, 408, 14816, 370, 598, 322, 556, 262, 18879, 45, 323, 272, 2779, 911, 9028, 314, 1022, 889, 66, 13038, 4057, 1470, 1901, 662, 8156, 63, 43, 2826, 34, 63, 31075, 1951, 4474, 272, 2779, 2597, 5847, 7485, 641, 15, 1997, 314, 29239, 4079, 641, 314, 3775, 314, 1453, 272, 2547, 883, 16470, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2446, 63, 576, 12, 1011, 958, 304, 267, 408, 267, 16568, 83, 314, 1642, 18879, 17684, 1911, 12, 436, 267, 2446, 63, 576, 334, 6756, 17856, 419, 9, 267, 14771, 26, 288, 4279, 26, 340, 314, 4403, 3181, 1133, 2291, 652, 288, 19021, 26, 340, 949, 18879, 17684, 365, 1911, 267, 408, 267, 327, 3254, 26, 2291, 1163, 4403, 2419, 10130, 31, 267, 340, 440, 984, 14, 3246, 14, 2460, 360, 5135, 735, 288, 746, 4279, 480, 6921, 17684, 1454, 3748, 641, 10130, 531, 398, 327, 6668, 314, 18879, 17684, 2243, 334, 14117, 3631, 2348, 340, 6548, 365, 1911, 9, 267, 291, 14, 1782, 275, 291, 423, 1623, 63, 5652, 17684, 63, 1782, 342, 398, 327, 710, 5544, 12123, 17160, 5174, 12, 880, 781, 883, 4215, 4426, 402, 5174, 31620, 267, 291, 14, 1818, 63, 2902, 275, 488, 267, 327, 4005, 4215, 4426, 402, 11727, 13788, 4568, 543, 314, 1453, 5174, 334, 26799, 12, 20055, 5423, 4959, 267, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 275, 488, 221, 327, 1275, 11231, 812, 33, 402, 314, 5174, 1402, 267, 327, 2900, 13788, 30226, 370, 314, 1453, 5174, 267, 291, 14, 1818, 63, 2902, 63, 11231, 275, 6248, 267, 327, 10935, 719, 370, 1314, 781, 3222, 4154, 4474, 267, 291, 14, 1375, 63, 25484, 275, 488, 398, 291, 14, 1146, 63, 22298, 275, 5450, 221, 327, 359, 16, 703, 2299, 61, 267, 291, 14, 1146, 63, 19538, 63, 7625, 275, 378, 221, 327, 359, 16, 703, 27161, 61, 398, 291, 14, 3250, 63, 5720, 275, 715, 398, 327, 17507, 5174, 31620, 12, 880, 781, 5715, 1380, 370, 3648, 367, 282, 892, 2455, 719, 267, 2446, 63, 576, 14, 2902, 14, 10108, 8, 277, 14, 265, 63, 2902, 63, 5656, 12, 4205, 29, 549, 9, 398, 327, 7707, 22721, 367, 1804, 889, 66, 1324, 267, 5796, 14, 4436, 855, 826, 721, 277, 12, 1011, 958, 9, 267, 291, 14, 10824, 275, 715, 267, 291, 14, 928, 342, 339, 327, 3254, 26, 2040, 370, 15095, 314, 2462, 31, 339, 347, 641, 63, 2902, 63, 5656, 8, 277, 12, 5174, 304, 267, 408, 4804, 5355, 370, 16470, 939, 2455, 4493, 1380, 314, 12123, 5174, 365, 2896, 408, 398, 327, 14836, 2269, 5174, 25708, 267, 340, 291, 14, 1818, 63, 2902, 26, 288, 340, 2688, 8, 277, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 12, 283, 12283, 939, 2768, 735, 355, 327, 14836, 314, 1453, 9966, 355, 291, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 14, 12283, 939, 2768, 14, 25592, 8, 277, 423, 265, 63, 12283, 939, 63, 1345, 9, 288, 340, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 365, 440, 488, 26, 355, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 14, 25592, 8, 277, 14, 265, 63, 2902, 63, 1745, 63, 1461, 9, 288, 291, 14, 1818, 63, 2902, 275, 488, 398, 327, 2494, 892, 25708, 267, 340, 2688, 8, 2902, 14, 2902, 63, 576, 63, 1238, 12, 283, 12283, 939, 2768, 358, 436, 2688, 8, 2902, 12, 283, 1345, 63, 5538, 735, 288, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 275, 5174, 14, 2902, 63, 576, 63, 1238, 14, 11231, 288, 291, 14, 2902, 63, 1238, 63, 11231, 63, 3042, 14, 10108, 8, 277, 14, 265, 63, 2902, 63, 1745, 63, 1461, 12, 4205, 29, 549, 9, 953, 291, 14, 1818, 63, 2902, 275, 5174, 288, 291, 14, 1818, 63, 2902, 14, 2902, 63, 576, 63, 1238, 14, 12283, 939, 2768, 14, 10108, 8, 277, 423, 265, 63, 12283, 939, 63, 1345, 12, 28095, 4205, 29, 549, 9, 339, 347, 641, 63, 2902, 63, 1745, 63, 1461, 8, 277, 12, 13788, 304, 267, 408, 2494, 314, 9966, 367, 314, 2547, 1380, 314, 5174, 1159, 2547, 663, 4493, 408, 398, 340, 291, 14, 1818, 63, 2902, 63, 11231, 26, 288, 367, 2547, 315, 291, 14, 1818, 63, 2902, 63, 11231, 26, 355, 2547, 14, 5626, 63, 873, 14, 25592, 8, 277, 423, 265, 63, 1745, 63, 873, 9, 398, 291, 14, 1818, 63, 2902, 63, 11231, 275, 13788, 398, 340, 291, 14, 1818, 63, 2902, 63, 11231, 26, 288, 367, 2547, 315, 291, 14, 1818, 63, 2902, 63, 11231, 26, 355, 2547, 14, 5626, 63, 873, 14, 10108, 8, 277, 423, 265, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dvliman/jaikuengine
.google_appengine/lib/yaml/lib/yaml/dumper.py
131
2718
__all__ = ['BaseDumper', 'SafeDumper', 'Dumper'] from emitter import * from serializer import * from representer import * from resolver import * class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_uncode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self) class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self) class Dumper(Emitter, Serializer, Representer, Resolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self)
apache-2.0
[ 199, 363, 452, 363, 275, 788, 1563, 28593, 297, 283, 11090, 28593, 297, 283, 28593, 418, 199, 199, 504, 8689, 351, 492, 627, 199, 504, 9146, 492, 627, 199, 504, 295, 22682, 492, 627, 199, 504, 15611, 492, 627, 199, 199, 533, 3523, 28593, 8, 37, 22541, 12, 25555, 12, 3523, 497, 22682, 12, 3523, 12407, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 324, 600, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 14969, 28593, 8, 37, 22541, 12, 25555, 12, 14969, 497, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 14969, 497, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 19460, 281, 8, 37, 22541, 12, 25555, 12, 799, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 363, 452, 363, 275, 788, 1563, 28593, 297, 283, 11090, 28593, 297, 283, 28593, 418, 199, 199, 504, 8689, 351, 492, 627, 199, 504, 9146, 492, 627, 199, 504, 295, 22682, 492, 627, 199, 504, 15611, 492, 627, 199, 199, 533, 3523, 28593, 8, 37, 22541, 12, 25555, 12, 3523, 497, 22682, 12, 3523, 12407, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 324, 600, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 14969, 28593, 8, 37, 22541, 12, 25555, 12, 14969, 497, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 14969, 497, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 19460, 281, 8, 37, 22541, 12, 25555, 12, 799, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Khan/khan-linter
vendor/py2/yaml/tokens.py
985
2573
class Token(object): def __init__(self, start_mark, end_mark): self.start_mark = start_mark self.end_mark = end_mark def __repr__(self): attributes = [key for key in self.__dict__ if not key.endswith('_mark')] attributes.sort() arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) for key in attributes]) return '%s(%s)' % (self.__class__.__name__, arguments) #class BOMToken(Token): # id = '<byte order mark>' class DirectiveToken(Token): id = '<directive>' def __init__(self, name, value, start_mark, end_mark): self.name = name self.value = value self.start_mark = start_mark self.end_mark = end_mark class DocumentStartToken(Token): id = '<document start>' class DocumentEndToken(Token): id = '<document end>' class StreamStartToken(Token): id = '<stream start>' def __init__(self, start_mark=None, end_mark=None, encoding=None): self.start_mark = start_mark self.end_mark = end_mark self.encoding = encoding class StreamEndToken(Token): id = '<stream end>' class BlockSequenceStartToken(Token): id = '<block sequence start>' class BlockMappingStartToken(Token): id = '<block mapping start>' class BlockEndToken(Token): id = '<block end>' class FlowSequenceStartToken(Token): id = '[' class FlowMappingStartToken(Token): id = '{' class FlowSequenceEndToken(Token): id = ']' class FlowMappingEndToken(Token): id = '}' class KeyToken(Token): id = '?' class ValueToken(Token): id = ':' class BlockEntryToken(Token): id = '-' class FlowEntryToken(Token): id = ',' class AliasToken(Token): id = '<alias>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class AnchorToken(Token): id = '<anchor>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class TagToken(Token): id = '<tag>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class ScalarToken(Token): id = '<scalar>' def __init__(self, value, plain, start_mark, end_mark, style=None): self.value = value self.plain = plain self.start_mark = start_mark self.end_mark = end_mark self.style = style
apache-2.0
[ 199, 533, 8767, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 272, 347, 636, 2722, 721, 277, 304, 267, 3004, 275, 359, 498, 367, 790, 315, 291, 855, 807, 363, 355, 340, 440, 790, 14, 4130, 6412, 1657, 5440, 267, 3004, 14, 3191, 342, 267, 2368, 275, 1656, 1987, 904, 26861, 83, 2458, 82, 7, 450, 334, 498, 12, 2519, 8, 277, 12, 790, 430, 355, 367, 790, 315, 3004, 566, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 2368, 9, 199, 199, 3, 533, 17720, 3264, 8, 3264, 304, 199, 3, 259, 1305, 275, 2650, 4414, 1865, 2216, 3524, 199, 199, 533, 3757, 8374, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 15047, 3524, 272, 347, 636, 826, 721, 277, 12, 536, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 7543, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3554, 1343, 3524, 199, 199, 533, 7543, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3554, 1284, 3524, 199, 199, 533, 8271, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1745, 1343, 3524, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 2644, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2991, 275, 2644, 199, 199, 533, 8271, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1745, 1284, 3524, 199, 199, 533, 8651, 5826, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 3414, 1343, 3524, 199, 199, 533, 8651, 7674, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 4412, 1343, 3524, 199, 199, 533, 8651, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 1284, 3524, 199, 199, 533, 20823, 5826, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 22640, 199, 199, 533, 20823, 7674, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 26109, 199, 199, 533, 20823, 5826, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 24840, 199, 199, 533, 20823, 7674, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 23618, 199, 199, 533, 2606, 3264, 8, 3264, 304, 272, 1305, 275, 15539, 199, 199, 533, 1594, 3264, 8, 3264, 304, 272, 1305, 275, 10871, 199, 199, 533, 8651, 3900, 3264, 8, 3264, 304, 272, 1305, 275, 10791, 199, 199, 533, 20823, 3900, 3264, 8, 3264, 304, 272, 1305, 275, 13647, 199, 199, 533, 24777, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3620, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 1626, 7050, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 11498, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 8053, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1450, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 24289, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 7033, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 8971, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 12, 3449, 29, 403, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 6104, 275, 8971, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2487, 275, 3449, 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 ]
[ 533, 8767, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 272, 347, 636, 2722, 721, 277, 304, 267, 3004, 275, 359, 498, 367, 790, 315, 291, 855, 807, 363, 355, 340, 440, 790, 14, 4130, 6412, 1657, 5440, 267, 3004, 14, 3191, 342, 267, 2368, 275, 1656, 1987, 904, 26861, 83, 2458, 82, 7, 450, 334, 498, 12, 2519, 8, 277, 12, 790, 430, 355, 367, 790, 315, 3004, 566, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 2368, 9, 199, 199, 3, 533, 17720, 3264, 8, 3264, 304, 199, 3, 259, 1305, 275, 2650, 4414, 1865, 2216, 3524, 199, 199, 533, 3757, 8374, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 15047, 3524, 272, 347, 636, 826, 721, 277, 12, 536, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 7543, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3554, 1343, 3524, 199, 199, 533, 7543, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3554, 1284, 3524, 199, 199, 533, 8271, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1745, 1343, 3524, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 2644, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2991, 275, 2644, 199, 199, 533, 8271, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1745, 1284, 3524, 199, 199, 533, 8651, 5826, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 3414, 1343, 3524, 199, 199, 533, 8651, 7674, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 4412, 1343, 3524, 199, 199, 533, 8651, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1457, 1284, 3524, 199, 199, 533, 20823, 5826, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 22640, 199, 199, 533, 20823, 7674, 3162, 3264, 8, 3264, 304, 272, 1305, 275, 26109, 199, 199, 533, 20823, 5826, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 24840, 199, 199, 533, 20823, 7674, 3005, 3264, 8, 3264, 304, 272, 1305, 275, 23618, 199, 199, 533, 2606, 3264, 8, 3264, 304, 272, 1305, 275, 15539, 199, 199, 533, 1594, 3264, 8, 3264, 304, 272, 1305, 275, 10871, 199, 199, 533, 8651, 3900, 3264, 8, 3264, 304, 272, 1305, 275, 10791, 199, 199, 533, 20823, 3900, 3264, 8, 3264, 304, 272, 1305, 275, 13647, 199, 199, 533, 24777, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 3620, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 1626, 7050, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 11498, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 8053, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 1450, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 24289, 3264, 8, 3264, 304, 272, 1305, 275, 2650, 7033, 3524, 272, 347, 636, 826, 721, 277, 12, 574, 12, 8971, 12, 1343, 63, 1657, 12, 1284, 63, 1657, 12, 3449, 29, 403, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 6104, 275, 8971, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2487, 275, 3449, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tumbl3w33d/ansible
lib/ansible/modules/network/fortios/fortios_system_management_tunnel.py
13
11162
#!/usr/bin/python from __future__ import (absolute_import, division, print_function) # Copyright 2019 Fortinet, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. __metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'} DOCUMENTATION = ''' --- module: fortios_system_management_tunnel short_description: Management tunnel configuration in Fortinet's FortiOS and FortiGate. description: - This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set and modify system feature and management_tunnel category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.5 version_added: "2.9" author: - Miguel Angel Munoz (@mamunozgonzalez) - Nicolas Thomas (@thomnico) notes: - Requires fortiosapi library developed by Fortinet - Run as a local_action in your playbook requirements: - fortiosapi>=0.9.8 options: host: description: - FortiOS or FortiGate IP address. type: str required: false username: description: - FortiOS or FortiGate username. type: str required: false password: description: - FortiOS or FortiGate password. type: str default: "" vdom: description: - Virtual domain, among those defined previously. A vdom is a virtual instance of the FortiGate that can be configured and used as a different unit. type: str default: root https: description: - Indicates if the requests towards FortiGate must use HTTPS protocol. type: bool default: true ssl_verify: description: - Ensures FortiGate certificate must be verified by a proper CA. type: bool default: true system_management_tunnel: description: - Management tunnel configuration. default: null type: dict suboptions: allow_collect_statistics: description: - Enable/disable collection of run time statistics. type: str choices: - enable - disable allow_config_restore: description: - Enable/disable allow config restore. type: str choices: - enable - disable allow_push_configuration: description: - Enable/disable push configuration. type: str choices: - enable - disable allow_push_firmware: description: - Enable/disable push firmware. type: str choices: - enable - disable authorized_manager_only: description: - Enable/disable restriction of authorized manager only. type: str choices: - enable - disable serial_number: description: - Serial number. type: str status: description: - Enable/disable FGFM tunnel. type: str choices: - enable - disable ''' EXAMPLES = ''' - hosts: localhost vars: host: "192.168.122.40" username: "admin" password: "" vdom: "root" ssl_verify: "False" tasks: - name: Management tunnel configuration. fortios_system_management_tunnel: host: "{{ host }}" username: "{{ username }}" password: "{{ password }}" vdom: "{{ vdom }}" https: "False" system_management_tunnel: allow_collect_statistics: "enable" allow_config_restore: "enable" allow_push_configuration: "enable" allow_push_firmware: "enable" authorized_manager_only: "enable" serial_number: "<your_own_value>" status: "enable" ''' RETURN = ''' build: description: Build number of the fortigate image returned: always type: str sample: '1547' http_method: description: Last method used to provision the content into FortiGate returned: always type: str sample: 'PUT' http_status: description: Last result given by FortiGate on last operation applied returned: always type: str sample: "200" mkey: description: Master key (id) used in the last call to FortiGate returned: success type: str sample: "id" name: description: Name of the table used to fulfill the request returned: always type: str sample: "urlfilter" path: description: Path of the table used to fulfill the request returned: always type: str sample: "webfilter" revision: description: Internal revision number returned: always type: str sample: "17.0.2.10658" serial: description: Serial number of the unit returned: always type: str sample: "FGVMEVYYQT3AB5352" status: description: Indication of the operation's result returned: always type: str sample: "success" vdom: description: Virtual domain used returned: always type: str sample: "root" version: description: Version of the FortiGate returned: always type: str sample: "v5.6.3" ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import Connection from ansible.module_utils.network.fortios.fortios import FortiOSHandler from ansible.module_utils.network.fortimanager.common import FAIL_SOCKET_MSG def login(data, fos): host = data['host'] username = data['username'] password = data['password'] ssl_verify = data['ssl_verify'] fos.debug('on') if 'https' in data and not data['https']: fos.https('off') else: fos.https('on') fos.login(host, username, password, verify=ssl_verify) def filter_system_management_tunnel_data(json): option_list = ['allow_collect_statistics', 'allow_config_restore', 'allow_push_configuration', 'allow_push_firmware', 'authorized_manager_only', 'serial_number', 'status'] dictionary = {} for attribute in option_list: if attribute in json and json[attribute] is not None: dictionary[attribute] = json[attribute] return dictionary def underscore_to_hyphen(data): if isinstance(data, list): for elem in data: elem = underscore_to_hyphen(elem) elif isinstance(data, dict): new_data = {} for k, v in data.items(): new_data[k.replace('_', '-')] = underscore_to_hyphen(v) data = new_data return data def system_management_tunnel(data, fos): vdom = data['vdom'] system_management_tunnel_data = data['system_management_tunnel'] filtered_data = underscore_to_hyphen(filter_system_management_tunnel_data(system_management_tunnel_data)) return fos.set('system', 'management-tunnel', data=filtered_data, vdom=vdom) def is_successful_status(status): return status['status'] == "success" or \ status['http_method'] == "DELETE" and status['http_status'] == 404 def fortios_system(data, fos): if data['system_management_tunnel']: resp = system_management_tunnel(data, fos) return not is_successful_status(resp), \ resp['status'] == "success", \ resp def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "system_management_tunnel": { "required": False, "type": "dict", "default": None, "options": { "allow_collect_statistics": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "allow_config_restore": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "allow_push_configuration": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "allow_push_firmware": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "authorized_manager_only": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "serial_number": {"required": False, "type": "str"}, "status": {"required": False, "type": "str", "choices": ["enable", "disable"]} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19516, 63, 2253, 63, 8110, 63, 15360, 199, 3612, 63, 1802, 26, 8259, 21496, 2897, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 334, 38, 3100, 9, 2243, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 2656, 3878, 436, 10041, 63, 15360, 4637, 14, 489, 6058, 2387, 1006, 2633, 436, 1338, 1929, 370, 506, 19477, 370, 29289, 83, 2544, 4503, 14, 489, 30568, 543, 481, 3100, 373, 22, 14, 16, 14, 21, 199, 1023, 63, 3270, 26, 298, 18, 14, 25, 2, 199, 2502, 26, 272, 446, 28195, 13086, 1626, 24920, 603, 324, 26051, 8593, 391, 32368, 26051, 27719, 90, 1895, 90, 9, 272, 446, 30650, 761, 305, 27864, 8593, 273, 676, 8445, 331, 9, 199, 5983, 26, 272, 446, 15127, 19516, 1246, 3555, 477, 27813, 701, 30205, 10811, 272, 446, 3378, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 199, 7538, 26, 272, 446, 19516, 1246, 8119, 16, 14, 25, 14, 24, 199, 1419, 26, 272, 1591, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3531, 2287, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 267, 730, 26, 620, 267, 849, 26, 3087, 272, 20822, 26, 267, 1369, 26, 288, 446, 13311, 2881, 12, 16885, 5204, 3247, 10889, 14, 437, 20822, 365, 282, 1598, 5791, 1256, 402, 314, 20306, 626, 883, 506, 7526, 436, 1598, 1202, 465, 282, 3365, 4137, 14, 267, 730, 26, 620, 267, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 4113, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6149, 63, 4712, 26, 267, 1369, 26, 288, 446, 29652, 20306, 5897, 1471, 506, 16317, 701, 282, 5576, 7240, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 2656, 63, 8110, 63, 15360, 26, 267, 1369, 26, 288, 446, 8259, 21496, 2897, 14, 267, 849, 26, 2973, 267, 730, 26, 1211, 267, 26265, 26, 288, 2040, 63, 7112, 63, 13724, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 3245, 402, 1255, 900, 11076, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 888, 63, 8011, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 2040, 1101, 9066, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 5335, 63, 4758, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 6675, 2897, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 5335, 63, 26374, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 6675, 27969, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 18788, 63, 2609, 63, 2118, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 10588, 402, 18788, 5256, 1454, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 3012, 63, 1955, 26, 355, 1369, 26, 490, 446, 11973, 1329, 14, 355, 730, 26, 620, 288, 2004, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 481, 17395, 45, 21496, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 7057, 26, 11667, 523, 6802, 26, 2043, 1591, 26, 298, 5756, 14, 6568, 14, 7507, 14, 2167, 2, 2043, 3434, 26, 298, 2113, 2, 2043, 2505, 26, 3087, 2043, 20822, 26, 298, 1231, 2, 2043, 6149, 63, 4712, 26, 298, 797, 2, 523, 6527, 26, 523, 446, 536, 26, 8259, 21496, 2897, 14, 272, 19516, 63, 2253, 63, 8110, 63, 15360, 26, 489, 1591, 26, 221, 7370, 1591, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 20822, 26, 221, 7370, 20822, 7820, 489, 4178, 26, 298, 797, 2, 489, 2656, 63, 8110, 63, 15360, 26, 267, 2040, 63, 7112, 63, 13724, 26, 298, 4296, 2, 267, 2040, 63, 888, 63, 8011, 26, 298, 4296, 2, 267, 2040, 63, 5335, 63, 4758, 26, 298, 4296, 2, 267, 2040, 63, 5335, 63, 26374, 26, 298, 4296, 2, 267, 18788, 63, 2609, 63, 2118, 26, 298, 4296, 2, 267, 3012, 63, 1955, 26, 3886, 12695, 63, 944, 63, 585, 4335, 267, 2004, 26, 298, 4296, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 1506, 26, 523, 1369, 26, 6516, 1329, 402, 314, 367, 280, 3237, 1834, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 283, 1046, 2417, 7, 199, 1014, 63, 765, 26 ]
[ 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19516, 63, 2253, 63, 8110, 63, 15360, 199, 3612, 63, 1802, 26, 8259, 21496, 2897, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 334, 38, 3100, 9, 2243, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 2656, 3878, 436, 10041, 63, 15360, 4637, 14, 489, 6058, 2387, 1006, 2633, 436, 1338, 1929, 370, 506, 19477, 370, 29289, 83, 2544, 4503, 14, 489, 30568, 543, 481, 3100, 373, 22, 14, 16, 14, 21, 199, 1023, 63, 3270, 26, 298, 18, 14, 25, 2, 199, 2502, 26, 272, 446, 28195, 13086, 1626, 24920, 603, 324, 26051, 8593, 391, 32368, 26051, 27719, 90, 1895, 90, 9, 272, 446, 30650, 761, 305, 27864, 8593, 273, 676, 8445, 331, 9, 199, 5983, 26, 272, 446, 15127, 19516, 1246, 3555, 477, 27813, 701, 30205, 10811, 272, 446, 3378, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 199, 7538, 26, 272, 446, 19516, 1246, 8119, 16, 14, 25, 14, 24, 199, 1419, 26, 272, 1591, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3531, 2287, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 267, 730, 26, 620, 267, 849, 26, 3087, 272, 20822, 26, 267, 1369, 26, 288, 446, 13311, 2881, 12, 16885, 5204, 3247, 10889, 14, 437, 20822, 365, 282, 1598, 5791, 1256, 402, 314, 20306, 626, 883, 506, 7526, 436, 1598, 1202, 465, 282, 3365, 4137, 14, 267, 730, 26, 620, 267, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 4113, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6149, 63, 4712, 26, 267, 1369, 26, 288, 446, 29652, 20306, 5897, 1471, 506, 16317, 701, 282, 5576, 7240, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 2656, 63, 8110, 63, 15360, 26, 267, 1369, 26, 288, 446, 8259, 21496, 2897, 14, 267, 849, 26, 2973, 267, 730, 26, 1211, 267, 26265, 26, 288, 2040, 63, 7112, 63, 13724, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 3245, 402, 1255, 900, 11076, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 888, 63, 8011, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 2040, 1101, 9066, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 5335, 63, 4758, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 6675, 2897, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 2040, 63, 5335, 63, 26374, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 6675, 27969, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 18788, 63, 2609, 63, 2118, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 10588, 402, 18788, 5256, 1454, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 3012, 63, 1955, 26, 355, 1369, 26, 490, 446, 11973, 1329, 14, 355, 730, 26, 620, 288, 2004, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 481, 17395, 45, 21496, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 7057, 26, 11667, 523, 6802, 26, 2043, 1591, 26, 298, 5756, 14, 6568, 14, 7507, 14, 2167, 2, 2043, 3434, 26, 298, 2113, 2, 2043, 2505, 26, 3087, 2043, 20822, 26, 298, 1231, 2, 2043, 6149, 63, 4712, 26, 298, 797, 2, 523, 6527, 26, 523, 446, 536, 26, 8259, 21496, 2897, 14, 272, 19516, 63, 2253, 63, 8110, 63, 15360, 26, 489, 1591, 26, 221, 7370, 1591, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 20822, 26, 221, 7370, 20822, 7820, 489, 4178, 26, 298, 797, 2, 489, 2656, 63, 8110, 63, 15360, 26, 267, 2040, 63, 7112, 63, 13724, 26, 298, 4296, 2, 267, 2040, 63, 888, 63, 8011, 26, 298, 4296, 2, 267, 2040, 63, 5335, 63, 4758, 26, 298, 4296, 2, 267, 2040, 63, 5335, 63, 26374, 26, 298, 4296, 2, 267, 18788, 63, 2609, 63, 2118, 26, 298, 4296, 2, 267, 3012, 63, 1955, 26, 3886, 12695, 63, 944, 63, 585, 4335, 267, 2004, 26, 298, 4296, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 1506, 26, 523, 1369, 26, 6516, 1329, 402, 314, 367, 280, 3237, 1834, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 283, 1046, 2417, 7, 199, 1014, 63, 765, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rhyolight/nupic.son
tests/app/soc/modules/gci/views/helper/test_redirect_helper.py
1
2784
# Copyright 2012 the Melange authors. # # 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. """This module unit tests for RedirectHelper class.""" from soc.views.helper.access_checker import unset from soc.modules.gci.views.base import GCIRequestHandler from tests.test_utils import GCITestCase from tests.test_utils import MockRequest class RedirectHelperTest(GCITestCase): """Unit tests for RedirectHelper class.""" def setUp(self): self.init() request = MockRequest(path="/") self.handler = GCIRequestHandler() data, _, _ = self.handler.initializer.initialize(request, (), {}) self.redirect = data.redirect def testProgram(self): expected = { 'sponsor': self.sponsor.link_id, 'program': self.gci.link_id, } self.handler.kwargs = {} self.redirect.program(program=self.gci) self.assertEqual(self.redirect.kwargs, expected) self.handler.kwargs = {} self.redirect.program() self.assertEqual(self.redirect.kwargs, expected) self.redirect._data._program = unset self._assertAssertionError(self.redirect.program) def testUserOrg(self): expected = { 'user': 'test_user', 'organization': self.org.link_id, 'sponsor': self.sponsor.link_id, 'program': self.gci.link_id } self.handler.kwargs = {} self.redirect.userOrg(user='test_user', organization=self.org) self.assertEqual(self.redirect.kwargs, expected) self.handler.kwargs = {} self.redirect._data.kwargs['user'] = 'test_user' self.redirect.userOrg(organization=self.org) self.assertEqual(self.redirect.kwargs, expected) self.handler.kwargs = {} del self.redirect._data.kwargs['user'] self.redirect._data.organization = self.org self.redirect.userOrg(user='test_user') self.assertEqual(self.redirect.kwargs, expected) self.handler.kwargs = {} self.redirect._data.organization = None self._assertAssertionError(self.redirect.userOrg) def _assertAssertionError(self, callable, *args, **kwargs): # TODO(daniel): replace this with the commented code # when app is updated to 2.7 runtime self.assertRaises(AssertionError, callable, *args, **kwargs) #with self.assertRaises(AssertionError): # callable(*args, **kwargs)
apache-2.0
[ 3, 1898, 6029, 314, 603, 352, 618, 11462, 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, 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, 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, 2765, 859, 4137, 2295, 367, 18532, 4433, 1021, 1041, 199, 199, 504, 308, 679, 14, 4196, 14, 3676, 14, 2732, 63, 6743, 492, 15376, 199, 199, 504, 308, 679, 14, 3112, 14, 71, 559, 14, 4196, 14, 1095, 492, 598, 3553, 11149, 199, 199, 504, 2295, 14, 396, 63, 1208, 492, 598, 24082, 27309, 199, 504, 2295, 14, 396, 63, 1208, 492, 4420, 2017, 421, 199, 533, 18532, 4433, 774, 8, 7484, 649, 27309, 304, 523, 408, 5072, 2295, 367, 18532, 4433, 1021, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 826, 342, 272, 1056, 275, 4420, 2017, 8, 515, 9555, 531, 339, 291, 14, 2232, 275, 598, 3553, 11149, 342, 272, 666, 12, 5501, 485, 275, 291, 14, 2232, 14, 6498, 14, 8489, 8, 1069, 12, 11969, 5009, 339, 291, 14, 4876, 275, 666, 14, 4876, 819, 347, 511, 9184, 8, 277, 304, 272, 1420, 275, 469, 267, 283, 83, 29733, 356, 291, 14, 83, 29733, 14, 1073, 63, 344, 12, 267, 283, 6815, 356, 291, 14, 71, 559, 14, 1073, 63, 344, 12, 267, 789, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 6815, 8, 6815, 29, 277, 14, 71, 559, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 6815, 342, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 4876, 423, 576, 423, 6815, 275, 15376, 272, 291, 423, 479, 14844, 8, 277, 14, 4876, 14, 6815, 9, 819, 347, 511, 1899, 11014, 8, 277, 304, 272, 1420, 275, 469, 267, 283, 751, 356, 283, 396, 63, 751, 297, 267, 283, 9071, 356, 291, 14, 1308, 14, 1073, 63, 344, 12, 267, 283, 83, 29733, 356, 291, 14, 83, 29733, 14, 1073, 63, 344, 12, 267, 283, 6815, 356, 291, 14, 71, 559, 14, 1073, 63, 344, 267, 789, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 751, 11014, 8, 751, 534, 396, 63, 751, 297, 13237, 29, 277, 14, 1308, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 423, 576, 14, 958, 459, 751, 418, 275, 283, 396, 63, 751, 7, 272, 291, 14, 4876, 14, 751, 11014, 8, 9071, 29, 277, 14, 1308, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 2150, 291, 14, 4876, 423, 576, 14, 958, 459, 751, 418, 272, 291, 14, 4876, 423, 576, 14, 9071, 275, 291, 14, 1308, 272, 291, 14, 4876, 14, 751, 11014, 8, 751, 534, 396, 63, 751, 358, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 423, 576, 14, 9071, 275, 488, 272, 291, 423, 479, 14844, 8, 277, 14, 4876, 14, 751, 11014, 9, 819, 347, 485, 479, 14844, 8, 277, 12, 4550, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 3254, 8, 24863, 14769, 304, 3350, 642, 543, 314, 21804, 1233, 272, 327, 1380, 1145, 365, 4588, 370, 499, 14, 23, 8836, 272, 291, 14, 1855, 8, 14844, 12, 4550, 12, 627, 589, 12, 1011, 958, 9, 272, 327, 1045, 291, 14, 1855, 8, 14844, 304, 272, 327, 221, 4550, 2031, 589, 12, 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 ]
[ 1898, 6029, 314, 603, 352, 618, 11462, 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, 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, 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, 2765, 859, 4137, 2295, 367, 18532, 4433, 1021, 1041, 199, 199, 504, 308, 679, 14, 4196, 14, 3676, 14, 2732, 63, 6743, 492, 15376, 199, 199, 504, 308, 679, 14, 3112, 14, 71, 559, 14, 4196, 14, 1095, 492, 598, 3553, 11149, 199, 199, 504, 2295, 14, 396, 63, 1208, 492, 598, 24082, 27309, 199, 504, 2295, 14, 396, 63, 1208, 492, 4420, 2017, 421, 199, 533, 18532, 4433, 774, 8, 7484, 649, 27309, 304, 523, 408, 5072, 2295, 367, 18532, 4433, 1021, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 826, 342, 272, 1056, 275, 4420, 2017, 8, 515, 9555, 531, 339, 291, 14, 2232, 275, 598, 3553, 11149, 342, 272, 666, 12, 5501, 485, 275, 291, 14, 2232, 14, 6498, 14, 8489, 8, 1069, 12, 11969, 5009, 339, 291, 14, 4876, 275, 666, 14, 4876, 819, 347, 511, 9184, 8, 277, 304, 272, 1420, 275, 469, 267, 283, 83, 29733, 356, 291, 14, 83, 29733, 14, 1073, 63, 344, 12, 267, 283, 6815, 356, 291, 14, 71, 559, 14, 1073, 63, 344, 12, 267, 789, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 6815, 8, 6815, 29, 277, 14, 71, 559, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 6815, 342, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 4876, 423, 576, 423, 6815, 275, 15376, 272, 291, 423, 479, 14844, 8, 277, 14, 4876, 14, 6815, 9, 819, 347, 511, 1899, 11014, 8, 277, 304, 272, 1420, 275, 469, 267, 283, 751, 356, 283, 396, 63, 751, 297, 267, 283, 9071, 356, 291, 14, 1308, 14, 1073, 63, 344, 12, 267, 283, 83, 29733, 356, 291, 14, 83, 29733, 14, 1073, 63, 344, 12, 267, 283, 6815, 356, 291, 14, 71, 559, 14, 1073, 63, 344, 267, 789, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 14, 751, 11014, 8, 751, 534, 396, 63, 751, 297, 13237, 29, 277, 14, 1308, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 423, 576, 14, 958, 459, 751, 418, 275, 283, 396, 63, 751, 7, 272, 291, 14, 4876, 14, 751, 11014, 8, 9071, 29, 277, 14, 1308, 9, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 2150, 291, 14, 4876, 423, 576, 14, 958, 459, 751, 418, 272, 291, 14, 4876, 423, 576, 14, 9071, 275, 291, 14, 1308, 272, 291, 14, 4876, 14, 751, 11014, 8, 751, 534, 396, 63, 751, 358, 272, 291, 14, 629, 8, 277, 14, 4876, 14, 958, 12, 1420, 9, 339, 291, 14, 2232, 14, 958, 275, 1052, 272, 291, 14, 4876, 423, 576, 14, 9071, 275, 488, 272, 291, 423, 479, 14844, 8, 277, 14, 4876, 14, 751, 11014, 9, 819, 347, 485, 479, 14844, 8, 277, 12, 4550, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 3254, 8, 24863, 14769, 304, 3350, 642, 543, 314, 21804, 1233, 272, 327, 1380, 1145, 365, 4588, 370, 499, 14, 23, 8836, 272, 291, 14, 1855, 8, 14844, 12, 4550, 12, 627, 589, 12, 1011, 958, 9, 272, 327, 1045, 291, 14, 1855, 8, 14844, 304, 272, 327, 221, 4550, 2031, 589, 12, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
schinke/solid-fortnight-ba
flask/venv/lib/python2.7/site-packages/pip/_vendor/packaging/_structures.py
1152
1416
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function class Infinity(object): def __repr__(self): return "Infinity" def __hash__(self): return hash(repr(self)) def __lt__(self, other): return False def __le__(self, other): return False def __eq__(self, other): return isinstance(other, self.__class__) def __ne__(self, other): return not isinstance(other, self.__class__) def __gt__(self, other): return True def __ge__(self, other): return True def __neg__(self): return NegativeInfinity Infinity = Infinity() class NegativeInfinity(object): def __repr__(self): return "-Infinity" def __hash__(self): return hash(repr(self)) def __lt__(self, other): return True def __le__(self, other): return True def __eq__(self, other): return isinstance(other, self.__class__) def __ne__(self, other): return not isinstance(other, self.__class__) def __gt__(self, other): return False def __ge__(self, other): return False def __neg__(self): return Infinity NegativeInfinity = NegativeInfinity()
mit
[ 3, 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 421, 199, 533, 1010, 9693, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 14660, 2, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 2722, 8, 277, 430, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 8705, 721, 277, 304, 267, 372, 32548, 14660, 199, 199, 14660, 275, 1010, 9693, 342, 421, 199, 533, 32548, 14660, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3905, 14660, 2, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 2722, 8, 277, 430, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 8705, 721, 277, 304, 267, 372, 1010, 9693, 199, 199, 15562, 14660, 275, 32548, 14660, 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 ]
[ 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 421, 199, 533, 1010, 9693, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 14660, 2, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 2722, 8, 277, 430, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 8705, 721, 277, 304, 267, 372, 32548, 14660, 199, 199, 14660, 275, 1010, 9693, 342, 421, 199, 533, 32548, 14660, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3905, 14660, 2, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 2722, 8, 277, 430, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 372, 715, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 1228, 8, 1848, 12, 291, 855, 533, 3368, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 756, 339, 347, 636, 8705, 721, 277, 304, 267, 372, 1010, 9693, 199, 199, 15562, 14660, 275, 32548, 14660, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
guaix-ucm/numina
numina/user/clirundal.py
3
1572
# # Copyright 2008-2019 Universidad Complutense de Madrid # # This file is part of Numina # # SPDX-License-Identifier: GPL-3.0+ # License-Filename: LICENSE.txt # """User command line interface of Numina.""" import logging from .baserun import run_reduce from .helpers import create_datamanager, load_observations _logger = logging.getLogger(__name__) def mode_run_common(args, extra_args, mode): # FIXME: implement 'recipe' run mode if mode == 'rec': print('Mode not implemented yet') return 1 elif mode == 'obs': return mode_run_common_obs(args, extra_args) else: raise ValueError(f'Not valid run mode {mode}') def mode_run_common_obs(args, extra_args): """Observing mode processing mode of numina.""" # Loading observation result if exists sessions, loaded_obs = load_observations(args.obsresult, args.session) datamanager = create_datamanager(args.reqs, args.basedir, args.datadir, extra_args.extra_control) datamanager.backend.add_obs(loaded_obs) # Start processing jobs = [] for session in sessions: for job in session: if job['enabled'] or job['id'] in args.enable: jobs.append(job) for job in jobs: run_reduce( datamanager, job['id'], copy_files=args.copy_files, validate_inputs=args.validate, validate_results=args.validate ) if args.dump_control: _logger.debug('dump control status') with open('control_dump.yaml', 'w') as fp: datamanager.backend.dump(fp)
gpl-3.0
[ 3, 199, 3, 1898, 9079, 13, 14982, 1910, 4380, 4148, 350, 1849, 2421, 85, 724, 261, 477, 603, 350, 1677, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 16817, 13765, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 14629, 13, 19, 14, 16, 11, 199, 3, 844, 13, 8117, 26, 5113, 14, 2424, 199, 3, 199, 199, 624, 1899, 1414, 1004, 3217, 402, 16817, 13765, 1041, 421, 199, 646, 2050, 199, 199, 504, 1275, 2470, 332, 324, 492, 1255, 63, 5270, 199, 504, 1275, 7546, 492, 1218, 63, 576, 2609, 12, 2248, 63, 2873, 12225, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 818, 63, 1065, 63, 2330, 8, 589, 12, 2402, 63, 589, 12, 818, 304, 272, 327, 7600, 26, 5669, 283, 13191, 7, 1255, 818, 272, 340, 818, 508, 283, 2761, 356, 267, 870, 360, 1385, 440, 6366, 5966, 358, 267, 372, 413, 272, 916, 818, 508, 283, 11226, 356, 267, 372, 818, 63, 1065, 63, 2330, 63, 11226, 8, 589, 12, 2402, 63, 589, 9, 272, 587, 26, 267, 746, 1722, 8, 70, 7, 1763, 1686, 1255, 818, 469, 632, 12216, 421, 199, 318, 818, 63, 1065, 63, 2330, 63, 11226, 8, 589, 12, 2402, 63, 589, 304, 272, 408, 11394, 14717, 818, 6661, 818, 402, 1967, 13765, 1041, 339, 327, 3835, 5384, 20038, 754, 340, 3495, 272, 12184, 12, 6511, 63, 11226, 275, 2248, 63, 2873, 12225, 8, 589, 14, 11226, 1099, 12, 1249, 14, 1730, 9, 339, 666, 2609, 275, 1218, 63, 576, 2609, 8, 589, 14, 12720, 12, 1249, 14, 12484, 12, 1249, 14, 18259, 12, 2402, 63, 589, 14, 2911, 63, 2785, 9, 272, 666, 2609, 14, 4620, 14, 525, 63, 11226, 8, 4591, 63, 11226, 9, 339, 327, 7707, 6661, 272, 9643, 275, 942, 272, 367, 2351, 315, 12184, 26, 267, 367, 3906, 315, 2351, 26, 288, 340, 3906, 459, 3827, 418, 503, 3906, 459, 344, 418, 315, 1249, 14, 4296, 26, 355, 9643, 14, 740, 8, 2423, 9, 339, 367, 3906, 315, 9643, 26, 398, 1255, 63, 5270, 8, 288, 666, 2609, 12, 3906, 459, 344, 995, 1331, 63, 1725, 29, 589, 14, 1574, 63, 1725, 12, 288, 4107, 63, 3711, 29, 589, 14, 3502, 12, 4107, 63, 2604, 29, 589, 14, 3502, 267, 776, 339, 340, 1249, 14, 2724, 63, 2785, 26, 267, 485, 2921, 14, 1757, 360, 2724, 3304, 2004, 358, 267, 543, 1551, 360, 2785, 63, 2724, 14, 5963, 297, 283, 87, 358, 465, 4090, 26, 288, 666, 2609, 14, 4620, 14, 2724, 8, 3997, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 9079, 13, 14982, 1910, 4380, 4148, 350, 1849, 2421, 85, 724, 261, 477, 603, 350, 1677, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 16817, 13765, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 14629, 13, 19, 14, 16, 11, 199, 3, 844, 13, 8117, 26, 5113, 14, 2424, 199, 3, 199, 199, 624, 1899, 1414, 1004, 3217, 402, 16817, 13765, 1041, 421, 199, 646, 2050, 199, 199, 504, 1275, 2470, 332, 324, 492, 1255, 63, 5270, 199, 504, 1275, 7546, 492, 1218, 63, 576, 2609, 12, 2248, 63, 2873, 12225, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 818, 63, 1065, 63, 2330, 8, 589, 12, 2402, 63, 589, 12, 818, 304, 272, 327, 7600, 26, 5669, 283, 13191, 7, 1255, 818, 272, 340, 818, 508, 283, 2761, 356, 267, 870, 360, 1385, 440, 6366, 5966, 358, 267, 372, 413, 272, 916, 818, 508, 283, 11226, 356, 267, 372, 818, 63, 1065, 63, 2330, 63, 11226, 8, 589, 12, 2402, 63, 589, 9, 272, 587, 26, 267, 746, 1722, 8, 70, 7, 1763, 1686, 1255, 818, 469, 632, 12216, 421, 199, 318, 818, 63, 1065, 63, 2330, 63, 11226, 8, 589, 12, 2402, 63, 589, 304, 272, 408, 11394, 14717, 818, 6661, 818, 402, 1967, 13765, 1041, 339, 327, 3835, 5384, 20038, 754, 340, 3495, 272, 12184, 12, 6511, 63, 11226, 275, 2248, 63, 2873, 12225, 8, 589, 14, 11226, 1099, 12, 1249, 14, 1730, 9, 339, 666, 2609, 275, 1218, 63, 576, 2609, 8, 589, 14, 12720, 12, 1249, 14, 12484, 12, 1249, 14, 18259, 12, 2402, 63, 589, 14, 2911, 63, 2785, 9, 272, 666, 2609, 14, 4620, 14, 525, 63, 11226, 8, 4591, 63, 11226, 9, 339, 327, 7707, 6661, 272, 9643, 275, 942, 272, 367, 2351, 315, 12184, 26, 267, 367, 3906, 315, 2351, 26, 288, 340, 3906, 459, 3827, 418, 503, 3906, 459, 344, 418, 315, 1249, 14, 4296, 26, 355, 9643, 14, 740, 8, 2423, 9, 339, 367, 3906, 315, 9643, 26, 398, 1255, 63, 5270, 8, 288, 666, 2609, 12, 3906, 459, 344, 995, 1331, 63, 1725, 29, 589, 14, 1574, 63, 1725, 12, 288, 4107, 63, 3711, 29, 589, 14, 3502, 12, 4107, 63, 2604, 29, 589, 14, 3502, 267, 776, 339, 340, 1249, 14, 2724, 63, 2785, 26, 267, 485, 2921, 14, 1757, 360, 2724, 3304, 2004, 358, 267, 543, 1551, 360, 2785, 63, 2724, 14, 5963, 297, 283, 87, 358, 465, 4090, 26, 288, 666, 2609, 14, 4620, 14, 2724, 8, 3997, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
OsirisSPS/osiris-sps
client/share/plugins/AF9A4C281070FDB0F34CF417CDB168AB38C8A388/lib/lib2to3/fixes/fix_sys_exc.py
327
1039
"""Fixer for sys.exc_{type, value, traceback} sys.exc_type -> sys.exc_info()[0] sys.exc_value -> sys.exc_info()[1] sys.exc_traceback -> sys.exc_info()[2] """ # By Jeff Balogh and Benjamin Peterson # Local imports from .. import fixer_base from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms class FixSysExc(fixer_base.BaseFix): # This order matches the ordering of sys.exc_info(). exc_info = [u"exc_type", u"exc_value", u"exc_traceback"] BM_compatible = True PATTERN = """ power< 'sys' trailer< dot='.' attribute=(%s) > > """ % '|'.join("'%s'" % e for e in exc_info) def transform(self, node, results): sys_attr = results["attribute"][0] index = Number(self.exc_info.index(sys_attr.value)) call = Call(Name(u"exc_info"), prefix=sys_attr.prefix) attr = Attr(Name(u"sys"), call) attr[1].children[0].prefix = results["dot"].prefix attr.append(Subscript(index)) return Node(syms.power, attr, prefix=node.prefix)
gpl-3.0
[ 624, 11985, 281, 367, 984, 14, 2804, 7348, 466, 12, 574, 12, 5190, 93, 199, 199, 1274, 14, 2804, 63, 466, 1035, 984, 14, 2804, 63, 815, 3430, 16, 61, 199, 1274, 14, 2804, 63, 585, 1035, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 1274, 14, 2804, 63, 6894, 1035, 984, 14, 2804, 63, 815, 3430, 18, 61, 199, 624, 199, 199, 3, 4885, 1603, 3609, 699, 2548, 72, 436, 26844, 16997, 262, 22912, 834, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 20516, 12, 6523, 12, 2812, 12, 4860, 12, 4804, 1579, 12, 5013, 12, 25308, 199, 199, 533, 14811, 11319, 20702, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 327, 961, 1865, 4450, 314, 7794, 402, 984, 14, 2804, 63, 815, 1252, 272, 3178, 63, 815, 275, 359, 85, 2, 2804, 63, 466, 401, 399, 2, 2804, 63, 585, 401, 399, 2, 2804, 63, 6894, 937, 272, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 1598, 7074, 28, 283, 1274, 7, 17357, 28, 6308, 534, 3530, 2225, 2687, 5, 83, 9, 690, 690, 1598, 408, 450, 21590, 904, 21065, 83, 4065, 450, 325, 367, 325, 315, 3178, 63, 815, 9, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 984, 63, 962, 275, 2058, 905, 3215, 9210, 16, 61, 267, 1478, 275, 4860, 8, 277, 14, 2804, 63, 815, 14, 1080, 8, 1274, 63, 962, 14, 585, 430, 398, 1240, 275, 6523, 8, 985, 8, 85, 2, 2804, 63, 815, 1288, 2403, 29, 1274, 63, 962, 14, 1861, 9, 267, 1921, 275, 20516, 8, 985, 8, 85, 2, 1274, 1288, 1240, 9, 267, 1921, 59, 17, 1055, 3223, 59, 16, 1055, 1861, 275, 2058, 905, 3287, 4140, 1861, 267, 1921, 14, 740, 8, 2610, 1579, 8, 1080, 430, 267, 372, 5013, 8, 13807, 14, 5652, 12, 1921, 12, 2403, 29, 932, 14, 1861, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11985, 281, 367, 984, 14, 2804, 7348, 466, 12, 574, 12, 5190, 93, 199, 199, 1274, 14, 2804, 63, 466, 1035, 984, 14, 2804, 63, 815, 3430, 16, 61, 199, 1274, 14, 2804, 63, 585, 1035, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 1274, 14, 2804, 63, 6894, 1035, 984, 14, 2804, 63, 815, 3430, 18, 61, 199, 624, 199, 199, 3, 4885, 1603, 3609, 699, 2548, 72, 436, 26844, 16997, 262, 22912, 834, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 20516, 12, 6523, 12, 2812, 12, 4860, 12, 4804, 1579, 12, 5013, 12, 25308, 199, 199, 533, 14811, 11319, 20702, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 327, 961, 1865, 4450, 314, 7794, 402, 984, 14, 2804, 63, 815, 1252, 272, 3178, 63, 815, 275, 359, 85, 2, 2804, 63, 466, 401, 399, 2, 2804, 63, 585, 401, 399, 2, 2804, 63, 6894, 937, 272, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 1598, 7074, 28, 283, 1274, 7, 17357, 28, 6308, 534, 3530, 2225, 2687, 5, 83, 9, 690, 690, 1598, 408, 450, 21590, 904, 21065, 83, 4065, 450, 325, 367, 325, 315, 3178, 63, 815, 9, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 984, 63, 962, 275, 2058, 905, 3215, 9210, 16, 61, 267, 1478, 275, 4860, 8, 277, 14, 2804, 63, 815, 14, 1080, 8, 1274, 63, 962, 14, 585, 430, 398, 1240, 275, 6523, 8, 985, 8, 85, 2, 2804, 63, 815, 1288, 2403, 29, 1274, 63, 962, 14, 1861, 9, 267, 1921, 275, 20516, 8, 985, 8, 85, 2, 1274, 1288, 1240, 9, 267, 1921, 59, 17, 1055, 3223, 59, 16, 1055, 1861, 275, 2058, 905, 3287, 4140, 1861, 267, 1921, 14, 740, 8, 2610, 1579, 8, 1080, 430, 267, 372, 5013, 8, 13807, 14, 5652, 12, 1921, 12, 2403, 29, 932, 14, 1861, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
groutr/numpy
numpy/matrixlib/tests/test_defmatrix.py
130
14801
from __future__ import division, absolute_import, print_function import collections import numpy as np from numpy import matrix, asmatrix, bmat from numpy.testing import ( TestCase, run_module_suite, assert_, assert_equal, assert_almost_equal, assert_array_equal, assert_array_almost_equal, assert_raises ) from numpy.matrixlib.defmatrix import matrix_power from numpy.matrixlib import mat class TestCtor(TestCase): def test_basic(self): A = np.array([[1, 2], [3, 4]]) mA = matrix(A) assert_(np.all(mA.A == A)) B = bmat("A,A;A,A") C = bmat([[A, A], [A, A]]) D = np.array([[1, 2, 1, 2], [3, 4, 3, 4], [1, 2, 1, 2], [3, 4, 3, 4]]) assert_(np.all(B.A == D)) assert_(np.all(C.A == D)) E = np.array([[5, 6], [7, 8]]) AEresult = matrix([[1, 2, 5, 6], [3, 4, 7, 8]]) assert_(np.all(bmat([A, E]) == AEresult)) vec = np.arange(5) mvec = matrix(vec) assert_(mvec.shape == (1, 5)) def test_exceptions(self): # Check for TypeError when called with invalid string data. assert_raises(TypeError, matrix, "invalid") def test_bmat_nondefault_str(self): A = np.array([[1, 2], [3, 4]]) B = np.array([[5, 6], [7, 8]]) Aresult = np.array([[1, 2, 1, 2], [3, 4, 3, 4], [1, 2, 1, 2], [3, 4, 3, 4]]) mixresult = np.array([[1, 2, 5, 6], [3, 4, 7, 8], [5, 6, 1, 2], [7, 8, 3, 4]]) assert_(np.all(bmat("A,A;A,A") == Aresult)) assert_(np.all(bmat("A,A;A,A", ldict={'A':B}) == Aresult)) assert_raises(TypeError, bmat, "A,A;A,A", gdict={'A':B}) assert_( np.all(bmat("A,A;A,A", ldict={'A':A}, gdict={'A':B}) == Aresult)) b2 = bmat("A,B;C,D", ldict={'A':A,'B':B}, gdict={'C':B,'D':A}) assert_(np.all(b2 == mixresult)) class TestProperties(TestCase): def test_sum(self): """Test whether matrix.sum(axis=1) preserves orientation. Fails in NumPy <= 0.9.6.2127. """ M = matrix([[1, 2, 0, 0], [3, 4, 0, 0], [1, 2, 1, 2], [3, 4, 3, 4]]) sum0 = matrix([8, 12, 4, 6]) sum1 = matrix([3, 7, 6, 14]).T sumall = 30 assert_array_equal(sum0, M.sum(axis=0)) assert_array_equal(sum1, M.sum(axis=1)) assert_equal(sumall, M.sum()) assert_array_equal(sum0, np.sum(M, axis=0)) assert_array_equal(sum1, np.sum(M, axis=1)) assert_equal(sumall, np.sum(M)) def test_prod(self): x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(x.prod(), 720) assert_equal(x.prod(0), matrix([[4, 10, 18]])) assert_equal(x.prod(1), matrix([[6], [120]])) assert_equal(np.prod(x), 720) assert_equal(np.prod(x, axis=0), matrix([[4, 10, 18]])) assert_equal(np.prod(x, axis=1), matrix([[6], [120]])) y = matrix([0, 1, 3]) assert_(y.prod() == 0) def test_max(self): x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(x.max(), 6) assert_equal(x.max(0), matrix([[4, 5, 6]])) assert_equal(x.max(1), matrix([[3], [6]])) assert_equal(np.max(x), 6) assert_equal(np.max(x, axis=0), matrix([[4, 5, 6]])) assert_equal(np.max(x, axis=1), matrix([[3], [6]])) def test_min(self): x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(x.min(), 1) assert_equal(x.min(0), matrix([[1, 2, 3]])) assert_equal(x.min(1), matrix([[1], [4]])) assert_equal(np.min(x), 1) assert_equal(np.min(x, axis=0), matrix([[1, 2, 3]])) assert_equal(np.min(x, axis=1), matrix([[1], [4]])) def test_ptp(self): x = np.arange(4).reshape((2, 2)) assert_(x.ptp() == 3) assert_(np.all(x.ptp(0) == np.array([2, 2]))) assert_(np.all(x.ptp(1) == np.array([1, 1]))) def test_var(self): x = np.arange(9).reshape((3, 3)) mx = x.view(np.matrix) assert_equal(x.var(ddof=0), mx.var(ddof=0)) assert_equal(x.var(ddof=1), mx.var(ddof=1)) def test_basic(self): import numpy.linalg as linalg A = np.array([[1., 2.], [3., 4.]]) mA = matrix(A) assert_(np.allclose(linalg.inv(A), mA.I)) assert_(np.all(np.array(np.transpose(A) == mA.T))) assert_(np.all(np.array(np.transpose(A) == mA.H))) assert_(np.all(A == mA.A)) B = A + 2j*A mB = matrix(B) assert_(np.allclose(linalg.inv(B), mB.I)) assert_(np.all(np.array(np.transpose(B) == mB.T))) assert_(np.all(np.array(np.transpose(B).conj() == mB.H))) def test_pinv(self): x = matrix(np.arange(6).reshape(2, 3)) xpinv = matrix([[-0.77777778, 0.27777778], [-0.11111111, 0.11111111], [ 0.55555556, -0.05555556]]) assert_almost_equal(x.I, xpinv) def test_comparisons(self): A = np.arange(100).reshape(10, 10) mA = matrix(A) mB = matrix(A) + 0.1 assert_(np.all(mB == A+0.1)) assert_(np.all(mB == matrix(A+0.1))) assert_(not np.any(mB == matrix(A-0.1))) assert_(np.all(mA < mB)) assert_(np.all(mA <= mB)) assert_(np.all(mA <= mA)) assert_(not np.any(mA < mA)) assert_(not np.any(mB < mA)) assert_(np.all(mB >= mA)) assert_(np.all(mB >= mB)) assert_(not np.any(mB > mB)) assert_(np.all(mA == mA)) assert_(not np.any(mA == mB)) assert_(np.all(mB != mA)) assert_(not np.all(abs(mA) > 0)) assert_(np.all(abs(mB > 0))) def test_asmatrix(self): A = np.arange(100).reshape(10, 10) mA = asmatrix(A) A[0, 0] = -10 assert_(A[0, 0] == mA[0, 0]) def test_noaxis(self): A = matrix([[1, 0], [0, 1]]) assert_(A.sum() == matrix(2)) assert_(A.mean() == matrix(0.5)) def test_repr(self): A = matrix([[1, 0], [0, 1]]) assert_(repr(A) == "matrix([[1, 0],\n [0, 1]])") class TestCasting(TestCase): def test_basic(self): A = np.arange(100).reshape(10, 10) mA = matrix(A) mB = mA.copy() O = np.ones((10, 10), np.float64) * 0.1 mB = mB + O assert_(mB.dtype.type == np.float64) assert_(np.all(mA != mB)) assert_(np.all(mB == mA+0.1)) mC = mA.copy() O = np.ones((10, 10), np.complex128) mC = mC * O assert_(mC.dtype.type == np.complex128) assert_(np.all(mA != mB)) class TestAlgebra(TestCase): def test_basic(self): import numpy.linalg as linalg A = np.array([[1., 2.], [3., 4.]]) mA = matrix(A) B = np.identity(2) for i in range(6): assert_(np.allclose((mA ** i).A, B)) B = np.dot(B, A) Ainv = linalg.inv(A) B = np.identity(2) for i in range(6): assert_(np.allclose((mA ** -i).A, B)) B = np.dot(B, Ainv) assert_(np.allclose((mA * mA).A, np.dot(A, A))) assert_(np.allclose((mA + mA).A, (A + A))) assert_(np.allclose((3*mA).A, (3*A))) mA2 = matrix(A) mA2 *= 3 assert_(np.allclose(mA2.A, 3*A)) def test_pow(self): """Test raising a matrix to an integer power works as expected.""" m = matrix("1. 2.; 3. 4.") m2 = m.copy() m2 **= 2 mi = m.copy() mi **= -1 m4 = m2.copy() m4 **= 2 assert_array_almost_equal(m2, m**2) assert_array_almost_equal(m4, np.dot(m2, m2)) assert_array_almost_equal(np.dot(mi, m), np.eye(2)) def test_notimplemented(self): '''Check that 'not implemented' operations produce a failure.''' A = matrix([[1., 2.], [3., 4.]]) # __rpow__ try: 1.0**A except TypeError: pass else: self.fail("matrix.__rpow__ doesn't raise a TypeError") # __mul__ with something not a list, ndarray, tuple, or scalar try: A*object() except TypeError: pass else: self.fail("matrix.__mul__ with non-numeric object doesn't raise" "a TypeError") class TestMatrixReturn(TestCase): def test_instance_methods(self): a = matrix([1.0], dtype='f8') methodargs = { 'astype': ('intc',), 'clip': (0.0, 1.0), 'compress': ([1],), 'repeat': (1,), 'reshape': (1,), 'swapaxes': (0, 0), 'dot': np.array([1.0]), } excluded_methods = [ 'argmin', 'choose', 'dump', 'dumps', 'fill', 'getfield', 'getA', 'getA1', 'item', 'nonzero', 'put', 'putmask', 'resize', 'searchsorted', 'setflags', 'setfield', 'sort', 'partition', 'argpartition', 'take', 'tofile', 'tolist', 'tostring', 'tobytes', 'all', 'any', 'sum', 'argmax', 'argmin', 'min', 'max', 'mean', 'var', 'ptp', 'prod', 'std', 'ctypes', 'itemset', ] for attrib in dir(a): if attrib.startswith('_') or attrib in excluded_methods: continue f = getattr(a, attrib) if isinstance(f, collections.Callable): # reset contents of a a.astype('f8') a.fill(1.0) if attrib in methodargs: args = methodargs[attrib] else: args = () b = f(*args) assert_(type(b) is matrix, "%s" % attrib) assert_(type(a.real) is matrix) assert_(type(a.imag) is matrix) c, d = matrix([0.0]).nonzero() assert_(type(c) is np.ndarray) assert_(type(d) is np.ndarray) class TestIndexing(TestCase): def test_basic(self): x = asmatrix(np.zeros((3, 2), float)) y = np.zeros((3, 1), float) y[:, 0] = [0.8, 0.2, 0.3] x[:, 1] = y > 0.5 assert_equal(x, [[0, 1], [0, 0], [0, 0]]) class TestNewScalarIndexing(TestCase): def setUp(self): self.a = matrix([[1, 2], [3, 4]]) def test_dimesions(self): a = self.a x = a[0] assert_equal(x.ndim, 2) def test_array_from_matrix_list(self): a = self.a x = np.array([a, a]) assert_equal(x.shape, [2, 2, 2]) def test_array_to_list(self): a = self.a assert_equal(a.tolist(), [[1, 2], [3, 4]]) def test_fancy_indexing(self): a = self.a x = a[1, [0, 1, 0]] assert_(isinstance(x, matrix)) assert_equal(x, matrix([[3, 4, 3]])) x = a[[1, 0]] assert_(isinstance(x, matrix)) assert_equal(x, matrix([[3, 4], [1, 2]])) x = a[[[1], [0]], [[1, 0], [0, 1]]] assert_(isinstance(x, matrix)) assert_equal(x, matrix([[4, 3], [1, 2]])) def test_matrix_element(self): x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(x[0][0], matrix([[1, 2, 3]])) assert_equal(x[0][0].shape, (1, 3)) assert_equal(x[0].shape, (1, 3)) assert_equal(x[:, 0].shape, (2, 1)) x = matrix(0) assert_equal(x[0, 0], 0) assert_equal(x[0], 0) assert_equal(x[:, 0].shape, x.shape) def test_scalar_indexing(self): x = asmatrix(np.zeros((3, 2), float)) assert_equal(x[0, 0], x[0][0]) def test_row_column_indexing(self): x = asmatrix(np.eye(2)) assert_array_equal(x[0,:], [[1, 0]]) assert_array_equal(x[1,:], [[0, 1]]) assert_array_equal(x[:, 0], [[1], [0]]) assert_array_equal(x[:, 1], [[0], [1]]) def test_boolean_indexing(self): A = np.arange(6) A.shape = (3, 2) x = asmatrix(A) assert_array_equal(x[:, np.array([True, False])], x[:, 0]) assert_array_equal(x[np.array([True, False, False]),:], x[0,:]) def test_list_indexing(self): A = np.arange(6) A.shape = (3, 2) x = asmatrix(A) assert_array_equal(x[:, [1, 0]], x[:, ::-1]) assert_array_equal(x[[2, 1, 0],:], x[::-1,:]) class TestPower(TestCase): def test_returntype(self): a = np.array([[0, 1], [0, 0]]) assert_(type(matrix_power(a, 2)) is np.ndarray) a = mat(a) assert_(type(matrix_power(a, 2)) is matrix) def test_list(self): assert_array_equal(matrix_power([[0, 1], [0, 0]], 2), [[0, 0], [0, 0]]) class TestShape(TestCase): def setUp(self): self.a = np.array([[1], [2]]) self.m = matrix([[1], [2]]) def test_shape(self): assert_equal(self.a.shape, (2, 1)) assert_equal(self.m.shape, (2, 1)) def test_numpy_ravel(self): assert_equal(np.ravel(self.a).shape, (2,)) assert_equal(np.ravel(self.m).shape, (2,)) def test_member_ravel(self): assert_equal(self.a.ravel().shape, (2,)) assert_equal(self.m.ravel().shape, (1, 2)) def test_member_flatten(self): assert_equal(self.a.flatten().shape, (2,)) assert_equal(self.m.flatten().shape, (1, 2)) def test_numpy_ravel_order(self): x = np.array([[1, 2, 3], [4, 5, 6]]) assert_equal(np.ravel(x), [1, 2, 3, 4, 5, 6]) assert_equal(np.ravel(x, order='F'), [1, 4, 2, 5, 3, 6]) assert_equal(np.ravel(x.T), [1, 4, 2, 5, 3, 6]) assert_equal(np.ravel(x.T, order='A'), [1, 2, 3, 4, 5, 6]) x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(np.ravel(x), [1, 2, 3, 4, 5, 6]) assert_equal(np.ravel(x, order='F'), [1, 4, 2, 5, 3, 6]) assert_equal(np.ravel(x.T), [1, 4, 2, 5, 3, 6]) assert_equal(np.ravel(x.T, order='A'), [1, 2, 3, 4, 5, 6]) def test_matrix_ravel_order(self): x = matrix([[1, 2, 3], [4, 5, 6]]) assert_equal(x.ravel(), [[1, 2, 3, 4, 5, 6]]) assert_equal(x.ravel(order='F'), [[1, 4, 2, 5, 3, 6]]) assert_equal(x.T.ravel(), [[1, 4, 2, 5, 3, 6]]) assert_equal(x.T.ravel(order='A'), [[1, 2, 3, 4, 5, 6]]) def test_array_memory_sharing(self): assert_(np.may_share_memory(self.a, self.a.ravel())) assert_(not np.may_share_memory(self.a, self.a.flatten())) def test_matrix_memory_sharing(self): assert_(np.may_share_memory(self.m, self.m.ravel())) assert_(not np.may_share_memory(self.m, self.m.flatten())) if __name__ == "__main__": run_module_suite()
bsd-3-clause
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 5055, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 492, 3634, 12, 465, 3642, 12, 330, 569, 199, 504, 2680, 14, 4776, 492, 334, 272, 7640, 12, 1255, 63, 578, 63, 5768, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 272, 702, 63, 1144, 63, 1452, 12, 702, 63, 1144, 63, 4398, 63, 1452, 12, 702, 63, 3536, 199, 9, 199, 504, 2680, 14, 3642, 773, 14, 318, 3642, 492, 3634, 63, 5652, 199, 504, 2680, 14, 3642, 773, 492, 2530, 199, 199, 533, 1379, 35, 8270, 8, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 267, 333, 33, 275, 3634, 8, 33, 9, 267, 702, 2531, 1590, 14, 452, 8, 77, 33, 14, 33, 508, 437, 430, 398, 699, 275, 330, 569, 480, 33, 12, 33, 27, 33, 12, 33, 531, 267, 445, 275, 330, 569, 4038, 33, 12, 437, 467, 359, 33, 12, 437, 3934, 267, 577, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 413, 12, 499, 467, 1993, 359, 19, 12, 841, 12, 650, 12, 841, 467, 1993, 359, 17, 12, 499, 12, 413, 12, 499, 467, 1993, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 702, 2531, 1590, 14, 452, 8, 34, 14, 33, 508, 577, 430, 267, 702, 2531, 1590, 14, 452, 8, 35, 14, 33, 508, 577, 430, 398, 662, 275, 980, 14, 1144, 4038, 21, 12, 1227, 467, 359, 23, 12, 1695, 3934, 267, 24475, 1099, 275, 3634, 4038, 17, 12, 499, 12, 959, 12, 1227, 467, 359, 19, 12, 841, 12, 1520, 12, 1695, 3934, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 779, 33, 12, 662, 566, 508, 24475, 1099, 430, 398, 10782, 275, 980, 14, 5605, 8, 21, 9, 267, 333, 6046, 275, 3634, 8, 6046, 9, 267, 702, 2531, 77, 6046, 14, 1392, 508, 334, 17, 12, 959, 430, 339, 347, 511, 63, 3924, 8, 277, 304, 267, 327, 2670, 367, 3146, 1380, 2797, 543, 3866, 1059, 666, 14, 267, 702, 63, 3536, 8, 4333, 12, 3634, 12, 298, 3197, 531, 339, 347, 511, 63, 66, 569, 63, 2865, 885, 63, 495, 8, 277, 304, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 267, 699, 275, 980, 14, 1144, 4038, 21, 12, 1227, 467, 359, 23, 12, 1695, 3934, 267, 437, 1099, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 413, 12, 499, 467, 1169, 359, 19, 12, 841, 12, 650, 12, 841, 467, 1169, 359, 17, 12, 499, 12, 413, 12, 499, 467, 1169, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 13667, 1099, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 959, 12, 1227, 467, 2892, 359, 19, 12, 841, 12, 1520, 12, 1695, 467, 2892, 359, 21, 12, 1227, 12, 413, 12, 499, 467, 2892, 359, 23, 12, 1695, 12, 650, 12, 841, 3934, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 531, 508, 437, 1099, 430, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 401, 634, 807, 3713, 33, 356, 34, 1552, 508, 437, 1099, 430, 267, 702, 63, 3536, 8, 4333, 12, 330, 569, 12, 298, 33, 12, 33, 27, 33, 12, 33, 401, 486, 807, 3713, 33, 356, 34, 1552, 267, 702, 2531, 288, 980, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 401, 634, 807, 3713, 33, 356, 33, 1386, 486, 807, 3713, 33, 356, 34, 1552, 508, 437, 1099, 430, 267, 330, 18, 275, 330, 569, 480, 33, 12, 34, 27, 35, 12, 36, 401, 634, 807, 3713, 33, 356, 33, 2584, 34, 356, 34, 1386, 486, 807, 3713, 35, 356, 34, 2584, 36, 356, 33, 1552, 267, 702, 2531, 1590, 14, 452, 8, 66, 18, 508, 13667, 1099, 430, 421, 199, 533, 1379, 8516, 8, 1746, 304, 272, 347, 511, 63, 1838, 8, 277, 304, 267, 408, 774, 3775, 3634, 14, 1838, 8, 3127, 29, 17, 9, 876, 20603, 16774, 14, 267, 12176, 83, 315, 20602, 2695, 378, 14, 25, 14, 22, 14, 18, 4195, 14, 267, 408, 267, 603, 275, 3634, 4038, 17, 12, 499, 12, 378, 12, 378, 467, 673, 359, 19, 12, 841, 12, 378, 12, 378, 467, 673, 359, 17, 12, 499, 12, 413, 12, 499, 467, 673, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 3089, 16, 275, 3634, 779, 24, 12, 3144, 12, 841, 12, 1227, 566, 267, 3089, 17, 275, 3634, 779, 19, 12, 1520, 12, 1227, 12, 4329, 6575, 52, 267, 3089, 452, 275, 4233, 267, 702, 63, 1144, 63, 1452, 8, 1838, 16, 12, 603, 14, 1838, 8, 3127, 29, 16, 430, 267, 702, 63, 1144, 63, 1452, 8, 1838, 17, 12, 603, 14, 1838, 8, 3127, 29, 17, 430, 267, 702, 63, 1452, 8, 1838, 452, 12, 603, 14, 1838, 1012, 398, 702, 63, 1144, 63, 1452, 8, 1838, 16, 12, 980, 14, 1838, 8, 45, 12, 3114, 29, 16, 430, 267, 702, 63, 1144, 63, 1452, 8, 1838, 17, 12, 980, 14, 1838, 8, 45, 12, 3114, 29, 17, 430, 267, 702, 63, 1452, 8, 1838, 452, 12, 980, 14, 1838, 8, 45, 430, 339, 347, 511, 63, 8788, 8, 277, 304, 267, 671, 275, 3634, 4038, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 3934, 267, 702, 63, 1452, 8, 88, 14, 8788, 1062, 29692, 9, 267, 702, 63, 1452, 8, 88, 14, 8788, 8, 16, 395, 3634, 4038, 20, 12, 1616, 12, 6155, 17723, 267, 702, 63, 1452, 8, 88, 14, 8788, 8, 17, 395, 3634, 4038, 22, 467, 359, 6708, 17723, 398, 702, 63, 1452, 8, 1590, 14, 8788, 8, 88, 395, 29692, 9, 267, 702, 63, 1452, 8, 1590, 14, 8788, 8, 88, 12, 3114, 29, 16, 395, 3634, 4038, 20, 12, 1616, 12, 6155, 17723, 267, 702, 63, 1452, 8, 1590 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 5055, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 492, 3634, 12, 465, 3642, 12, 330, 569, 199, 504, 2680, 14, 4776, 492, 334, 272, 7640, 12, 1255, 63, 578, 63, 5768, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 272, 702, 63, 1144, 63, 1452, 12, 702, 63, 1144, 63, 4398, 63, 1452, 12, 702, 63, 3536, 199, 9, 199, 504, 2680, 14, 3642, 773, 14, 318, 3642, 492, 3634, 63, 5652, 199, 504, 2680, 14, 3642, 773, 492, 2530, 199, 199, 533, 1379, 35, 8270, 8, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 267, 333, 33, 275, 3634, 8, 33, 9, 267, 702, 2531, 1590, 14, 452, 8, 77, 33, 14, 33, 508, 437, 430, 398, 699, 275, 330, 569, 480, 33, 12, 33, 27, 33, 12, 33, 531, 267, 445, 275, 330, 569, 4038, 33, 12, 437, 467, 359, 33, 12, 437, 3934, 267, 577, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 413, 12, 499, 467, 1993, 359, 19, 12, 841, 12, 650, 12, 841, 467, 1993, 359, 17, 12, 499, 12, 413, 12, 499, 467, 1993, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 702, 2531, 1590, 14, 452, 8, 34, 14, 33, 508, 577, 430, 267, 702, 2531, 1590, 14, 452, 8, 35, 14, 33, 508, 577, 430, 398, 662, 275, 980, 14, 1144, 4038, 21, 12, 1227, 467, 359, 23, 12, 1695, 3934, 267, 24475, 1099, 275, 3634, 4038, 17, 12, 499, 12, 959, 12, 1227, 467, 359, 19, 12, 841, 12, 1520, 12, 1695, 3934, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 779, 33, 12, 662, 566, 508, 24475, 1099, 430, 398, 10782, 275, 980, 14, 5605, 8, 21, 9, 267, 333, 6046, 275, 3634, 8, 6046, 9, 267, 702, 2531, 77, 6046, 14, 1392, 508, 334, 17, 12, 959, 430, 339, 347, 511, 63, 3924, 8, 277, 304, 267, 327, 2670, 367, 3146, 1380, 2797, 543, 3866, 1059, 666, 14, 267, 702, 63, 3536, 8, 4333, 12, 3634, 12, 298, 3197, 531, 339, 347, 511, 63, 66, 569, 63, 2865, 885, 63, 495, 8, 277, 304, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 267, 699, 275, 980, 14, 1144, 4038, 21, 12, 1227, 467, 359, 23, 12, 1695, 3934, 267, 437, 1099, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 413, 12, 499, 467, 1169, 359, 19, 12, 841, 12, 650, 12, 841, 467, 1169, 359, 17, 12, 499, 12, 413, 12, 499, 467, 1169, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 13667, 1099, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 959, 12, 1227, 467, 2892, 359, 19, 12, 841, 12, 1520, 12, 1695, 467, 2892, 359, 21, 12, 1227, 12, 413, 12, 499, 467, 2892, 359, 23, 12, 1695, 12, 650, 12, 841, 3934, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 531, 508, 437, 1099, 430, 267, 702, 2531, 1590, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 401, 634, 807, 3713, 33, 356, 34, 1552, 508, 437, 1099, 430, 267, 702, 63, 3536, 8, 4333, 12, 330, 569, 12, 298, 33, 12, 33, 27, 33, 12, 33, 401, 486, 807, 3713, 33, 356, 34, 1552, 267, 702, 2531, 288, 980, 14, 452, 8, 66, 569, 480, 33, 12, 33, 27, 33, 12, 33, 401, 634, 807, 3713, 33, 356, 33, 1386, 486, 807, 3713, 33, 356, 34, 1552, 508, 437, 1099, 430, 267, 330, 18, 275, 330, 569, 480, 33, 12, 34, 27, 35, 12, 36, 401, 634, 807, 3713, 33, 356, 33, 2584, 34, 356, 34, 1386, 486, 807, 3713, 35, 356, 34, 2584, 36, 356, 33, 1552, 267, 702, 2531, 1590, 14, 452, 8, 66, 18, 508, 13667, 1099, 430, 421, 199, 533, 1379, 8516, 8, 1746, 304, 272, 347, 511, 63, 1838, 8, 277, 304, 267, 408, 774, 3775, 3634, 14, 1838, 8, 3127, 29, 17, 9, 876, 20603, 16774, 14, 267, 12176, 83, 315, 20602, 2695, 378, 14, 25, 14, 22, 14, 18, 4195, 14, 267, 408, 267, 603, 275, 3634, 4038, 17, 12, 499, 12, 378, 12, 378, 467, 673, 359, 19, 12, 841, 12, 378, 12, 378, 467, 673, 359, 17, 12, 499, 12, 413, 12, 499, 467, 673, 359, 19, 12, 841, 12, 650, 12, 841, 3934, 267, 3089, 16, 275, 3634, 779, 24, 12, 3144, 12, 841, 12, 1227, 566, 267, 3089, 17, 275, 3634, 779, 19, 12, 1520, 12, 1227, 12, 4329, 6575, 52, 267, 3089, 452, 275, 4233, 267, 702, 63, 1144, 63, 1452, 8, 1838, 16, 12, 603, 14, 1838, 8, 3127, 29, 16, 430, 267, 702, 63, 1144, 63, 1452, 8, 1838, 17, 12, 603, 14, 1838, 8, 3127, 29, 17, 430, 267, 702, 63, 1452, 8, 1838, 452, 12, 603, 14, 1838, 1012, 398, 702, 63, 1144, 63, 1452, 8, 1838, 16, 12, 980, 14, 1838, 8, 45, 12, 3114, 29, 16, 430, 267, 702, 63, 1144, 63, 1452, 8, 1838, 17, 12, 980, 14, 1838, 8, 45, 12, 3114, 29, 17, 430, 267, 702, 63, 1452, 8, 1838, 452, 12, 980, 14, 1838, 8, 45, 430, 339, 347, 511, 63, 8788, 8, 277, 304, 267, 671, 275, 3634, 4038, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 3934, 267, 702, 63, 1452, 8, 88, 14, 8788, 1062, 29692, 9, 267, 702, 63, 1452, 8, 88, 14, 8788, 8, 16, 395, 3634, 4038, 20, 12, 1616, 12, 6155, 17723, 267, 702, 63, 1452, 8, 88, 14, 8788, 8, 17, 395, 3634, 4038, 22, 467, 359, 6708, 17723, 398, 702, 63, 1452, 8, 1590, 14, 8788, 8, 88, 395, 29692, 9, 267, 702, 63, 1452, 8, 1590, 14, 8788, 8, 88, 12, 3114, 29, 16, 395, 3634, 4038, 20, 12, 1616, 12, 6155, 17723, 267, 702, 63, 1452, 8, 1590, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
emijrp/WikiApiary
apiary/tasks/website/extensions.py
2
7314
"""Record extension data.""" # pylint: disable=C0301,W1201 from apiary.tasks import BaseApiaryTask import requests import logging import HTMLParser import re import semantic_version LOGGER = logging.getLogger() class RecordExtensionsTask(BaseApiaryTask): def run(self, site_id, sitename, api_url): """Get extensions from the website and write them to WikiApiary.""" LOGGER.info("Retrieve record_extensions for %d", site_id) data_url = api_url + '?action=query&meta=siteinfo&siprop=extensions&format=json' LOGGER.debug("Requesting from %s" % data_url) try: req = requests.get(data_url, timeout = 15, verify=False) data = req.json() except Exception, e: LOGGER.error(e) raise Exception(e) if req.status_code == 200: # Successfully pulled data if 'query' in data: # Looks like a valid response template_block = self.generate_template(data['query']['extensions']) wiki_return = self.bumble_bee.call({ 'action': 'edit', 'title': "%s/Extensions" % sitename, 'text': template_block, 'token': self.bumble_bee_token, 'bot': 'true' }) LOGGER.debug(wiki_return) if 'error' in wiki_return: raise Exception(wiki_return) return wiki_return else: self.record_error( site_id=site_id, sitename=sitename, log_message='Returned unexpected JSON when requesting extension data.', log_type='warn', log_severity='normal', log_bot='Bumble Bee', log_url=data_url ) raise Exception('Returned unexpected JSON when requesting extension data.') def generate_template(self, ext_obj): """Build a the wikitext for the extensions subpage.""" h = HTMLParser.HTMLParser() # Some keys we do not want to store in WikiApiary ignore_keys = ['descriptionmsg'] # Some keys we turn into more readable names for using inside of WikiApiary key_names = { 'author': 'Extension author', 'name': 'Extension name', 'version': 'Extension version', 'type': 'Extension type', 'url': 'Extension URL' } template_block = "<noinclude>{{Extensions subpage}}</noinclude><includeonly>" for extension in ext_obj: if 'name' in extension: template_block += "{{Extension in use\n" for item in extension: if item not in ignore_keys: name = key_names.get(item, item) value = extension[item] if item == 'name': # Sometimes people make the name of the extension a hyperlink using # wikitext links and this makes things ugly. So, let's detect that if present. if re.match(r'\[(http[^\s]+)\s+([^\]]+)\]', value): (possible_url, value) = re.findall(r'\[(http[^\s]+)\s+([^\]]+)\]', value)[0] # If a URL was given in the name, and not given as a formal part of the # extension definition (yes, this happens) then add this to the template # it is up to the template to decide what to do with this template_block += "|URL Embedded in name=%s" % possible_url value = self.filter_illegal_chars(value) # Before unescaping 'regular' unicode characters, first deal with spaces # because they cause problems when converted to unicode non-breaking spaces value = value.replace('&nbsp;', ' ').replace('&#160;', ' ').replace('&160;', ' ') value = h.unescape(value) if item == 'version': try: # Breakdown the version information for more detailed analysis version_details = semantic_version.Version(value, partial=True) if version_details.major is not None: template_block += "|Version major=%s\n" % version_details.major if version_details.minor is not None: template_block += "|Version minor=%s\n" % version_details.minor if version_details.patch is not None: template_block += "|Version patch=%s\n" % version_details.patch if version_details.prerelease is not None: prerelease_string = ','.join(version_details.prerelease) template_block += "|Version prerelease=%s\n" % prerelease_string if version_details.build is not None: build_string = ','.join(version_details.build) template_block += "|Version build=%s\n" % build_string except Exception, e: LOGGER.debug("Unable to parse version string %s (%s)" % (value, e)) if item == 'author': # Authors can have a lot of junk in them, wikitext and such. # We'll try to clean that up. # Wikilinks with names # "[[Foobar | Foo Bar]]" value = re.sub(r'\[\[.*\|(.*)\]\]', r'\1', value) # Simple Wikilinks value = re.sub(r'\[\[(.*)\]\]', r'\1', value) # Hyperlinks as wikiext # "[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]" value = re.sub(r'\[\S+\s+([^\]]+)\]', r'\1', value) # Misc text value = re.sub(r'\sand\s', r', ', value) value = re.sub(r'\.\.\.', r'', value) value = re.sub(r'&nbsp;', r' ', value) # Lastly, there could be HTML encoded stuff in these value = h.unescape(value) if item == 'url': # Seems some people really really love protocol agnostic URL's # We detect them and add a generic http: protocol to them if re.match(r'^\/\/', value): value = 'http:' + value template_block += "|%s=%s\n" % (name, value) template_block += "}}\n" template_block += "</includeonly>" return template_block
gpl-2.0
[ 624, 5433, 3329, 666, 1041, 199, 3, 4287, 26, 3507, 29, 35, 1644, 614, 12, 55, 713, 614, 199, 199, 504, 2986, 695, 14, 5054, 492, 3523, 7394, 695, 4476, 199, 646, 4145, 199, 646, 2050, 199, 646, 24581, 199, 646, 295, 199, 646, 32451, 63, 1023, 421, 199, 10186, 275, 2050, 14, 5572, 342, 199, 199, 533, 12651, 10597, 4476, 8, 1563, 7394, 695, 4476, 304, 339, 347, 1255, 8, 277, 12, 4770, 63, 344, 12, 4770, 354, 12, 2986, 63, 633, 304, 267, 408, 1002, 5478, 687, 314, 10691, 436, 2218, 3062, 370, 644, 11545, 7394, 695, 1041, 398, 20184, 14, 815, 480, 15310, 2777, 63, 5359, 367, 450, 68, 401, 4770, 63, 344, 9, 398, 666, 63, 633, 275, 2986, 63, 633, 435, 8720, 1287, 29, 1131, 6, 2024, 29, 2124, 815, 6, 338, 4469, 29, 5359, 6, 908, 29, 1001, 7, 398, 20184, 14, 1757, 480, 2017, 316, 687, 450, 83, 2, 450, 666, 63, 633, 9, 267, 862, 26, 288, 2648, 275, 4145, 14, 362, 8, 576, 63, 633, 12, 2653, 275, 4114, 12, 4911, 29, 797, 9, 288, 666, 275, 2648, 14, 1001, 342, 267, 871, 2186, 12, 325, 26, 288, 20184, 14, 705, 8, 69, 9, 288, 746, 2186, 8, 69, 9, 398, 340, 2648, 14, 1205, 63, 600, 508, 1926, 26, 288, 327, 22318, 5836, 25239, 1146, 666, 288, 340, 283, 1131, 7, 315, 666, 26, 355, 327, 12077, 83, 2839, 282, 1686, 1177, 355, 1978, 63, 1457, 275, 291, 14, 4208, 63, 1160, 8, 576, 459, 1131, 2545, 5359, 1105, 355, 17195, 63, 1107, 275, 291, 14, 7767, 830, 63, 19446, 14, 1250, 2561, 490, 283, 1287, 356, 283, 3773, 297, 490, 283, 1213, 356, 2071, 83, 15, 10597, 2, 450, 4770, 354, 12, 490, 283, 505, 356, 1978, 63, 1457, 12, 490, 283, 1418, 356, 291, 14, 7767, 830, 63, 19446, 63, 1418, 12, 490, 283, 3018, 356, 283, 2052, 7, 490, 3828, 355, 20184, 14, 1757, 8, 6797, 63, 1107, 9, 2234, 340, 283, 705, 7, 315, 17195, 63, 1107, 26, 490, 746, 2186, 8, 6797, 63, 1107, 9, 2234, 372, 17195, 63, 1107, 288, 587, 26, 355, 291, 14, 3059, 63, 705, 8, 490, 4770, 63, 344, 29, 2124, 63, 344, 12, 490, 4770, 354, 29, 2124, 354, 12, 490, 943, 63, 1188, 534, 28239, 10537, 4840, 1380, 23502, 3329, 666, 3130, 490, 943, 63, 466, 534, 4050, 297, 490, 943, 63, 20394, 534, 3302, 297, 490, 943, 63, 3018, 534, 34, 453, 830, 699, 1024, 297, 490, 943, 63, 633, 29, 576, 63, 633, 355, 776, 355, 746, 2186, 360, 28239, 10537, 4840, 1380, 23502, 3329, 666, 2659, 326, 339, 347, 3550, 63, 1160, 8, 277, 12, 1599, 63, 1113, 304, 267, 408, 3425, 282, 314, 17195, 505, 367, 314, 5478, 1007, 1606, 1041, 398, 394, 275, 24581, 14, 27375, 342, 398, 327, 6601, 2883, 781, 886, 440, 2934, 370, 3877, 315, 644, 11545, 7394, 695, 267, 3686, 63, 1612, 275, 788, 1802, 1328, 418, 267, 327, 6601, 2883, 781, 7485, 1901, 1655, 12701, 1561, 367, 1808, 6272, 402, 644, 11545, 7394, 695, 267, 790, 63, 1247, 275, 469, 288, 283, 2502, 356, 283, 6382, 4132, 297, 288, 283, 354, 356, 283, 6382, 536, 297, 288, 283, 1023, 356, 283, 6382, 1015, 297, 288, 283, 466, 356, 283, 6382, 730, 297, 288, 283, 633, 356, 283, 6382, 2851, 7, 267, 789, 398, 1978, 63, 1457, 275, 3886, 889, 2613, 19386, 10597, 1007, 1606, 4863, 1108, 889, 2613, 2535, 2613, 2118, 4335, 398, 367, 3329, 315, 1599, 63, 1113, 26, 288, 340, 283, 354, 7, 315, 3329, 26, 355, 1978, 63, 1457, 847, 7370, 6382, 315, 675, 60, 78, 2, 2234, 367, 1242, 315, 3329, 26, 490, 340, 1242, 440, 315, 3686, 63, 1612, 26, 9453, 536, 275, 790, 63, 1247, 14, 362, 8, 1053, 12, 1242, 9, 717, 574, 275, 3329, 59, 1053, 61, 9453, 340, 1242, 508, 283, 354, 356, 1169, 327, 30094, 13135, 1852, 314, 536, 402, 314, 3329, 282, 10342, 1073, 1808, 1169, 327, 17195, 505, 6220, 436, 642, 7704, 7645, 23761, 14, 2002, 12, 4691, 1159, 9696, 626, 340, 3451, 14, 1169, 340, 295, 14, 1431, 8, 82, 1154, 7528, 1014, 16045, 83, 18096, 83, 11, 21690, 2677, 13439, 4300, 574, 304, 1816, 334, 13893, 63, 633, 12, 574, 9, 275, 295, 14, 6452, 8, 82, 1154, 7528, 1014, 16045, 83, 18096, 83, 11, 21690, 2677, 13439, 4300, 574, 2788, 16, 61, 1816, 327, 982, 282, 2851, 1990, 1627, 315, 314, 536, 12, 436, 440, 1627, 465, 282, 1824, 279, 1777, 402, 314, 1816, 327, 3329, 5492, 334, 5066, 12, 642, 10986, 9, 2066, 1050, 642, 370, 314, 1978, 1816, 327, 652, 365, 1536, 370, 314, 1978, 370, 19822, 4052, 370, 886, 543, 642, 1816, 1978, 63, 1457, 847, 15733, 2632, 24297, 770, 315, 536, 2458, 83, 2, 450, 3962, 63, 633, 18008, 574, 275, 291, 14, 1541, 63, 23375, 63, 6574, 8, 585, 9, 1169, 327, 21467, 625, 26306, 283, 7898, 7, 2649, 4110, 12, 1642, 7962, 543, 7883, 1169, 327, 2952, 2985, 7675, 8826, 1380, 6702, 370, 2649, 2222, 13, 4785, 316, 7883, 1169, 574, 275, 574, 14, 1814, 20040, 10758, 10805, 283, 27274, 1814, 360, 7997, 8488, 10805, 283, 27274, 1814, 20040, 8488, 10805, 283, 5320, 1169, 574, 275, 394, 14, 22726, 8, 585, 9, 9453, 340, 1242, 508, 283, 1023, 356, 1169, 862, 26, 1816, 327, 22535, 2110, 314, 1015, 2556, 367, 1655, 16212, 11284, 1816, 1015, 63, 5087, 275, 32451, 63, 1023, 14, 3353, 8, 585, 12, 7417, 29, 549, 9, 1816, 340, 1015, 63, 5087, 14, 8452, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 12160, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 8452, 1816, 340, 1015, 63, 5087, 14, 11067, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 12612, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 11067, 1816, 340, 1015, 63, 5087, 14, 2068, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 3371, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 2068, 1816, 340, 1015, 63, 5087, 14, 657, 3221, 365, 440, 488 ]
[ 5433, 3329, 666, 1041, 199, 3, 4287, 26, 3507, 29, 35, 1644, 614, 12, 55, 713, 614, 199, 199, 504, 2986, 695, 14, 5054, 492, 3523, 7394, 695, 4476, 199, 646, 4145, 199, 646, 2050, 199, 646, 24581, 199, 646, 295, 199, 646, 32451, 63, 1023, 421, 199, 10186, 275, 2050, 14, 5572, 342, 199, 199, 533, 12651, 10597, 4476, 8, 1563, 7394, 695, 4476, 304, 339, 347, 1255, 8, 277, 12, 4770, 63, 344, 12, 4770, 354, 12, 2986, 63, 633, 304, 267, 408, 1002, 5478, 687, 314, 10691, 436, 2218, 3062, 370, 644, 11545, 7394, 695, 1041, 398, 20184, 14, 815, 480, 15310, 2777, 63, 5359, 367, 450, 68, 401, 4770, 63, 344, 9, 398, 666, 63, 633, 275, 2986, 63, 633, 435, 8720, 1287, 29, 1131, 6, 2024, 29, 2124, 815, 6, 338, 4469, 29, 5359, 6, 908, 29, 1001, 7, 398, 20184, 14, 1757, 480, 2017, 316, 687, 450, 83, 2, 450, 666, 63, 633, 9, 267, 862, 26, 288, 2648, 275, 4145, 14, 362, 8, 576, 63, 633, 12, 2653, 275, 4114, 12, 4911, 29, 797, 9, 288, 666, 275, 2648, 14, 1001, 342, 267, 871, 2186, 12, 325, 26, 288, 20184, 14, 705, 8, 69, 9, 288, 746, 2186, 8, 69, 9, 398, 340, 2648, 14, 1205, 63, 600, 508, 1926, 26, 288, 327, 22318, 5836, 25239, 1146, 666, 288, 340, 283, 1131, 7, 315, 666, 26, 355, 327, 12077, 83, 2839, 282, 1686, 1177, 355, 1978, 63, 1457, 275, 291, 14, 4208, 63, 1160, 8, 576, 459, 1131, 2545, 5359, 1105, 355, 17195, 63, 1107, 275, 291, 14, 7767, 830, 63, 19446, 14, 1250, 2561, 490, 283, 1287, 356, 283, 3773, 297, 490, 283, 1213, 356, 2071, 83, 15, 10597, 2, 450, 4770, 354, 12, 490, 283, 505, 356, 1978, 63, 1457, 12, 490, 283, 1418, 356, 291, 14, 7767, 830, 63, 19446, 63, 1418, 12, 490, 283, 3018, 356, 283, 2052, 7, 490, 3828, 355, 20184, 14, 1757, 8, 6797, 63, 1107, 9, 2234, 340, 283, 705, 7, 315, 17195, 63, 1107, 26, 490, 746, 2186, 8, 6797, 63, 1107, 9, 2234, 372, 17195, 63, 1107, 288, 587, 26, 355, 291, 14, 3059, 63, 705, 8, 490, 4770, 63, 344, 29, 2124, 63, 344, 12, 490, 4770, 354, 29, 2124, 354, 12, 490, 943, 63, 1188, 534, 28239, 10537, 4840, 1380, 23502, 3329, 666, 3130, 490, 943, 63, 466, 534, 4050, 297, 490, 943, 63, 20394, 534, 3302, 297, 490, 943, 63, 3018, 534, 34, 453, 830, 699, 1024, 297, 490, 943, 63, 633, 29, 576, 63, 633, 355, 776, 355, 746, 2186, 360, 28239, 10537, 4840, 1380, 23502, 3329, 666, 2659, 326, 339, 347, 3550, 63, 1160, 8, 277, 12, 1599, 63, 1113, 304, 267, 408, 3425, 282, 314, 17195, 505, 367, 314, 5478, 1007, 1606, 1041, 398, 394, 275, 24581, 14, 27375, 342, 398, 327, 6601, 2883, 781, 886, 440, 2934, 370, 3877, 315, 644, 11545, 7394, 695, 267, 3686, 63, 1612, 275, 788, 1802, 1328, 418, 267, 327, 6601, 2883, 781, 7485, 1901, 1655, 12701, 1561, 367, 1808, 6272, 402, 644, 11545, 7394, 695, 267, 790, 63, 1247, 275, 469, 288, 283, 2502, 356, 283, 6382, 4132, 297, 288, 283, 354, 356, 283, 6382, 536, 297, 288, 283, 1023, 356, 283, 6382, 1015, 297, 288, 283, 466, 356, 283, 6382, 730, 297, 288, 283, 633, 356, 283, 6382, 2851, 7, 267, 789, 398, 1978, 63, 1457, 275, 3886, 889, 2613, 19386, 10597, 1007, 1606, 4863, 1108, 889, 2613, 2535, 2613, 2118, 4335, 398, 367, 3329, 315, 1599, 63, 1113, 26, 288, 340, 283, 354, 7, 315, 3329, 26, 355, 1978, 63, 1457, 847, 7370, 6382, 315, 675, 60, 78, 2, 2234, 367, 1242, 315, 3329, 26, 490, 340, 1242, 440, 315, 3686, 63, 1612, 26, 9453, 536, 275, 790, 63, 1247, 14, 362, 8, 1053, 12, 1242, 9, 717, 574, 275, 3329, 59, 1053, 61, 9453, 340, 1242, 508, 283, 354, 356, 1169, 327, 30094, 13135, 1852, 314, 536, 402, 314, 3329, 282, 10342, 1073, 1808, 1169, 327, 17195, 505, 6220, 436, 642, 7704, 7645, 23761, 14, 2002, 12, 4691, 1159, 9696, 626, 340, 3451, 14, 1169, 340, 295, 14, 1431, 8, 82, 1154, 7528, 1014, 16045, 83, 18096, 83, 11, 21690, 2677, 13439, 4300, 574, 304, 1816, 334, 13893, 63, 633, 12, 574, 9, 275, 295, 14, 6452, 8, 82, 1154, 7528, 1014, 16045, 83, 18096, 83, 11, 21690, 2677, 13439, 4300, 574, 2788, 16, 61, 1816, 327, 982, 282, 2851, 1990, 1627, 315, 314, 536, 12, 436, 440, 1627, 465, 282, 1824, 279, 1777, 402, 314, 1816, 327, 3329, 5492, 334, 5066, 12, 642, 10986, 9, 2066, 1050, 642, 370, 314, 1978, 1816, 327, 652, 365, 1536, 370, 314, 1978, 370, 19822, 4052, 370, 886, 543, 642, 1816, 1978, 63, 1457, 847, 15733, 2632, 24297, 770, 315, 536, 2458, 83, 2, 450, 3962, 63, 633, 18008, 574, 275, 291, 14, 1541, 63, 23375, 63, 6574, 8, 585, 9, 1169, 327, 21467, 625, 26306, 283, 7898, 7, 2649, 4110, 12, 1642, 7962, 543, 7883, 1169, 327, 2952, 2985, 7675, 8826, 1380, 6702, 370, 2649, 2222, 13, 4785, 316, 7883, 1169, 574, 275, 574, 14, 1814, 20040, 10758, 10805, 283, 27274, 1814, 360, 7997, 8488, 10805, 283, 27274, 1814, 20040, 8488, 10805, 283, 5320, 1169, 574, 275, 394, 14, 22726, 8, 585, 9, 9453, 340, 1242, 508, 283, 1023, 356, 1169, 862, 26, 1816, 327, 22535, 2110, 314, 1015, 2556, 367, 1655, 16212, 11284, 1816, 1015, 63, 5087, 275, 32451, 63, 1023, 14, 3353, 8, 585, 12, 7417, 29, 549, 9, 1816, 340, 1015, 63, 5087, 14, 8452, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 12160, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 8452, 1816, 340, 1015, 63, 5087, 14, 11067, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 12612, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 11067, 1816, 340, 1015, 63, 5087, 14, 2068, 365, 440, 488, 26, 2511, 1978, 63, 1457, 847, 15733, 3353, 3371, 2458, 83, 60, 78, 2, 450, 1015, 63, 5087, 14, 2068, 1816, 340, 1015, 63, 5087, 14, 657, 3221, 365, 440, 488, 0 ]
[ 1, 1, 1, 1,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ining-rdbms
src/phase-3/src/radius/radius.py
1
5219
import sys import random import math def time_it(fn): def wrapped(*args): import time start = time.time() fn(*args) used = time.time() - start print "%s used %s" % (str(fn), used) return wrapped @time_it def assign_fm(conn, tbl_name, edge_table, k): cur = conn.cursor() # cur.execute("delete from %s" % tbl_name) # cur.execute("insert into %s select src_id, fm_assign(%d) from %s group by src_id" % (tbl_name, s, edge_table)) cur.execute("select distinct src_id from %s"% edge_table) records = cur.fetchall() query = "insert into " + tbl_name + " values(%s, %s)" for i in range(len(records)): src_id = records[i][0] fm_string = generate_k_fm_strings(k) cur.execute(query, (src_id, fm_string)) conn.commit() cur.close() def generate_k_fm_strings(k): return [generate_fm_string() for i in range(k)] def generate_fm_string(): ran = random.random() index = math.floor(math.log(ran, 0.5)) if index > 31: index = 31 return 1<<int(index) @time_it def update_bitstring(conn, edge_table, vertex_table, tmp_table): cur = conn.cursor() #cur.execute("delete from %s" % tmp_table) cur.execute("update %s as A set fm = foo.fm from (select src_id as id, agg_bit_or(fm) as fm from %s, %s where dst_id = id group by src_id) as foo where A.id = foo.id" %(tmp_table, edge_table, vertex_table)) conn.commit() cur.close() def is_stablized(conn, vertex_table, tmp_table): cur = conn.cursor() diff = cur.execute("select count(*) from %s as A, %s as B where A.id = B.id and A.fm <> B.fm" % (vertex_table, tmp_table)) diff = cur.fetchone()[0] print diff if diff == 0: return True else: return False def drop_if_exists(conn, table_name): cur = conn.cursor() cur.execute("drop table if exists %s" % table_name) conn.commit() cur.close() @time_it def summarize(conn, radius_table, dataset): cur = conn.cursor() drop_if_exists(conn, "tmp") cur.execute("select radius, count(*) into tmp from %s group by radius order by radius" % radius_table) f = open('radius_' + dataset + ".csv", 'w') cur.copy_to(sys.stdout, "tmp", sep = '\t') cur.copy_to(f, "tmp", sep = ',') def compute_radius(conn, edge_table, dataset, s): """ edge_table: edge table """ print "computing radius.." vertex_table = "vertex" tmp_table = "tmp_v" hop_table = "hops" tmp_edge = "tmp_edge" radius_table = "radius_" + dataset cur = conn.cursor() drop_if_exists(conn, tmp_table) drop_if_exists(conn, vertex_table) drop_if_exists(conn, tmp_edge) drop_if_exists(conn, radius_table) drop_if_exists(conn, hop_table) cur.execute("create table %s(src_id int, dst_id int)" % tmp_edge) cur.execute("insert into %s select src_id, dst_id from %s" % (tmp_edge, edge_table)) cur.execute("insert into %s select src_id, src_id from %s group by src_id except select src_id, dst_id from %s" % (tmp_edge, edge_table, edge_table)) #cur.execute("insert into %s select dst_id, dst_id from %s where dst_id not in (select src_id from %s) group by dst_id" % (tmp_edge, edge_table, edge_table)) #cur.execute("drop index if exists radius_index ") #cur.execute("create index radius_index on %s (src_id) " % edge_table) cur.execute("create table %s(id int, fm int[])" % vertex_table) cur.execute("create table %s(id int, fm int[])" % tmp_table) cur.execute("create table %s(id int, radius int)" % hop_table) cur.execute("create table %s(id int, radius int)" % radius_table) cur.execute("insert into %s select src_id, 0 from %s group by src_id" % (hop_table, tmp_edge)) cur.execute("drop index if exists edge_src_index") cur.execute("drop index if exists edge_dst_index") cur.execute("drop index if exists vertex_index") cur.execute("drop index if exists tmp_index") cur.execute("create index edge_src_index on %s (src_id)" % tmp_edge) cur.execute("create index edge_dst_index on %s(dst_id)" % tmp_edge) conn.commit() assign_fm(conn, vertex_table, tmp_edge, s) cur.execute("insert into %s select * from %s" % (tmp_table, vertex_table)) cur.execute("create index vertex_index on %s (id)" % vertex_table) cur.execute("create index tmp_index on %s (id)" % tmp_table) conn.commit() print "initialized.." max_iteration = 256 for i in range(max_iteration): print "iteration %d" % i if (i != 0): # cur.execute("delete from %s" % vertex_table) # cur.execute("insert into %s select * from %s" % (vertex_table, tmp_table)) cur.execute("update %s as A set fm = B.fm from %s as B where A.id = B.id" % (vertex_table, tmp_table)) conn.commit() update_bitstring(conn, tmp_edge, vertex_table, tmp_table) if (is_stablized(conn, vertex_table, tmp_table)): break cur.execute("insert into %s (select A.id, %d from %s as A, %s as B where A.id = B.id and A.fm <> B.fm)" % (hop_table, i + 1, vertex_table, tmp_table)) cur.execute("insert into %s select id, max(radius) from %s group by id" %(radius_table, hop_table)) cur.execute("insert into %s select distinct dst_id, 0 from %s except (select distinct src_id, 0 from %s)" % (radius_table, edge_table, edge_table)) conn.commit() summarize(conn, radius_table, dataset) drop_if_exists(conn, tmp_table) drop_if_exists(conn, vertex_table) drop_if_exists(conn, tmp_edge) drop_if_exists(conn, hop_table) cur.close() conn.close()
mit
[ 646, 984, 199, 646, 2196, 199, 646, 3473, 199, 199, 318, 900, 63, 390, 8, 2324, 304, 199, 198, 318, 8072, 2031, 589, 304, 507, 198, 646, 900, 507, 198, 928, 275, 900, 14, 521, 342, 507, 198, 2324, 2031, 589, 9, 507, 198, 2972, 275, 900, 14, 521, 342, 446, 1343, 507, 198, 1361, 2071, 83, 1202, 450, 83, 2, 450, 334, 495, 8, 2324, 395, 1202, 9, 199, 198, 1107, 8072, 199, 199, 32, 521, 63, 390, 199, 318, 5090, 63, 10886, 8, 1631, 12, 19049, 63, 354, 12, 6275, 63, 1224, 12, 1022, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3, 1094, 14, 2526, 480, 1807, 687, 450, 83, 2, 450, 19049, 63, 354, 9, 199, 198, 3, 1094, 14, 2526, 480, 3176, 1901, 450, 83, 3504, 2928, 63, 344, 12, 20831, 63, 5038, 4042, 68, 9, 687, 450, 83, 1572, 701, 2928, 63, 344, 2, 450, 334, 14806, 63, 354, 12, 308, 12, 6275, 63, 1224, 430, 199, 198, 895, 14, 2526, 480, 2416, 15392, 2928, 63, 344, 687, 450, 83, 6808, 6275, 63, 1224, 9, 199, 198, 6502, 275, 1094, 14, 10174, 342, 199, 198, 1131, 275, 298, 3176, 1901, 298, 435, 19049, 63, 354, 435, 298, 1338, 4042, 83, 12, 450, 83, 2924, 199, 198, 509, 284, 315, 1425, 8, 552, 8, 6502, 2298, 507, 198, 2164, 63, 344, 275, 5767, 59, 73, 1527, 16, 61, 507, 198, 10886, 63, 875, 275, 3550, 63, 75, 63, 10886, 63, 5465, 8, 75, 9, 507, 198, 895, 14, 2526, 8, 1131, 12, 334, 2164, 63, 344, 12, 20831, 63, 875, 430, 421, 198, 1631, 14, 3543, 342, 421, 198, 895, 14, 1600, 342, 199, 199, 318, 3550, 63, 75, 63, 10886, 63, 5465, 8, 75, 304, 199, 198, 1107, 359, 4208, 63, 10886, 63, 875, 342, 367, 284, 315, 1425, 8, 75, 1874, 507, 199, 318, 3550, 63, 10886, 63, 875, 837, 199, 198, 1312, 275, 2196, 14, 2355, 342, 199, 198, 1080, 275, 3473, 14, 11289, 8, 3442, 14, 793, 8, 1312, 12, 378, 14, 21, 430, 199, 198, 692, 1478, 690, 7105, 26, 507, 198, 1080, 275, 7105, 199, 198, 1107, 413, 8999, 442, 8, 1080, 9, 421, 199, 32, 521, 63, 390, 199, 318, 1678, 63, 2075, 875, 8, 1631, 12, 6275, 63, 1224, 12, 12759, 63, 1224, 12, 3529, 63, 1224, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3, 895, 14, 2526, 480, 1807, 687, 450, 83, 2, 450, 3529, 63, 1224, 9, 199, 198, 895, 14, 2526, 480, 873, 450, 83, 465, 437, 663, 20831, 275, 3925, 14, 10886, 687, 334, 2416, 2928, 63, 344, 465, 1305, 12, 19408, 63, 2075, 63, 269, 8, 10886, 9, 465, 20831, 687, 450, 83, 12, 450, 83, 2382, 5042, 63, 344, 275, 1305, 1572, 701, 2928, 63, 344, 9, 465, 3925, 2382, 437, 14, 344, 275, 3925, 14, 344, 2, 2818, 2791, 63, 1224, 12, 6275, 63, 1224, 12, 12759, 63, 1224, 430, 199, 198, 1631, 14, 3543, 342, 199, 198, 895, 14, 1600, 342, 199, 199, 318, 365, 63, 270, 371, 317, 7068, 8, 1631, 12, 12759, 63, 1224, 12, 3529, 63, 1224, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3028, 275, 1094, 14, 2526, 480, 2416, 2338, 21565, 687, 450, 83, 465, 437, 12, 450, 83, 465, 699, 2382, 437, 14, 344, 275, 699, 14, 344, 436, 437, 14, 10886, 20941, 699, 14, 10886, 2, 450, 334, 11417, 63, 1224, 12, 3529, 63, 1224, 430, 199, 198, 3028, 275, 1094, 14, 11591, 3430, 16, 61, 199, 198, 1361, 3915, 199, 198, 692, 3915, 508, 378, 26, 507, 198, 1107, 715, 199, 198, 2836, 26, 507, 198, 1107, 756, 421, 199, 318, 5978, 63, 692, 63, 2444, 8, 1631, 12, 1817, 63, 354, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 895, 14, 2526, 480, 4824, 1817, 340, 3495, 450, 83, 2, 450, 1817, 63, 354, 9, 199, 198, 1631, 14, 3543, 342, 199, 198, 895, 14, 1600, 342, 4388, 199, 32, 521, 63, 390, 199, 318, 22301, 8, 1631, 12, 9362, 63, 1224, 12, 4789, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 298, 2791, 531, 199, 198, 895, 14, 2526, 480, 2416, 9362, 12, 2338, 21565, 1901, 3529, 687, 450, 83, 1572, 701, 9362, 1865, 701, 9362, 2, 450, 9362, 63, 1224, 9, 199, 198, 70, 275, 1551, 360, 8017, 8650, 435, 4789, 435, 3680, 4737, 401, 283, 87, 358, 199, 198, 895, 14, 1574, 63, 475, 8, 1274, 14, 2703, 12, 298, 2791, 401, 7375, 275, 1557, 84, 358, 199, 198, 895, 14, 1574, 63, 475, 8, 70, 12, 298, 2791, 401, 7375, 275, 1656, 358, 199, 199, 318, 4526, 63, 8017, 8, 1631, 12, 6275, 63, 1224, 12, 4789, 12, 308, 304, 199, 198, 624, 199, 198, 5173, 63, 1224, 26, 6275, 1817, 199, 198, 624, 199, 198, 1361, 298, 863, 4655, 9362, 703, 2, 199, 198, 11417, 63, 1224, 275, 298, 11417, 2, 199, 198, 2791, 63, 1224, 275, 298, 2791, 63, 86, 2, 199, 198, 13376, 63, 1224, 275, 298, 72, 1483, 2, 199, 198, 2791, 63, 5173, 275, 298, 2791, 63, 5173, 2, 199, 198, 8017, 63, 1224, 275, 298, 8017, 12172, 435, 4789, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 3529, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 12759, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 3529, 63, 5173, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 9362, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 22377, 63, 1224, 9, 199, 198, 895, 14, 2526, 480, 981, 1817, 450, 83, 8, 2164, 63, 344, 1109, 12, 5042, 63, 344, 1109, 2924, 450, 3529, 63, 5173, 9, 199, 198, 895, 14, 2526, 480, 3176, 1901, 450, 83, 3504, 2928, 63, 344, 12, 5042, 63, 344, 687, 450, 83, 2, 450, 334, 2791, 63, 5173, 12, 6275, 63, 1224, 430, 199, 198, 895, 14 ]
[ 984, 199, 646, 2196, 199, 646, 3473, 199, 199, 318, 900, 63, 390, 8, 2324, 304, 199, 198, 318, 8072, 2031, 589, 304, 507, 198, 646, 900, 507, 198, 928, 275, 900, 14, 521, 342, 507, 198, 2324, 2031, 589, 9, 507, 198, 2972, 275, 900, 14, 521, 342, 446, 1343, 507, 198, 1361, 2071, 83, 1202, 450, 83, 2, 450, 334, 495, 8, 2324, 395, 1202, 9, 199, 198, 1107, 8072, 199, 199, 32, 521, 63, 390, 199, 318, 5090, 63, 10886, 8, 1631, 12, 19049, 63, 354, 12, 6275, 63, 1224, 12, 1022, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3, 1094, 14, 2526, 480, 1807, 687, 450, 83, 2, 450, 19049, 63, 354, 9, 199, 198, 3, 1094, 14, 2526, 480, 3176, 1901, 450, 83, 3504, 2928, 63, 344, 12, 20831, 63, 5038, 4042, 68, 9, 687, 450, 83, 1572, 701, 2928, 63, 344, 2, 450, 334, 14806, 63, 354, 12, 308, 12, 6275, 63, 1224, 430, 199, 198, 895, 14, 2526, 480, 2416, 15392, 2928, 63, 344, 687, 450, 83, 6808, 6275, 63, 1224, 9, 199, 198, 6502, 275, 1094, 14, 10174, 342, 199, 198, 1131, 275, 298, 3176, 1901, 298, 435, 19049, 63, 354, 435, 298, 1338, 4042, 83, 12, 450, 83, 2924, 199, 198, 509, 284, 315, 1425, 8, 552, 8, 6502, 2298, 507, 198, 2164, 63, 344, 275, 5767, 59, 73, 1527, 16, 61, 507, 198, 10886, 63, 875, 275, 3550, 63, 75, 63, 10886, 63, 5465, 8, 75, 9, 507, 198, 895, 14, 2526, 8, 1131, 12, 334, 2164, 63, 344, 12, 20831, 63, 875, 430, 421, 198, 1631, 14, 3543, 342, 421, 198, 895, 14, 1600, 342, 199, 199, 318, 3550, 63, 75, 63, 10886, 63, 5465, 8, 75, 304, 199, 198, 1107, 359, 4208, 63, 10886, 63, 875, 342, 367, 284, 315, 1425, 8, 75, 1874, 507, 199, 318, 3550, 63, 10886, 63, 875, 837, 199, 198, 1312, 275, 2196, 14, 2355, 342, 199, 198, 1080, 275, 3473, 14, 11289, 8, 3442, 14, 793, 8, 1312, 12, 378, 14, 21, 430, 199, 198, 692, 1478, 690, 7105, 26, 507, 198, 1080, 275, 7105, 199, 198, 1107, 413, 8999, 442, 8, 1080, 9, 421, 199, 32, 521, 63, 390, 199, 318, 1678, 63, 2075, 875, 8, 1631, 12, 6275, 63, 1224, 12, 12759, 63, 1224, 12, 3529, 63, 1224, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3, 895, 14, 2526, 480, 1807, 687, 450, 83, 2, 450, 3529, 63, 1224, 9, 199, 198, 895, 14, 2526, 480, 873, 450, 83, 465, 437, 663, 20831, 275, 3925, 14, 10886, 687, 334, 2416, 2928, 63, 344, 465, 1305, 12, 19408, 63, 2075, 63, 269, 8, 10886, 9, 465, 20831, 687, 450, 83, 12, 450, 83, 2382, 5042, 63, 344, 275, 1305, 1572, 701, 2928, 63, 344, 9, 465, 3925, 2382, 437, 14, 344, 275, 3925, 14, 344, 2, 2818, 2791, 63, 1224, 12, 6275, 63, 1224, 12, 12759, 63, 1224, 430, 199, 198, 1631, 14, 3543, 342, 199, 198, 895, 14, 1600, 342, 199, 199, 318, 365, 63, 270, 371, 317, 7068, 8, 1631, 12, 12759, 63, 1224, 12, 3529, 63, 1224, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 3028, 275, 1094, 14, 2526, 480, 2416, 2338, 21565, 687, 450, 83, 465, 437, 12, 450, 83, 465, 699, 2382, 437, 14, 344, 275, 699, 14, 344, 436, 437, 14, 10886, 20941, 699, 14, 10886, 2, 450, 334, 11417, 63, 1224, 12, 3529, 63, 1224, 430, 199, 198, 3028, 275, 1094, 14, 11591, 3430, 16, 61, 199, 198, 1361, 3915, 199, 198, 692, 3915, 508, 378, 26, 507, 198, 1107, 715, 199, 198, 2836, 26, 507, 198, 1107, 756, 421, 199, 318, 5978, 63, 692, 63, 2444, 8, 1631, 12, 1817, 63, 354, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 895, 14, 2526, 480, 4824, 1817, 340, 3495, 450, 83, 2, 450, 1817, 63, 354, 9, 199, 198, 1631, 14, 3543, 342, 199, 198, 895, 14, 1600, 342, 4388, 199, 32, 521, 63, 390, 199, 318, 22301, 8, 1631, 12, 9362, 63, 1224, 12, 4789, 304, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 298, 2791, 531, 199, 198, 895, 14, 2526, 480, 2416, 9362, 12, 2338, 21565, 1901, 3529, 687, 450, 83, 1572, 701, 9362, 1865, 701, 9362, 2, 450, 9362, 63, 1224, 9, 199, 198, 70, 275, 1551, 360, 8017, 8650, 435, 4789, 435, 3680, 4737, 401, 283, 87, 358, 199, 198, 895, 14, 1574, 63, 475, 8, 1274, 14, 2703, 12, 298, 2791, 401, 7375, 275, 1557, 84, 358, 199, 198, 895, 14, 1574, 63, 475, 8, 70, 12, 298, 2791, 401, 7375, 275, 1656, 358, 199, 199, 318, 4526, 63, 8017, 8, 1631, 12, 6275, 63, 1224, 12, 4789, 12, 308, 304, 199, 198, 624, 199, 198, 5173, 63, 1224, 26, 6275, 1817, 199, 198, 624, 199, 198, 1361, 298, 863, 4655, 9362, 703, 2, 199, 198, 11417, 63, 1224, 275, 298, 11417, 2, 199, 198, 2791, 63, 1224, 275, 298, 2791, 63, 86, 2, 199, 198, 13376, 63, 1224, 275, 298, 72, 1483, 2, 199, 198, 2791, 63, 5173, 275, 298, 2791, 63, 5173, 2, 199, 198, 8017, 63, 1224, 275, 298, 8017, 12172, 435, 4789, 199, 198, 895, 275, 2557, 14, 3937, 342, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 3529, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 12759, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 3529, 63, 5173, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 9362, 63, 1224, 9, 199, 198, 4824, 63, 692, 63, 2444, 8, 1631, 12, 22377, 63, 1224, 9, 199, 198, 895, 14, 2526, 480, 981, 1817, 450, 83, 8, 2164, 63, 344, 1109, 12, 5042, 63, 344, 1109, 2924, 450, 3529, 63, 5173, 9, 199, 198, 895, 14, 2526, 480, 3176, 1901, 450, 83, 3504, 2928, 63, 344, 12, 5042, 63, 344, 687, 450, 83, 2, 450, 334, 2791, 63, 5173, 12, 6275, 63, 1224, 430, 199, 198, 895, 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,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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 ]
CatherineWong/zxing-glass
cpp/scons/scons-local-2.0.0.final.0/SCons/Tool/bcc32.py
34
2986
"""SCons.Tool.bcc32 XXX """ # # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # 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. # __revision__ = "src/engine/SCons/Tool/bcc32.py 5023 2010/06/14 22:05:46 scons" import os import os.path import SCons.Defaults import SCons.Tool import SCons.Util def findIt(program, env): # First search in the SCons path and then the OS path: borwin = env.WhereIs(program) or SCons.Util.WhereIs(program) if borwin: dir = os.path.dirname(borwin) env.PrependENVPath('PATH', dir) return borwin def generate(env): findIt('bcc32', env) """Add Builders and construction variables for bcc to an Environment.""" static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in ['.c', '.cpp']: static_obj.add_action(suffix, SCons.Defaults.CAction) shared_obj.add_action(suffix, SCons.Defaults.ShCAction) static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) env['CC'] = 'bcc32' env['CCFLAGS'] = SCons.Util.CLVar('') env['CFLAGS'] = SCons.Util.CLVar('') env['CCCOM'] = '$CC -q $CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o$TARGET $SOURCES' env['SHCC'] = '$CC' env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS') env['SHCCCOM'] = '$SHCC -WD $SHCFLAGS $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o$TARGET $SOURCES' env['CPPDEFPREFIX'] = '-D' env['CPPDEFSUFFIX'] = '' env['INCPREFIX'] = '-I' env['INCSUFFIX'] = '' env['SHOBJSUFFIX'] = '.dll' env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0 env['CFILESUFFIX'] = '.cpp' def exists(env): return findIt('bcc32', env) # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
apache-2.0
[ 624, 18521, 14, 5157, 14, 21976, 708, 199, 199, 13933, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 21976, 708, 14, 647, 959, 16771, 7129, 15, 1690, 15, 1079, 6928, 26, 1717, 26, 2466, 31551, 2, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 199, 646, 8218, 14, 16986, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 9562, 199, 199, 318, 2342, 7940, 8, 6815, 12, 2589, 304, 272, 327, 7758, 2754, 315, 314, 8218, 931, 436, 2066, 314, 4403, 931, 26, 272, 330, 269, 2676, 275, 2589, 14, 26493, 1831, 8, 6815, 9, 503, 8218, 14, 9562, 14, 26493, 1831, 8, 6815, 9, 272, 340, 330, 269, 2676, 26, 267, 2935, 275, 747, 14, 515, 14, 3475, 8, 31938, 2676, 9, 267, 2589, 14, 24001, 500, 9984, 2042, 360, 3243, 297, 2935, 9, 272, 372, 330, 269, 2676, 199, 199, 318, 3550, 8, 1813, 304, 272, 2342, 7940, 360, 21976, 708, 297, 2589, 9, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 330, 2055, 370, 376, 272, 9711, 1041, 272, 2955, 63, 1113, 12, 5709, 63, 1113, 275, 8218, 14, 5157, 14, 981, 5665, 6437, 83, 8, 1813, 9, 272, 367, 4739, 315, 18953, 67, 297, 1987, 5910, 2565, 267, 2955, 63, 1113, 14, 525, 63, 1287, 8, 4511, 12, 8218, 14, 16986, 14, 3263, 414, 9, 267, 5709, 63, 1113, 14, 525, 63, 1287, 8, 4511, 12, 8218, 14, 16986, 14, 2662, 3263, 414, 9, 267, 2955, 63, 1113, 14, 525, 63, 8159, 351, 8, 4511, 12, 8218, 14, 16986, 14, 9278, 1692, 37, 22541, 9, 267, 5709, 63, 1113, 14, 525, 63, 8159, 351, 8, 4511, 12, 8218, 14, 16986, 14, 12197, 1692, 37, 22541, 9, 339, 2589, 459, 2571, 418, 263, 275, 283, 21976, 708, 7, 272, 2589, 459, 2571, 4831, 418, 257, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 14804, 418, 257, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 2571, 11265, 418, 258, 275, 4505, 2571, 446, 81, 2672, 14804, 2672, 2571, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 14533, 568, 14804, 446, 67, 446, 79, 4, 9268, 2672, 25744, 7, 272, 2589, 459, 3234, 2571, 418, 420, 275, 4505, 2571, 7, 272, 2589, 459, 3234, 2571, 4831, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 14676, 2571, 4831, 358, 272, 2589, 459, 3234, 14804, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 14676, 14804, 358, 272, 2589, 459, 3234, 2571, 11265, 418, 257, 275, 4505, 3234, 2571, 446, 16698, 2672, 3234, 14804, 2672, 3234, 2571, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 14533, 568, 14804, 446, 67, 446, 79, 4, 9268, 2672, 25744, 7, 272, 2589, 459, 14533, 5638, 6351, 418, 221, 275, 2475, 36, 7, 272, 2589, 459, 14533, 5638, 12273, 418, 221, 275, 2125, 272, 2589, 459, 568, 2890, 907, 5192, 418, 221, 275, 2475, 41, 7, 272, 2589, 459, 568, 3298, 8158, 3867, 418, 221, 275, 2125, 272, 2589, 459, 51, 2979, 16262, 12273, 418, 275, 1987, 9259, 7, 272, 2589, 459, 10449, 63, 3649, 63, 13772, 63, 9868, 51, 63, 8693, 63, 18061, 63, 19935, 418, 275, 378, 272, 2589, 459, 35, 9472, 8158, 3867, 418, 275, 1987, 5910, 7, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2342, 7940, 360, 21976, 708, 297, 2589, 9, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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 ]
[ 18521, 14, 5157, 14, 21976, 708, 199, 199, 13933, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 21976, 708, 14, 647, 959, 16771, 7129, 15, 1690, 15, 1079, 6928, 26, 1717, 26, 2466, 31551, 2, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 199, 646, 8218, 14, 16986, 199, 646, 8218, 14, 5157, 199, 646, 8218, 14, 9562, 199, 199, 318, 2342, 7940, 8, 6815, 12, 2589, 304, 272, 327, 7758, 2754, 315, 314, 8218, 931, 436, 2066, 314, 4403, 931, 26, 272, 330, 269, 2676, 275, 2589, 14, 26493, 1831, 8, 6815, 9, 503, 8218, 14, 9562, 14, 26493, 1831, 8, 6815, 9, 272, 340, 330, 269, 2676, 26, 267, 2935, 275, 747, 14, 515, 14, 3475, 8, 31938, 2676, 9, 267, 2589, 14, 24001, 500, 9984, 2042, 360, 3243, 297, 2935, 9, 272, 372, 330, 269, 2676, 199, 199, 318, 3550, 8, 1813, 304, 272, 2342, 7940, 360, 21976, 708, 297, 2589, 9, 272, 408, 1123, 19286, 83, 436, 14538, 2860, 367, 330, 2055, 370, 376, 272, 9711, 1041, 272, 2955, 63, 1113, 12, 5709, 63, 1113, 275, 8218, 14, 5157, 14, 981, 5665, 6437, 83, 8, 1813, 9, 272, 367, 4739, 315, 18953, 67, 297, 1987, 5910, 2565, 267, 2955, 63, 1113, 14, 525, 63, 1287, 8, 4511, 12, 8218, 14, 16986, 14, 3263, 414, 9, 267, 5709, 63, 1113, 14, 525, 63, 1287, 8, 4511, 12, 8218, 14, 16986, 14, 2662, 3263, 414, 9, 267, 2955, 63, 1113, 14, 525, 63, 8159, 351, 8, 4511, 12, 8218, 14, 16986, 14, 9278, 1692, 37, 22541, 9, 267, 5709, 63, 1113, 14, 525, 63, 8159, 351, 8, 4511, 12, 8218, 14, 16986, 14, 12197, 1692, 37, 22541, 9, 339, 2589, 459, 2571, 418, 263, 275, 283, 21976, 708, 7, 272, 2589, 459, 2571, 4831, 418, 257, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 14804, 418, 257, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 2571, 11265, 418, 258, 275, 4505, 2571, 446, 81, 2672, 14804, 2672, 2571, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 14533, 568, 14804, 446, 67, 446, 79, 4, 9268, 2672, 25744, 7, 272, 2589, 459, 3234, 2571, 418, 420, 275, 4505, 2571, 7, 272, 2589, 459, 3234, 2571, 4831, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 14676, 2571, 4831, 358, 272, 2589, 459, 3234, 14804, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 14676, 14804, 358, 272, 2589, 459, 3234, 2571, 11265, 418, 257, 275, 4505, 3234, 2571, 446, 16698, 2672, 3234, 14804, 2672, 3234, 2571, 4831, 2672, 14533, 4831, 2672, 63, 14533, 1093, 1665, 44, 1254, 51, 2672, 63, 14533, 568, 14804, 446, 67, 446, 79, 4, 9268, 2672, 25744, 7, 272, 2589, 459, 14533, 5638, 6351, 418, 221, 275, 2475, 36, 7, 272, 2589, 459, 14533, 5638, 12273, 418, 221, 275, 2125, 272, 2589, 459, 568, 2890, 907, 5192, 418, 221, 275, 2475, 41, 7, 272, 2589, 459, 568, 3298, 8158, 3867, 418, 221, 275, 2125, 272, 2589, 459, 51, 2979, 16262, 12273, 418, 275, 1987, 9259, 7, 272, 2589, 459, 10449, 63, 3649, 63, 13772, 63, 9868, 51, 63, 8693, 63, 18061, 63, 19935, 418, 275, 378, 272, 2589, 459, 35, 9472, 8158, 3867, 418, 275, 1987, 5910, 7, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2342, 7940, 360, 21976, 708, 297, 2589, 9, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
eabatalov/au-linux-kernel-autumn-2017
linux/tools/perf/python/tracepoint.py
270
1465
#! /usr/bin/python # -*- python -*- # -*- coding: utf-8 -*- import perf class tracepoint(perf.evsel): def __init__(self, sys, name): config = perf.tracepoint(sys, name) perf.evsel.__init__(self, type = perf.TYPE_TRACEPOINT, config = config, freq = 0, sample_period = 1, wakeup_events = 1, sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_RAW | perf.SAMPLE_TIME) def main(): tp = tracepoint("sched", "sched_switch") cpus = perf.cpu_map() threads = perf.thread_map(-1) evlist = perf.evlist(cpus, threads) evlist.add(tp) evlist.open() evlist.mmap() while True: evlist.poll(timeout = -1) for cpu in cpus: event = evlist.read_on_cpu(cpu) if not event: continue if not isinstance(event, perf.sample_event): continue print "time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( event.sample_time, event.prev_comm, event.prev_pid, event.prev_prio, event.prev_state, event.next_comm, event.next_pid, event.next_prio) if __name__ == '__main__': main()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 8582, 199, 199, 533, 3307, 1403, 8, 9452, 14, 6857, 5891, 304, 272, 347, 636, 826, 721, 277, 12, 984, 12, 536, 304, 267, 1101, 275, 8582, 14, 3446, 1403, 8, 1274, 12, 536, 9, 267, 8582, 14, 6857, 5891, 855, 826, 721, 277, 12, 1169, 730, 257, 275, 8582, 14, 2711, 63, 20112, 7217, 12, 1169, 1101, 275, 1101, 12, 1169, 9220, 275, 378, 12, 2690, 63, 5191, 275, 413, 12, 21560, 384, 63, 4368, 275, 413, 12, 1169, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 4307, 1204, 8582, 14, 15827, 63, 4961, 9, 199, 199, 318, 2446, 837, 272, 9253, 420, 275, 3307, 1403, 480, 10487, 401, 298, 10487, 63, 5656, 531, 272, 24174, 259, 275, 8582, 14, 3541, 63, 1130, 342, 272, 7183, 275, 8582, 14, 2671, 63, 1130, 2801, 17, 9, 339, 8145, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 272, 8145, 513, 14, 525, 8, 683, 9, 272, 8145, 513, 14, 1490, 342, 272, 8145, 513, 14, 20671, 342, 339, 1830, 715, 26, 267, 8145, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 267, 367, 5033, 315, 24174, 26, 288, 1566, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 288, 340, 440, 1566, 26, 355, 1980, 953, 340, 440, 1228, 8, 1430, 12, 8582, 14, 3271, 63, 1430, 304, 355, 1980, 953, 870, 298, 521, 450, 85, 5071, 63, 1404, 2458, 83, 5071, 63, 3150, 2458, 68, 5071, 63, 20572, 2458, 68, 5071, 63, 929, 29, 16, 88, 5, 88, 25375, 2163, 63, 1404, 2458, 83, 2163, 63, 3150, 2458, 68, 2163, 63, 20572, 2458, 68, 2, 450, 334, 673, 1566, 14, 3271, 63, 521, 12, 673, 1566, 14, 5701, 63, 1404, 12, 673, 1566, 14, 5701, 63, 3150, 12, 673, 1566, 14, 5701, 63, 20572, 12, 673, 1566, 14, 5701, 63, 929, 12, 673, 1566, 14, 2184, 63, 1404, 12, 673, 1566, 14, 2184, 63, 3150, 12, 673, 1566, 14, 2184, 63, 20572, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 8582, 199, 199, 533, 3307, 1403, 8, 9452, 14, 6857, 5891, 304, 272, 347, 636, 826, 721, 277, 12, 984, 12, 536, 304, 267, 1101, 275, 8582, 14, 3446, 1403, 8, 1274, 12, 536, 9, 267, 8582, 14, 6857, 5891, 855, 826, 721, 277, 12, 1169, 730, 257, 275, 8582, 14, 2711, 63, 20112, 7217, 12, 1169, 1101, 275, 1101, 12, 1169, 9220, 275, 378, 12, 2690, 63, 5191, 275, 413, 12, 21560, 384, 63, 4368, 275, 413, 12, 1169, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 4307, 1204, 8582, 14, 15827, 63, 4961, 9, 199, 199, 318, 2446, 837, 272, 9253, 420, 275, 3307, 1403, 480, 10487, 401, 298, 10487, 63, 5656, 531, 272, 24174, 259, 275, 8582, 14, 3541, 63, 1130, 342, 272, 7183, 275, 8582, 14, 2671, 63, 1130, 2801, 17, 9, 339, 8145, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 272, 8145, 513, 14, 525, 8, 683, 9, 272, 8145, 513, 14, 1490, 342, 272, 8145, 513, 14, 20671, 342, 339, 1830, 715, 26, 267, 8145, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 267, 367, 5033, 315, 24174, 26, 288, 1566, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 288, 340, 440, 1566, 26, 355, 1980, 953, 340, 440, 1228, 8, 1430, 12, 8582, 14, 3271, 63, 1430, 304, 355, 1980, 953, 870, 298, 521, 450, 85, 5071, 63, 1404, 2458, 83, 5071, 63, 3150, 2458, 68, 5071, 63, 20572, 2458, 68, 5071, 63, 929, 29, 16, 88, 5, 88, 25375, 2163, 63, 1404, 2458, 83, 2163, 63, 3150, 2458, 68, 2163, 63, 20572, 2458, 68, 2, 450, 334, 673, 1566, 14, 3271, 63, 521, 12, 673, 1566, 14, 5701, 63, 1404, 12, 673, 1566, 14, 5701, 63, 3150, 12, 673, 1566, 14, 5701, 63, 20572, 12, 673, 1566, 14, 5701, 63, 929, 12, 673, 1566, 14, 2184, 63, 1404, 12, 673, 1566, 14, 2184, 63, 3150, 12, 673, 1566, 14, 2184, 63, 20572, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vponomaryov/manila
manila/tests/network/linux/test_ovs_lib.py
4
2879
# Copyright 2014 Mirantis Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import mock from manila.network.linux import ovs_lib from manila import test class OVS_Lib_Test(test.TestCase): """A test suite to exercise the OVS libraries.""" def setUp(self): super(OVS_Lib_Test, self).setUp() self.BR_NAME = "br-int" self.TO = "--timeout=2" self.br = ovs_lib.OVSBridge(self.BR_NAME) self.execute_p = mock.patch('manila.utils.execute') self.execute = self.execute_p.start() def tearDown(self): self.execute_p.stop() super(OVS_Lib_Test, self).tearDown() def test_reset_bridge(self): self.br.reset_bridge() self.execute.assert_has_calls([mock.call("ovs-vsctl", self.TO, "--", "--if-exists", "del-br", self.BR_NAME, run_as_root=True), mock.call("ovs-vsctl", self.TO, "add-br", self.BR_NAME, run_as_root=True)]) def test_delete_port(self): pname = "tap5" self.br.delete_port(pname) self.execute.assert_called_once_with("ovs-vsctl", self.TO, "--", "--if-exists", "del-port", self.BR_NAME, pname, run_as_root=True) def test_port_id_regex(self): result = ('external_ids : {attached-mac="fa:16:3e:23:5b:f2",' ' iface-id="5c1321a7-c73f-4a77-95e6-9f86402e5c8f",' ' iface-status=active}\nname :' ' "dhc5c1321a7-c7"\nofport : 2\n') match = self.br.re_id.search(result) vif_mac = match.group('vif_mac') vif_id = match.group('vif_id') port_name = match.group('port_name') ofport = int(match.group('ofport')) self.assertEqual('fa:16:3e:23:5b:f2', vif_mac) self.assertEqual('5c1321a7-c73f-4a77-95e6-9f86402e5c8f', vif_id) self.assertEqual('dhc5c1321a7-c7', port_name) self.assertEqual(2, ofport)
apache-2.0
[ 3, 1898, 6927, 603, 723, 4466, 83, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 2169, 25330, 14, 1200, 14, 5135, 492, 23671, 63, 773, 199, 504, 2169, 25330, 492, 511, 421, 199, 533, 593, 7428, 63, 4728, 63, 774, 8, 396, 14, 1746, 304, 272, 408, 33, 511, 5241, 370, 26511, 314, 593, 7428, 8363, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 47, 7428, 63, 4728, 63, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 7184, 63, 2339, 275, 298, 3289, 13, 442, 2, 267, 291, 14, 2566, 275, 4320, 2593, 29, 18, 2, 398, 291, 14, 3289, 275, 23671, 63, 773, 14, 47, 7428, 14491, 8, 277, 14, 7184, 63, 2339, 9, 267, 291, 14, 2526, 63, 80, 275, 1683, 14, 2068, 360, 1237, 25330, 14, 1208, 14, 2526, 358, 267, 291, 14, 2526, 275, 291, 14, 2526, 63, 80, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2526, 63, 80, 14, 2379, 342, 267, 1613, 8, 47, 7428, 63, 4728, 63, 774, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 3958, 63, 9528, 8, 277, 304, 267, 291, 14, 3289, 14, 3958, 63, 9528, 342, 267, 291, 14, 2526, 14, 479, 63, 1989, 63, 5352, 779, 1805, 14, 1250, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 4320, 401, 1740, 4320, 692, 13, 2444, 401, 298, 2264, 13, 3289, 401, 1740, 291, 14, 7184, 63, 2339, 12, 1740, 1255, 63, 305, 63, 1231, 29, 549, 395, 4318, 1683, 14, 1250, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 1740, 298, 525, 13, 3289, 401, 1740, 291, 14, 7184, 63, 2339, 12, 1740, 1255, 63, 305, 63, 1231, 29, 549, 3948, 339, 347, 511, 63, 1807, 63, 719, 8, 277, 304, 267, 27700, 275, 298, 16609, 21, 2, 267, 291, 14, 3289, 14, 1807, 63, 719, 8, 23346, 9, 267, 291, 14, 2526, 14, 479, 63, 3527, 63, 5089, 63, 1045, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 4320, 401, 6163, 4320, 692, 13, 2444, 401, 298, 2264, 13, 719, 401, 6163, 291, 14, 7184, 63, 2339, 12, 27700, 12, 6163, 1255, 63, 305, 63, 1231, 29, 549, 9, 339, 347, 511, 63, 719, 63, 344, 63, 3821, 8, 277, 304, 267, 754, 275, 661, 5159, 63, 1580, 263, 520, 469, 17099, 13, 3088, 628, 667, 26, 975, 26, 19, 69, 26, 1789, 26, 21, 66, 26, 70, 18, 21891, 2116, 283, 13395, 13, 344, 628, 21, 67, 6557, 17, 65, 23, 13, 67, 2898, 70, 13, 20, 65, 1138, 13, 2720, 69, 22, 13, 25, 70, 27141, 996, 69, 21, 67, 24, 70, 21891, 2116, 283, 13395, 13, 1205, 29, 2682, 4988, 78, 354, 4483, 520, 7, 2116, 283, 298, 7821, 67, 21, 67, 6557, 17, 65, 23, 13, 67, 23, 3212, 889, 70, 719, 4519, 520, 499, 60, 78, 358, 267, 1336, 275, 291, 14, 3289, 14, 264, 63, 344, 14, 1733, 8, 1099, 9, 267, 15205, 63, 3088, 275, 1336, 14, 923, 360, 14430, 63, 3088, 358, 267, 15205, 63, 344, 275, 1336, 14, 923, 360, 14430, 63, 344, 358, 267, 1844, 63, 354, 275, 1336, 14, 923, 360, 719, 63, 354, 358, 267, 402, 719, 275, 1109, 8, 1431, 14, 923, 360, 1618, 719, 1333, 267, 291, 14, 629, 360, 667, 26, 975, 26, 19, 69, 26, 1789, 26, 21, 66, 26, 70, 18, 297, 15205, 63, 3088, 9, 267, 291, 14, 629, 360, 21, 67, 6557, 17, 65, 23, 13, 67, 2898, 70, 13, 20, 65, 1138, 13, 2720, 69, 22, 13, 25, 70, 27141, 996, 69, 21, 67, 24, 70, 297, 15205, 63, 344, 9, 267, 291, 14, 629, 360, 7821, 67, 21, 67, 6557, 17, 65, 23, 13, 67, 23, 297, 1844, 63, 354, 9, 267, 291, 14, 629, 8, 18, 12, 402, 719, 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 ]
[ 1898, 6927, 603, 723, 4466, 83, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 2169, 25330, 14, 1200, 14, 5135, 492, 23671, 63, 773, 199, 504, 2169, 25330, 492, 511, 421, 199, 533, 593, 7428, 63, 4728, 63, 774, 8, 396, 14, 1746, 304, 272, 408, 33, 511, 5241, 370, 26511, 314, 593, 7428, 8363, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 47, 7428, 63, 4728, 63, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 7184, 63, 2339, 275, 298, 3289, 13, 442, 2, 267, 291, 14, 2566, 275, 4320, 2593, 29, 18, 2, 398, 291, 14, 3289, 275, 23671, 63, 773, 14, 47, 7428, 14491, 8, 277, 14, 7184, 63, 2339, 9, 267, 291, 14, 2526, 63, 80, 275, 1683, 14, 2068, 360, 1237, 25330, 14, 1208, 14, 2526, 358, 267, 291, 14, 2526, 275, 291, 14, 2526, 63, 80, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2526, 63, 80, 14, 2379, 342, 267, 1613, 8, 47, 7428, 63, 4728, 63, 774, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 3958, 63, 9528, 8, 277, 304, 267, 291, 14, 3289, 14, 3958, 63, 9528, 342, 267, 291, 14, 2526, 14, 479, 63, 1989, 63, 5352, 779, 1805, 14, 1250, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 4320, 401, 1740, 4320, 692, 13, 2444, 401, 298, 2264, 13, 3289, 401, 1740, 291, 14, 7184, 63, 2339, 12, 1740, 1255, 63, 305, 63, 1231, 29, 549, 395, 4318, 1683, 14, 1250, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 1740, 298, 525, 13, 3289, 401, 1740, 291, 14, 7184, 63, 2339, 12, 1740, 1255, 63, 305, 63, 1231, 29, 549, 3948, 339, 347, 511, 63, 1807, 63, 719, 8, 277, 304, 267, 27700, 275, 298, 16609, 21, 2, 267, 291, 14, 3289, 14, 1807, 63, 719, 8, 23346, 9, 267, 291, 14, 2526, 14, 479, 63, 3527, 63, 5089, 63, 1045, 480, 22409, 13, 3122, 8077, 401, 291, 14, 2566, 12, 4320, 401, 6163, 4320, 692, 13, 2444, 401, 298, 2264, 13, 719, 401, 6163, 291, 14, 7184, 63, 2339, 12, 27700, 12, 6163, 1255, 63, 305, 63, 1231, 29, 549, 9, 339, 347, 511, 63, 719, 63, 344, 63, 3821, 8, 277, 304, 267, 754, 275, 661, 5159, 63, 1580, 263, 520, 469, 17099, 13, 3088, 628, 667, 26, 975, 26, 19, 69, 26, 1789, 26, 21, 66, 26, 70, 18, 21891, 2116, 283, 13395, 13, 344, 628, 21, 67, 6557, 17, 65, 23, 13, 67, 2898, 70, 13, 20, 65, 1138, 13, 2720, 69, 22, 13, 25, 70, 27141, 996, 69, 21, 67, 24, 70, 21891, 2116, 283, 13395, 13, 1205, 29, 2682, 4988, 78, 354, 4483, 520, 7, 2116, 283, 298, 7821, 67, 21, 67, 6557, 17, 65, 23, 13, 67, 23, 3212, 889, 70, 719, 4519, 520, 499, 60, 78, 358, 267, 1336, 275, 291, 14, 3289, 14, 264, 63, 344, 14, 1733, 8, 1099, 9, 267, 15205, 63, 3088, 275, 1336, 14, 923, 360, 14430, 63, 3088, 358, 267, 15205, 63, 344, 275, 1336, 14, 923, 360, 14430, 63, 344, 358, 267, 1844, 63, 354, 275, 1336, 14, 923, 360, 719, 63, 354, 358, 267, 402, 719, 275, 1109, 8, 1431, 14, 923, 360, 1618, 719, 1333, 267, 291, 14, 629, 360, 667, 26, 975, 26, 19, 69, 26, 1789, 26, 21, 66, 26, 70, 18, 297, 15205, 63, 3088, 9, 267, 291, 14, 629, 360, 21, 67, 6557, 17, 65, 23, 13, 67, 2898, 70, 13, 20, 65, 1138, 13, 2720, 69, 22, 13, 25, 70, 27141, 996, 69, 21, 67, 24, 70, 297, 15205, 63, 344, 9, 267, 291, 14, 629, 360, 7821, 67, 21, 67, 6557, 17, 65, 23, 13, 67, 23, 297, 1844, 63, 354, 9, 267, 291, 14, 629, 8, 18, 12, 402, 719, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thomasvs/morituri
examples/readhtoa.py
2
1662
# -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 import os import sys import optparse import tempfile import shutil from morituri.common import task, checksum, log from morituri.program import cdrdao, cdparanoia import gobject gobject.threads_init() def main(): log.init() parser = optparse.OptionParser() default = 0 parser.add_option('-o', '--offset', action="store", dest="offset", help="sample offset (defaults to %d)" % default, default=default) options, args = parser.parse_args(sys.argv[1:]) runner = task.SyncRunner() # first do a simple TOC scan t = cdrdao.ReadTOCTask() runner.run(t) toc = t.table offset = t.table.tracks[0].getIndex(1).absolute if offset < 150: print 'Disc is unlikely to have Hidden Track One Audio.' else: print 'Disc seems to have a %d frame HTOA.' % offset # now do a more extensive scan t = cdrdao.ReadTableTask() runner.run(t) # now check if we have a hidden track one audio track = t.table.tracks[0] try: index = track.getIndex(0) except KeyError: print 'No Hidden Track One Audio found.' return start = index.absolute stop = track.getIndex(1).absolute print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop) # rip it riptask = cdparanoia.ReadVerifyTrackTask('track00.wav', t.table, start, stop - 1, offset=int(options.offset)) runner.run(riptask) print 'runner done' if riptask.checksum is not None: print 'Checksums match' else: print 'Checksums did not match' main()
gpl-3.0
[ 3, 1882, 4900, 26, 2018, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 646, 747, 199, 646, 984, 199, 646, 8691, 199, 646, 5549, 199, 646, 5145, 199, 199, 504, 21333, 390, 2302, 14, 2330, 492, 2120, 12, 9040, 12, 943, 199, 504, 21333, 390, 2302, 14, 6815, 492, 286, 5012, 20431, 12, 12829, 462, 8143, 4674, 199, 199, 646, 25595, 199, 71, 785, 14, 6962, 63, 826, 342, 199, 199, 318, 2446, 837, 272, 943, 14, 826, 342, 339, 1798, 275, 8691, 14, 14553, 342, 339, 849, 275, 378, 272, 1798, 14, 525, 63, 1422, 3654, 79, 297, 2850, 2743, 297, 267, 1595, 628, 1617, 401, 2053, 628, 2743, 401, 267, 1720, 628, 3271, 3268, 334, 4322, 370, 450, 68, 2924, 450, 849, 12, 267, 849, 29, 885, 9, 339, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 1274, 14, 3020, 59, 17, 5728, 339, 7876, 275, 2120, 14, 10878, 7446, 342, 339, 327, 1642, 886, 282, 3486, 2296, 35, 8000, 272, 307, 275, 286, 5012, 20431, 14, 3284, 2566, 1028, 813, 342, 272, 7876, 14, 1065, 8, 84, 9, 272, 22021, 275, 307, 14, 1224, 339, 3268, 275, 307, 14, 1224, 14, 16274, 59, 16, 1055, 362, 2681, 8, 17, 680, 6116, 339, 340, 3268, 665, 14711, 26, 267, 870, 283, 18230, 365, 625, 24227, 370, 1172, 26401, 17507, 7309, 30885, 3530, 272, 587, 26, 267, 870, 283, 18230, 12237, 370, 1172, 282, 450, 68, 2787, 869, 2566, 33, 3530, 450, 3268, 2378, 327, 3063, 886, 282, 1655, 2178, 3398, 8000, 272, 307, 275, 286, 5012, 20431, 14, 3284, 3186, 4476, 342, 272, 7876, 14, 1065, 8, 84, 9, 339, 327, 3063, 1104, 340, 781, 1172, 282, 8752, 4426, 1373, 10491, 272, 4426, 275, 307, 14, 1224, 14, 16274, 59, 16, 61, 272, 862, 26, 267, 1478, 275, 4426, 14, 362, 2681, 8, 16, 9, 272, 871, 4067, 26, 267, 870, 283, 1944, 26401, 17507, 7309, 30885, 1911, 3530, 267, 372, 339, 1343, 275, 1478, 14, 6116, 272, 3631, 275, 4426, 14, 362, 2681, 8, 17, 680, 6116, 272, 870, 283, 3601, 26401, 17507, 7309, 30885, 687, 2787, 450, 68, 370, 450, 68, 7, 450, 334, 928, 12, 3631, 9, 5493, 327, 8012, 80, 652, 272, 8012, 541, 813, 275, 12829, 462, 8143, 4674, 14, 3284, 7496, 7927, 4476, 360, 3885, 383, 14, 19118, 297, 307, 14, 1224, 12, 267, 1343, 12, 3631, 446, 413, 12, 267, 3268, 29, 442, 8, 1419, 14, 2743, 430, 272, 7876, 14, 1065, 8, 322, 541, 813, 9, 339, 870, 283, 5933, 4224, 7, 339, 340, 8012, 541, 813, 14, 8928, 365, 440, 488, 26, 267, 870, 283, 17394, 83, 1336, 7, 272, 587, 26, 267, 870, 283, 17394, 83, 8103, 440, 1336, 7, 199, 199, 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 ]
[ 1882, 4900, 26, 2018, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 646, 747, 199, 646, 984, 199, 646, 8691, 199, 646, 5549, 199, 646, 5145, 199, 199, 504, 21333, 390, 2302, 14, 2330, 492, 2120, 12, 9040, 12, 943, 199, 504, 21333, 390, 2302, 14, 6815, 492, 286, 5012, 20431, 12, 12829, 462, 8143, 4674, 199, 199, 646, 25595, 199, 71, 785, 14, 6962, 63, 826, 342, 199, 199, 318, 2446, 837, 272, 943, 14, 826, 342, 339, 1798, 275, 8691, 14, 14553, 342, 339, 849, 275, 378, 272, 1798, 14, 525, 63, 1422, 3654, 79, 297, 2850, 2743, 297, 267, 1595, 628, 1617, 401, 2053, 628, 2743, 401, 267, 1720, 628, 3271, 3268, 334, 4322, 370, 450, 68, 2924, 450, 849, 12, 267, 849, 29, 885, 9, 339, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 1274, 14, 3020, 59, 17, 5728, 339, 7876, 275, 2120, 14, 10878, 7446, 342, 339, 327, 1642, 886, 282, 3486, 2296, 35, 8000, 272, 307, 275, 286, 5012, 20431, 14, 3284, 2566, 1028, 813, 342, 272, 7876, 14, 1065, 8, 84, 9, 272, 22021, 275, 307, 14, 1224, 339, 3268, 275, 307, 14, 1224, 14, 16274, 59, 16, 1055, 362, 2681, 8, 17, 680, 6116, 339, 340, 3268, 665, 14711, 26, 267, 870, 283, 18230, 365, 625, 24227, 370, 1172, 26401, 17507, 7309, 30885, 3530, 272, 587, 26, 267, 870, 283, 18230, 12237, 370, 1172, 282, 450, 68, 2787, 869, 2566, 33, 3530, 450, 3268, 2378, 327, 3063, 886, 282, 1655, 2178, 3398, 8000, 272, 307, 275, 286, 5012, 20431, 14, 3284, 3186, 4476, 342, 272, 7876, 14, 1065, 8, 84, 9, 339, 327, 3063, 1104, 340, 781, 1172, 282, 8752, 4426, 1373, 10491, 272, 4426, 275, 307, 14, 1224, 14, 16274, 59, 16, 61, 272, 862, 26, 267, 1478, 275, 4426, 14, 362, 2681, 8, 16, 9, 272, 871, 4067, 26, 267, 870, 283, 1944, 26401, 17507, 7309, 30885, 1911, 3530, 267, 372, 339, 1343, 275, 1478, 14, 6116, 272, 3631, 275, 4426, 14, 362, 2681, 8, 17, 680, 6116, 272, 870, 283, 3601, 26401, 17507, 7309, 30885, 687, 2787, 450, 68, 370, 450, 68, 7, 450, 334, 928, 12, 3631, 9, 5493, 327, 8012, 80, 652, 272, 8012, 541, 813, 275, 12829, 462, 8143, 4674, 14, 3284, 7496, 7927, 4476, 360, 3885, 383, 14, 19118, 297, 307, 14, 1224, 12, 267, 1343, 12, 3631, 446, 413, 12, 267, 3268, 29, 442, 8, 1419, 14, 2743, 430, 272, 7876, 14, 1065, 8, 322, 541, 813, 9, 339, 870, 283, 5933, 4224, 7, 339, 340, 8012, 541, 813, 14, 8928, 365, 440, 488, 26, 267, 870, 283, 17394, 83, 1336, 7, 272, 587, 26, 267, 870, 283, 17394, 83, 8103, 440, 1336, 7, 199, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
trondhindenes/ansible
lib/ansible/plugins/action/enos.py
21
3504
# (C) 2017 Red Hat Inc. # Copyright (C) 2017 Lenovo. # # GNU General Public License v3.0+ # # 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. # # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # # Contains Action Plugin methods for ENOS Config Module # Lenovo Networking # from __future__ import (absolute_import, division, print_function) __metaclass__ = type import sys import copy from ansible import constants as C from ansible.plugins.action.normal import ActionModule as _ActionModule from ansible.module_utils.network.enos.enos import enos_provider_spec from ansible.module_utils.network.common.utils import load_provider from ansible.module_utils.connection import Connection from ansible.module_utils._text import to_text try: from __main__ import display except ImportError: from ansible.utils.display import Display display = Display() class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect socket_path = None if self._play_context.connection == 'local': provider = load_provider(enos_provider_spec, self._task.args) pc = copy.deepcopy(self._play_context) pc.connection = 'network_cli' pc.network_os = 'enos' pc.remote_addr = provider['host'] or self._play_context.remote_addr pc.port = provider['port'] or self._play_context.port or 22 pc.remote_user = provider['username'] or self._play_context.connection_user pc.password = provider['password'] or self._play_context.password pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT) pc.become = provider['authorize'] or True pc.become_pass = provider['auth_pass'] pc.become_method = 'enable' display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr) connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin) connection.set_options(direct={'persistent_command_timeout': command_timeout}) socket_path = connection.run() display.vvvv('socket_path: %s' % socket_path, pc.remote_addr) if not socket_path: return {'failed': True, 'msg': 'unable to open shell. Please see: ' + 'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'} task_vars['ansible_socket'] = socket_path # make sure we are in the right cli context which should be # enable mode and not config module or exec mode if socket_path is None: socket_path = self._connection.socket_path conn = Connection(socket_path) out = conn.get_prompt() if to_text(out, errors='surrogate_then_replace').strip().endswith(')#'): display.vvvv('In Config mode, sending exit to device', self._play_context.remote_addr) conn.send_command('exit') else: conn.send_command('enable') result = super(ActionModule, self).run(task_vars=task_vars) return result
gpl-3.0
[ 3, 334, 35, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 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, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 3, 22493, 10033, 11349, 3102, 367, 662, 23141, 4094, 5673, 199, 3, 15757, 31445, 7220, 316, 199, 3, 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, 984, 199, 646, 1331, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 14, 1287, 14, 3302, 492, 10033, 2377, 465, 485, 3310, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 287, 736, 14, 287, 736, 492, 655, 736, 63, 3780, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 2248, 63, 3780, 199, 504, 3242, 14, 578, 63, 1208, 14, 2105, 492, 8113, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 421, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 533, 10033, 2377, 1547, 3310, 2377, 304, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 403, 304, 267, 2150, 3529, 221, 327, 3529, 949, 8088, 965, 1263, 7763, 398, 2838, 63, 515, 275, 488, 267, 340, 291, 423, 2802, 63, 1100, 14, 2105, 508, 283, 1832, 356, 288, 5022, 275, 2248, 63, 3780, 8, 287, 736, 63, 3780, 63, 1650, 12, 291, 423, 1765, 14, 589, 9, 288, 13171, 275, 1331, 14, 8293, 8, 277, 423, 2802, 63, 1100, 9, 288, 13171, 14, 2105, 275, 283, 1200, 63, 2764, 7, 288, 13171, 14, 1200, 63, 736, 275, 283, 287, 736, 7, 288, 13171, 14, 3846, 63, 2697, 275, 5022, 459, 1102, 418, 503, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 288, 13171, 14, 719, 275, 5022, 459, 719, 418, 503, 291, 423, 2802, 63, 1100, 14, 719, 503, 6928, 288, 13171, 14, 3846, 63, 751, 275, 5022, 459, 2473, 418, 503, 291, 423, 2802, 63, 1100, 14, 2105, 63, 751, 288, 13171, 14, 2060, 275, 5022, 459, 2060, 418, 503, 291, 423, 2802, 63, 1100, 14, 2060, 288, 13171, 14, 4239, 63, 498, 63, 493, 275, 5022, 459, 5510, 63, 21856, 418, 503, 291, 423, 2802, 63, 1100, 14, 4239, 63, 498, 63, 493, 288, 1414, 63, 2593, 275, 1109, 8, 3780, 459, 2593, 418, 503, 445, 14, 4227, 29367, 1309, 63, 10761, 63, 8899, 9, 288, 13171, 14, 13970, 275, 5022, 459, 14204, 418, 503, 715, 288, 13171, 14, 13970, 63, 1529, 275, 5022, 459, 1178, 63, 1529, 418, 288, 13171, 14, 13970, 63, 765, 275, 283, 4296, 7, 953, 2929, 14, 24622, 360, 4941, 1950, 3589, 450, 83, 334, 10274, 2257, 3171, 450, 13171, 14, 2105, 12, 13171, 14, 3846, 63, 2697, 9, 288, 1950, 275, 291, 423, 5555, 63, 3422, 63, 1113, 14, 2105, 63, 3422, 14, 362, 360, 18539, 297, 13171, 12, 984, 14, 6626, 9, 288, 1950, 14, 409, 63, 1419, 8, 2275, 3713, 18539, 63, 1531, 63, 2593, 356, 1414, 63, 2593, 1552, 953, 2838, 63, 515, 275, 1950, 14, 1065, 342, 288, 2929, 14, 30448, 360, 3450, 63, 515, 26, 450, 83, 7, 450, 2838, 63, 515, 12, 13171, 14, 3846, 63, 2697, 9, 288, 340, 440, 2838, 63, 515, 26, 355, 372, 791, 4892, 356, 715, 12, 717, 283, 1328, 356, 283, 17200, 370, 1551, 5218, 14, 7754, 1937, 26, 283, 435, 3044, 283, 2859, 921, 4757, 14, 4853, 14, 957, 15, 4853, 15, 1200, 63, 1757, 63, 1374, 2016, 13927, 15866, 14, 1360, 3, 17200, 13, 475, 13, 1490, 13, 5641, 936, 953, 2120, 63, 2936, 459, 4853, 63, 3450, 418, 275, 2838, 63, 515, 398, 327, 1852, 3238, 781, 787, 315, 314, 2451, 5053, 1067, 1314, 1077, 506, 267, 327, 4756, 818, 436, 440, 1101, 859, 503, 2146, 818, 267, 340, 2838, 63, 515, 365, 488, 26, 288, 2838, 63, 515, 275, 291, 423, 2105, 14, 3450, 63, 515, 398, 2557, 275, 8113, 8, 3450, 63, 515, 9, 267, 734, 275, 2557, 14, 362, 63, 7650, 342, 267, 340, 370, 63, 505, 8, 548, 12, 2552, 534, 16380, 63, 12726, 63, 1814, 1959, 1913, 1252, 4130, 15938, 3, 735, 288, 2929, 14, 30448, 360, 607, 4094, 818, 12, 10209, 4458, 370, 2243, 297, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 9, 288, 2557, 14, 2254, 63, 1531, 360, 2224, 358, 267, 587, 26, 288, 2557, 14, 2254, 63, 1531, 360, 4296, 358, 398, 754, 275, 1613, 8, 3310, 2377, 12, 291, 680, 1065, 8, 1765, 63, 2936, 29, 1765, 63, 2936, 9, 267, 372, 754, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 35, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 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, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 3, 22493, 10033, 11349, 3102, 367, 662, 23141, 4094, 5673, 199, 3, 15757, 31445, 7220, 316, 199, 3, 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, 984, 199, 646, 1331, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 14, 1287, 14, 3302, 492, 10033, 2377, 465, 485, 3310, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 287, 736, 14, 287, 736, 492, 655, 736, 63, 3780, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 2248, 63, 3780, 199, 504, 3242, 14, 578, 63, 1208, 14, 2105, 492, 8113, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 421, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 533, 10033, 2377, 1547, 3310, 2377, 304, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 403, 304, 267, 2150, 3529, 221, 327, 3529, 949, 8088, 965, 1263, 7763, 398, 2838, 63, 515, 275, 488, 267, 340, 291, 423, 2802, 63, 1100, 14, 2105, 508, 283, 1832, 356, 288, 5022, 275, 2248, 63, 3780, 8, 287, 736, 63, 3780, 63, 1650, 12, 291, 423, 1765, 14, 589, 9, 288, 13171, 275, 1331, 14, 8293, 8, 277, 423, 2802, 63, 1100, 9, 288, 13171, 14, 2105, 275, 283, 1200, 63, 2764, 7, 288, 13171, 14, 1200, 63, 736, 275, 283, 287, 736, 7, 288, 13171, 14, 3846, 63, 2697, 275, 5022, 459, 1102, 418, 503, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 288, 13171, 14, 719, 275, 5022, 459, 719, 418, 503, 291, 423, 2802, 63, 1100, 14, 719, 503, 6928, 288, 13171, 14, 3846, 63, 751, 275, 5022, 459, 2473, 418, 503, 291, 423, 2802, 63, 1100, 14, 2105, 63, 751, 288, 13171, 14, 2060, 275, 5022, 459, 2060, 418, 503, 291, 423, 2802, 63, 1100, 14, 2060, 288, 13171, 14, 4239, 63, 498, 63, 493, 275, 5022, 459, 5510, 63, 21856, 418, 503, 291, 423, 2802, 63, 1100, 14, 4239, 63, 498, 63, 493, 288, 1414, 63, 2593, 275, 1109, 8, 3780, 459, 2593, 418, 503, 445, 14, 4227, 29367, 1309, 63, 10761, 63, 8899, 9, 288, 13171, 14, 13970, 275, 5022, 459, 14204, 418, 503, 715, 288, 13171, 14, 13970, 63, 1529, 275, 5022, 459, 1178, 63, 1529, 418, 288, 13171, 14, 13970, 63, 765, 275, 283, 4296, 7, 953, 2929, 14, 24622, 360, 4941, 1950, 3589, 450, 83, 334, 10274, 2257, 3171, 450, 13171, 14, 2105, 12, 13171, 14, 3846, 63, 2697, 9, 288, 1950, 275, 291, 423, 5555, 63, 3422, 63, 1113, 14, 2105, 63, 3422, 14, 362, 360, 18539, 297, 13171, 12, 984, 14, 6626, 9, 288, 1950, 14, 409, 63, 1419, 8, 2275, 3713, 18539, 63, 1531, 63, 2593, 356, 1414, 63, 2593, 1552, 953, 2838, 63, 515, 275, 1950, 14, 1065, 342, 288, 2929, 14, 30448, 360, 3450, 63, 515, 26, 450, 83, 7, 450, 2838, 63, 515, 12, 13171, 14, 3846, 63, 2697, 9, 288, 340, 440, 2838, 63, 515, 26, 355, 372, 791, 4892, 356, 715, 12, 717, 283, 1328, 356, 283, 17200, 370, 1551, 5218, 14, 7754, 1937, 26, 283, 435, 3044, 283, 2859, 921, 4757, 14, 4853, 14, 957, 15, 4853, 15, 1200, 63, 1757, 63, 1374, 2016, 13927, 15866, 14, 1360, 3, 17200, 13, 475, 13, 1490, 13, 5641, 936, 953, 2120, 63, 2936, 459, 4853, 63, 3450, 418, 275, 2838, 63, 515, 398, 327, 1852, 3238, 781, 787, 315, 314, 2451, 5053, 1067, 1314, 1077, 506, 267, 327, 4756, 818, 436, 440, 1101, 859, 503, 2146, 818, 267, 340, 2838, 63, 515, 365, 488, 26, 288, 2838, 63, 515, 275, 291, 423, 2105, 14, 3450, 63, 515, 398, 2557, 275, 8113, 8, 3450, 63, 515, 9, 267, 734, 275, 2557, 14, 362, 63, 7650, 342, 267, 340, 370, 63, 505, 8, 548, 12, 2552, 534, 16380, 63, 12726, 63, 1814, 1959, 1913, 1252, 4130, 15938, 3, 735, 288, 2929, 14, 30448, 360, 607, 4094, 818, 12, 10209, 4458, 370, 2243, 297, 291, 423, 2802, 63, 1100, 14, 3846, 63, 2697, 9, 288, 2557, 14, 2254, 63, 1531, 360, 2224, 358, 267, 587, 26, 288, 2557, 14, 2254, 63, 1531, 360, 4296, 358, 398, 754, 275, 1613, 8, 3310, 2377, 12, 291, 680, 1065, 8, 1765, 63, 2936, 29, 1765, 63, 2936, 9, 267, 372, 754, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hwroitzsch/BikersLifeSaver
local/share/OpenCV/samples/python/video_threaded.py
5
2365
#!/usr/bin/env python ''' Multithreaded video processing sample. Usage: video_threaded.py {<video device number>|<video file name>} Shows how python threading capabilities can be used to organize parallel captured frame processing pipeline for smoother playback. Keyboard shortcuts: ESC - exit space - switch between multi and single threaded processing ''' # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 from multiprocessing.pool import ThreadPool from collections import deque from common import clock, draw_str, StatValue import video class DummyTask: def __init__(self, data): self.data = data def ready(self): return True def get(self): return self.data if __name__ == '__main__': import sys print(__doc__) try: fn = sys.argv[1] except: fn = 0 cap = video.create_capture(fn) def process_frame(frame, t0): # some intensive computation... frame = cv2.medianBlur(frame, 19) frame = cv2.medianBlur(frame, 19) return frame, t0 threadn = cv2.getNumberOfCPUs() pool = ThreadPool(processes = threadn) pending = deque() threaded_mode = True latency = StatValue() frame_interval = StatValue() last_frame_time = clock() while True: while len(pending) > 0 and pending[0].ready(): res, t0 = pending.popleft().get() latency.update(clock() - t0) draw_str(res, (20, 20), "threaded : " + str(threaded_mode)) draw_str(res, (20, 40), "latency : %.1f ms" % (latency.value*1000)) draw_str(res, (20, 60), "frame interval : %.1f ms" % (frame_interval.value*1000)) cv2.imshow('threaded video', res) if len(pending) < threadn: ret, frame = cap.read() t = clock() frame_interval.update(t - last_frame_time) last_frame_time = t if threaded_mode: task = pool.apply_async(process_frame, (frame.copy(), t)) else: task = DummyTask(process_frame(frame, t)) pending.append(task) ch = 0xFF & cv2.waitKey(1) if ch == ord(' '): threaded_mode = not threaded_mode if ch == 27: break cv2.destroyAllWindows()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 3947, 19710, 3991, 6661, 2690, 14, 199, 7692, 26, 2043, 3991, 63, 19710, 14, 647, 469, 28, 3722, 2243, 1329, 21521, 28, 3722, 570, 536, 23307, 8410, 12968, 83, 4212, 2366, 5796, 14918, 883, 506, 1202, 2043, 370, 20765, 794, 9861, 17487, 2787, 6661, 7679, 2043, 367, 308, 573, 1848, 5232, 894, 14, 199, 199, 28377, 3974, 12946, 26, 8410, 10427, 35, 446, 4458, 2043, 4601, 446, 6258, 3382, 3510, 436, 2849, 25396, 6661, 199, 2344, 199, 199, 3, 2018, 499, 15, 19, 7163, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 504, 12866, 14, 2293, 492, 11086, 5453, 199, 504, 5055, 492, 15782, 199, 199, 504, 2863, 492, 12516, 12, 5954, 63, 495, 12, 27673, 1110, 199, 646, 3991, 421, 199, 533, 9762, 4476, 26, 272, 347, 636, 826, 721, 277, 12, 666, 304, 267, 291, 14, 576, 275, 666, 272, 347, 10144, 8, 277, 304, 267, 372, 715, 272, 347, 664, 8, 277, 304, 267, 372, 291, 14, 576, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 339, 870, 3460, 1301, 3368, 339, 862, 26, 267, 4325, 275, 984, 14, 3020, 59, 17, 61, 272, 871, 26, 267, 4325, 275, 378, 272, 4021, 275, 3991, 14, 981, 63, 12685, 8, 2324, 9, 2378, 347, 2112, 63, 1943, 8, 1943, 12, 307, 16, 304, 267, 327, 2005, 315, 724, 3398, 14009, 1396, 267, 2787, 275, 6277, 18, 14, 13106, 24613, 300, 8, 1943, 12, 5851, 9, 267, 2787, 275, 6277, 18, 14, 13106, 24613, 300, 8, 1943, 12, 5851, 9, 267, 372, 2787, 12, 307, 16, 339, 2462, 78, 275, 6277, 18, 14, 362, 16030, 11011, 83, 342, 272, 4203, 275, 11086, 5453, 8, 11816, 275, 2462, 78, 9, 272, 9413, 275, 15782, 342, 339, 25396, 63, 632, 275, 715, 339, 23967, 275, 27673, 1110, 342, 272, 2787, 63, 4284, 275, 27673, 1110, 342, 272, 2061, 63, 1943, 63, 521, 275, 12516, 342, 272, 1830, 715, 26, 267, 1830, 822, 8, 6455, 9, 690, 378, 436, 9413, 59, 16, 1055, 2179, 837, 288, 522, 12, 307, 16, 275, 9413, 14, 25704, 1252, 362, 342, 288, 23967, 14, 873, 8, 9597, 342, 446, 307, 16, 9, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 3388, 395, 298, 19710, 420, 520, 221, 298, 435, 620, 8, 19710, 63, 632, 430, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 6335, 395, 298, 19645, 263, 520, 221, 10536, 17, 70, 6605, 2, 450, 334, 19645, 14, 585, 10, 5279, 430, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 5212, 395, 298, 1943, 6252, 520, 221, 10536, 17, 70, 6605, 2, 450, 334, 1943, 63, 4284, 14, 585, 10, 5279, 430, 288, 6277, 18, 14, 20413, 360, 19710, 3991, 297, 522, 9, 267, 340, 822, 8, 6455, 9, 665, 2462, 78, 26, 288, 2203, 12, 2787, 275, 4021, 14, 739, 342, 288, 307, 275, 12516, 342, 288, 2787, 63, 4284, 14, 873, 8, 84, 446, 2061, 63, 1943, 63, 521, 9, 288, 2061, 63, 1943, 63, 521, 275, 307, 288, 340, 25396, 63, 632, 26, 355, 2120, 275, 4203, 14, 4998, 63, 4146, 8, 1412, 63, 1943, 12, 334, 1943, 14, 1574, 1062, 307, 430, 288, 587, 26, 355, 2120, 275, 9762, 4476, 8, 1412, 63, 1943, 8, 1943, 12, 307, 430, 288, 9413, 14, 740, 8, 1765, 9, 267, 682, 275, 378, 9039, 1253, 6277, 18, 14, 2573, 1197, 8, 17, 9, 267, 340, 682, 508, 6206, 360, 18927, 288, 25396, 63, 632, 275, 440, 25396, 63, 632, 267, 340, 682, 508, 8087, 26, 288, 2059, 199, 5107, 18, 14, 7237, 2422, 8647, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 3947, 19710, 3991, 6661, 2690, 14, 199, 7692, 26, 2043, 3991, 63, 19710, 14, 647, 469, 28, 3722, 2243, 1329, 21521, 28, 3722, 570, 536, 23307, 8410, 12968, 83, 4212, 2366, 5796, 14918, 883, 506, 1202, 2043, 370, 20765, 794, 9861, 17487, 2787, 6661, 7679, 2043, 367, 308, 573, 1848, 5232, 894, 14, 199, 199, 28377, 3974, 12946, 26, 8410, 10427, 35, 446, 4458, 2043, 4601, 446, 6258, 3382, 3510, 436, 2849, 25396, 6661, 199, 2344, 199, 199, 3, 2018, 499, 15, 19, 7163, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 504, 12866, 14, 2293, 492, 11086, 5453, 199, 504, 5055, 492, 15782, 199, 199, 504, 2863, 492, 12516, 12, 5954, 63, 495, 12, 27673, 1110, 199, 646, 3991, 421, 199, 533, 9762, 4476, 26, 272, 347, 636, 826, 721, 277, 12, 666, 304, 267, 291, 14, 576, 275, 666, 272, 347, 10144, 8, 277, 304, 267, 372, 715, 272, 347, 664, 8, 277, 304, 267, 372, 291, 14, 576, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 339, 870, 3460, 1301, 3368, 339, 862, 26, 267, 4325, 275, 984, 14, 3020, 59, 17, 61, 272, 871, 26, 267, 4325, 275, 378, 272, 4021, 275, 3991, 14, 981, 63, 12685, 8, 2324, 9, 2378, 347, 2112, 63, 1943, 8, 1943, 12, 307, 16, 304, 267, 327, 2005, 315, 724, 3398, 14009, 1396, 267, 2787, 275, 6277, 18, 14, 13106, 24613, 300, 8, 1943, 12, 5851, 9, 267, 2787, 275, 6277, 18, 14, 13106, 24613, 300, 8, 1943, 12, 5851, 9, 267, 372, 2787, 12, 307, 16, 339, 2462, 78, 275, 6277, 18, 14, 362, 16030, 11011, 83, 342, 272, 4203, 275, 11086, 5453, 8, 11816, 275, 2462, 78, 9, 272, 9413, 275, 15782, 342, 339, 25396, 63, 632, 275, 715, 339, 23967, 275, 27673, 1110, 342, 272, 2787, 63, 4284, 275, 27673, 1110, 342, 272, 2061, 63, 1943, 63, 521, 275, 12516, 342, 272, 1830, 715, 26, 267, 1830, 822, 8, 6455, 9, 690, 378, 436, 9413, 59, 16, 1055, 2179, 837, 288, 522, 12, 307, 16, 275, 9413, 14, 25704, 1252, 362, 342, 288, 23967, 14, 873, 8, 9597, 342, 446, 307, 16, 9, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 3388, 395, 298, 19710, 420, 520, 221, 298, 435, 620, 8, 19710, 63, 632, 430, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 6335, 395, 298, 19645, 263, 520, 221, 10536, 17, 70, 6605, 2, 450, 334, 19645, 14, 585, 10, 5279, 430, 288, 5954, 63, 495, 8, 470, 12, 334, 1165, 12, 5212, 395, 298, 1943, 6252, 520, 221, 10536, 17, 70, 6605, 2, 450, 334, 1943, 63, 4284, 14, 585, 10, 5279, 430, 288, 6277, 18, 14, 20413, 360, 19710, 3991, 297, 522, 9, 267, 340, 822, 8, 6455, 9, 665, 2462, 78, 26, 288, 2203, 12, 2787, 275, 4021, 14, 739, 342, 288, 307, 275, 12516, 342, 288, 2787, 63, 4284, 14, 873, 8, 84, 446, 2061, 63, 1943, 63, 521, 9, 288, 2061, 63, 1943, 63, 521, 275, 307, 288, 340, 25396, 63, 632, 26, 355, 2120, 275, 4203, 14, 4998, 63, 4146, 8, 1412, 63, 1943, 12, 334, 1943, 14, 1574, 1062, 307, 430, 288, 587, 26, 355, 2120, 275, 9762, 4476, 8, 1412, 63, 1943, 8, 1943, 12, 307, 430, 288, 9413, 14, 740, 8, 1765, 9, 267, 682, 275, 378, 9039, 1253, 6277, 18, 14, 2573, 1197, 8, 17, 9, 267, 340, 682, 508, 6206, 360, 18927, 288, 25396, 63, 632, 275, 440, 25396, 63, 632, 267, 340, 682, 508, 8087, 26, 288, 2059, 199, 5107, 18, 14, 7237, 2422, 8647, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
py-geek/City-Air
venv/lib/python2.7/site-packages/pymysql/err.py
29
4025
import struct from .constants import ER class MySQLError(Exception): """Exception related to operation with MySQL.""" class Warning(Warning, MySQLError): """Exception raised for important warnings like data truncations while inserting, etc.""" class Error(MySQLError): """Exception that is the base class of all other error exceptions (not Warning).""" class InterfaceError(Error): """Exception raised for errors that are related to the database interface rather than the database itself.""" class DatabaseError(Error): """Exception raised for errors that are related to the database.""" class DataError(DatabaseError): """Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.""" class OperationalError(DatabaseError): """Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.""" class IntegrityError(DatabaseError): """Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails, duplicate key, etc.""" class InternalError(DatabaseError): """Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync, etc.""" class ProgrammingError(DatabaseError): """Exception raised for programming errors, e.g. table not found or already exists, syntax error in the SQL statement, wrong number of parameters specified, etc.""" class NotSupportedError(DatabaseError): """Exception raised in case a method or database API was used which is not supported by the database, e.g. requesting a .rollback() on a connection that does not support transaction or has transactions turned off.""" error_map = {} def _map_error(exc, *errors): for error in errors: error_map[error] = exc _map_error(ProgrammingError, ER.DB_CREATE_EXISTS, ER.SYNTAX_ERROR, ER.PARSE_ERROR, ER.NO_SUCH_TABLE, ER.WRONG_DB_NAME, ER.WRONG_TABLE_NAME, ER.FIELD_SPECIFIED_TWICE, ER.INVALID_GROUP_FUNC_USE, ER.UNSUPPORTED_EXTENSION, ER.TABLE_MUST_HAVE_COLUMNS, ER.CANT_DO_THIS_DURING_AN_TRANSACTION) _map_error(DataError, ER.WARN_DATA_TRUNCATED, ER.WARN_NULL_TO_NOTNULL, ER.WARN_DATA_OUT_OF_RANGE, ER.NO_DEFAULT, ER.PRIMARY_CANT_HAVE_NULL, ER.DATA_TOO_LONG, ER.DATETIME_FUNCTION_OVERFLOW) _map_error(IntegrityError, ER.DUP_ENTRY, ER.NO_REFERENCED_ROW, ER.NO_REFERENCED_ROW_2, ER.ROW_IS_REFERENCED, ER.ROW_IS_REFERENCED_2, ER.CANNOT_ADD_FOREIGN, ER.BAD_NULL_ERROR) _map_error(NotSupportedError, ER.WARNING_NOT_COMPLETE_ROLLBACK, ER.NOT_SUPPORTED_YET, ER.FEATURE_DISABLED, ER.UNKNOWN_STORAGE_ENGINE) _map_error(OperationalError, ER.DBACCESS_DENIED_ERROR, ER.ACCESS_DENIED_ERROR, ER.CON_COUNT_ERROR, ER.TABLEACCESS_DENIED_ERROR, ER.COLUMNACCESS_DENIED_ERROR) del _map_error, ER def _get_error_info(data): errno = struct.unpack('<h', data[1:3])[0] is_41 = data[3:4] == b"#" if is_41: # version 4.1 sqlstate = data[4:9].decode("utf8", 'replace') errorvalue = data[9:].decode("utf8", 'replace') return (errno, sqlstate, errorvalue) else: # version 4.0 return (errno, None, data[3:].decode("utf8", 'replace')) def _check_mysql_exception(errinfo): errno, sqlstate, errorvalue = errinfo errorclass = error_map.get(errno, None) if errorclass: raise errorclass(errno, errorvalue) # couldn't find the right error number raise InternalError(errno, errorvalue) def raise_mysql_exception(data): errinfo = _get_error_info(data) _check_mysql_exception(errinfo)
mit
[ 646, 2702, 199, 199, 504, 1275, 5559, 492, 221, 540, 421, 199, 533, 11200, 547, 8, 1726, 304, 272, 408, 1726, 4048, 370, 3439, 543, 11200, 1041, 421, 199, 533, 15902, 8, 3849, 12, 11200, 547, 304, 272, 408, 1726, 4915, 367, 11012, 3598, 2839, 666, 8181, 1063, 83, 272, 1830, 28498, 12, 5423, 1041, 421, 199, 533, 4520, 8, 20784, 547, 304, 272, 408, 1726, 626, 365, 314, 1300, 1021, 402, 1006, 1163, 1125, 4967, 272, 334, 1397, 15902, 10477, 421, 199, 533, 14816, 547, 8, 547, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 3050, 272, 3217, 7830, 2419, 314, 3050, 6337, 1041, 421, 199, 533, 27728, 8, 547, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 272, 3050, 1041, 421, 199, 533, 3918, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 7037, 370, 8826, 543, 314, 272, 7686, 666, 2839, 4629, 701, 4697, 12, 8950, 574, 734, 402, 1425, 12, 272, 5423, 1041, 421, 199, 533, 6654, 6279, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 3050, 1159, 272, 3439, 436, 440, 20513, 1334, 314, 3304, 402, 314, 2240, 2626, 12, 272, 325, 14, 71, 14, 376, 10537, 17639, 11058, 12, 314, 666, 1350, 536, 365, 440, 272, 1911, 12, 282, 6008, 4293, 440, 506, 7686, 12, 282, 4402, 18723, 272, 1125, 8920, 5309, 6661, 12, 5423, 1041, 421, 199, 533, 26864, 8, 25198, 304, 272, 408, 1726, 4915, 1380, 314, 5850, 279, 4661, 12997, 402, 314, 3050, 272, 365, 16955, 12, 325, 14, 71, 14, 282, 11608, 790, 1104, 6918, 12, 9250, 790, 12, 272, 5423, 1041, 421, 199, 533, 12624, 547, 8, 25198, 304, 272, 408, 1726, 4915, 1380, 314, 3050, 655, 16558, 376, 5007, 272, 1125, 12, 325, 14, 71, 14, 314, 3920, 365, 440, 1686, 20827, 12, 314, 6008, 365, 272, 734, 402, 7604, 12, 5423, 1041, 421, 199, 533, 2165, 9258, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 31768, 2552, 12, 325, 14, 71, 14, 1817, 440, 1911, 272, 503, 2575, 3495, 12, 6302, 1125, 315, 314, 5385, 5164, 12, 6835, 1329, 272, 402, 2633, 2013, 12, 5423, 1041, 421, 199, 533, 2832, 10682, 547, 8, 25198, 304, 272, 408, 1726, 4915, 315, 1930, 282, 1083, 503, 3050, 3261, 1990, 1202, 272, 1314, 365, 440, 3748, 701, 314, 3050, 12, 325, 14, 71, 14, 23502, 282, 272, 1275, 10437, 342, 641, 282, 1950, 626, 1630, 440, 2291, 6008, 503, 272, 965, 15809, 19136, 2331, 1041, 421, 199, 705, 63, 1130, 275, 1052, 199, 199, 318, 485, 1130, 63, 705, 8, 2804, 12, 627, 2550, 304, 272, 367, 1125, 315, 2552, 26, 267, 1125, 63, 1130, 59, 705, 61, 275, 3178, 199, 199, 63, 1130, 63, 705, 8, 11411, 547, 12, 221, 540, 14, 2846, 63, 8366, 63, 23558, 12, 221, 540, 14, 20763, 63, 3170, 12, 1779, 221, 540, 14, 23354, 63, 3170, 12, 221, 540, 14, 2826, 63, 6195, 1244, 63, 8723, 12, 221, 540, 14, 6524, 7770, 63, 2846, 63, 2339, 12, 1779, 221, 540, 14, 6524, 7770, 63, 8723, 63, 2339, 12, 221, 540, 14, 8609, 63, 22917, 19679, 63, 16491, 4047, 12, 1779, 221, 540, 14, 9692, 63, 7823, 63, 19587, 63, 4701, 12, 221, 540, 14, 1734, 15925, 63, 15498, 12, 1779, 221, 540, 14, 8723, 63, 45, 7698, 63, 10767, 63, 28427, 12, 221, 540, 14, 35, 1441, 63, 1649, 63, 24571, 63, 36, 1230, 1206, 63, 879, 63, 12191, 10052, 9, 199, 63, 1130, 63, 705, 8, 1451, 547, 12, 221, 540, 14, 17449, 63, 3998, 63, 22346, 6989, 12, 221, 540, 14, 17449, 63, 8084, 63, 2566, 63, 4609, 8084, 12, 1779, 221, 540, 14, 17449, 63, 3998, 63, 1877, 63, 3359, 63, 15167, 12, 221, 540, 14, 2826, 63, 3472, 12, 221, 540, 14, 31035, 63, 35, 1441, 63, 10767, 63, 8084, 12, 1779, 221, 540, 14, 3998, 63, 30947, 63, 12375, 12, 221, 540, 14, 12488, 63, 15476, 63, 14336, 17114, 9, 199, 63, 1130, 63, 705, 8, 24823, 12, 221, 540, 14, 24099, 63, 7285, 12, 221, 540, 14, 2826, 63, 19494, 9415, 1149, 63, 11415, 12, 1779, 221, 540, 14, 2826, 63, 19494, 9415, 1149, 63, 11415, 63, 18, 12, 221, 540, 14, 11415, 63, 1311, 63, 19494, 9415, 1149, 12, 221, 540, 14, 11415, 63, 1311, 63, 19494, 9415, 1149, 63, 18, 12, 1779, 221, 540, 14, 18988, 4609, 63, 9732, 63, 18155, 3203, 12, 221, 540, 14, 9439, 63, 8084, 63, 3170, 9, 199, 63, 1130, 63, 705, 8, 26077, 547, 12, 221, 540, 14, 9171, 63, 4609, 63, 15558, 63, 14881, 7111, 12, 1779, 221, 540, 14, 4609, 63, 15925, 63, 57, 775, 12, 221, 540, 14, 22884, 63, 16205, 12, 221, 540, 14, 11588, 63, 17467, 63, 15956, 9, 199, 63, 1130, 63, 705, 8, 31998, 547, 12, 221, 540, 14, 2846, 11074, 63, 23282, 29848, 63, 3170, 12, 221, 540, 14, 11074, 63, 23282, 29848, 63, 3170, 12, 1779, 221, 540, 14, 1864, 63, 8760, 63, 3170, 12, 221, 540, 14, 8723, 11074, 63, 23282, 29848, 63, 3170, 12, 1779, 221, 540, 14, 21436, 11074, 63, 23282, 29848, 63, 3170, 9, 199, 199, 2264, 485, 1130, 63, 705, 12, 221, 540, 421, 199, 318, 485, 362, 63, 705, 63, 815, 8, 576, 304, 272, 7554, 275, 2702, 14, 5301, 4827, 72, 297, 666, 59, 17, 26, 19, 11057, 16, 61, 272, 365, 63, 2953, 275, 666, 59, 19, 26, 20, 61, 508, 330, 2, 23662, 272, 340, 365, 63, 2953, 26, 267, 327, 1015, 841, 14, 17, 267, 3875, 929, 275, 666, 59, 20, 26, 25, 1055, 2708, 480, 1624, 24, 401, 283, 1814, 358, 267, 1125, 585, 275, 666, 59, 25, 11455, 2708, 480, 1624, 24, 401, 283, 1814, 358, 267, 372, 334, 7931, 12, 3875, 929, 12, 1125, 585, 9, 272, 587, 26, 267, 327, 1015, 841, 14, 16, 267, 372, 334, 7931, 12, 488, 12, 666, 59, 19, 11455, 2708, 480, 1624, 24, 401, 283, 1814, 1333, 421, 199, 318, 485, 1074, 63, 8644, 63, 1971, 8, 1508, 815, 304, 272, 7554, 12, 3875, 929 ]
[ 2702, 199, 199, 504, 1275, 5559, 492, 221, 540, 421, 199, 533, 11200, 547, 8, 1726, 304, 272, 408, 1726, 4048, 370, 3439, 543, 11200, 1041, 421, 199, 533, 15902, 8, 3849, 12, 11200, 547, 304, 272, 408, 1726, 4915, 367, 11012, 3598, 2839, 666, 8181, 1063, 83, 272, 1830, 28498, 12, 5423, 1041, 421, 199, 533, 4520, 8, 20784, 547, 304, 272, 408, 1726, 626, 365, 314, 1300, 1021, 402, 1006, 1163, 1125, 4967, 272, 334, 1397, 15902, 10477, 421, 199, 533, 14816, 547, 8, 547, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 3050, 272, 3217, 7830, 2419, 314, 3050, 6337, 1041, 421, 199, 533, 27728, 8, 547, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 272, 3050, 1041, 421, 199, 533, 3918, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 7037, 370, 8826, 543, 314, 272, 7686, 666, 2839, 4629, 701, 4697, 12, 8950, 574, 734, 402, 1425, 12, 272, 5423, 1041, 421, 199, 533, 6654, 6279, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 2552, 626, 787, 4048, 370, 314, 3050, 1159, 272, 3439, 436, 440, 20513, 1334, 314, 3304, 402, 314, 2240, 2626, 12, 272, 325, 14, 71, 14, 376, 10537, 17639, 11058, 12, 314, 666, 1350, 536, 365, 440, 272, 1911, 12, 282, 6008, 4293, 440, 506, 7686, 12, 282, 4402, 18723, 272, 1125, 8920, 5309, 6661, 12, 5423, 1041, 421, 199, 533, 26864, 8, 25198, 304, 272, 408, 1726, 4915, 1380, 314, 5850, 279, 4661, 12997, 402, 314, 3050, 272, 365, 16955, 12, 325, 14, 71, 14, 282, 11608, 790, 1104, 6918, 12, 9250, 790, 12, 272, 5423, 1041, 421, 199, 533, 12624, 547, 8, 25198, 304, 272, 408, 1726, 4915, 1380, 314, 3050, 655, 16558, 376, 5007, 272, 1125, 12, 325, 14, 71, 14, 314, 3920, 365, 440, 1686, 20827, 12, 314, 6008, 365, 272, 734, 402, 7604, 12, 5423, 1041, 421, 199, 533, 2165, 9258, 547, 8, 25198, 304, 272, 408, 1726, 4915, 367, 31768, 2552, 12, 325, 14, 71, 14, 1817, 440, 1911, 272, 503, 2575, 3495, 12, 6302, 1125, 315, 314, 5385, 5164, 12, 6835, 1329, 272, 402, 2633, 2013, 12, 5423, 1041, 421, 199, 533, 2832, 10682, 547, 8, 25198, 304, 272, 408, 1726, 4915, 315, 1930, 282, 1083, 503, 3050, 3261, 1990, 1202, 272, 1314, 365, 440, 3748, 701, 314, 3050, 12, 325, 14, 71, 14, 23502, 282, 272, 1275, 10437, 342, 641, 282, 1950, 626, 1630, 440, 2291, 6008, 503, 272, 965, 15809, 19136, 2331, 1041, 421, 199, 705, 63, 1130, 275, 1052, 199, 199, 318, 485, 1130, 63, 705, 8, 2804, 12, 627, 2550, 304, 272, 367, 1125, 315, 2552, 26, 267, 1125, 63, 1130, 59, 705, 61, 275, 3178, 199, 199, 63, 1130, 63, 705, 8, 11411, 547, 12, 221, 540, 14, 2846, 63, 8366, 63, 23558, 12, 221, 540, 14, 20763, 63, 3170, 12, 1779, 221, 540, 14, 23354, 63, 3170, 12, 221, 540, 14, 2826, 63, 6195, 1244, 63, 8723, 12, 221, 540, 14, 6524, 7770, 63, 2846, 63, 2339, 12, 1779, 221, 540, 14, 6524, 7770, 63, 8723, 63, 2339, 12, 221, 540, 14, 8609, 63, 22917, 19679, 63, 16491, 4047, 12, 1779, 221, 540, 14, 9692, 63, 7823, 63, 19587, 63, 4701, 12, 221, 540, 14, 1734, 15925, 63, 15498, 12, 1779, 221, 540, 14, 8723, 63, 45, 7698, 63, 10767, 63, 28427, 12, 221, 540, 14, 35, 1441, 63, 1649, 63, 24571, 63, 36, 1230, 1206, 63, 879, 63, 12191, 10052, 9, 199, 63, 1130, 63, 705, 8, 1451, 547, 12, 221, 540, 14, 17449, 63, 3998, 63, 22346, 6989, 12, 221, 540, 14, 17449, 63, 8084, 63, 2566, 63, 4609, 8084, 12, 1779, 221, 540, 14, 17449, 63, 3998, 63, 1877, 63, 3359, 63, 15167, 12, 221, 540, 14, 2826, 63, 3472, 12, 221, 540, 14, 31035, 63, 35, 1441, 63, 10767, 63, 8084, 12, 1779, 221, 540, 14, 3998, 63, 30947, 63, 12375, 12, 221, 540, 14, 12488, 63, 15476, 63, 14336, 17114, 9, 199, 63, 1130, 63, 705, 8, 24823, 12, 221, 540, 14, 24099, 63, 7285, 12, 221, 540, 14, 2826, 63, 19494, 9415, 1149, 63, 11415, 12, 1779, 221, 540, 14, 2826, 63, 19494, 9415, 1149, 63, 11415, 63, 18, 12, 221, 540, 14, 11415, 63, 1311, 63, 19494, 9415, 1149, 12, 221, 540, 14, 11415, 63, 1311, 63, 19494, 9415, 1149, 63, 18, 12, 1779, 221, 540, 14, 18988, 4609, 63, 9732, 63, 18155, 3203, 12, 221, 540, 14, 9439, 63, 8084, 63, 3170, 9, 199, 63, 1130, 63, 705, 8, 26077, 547, 12, 221, 540, 14, 9171, 63, 4609, 63, 15558, 63, 14881, 7111, 12, 1779, 221, 540, 14, 4609, 63, 15925, 63, 57, 775, 12, 221, 540, 14, 22884, 63, 16205, 12, 221, 540, 14, 11588, 63, 17467, 63, 15956, 9, 199, 63, 1130, 63, 705, 8, 31998, 547, 12, 221, 540, 14, 2846, 11074, 63, 23282, 29848, 63, 3170, 12, 221, 540, 14, 11074, 63, 23282, 29848, 63, 3170, 12, 1779, 221, 540, 14, 1864, 63, 8760, 63, 3170, 12, 221, 540, 14, 8723, 11074, 63, 23282, 29848, 63, 3170, 12, 1779, 221, 540, 14, 21436, 11074, 63, 23282, 29848, 63, 3170, 9, 199, 199, 2264, 485, 1130, 63, 705, 12, 221, 540, 421, 199, 318, 485, 362, 63, 705, 63, 815, 8, 576, 304, 272, 7554, 275, 2702, 14, 5301, 4827, 72, 297, 666, 59, 17, 26, 19, 11057, 16, 61, 272, 365, 63, 2953, 275, 666, 59, 19, 26, 20, 61, 508, 330, 2, 23662, 272, 340, 365, 63, 2953, 26, 267, 327, 1015, 841, 14, 17, 267, 3875, 929, 275, 666, 59, 20, 26, 25, 1055, 2708, 480, 1624, 24, 401, 283, 1814, 358, 267, 1125, 585, 275, 666, 59, 25, 11455, 2708, 480, 1624, 24, 401, 283, 1814, 358, 267, 372, 334, 7931, 12, 3875, 929, 12, 1125, 585, 9, 272, 587, 26, 267, 327, 1015, 841, 14, 16, 267, 372, 334, 7931, 12, 488, 12, 666, 59, 19, 11455, 2708, 480, 1624, 24, 401, 283, 1814, 1333, 421, 199, 318, 485, 1074, 63, 8644, 63, 1971, 8, 1508, 815, 304, 272, 7554, 12, 3875, 929, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1,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4287
"Thread-safe in-memory cache backend." import time from contextlib import contextmanager from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache from django.utils.synch import RWLock try: from django.utils.six.moves import cPickle as pickle except ImportError: import pickle # Global in-memory store of cache data. Keyed by name, to provide # multiple named local memory caches. _caches = {} _expire_info = {} _locks = {} @contextmanager def dummy(): """A context manager that does nothing special.""" yield class LocMemCache(BaseCache): def __init__(self, name, params): BaseCache.__init__(self, params) self._cache = _caches.setdefault(name, {}) self._expire_info = _expire_info.setdefault(name, {}) self._lock = _locks.setdefault(name, RWLock()) def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): key = self.make_key(key, version=version) self.validate_key(key) pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) with self._lock.writer(): if self._has_expired(key): self._set(key, pickled, timeout) return True return False def get(self, key, default=None, version=None, acquire_lock=True): key = self.make_key(key, version=version) self.validate_key(key) pickled = None with (self._lock.reader() if acquire_lock else dummy()): if not self._has_expired(key): pickled = self._cache[key] if pickled is not None: try: return pickle.loads(pickled) except pickle.PickleError: return default with (self._lock.writer() if acquire_lock else dummy()): try: del self._cache[key] del self._expire_info[key] except KeyError: pass return default def _set(self, key, value, timeout=DEFAULT_TIMEOUT): if len(self._cache) >= self._max_entries: self._cull() self._cache[key] = value self._expire_info[key] = self.get_backend_timeout(timeout) def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): key = self.make_key(key, version=version) self.validate_key(key) pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) with self._lock.writer(): self._set(key, pickled, timeout) def incr(self, key, delta=1, version=None): with self._lock.writer(): value = self.get(key, version=version, acquire_lock=False) if value is None: raise ValueError("Key '%s' not found" % key) new_value = value + delta key = self.make_key(key, version=version) pickled = pickle.dumps(new_value, pickle.HIGHEST_PROTOCOL) self._cache[key] = pickled return new_value def has_key(self, key, version=None): key = self.make_key(key, version=version) self.validate_key(key) with self._lock.reader(): if not self._has_expired(key): return True with self._lock.writer(): try: del self._cache[key] del self._expire_info[key] except KeyError: pass return False def _has_expired(self, key): exp = self._expire_info.get(key, -1) if exp is None or exp > time.time(): return False return True def _cull(self): if self._cull_frequency == 0: self.clear() else: doomed = [k for (i, k) in enumerate(self._cache) if i % self._cull_frequency == 0] for k in doomed: self._delete(k) def _delete(self, key): try: del self._cache[key] except KeyError: pass try: del self._expire_info[key] except KeyError: pass def delete(self, key, version=None): key = self.make_key(key, version=version) self.validate_key(key) with self._lock.writer(): self._delete(key) def clear(self): self._cache.clear() self._expire_info.clear()
bsd-3-clause
[ 2, 4436, 13, 3489, 315, 13, 4844, 2581, 4865, 2122, 199, 199, 646, 900, 199, 504, 15502, 492, 27608, 199, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 1095, 492, 6186, 63, 8899, 12, 3523, 4437, 199, 504, 1639, 14, 1208, 14, 83, 5654, 492, 820, 55, 6432, 199, 199, 893, 26, 272, 687, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 17572, 465, 5927, 199, 2590, 3545, 26, 272, 492, 5927, 421, 199, 3, 13641, 315, 13, 4844, 3877, 402, 2581, 666, 14, 2606, 379, 701, 536, 12, 370, 5647, 199, 3, 3663, 4310, 2257, 4402, 18014, 14, 199, 63, 17595, 275, 1052, 199, 63, 14691, 63, 815, 275, 1052, 199, 63, 20218, 275, 1052, 421, 199, 32, 14237, 199, 318, 7283, 837, 272, 408, 33, 1067, 5256, 626, 1630, 6548, 4539, 1041, 272, 1995, 421, 199, 533, 6263, 14169, 4437, 8, 1563, 4437, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 1862, 304, 267, 3523, 4437, 855, 826, 721, 277, 12, 1862, 9, 267, 291, 423, 1637, 275, 485, 17595, 14, 5486, 8, 354, 12, 5009, 267, 291, 423, 14691, 63, 815, 275, 485, 14691, 63, 815, 14, 5486, 8, 354, 12, 5009, 267, 291, 423, 831, 275, 485, 20218, 14, 5486, 8, 354, 12, 820, 55, 6432, 1012, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 5927, 14, 4180, 8, 585, 12, 5927, 14, 31977, 63, 9583, 9, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 340, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 291, 423, 409, 8, 498, 12, 18731, 12, 2653, 9, 355, 372, 715, 288, 372, 756, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 12, 16919, 63, 831, 29, 549, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 488, 267, 543, 334, 277, 423, 831, 14, 5503, 342, 340, 16919, 63, 831, 587, 7283, 5109, 288, 340, 440, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 18731, 275, 291, 423, 1637, 59, 498, 61, 267, 340, 18731, 365, 440, 488, 26, 288, 862, 26, 355, 372, 5927, 14, 3640, 8, 20428, 9, 288, 871, 5927, 14, 12755, 547, 26, 355, 372, 849, 398, 543, 334, 277, 423, 831, 14, 5491, 342, 340, 16919, 63, 831, 587, 7283, 5109, 288, 862, 26, 355, 2150, 291, 423, 1637, 59, 498, 61, 355, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 288, 871, 4067, 26, 355, 986, 288, 372, 849, 339, 347, 485, 409, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 304, 267, 340, 822, 8, 277, 423, 1637, 9, 2356, 291, 423, 988, 63, 3189, 26, 288, 291, 423, 67, 979, 342, 267, 291, 423, 1637, 59, 498, 61, 275, 574, 267, 291, 423, 14691, 63, 815, 59, 498, 61, 275, 291, 14, 362, 63, 4620, 63, 2593, 8, 2593, 9, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 5927, 14, 4180, 8, 585, 12, 5927, 14, 31977, 63, 9583, 9, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 291, 423, 409, 8, 498, 12, 18731, 12, 2653, 9, 339, 347, 315, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 12, 1015, 29, 403, 304, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 574, 275, 291, 14, 362, 8, 498, 12, 1015, 29, 1023, 12, 16919, 63, 831, 29, 797, 9, 288, 340, 574, 365, 488, 26, 355, 746, 1722, 480, 1197, 1543, 83, 7, 440, 1911, 2, 450, 790, 9, 288, 892, 63, 585, 275, 574, 435, 5762, 288, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 288, 18731, 275, 5927, 14, 4180, 8, 1222, 63, 585, 12, 5927, 14, 31977, 63, 9583, 9, 288, 291, 423, 1637, 59, 498, 61, 275, 18731, 267, 372, 892, 63, 585, 339, 347, 965, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 543, 291, 423, 831, 14, 5503, 837, 288, 340, 440, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 372, 715, 398, 543, 291, 423, 831, 14, 5491, 837, 288, 862, 26, 355, 2150, 291, 423, 1637, 59, 498, 61, 355, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 288, 871, 4067, 26, 355, 986, 288, 372, 756, 339, 347, 485, 1989, 63, 16340, 8, 277, 12, 790, 304, 267, 1437, 275, 291, 423, 14691, 63, 815, 14, 362, 8, 498, 12, 446, 17, 9, 267, 340, 1437, 365, 488, 503, 1437, 690, 900, 14, 521, 837, 288, 372, 756, 267, 372, 715, 339, 347, 485, 67, 979, 8, 277, 304, 267, 340, 291, 423, 67, 979, 63, 11132, 508, 378, 26, 288, 291, 14, 3584, 342, 267, 587, 26, 288, 886, 1377, 68, 275, 359, 75, 367, 334, 73, 12, 1022, 9, 315, 3874, 8, 277, 423, 1637, 9, 340, 284, 450, 291, 423, 67, 979, 63, 11132, 508, 378, 61, 288, 367, 1022, 315, 886, 1377, 68, 26, 355, 291, 423, 1807, 8, 75, 9, 339, 347, 485, 1807, 8, 277, 12, 790, 304, 267, 862, 26, 288, 2150, 291, 423, 1637, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 267, 862, 26, 288, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14 ]
[ 4436, 13, 3489, 315, 13, 4844, 2581, 4865, 2122, 199, 199, 646, 900, 199, 504, 15502, 492, 27608, 199, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 1095, 492, 6186, 63, 8899, 12, 3523, 4437, 199, 504, 1639, 14, 1208, 14, 83, 5654, 492, 820, 55, 6432, 199, 199, 893, 26, 272, 687, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 17572, 465, 5927, 199, 2590, 3545, 26, 272, 492, 5927, 421, 199, 3, 13641, 315, 13, 4844, 3877, 402, 2581, 666, 14, 2606, 379, 701, 536, 12, 370, 5647, 199, 3, 3663, 4310, 2257, 4402, 18014, 14, 199, 63, 17595, 275, 1052, 199, 63, 14691, 63, 815, 275, 1052, 199, 63, 20218, 275, 1052, 421, 199, 32, 14237, 199, 318, 7283, 837, 272, 408, 33, 1067, 5256, 626, 1630, 6548, 4539, 1041, 272, 1995, 421, 199, 533, 6263, 14169, 4437, 8, 1563, 4437, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 1862, 304, 267, 3523, 4437, 855, 826, 721, 277, 12, 1862, 9, 267, 291, 423, 1637, 275, 485, 17595, 14, 5486, 8, 354, 12, 5009, 267, 291, 423, 14691, 63, 815, 275, 485, 14691, 63, 815, 14, 5486, 8, 354, 12, 5009, 267, 291, 423, 831, 275, 485, 20218, 14, 5486, 8, 354, 12, 820, 55, 6432, 1012, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 5927, 14, 4180, 8, 585, 12, 5927, 14, 31977, 63, 9583, 9, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 340, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 291, 423, 409, 8, 498, 12, 18731, 12, 2653, 9, 355, 372, 715, 288, 372, 756, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 12, 16919, 63, 831, 29, 549, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 488, 267, 543, 334, 277, 423, 831, 14, 5503, 342, 340, 16919, 63, 831, 587, 7283, 5109, 288, 340, 440, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 18731, 275, 291, 423, 1637, 59, 498, 61, 267, 340, 18731, 365, 440, 488, 26, 288, 862, 26, 355, 372, 5927, 14, 3640, 8, 20428, 9, 288, 871, 5927, 14, 12755, 547, 26, 355, 372, 849, 398, 543, 334, 277, 423, 831, 14, 5491, 342, 340, 16919, 63, 831, 587, 7283, 5109, 288, 862, 26, 355, 2150, 291, 423, 1637, 59, 498, 61, 355, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 288, 871, 4067, 26, 355, 986, 288, 372, 849, 339, 347, 485, 409, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 304, 267, 340, 822, 8, 277, 423, 1637, 9, 2356, 291, 423, 988, 63, 3189, 26, 288, 291, 423, 67, 979, 342, 267, 291, 423, 1637, 59, 498, 61, 275, 574, 267, 291, 423, 14691, 63, 815, 59, 498, 61, 275, 291, 14, 362, 63, 4620, 63, 2593, 8, 2593, 9, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 18731, 275, 5927, 14, 4180, 8, 585, 12, 5927, 14, 31977, 63, 9583, 9, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 291, 423, 409, 8, 498, 12, 18731, 12, 2653, 9, 339, 347, 315, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 12, 1015, 29, 403, 304, 267, 543, 291, 423, 831, 14, 5491, 837, 288, 574, 275, 291, 14, 362, 8, 498, 12, 1015, 29, 1023, 12, 16919, 63, 831, 29, 797, 9, 288, 340, 574, 365, 488, 26, 355, 746, 1722, 480, 1197, 1543, 83, 7, 440, 1911, 2, 450, 790, 9, 288, 892, 63, 585, 275, 574, 435, 5762, 288, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 288, 18731, 275, 5927, 14, 4180, 8, 1222, 63, 585, 12, 5927, 14, 31977, 63, 9583, 9, 288, 291, 423, 1637, 59, 498, 61, 275, 18731, 267, 372, 892, 63, 585, 339, 347, 965, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 3502, 63, 498, 8, 498, 9, 267, 543, 291, 423, 831, 14, 5503, 837, 288, 340, 440, 291, 423, 1989, 63, 16340, 8, 498, 304, 355, 372, 715, 398, 543, 291, 423, 831, 14, 5491, 837, 288, 862, 26, 355, 2150, 291, 423, 1637, 59, 498, 61, 355, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 288, 871, 4067, 26, 355, 986, 288, 372, 756, 339, 347, 485, 1989, 63, 16340, 8, 277, 12, 790, 304, 267, 1437, 275, 291, 423, 14691, 63, 815, 14, 362, 8, 498, 12, 446, 17, 9, 267, 340, 1437, 365, 488, 503, 1437, 690, 900, 14, 521, 837, 288, 372, 756, 267, 372, 715, 339, 347, 485, 67, 979, 8, 277, 304, 267, 340, 291, 423, 67, 979, 63, 11132, 508, 378, 26, 288, 291, 14, 3584, 342, 267, 587, 26, 288, 886, 1377, 68, 275, 359, 75, 367, 334, 73, 12, 1022, 9, 315, 3874, 8, 277, 423, 1637, 9, 340, 284, 450, 291, 423, 67, 979, 63, 11132, 508, 378, 61, 288, 367, 1022, 315, 886, 1377, 68, 26, 355, 291, 423, 1807, 8, 75, 9, 339, 347, 485, 1807, 8, 277, 12, 790, 304, 267, 862, 26, 288, 2150, 291, 423, 1637, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 267, 862, 26, 288, 2150, 291, 423, 14691, 63, 815, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 790, 275, 291, 14, 1875, 63, 498, 8, 498, 12, 1015, 29, 1023, 9, 267, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shayanb/pycoin
pycoin/encoding.py
14
10776
# -*- coding: utf-8 -*- """ Various utilities useful for converting one Bitcoin format to another, including some the human-transcribable format hashed_base58. The MIT License (MIT) Copyright (c) 2013 by Richard Kiss 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. """ import hashlib from .intbytes import byte_to_int, bytes_from_int BASE58_ALPHABET = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' BASE58_BASE = len(BASE58_ALPHABET) BASE58_LOOKUP = dict((c, i) for i, c in enumerate(BASE58_ALPHABET)) class EncodingError(Exception): pass def ripemd160(data): return hashlib.new("ripemd160", data) try: ripemd160(b'').digest() except Exception: # stupid Google App Engine hashlib doesn't support ripemd160 for some stupid reason # import it from pycrypto. You need to add # - name: pycrypto # version: "latest" # to the "libraries" section of your app.yaml from Crypto.Hash.RIPEMD import RIPEMD160Hash as ripemd160 def to_long(base, lookup_f, s): """ Convert an array to a (possibly bignum) integer, along with a prefix value of how many prefixed zeros there are. base: the source base lookup_f: a function to convert an element of s to a value between 0 and base-1. s: the value to convert """ prefix = 0 v = 0 for c in s: v *= base try: v += lookup_f(c) except Exception: raise EncodingError("bad character %s in string %s" % (c, s)) if v == 0: prefix += 1 return v, prefix def from_long(v, prefix, base, charset): """The inverse of to_long. Convert an integer to an arbitrary base. v: the integer value to convert prefix: the number of prefixed 0s to include base: the new base charset: an array indicating what printable character to use for each value. """ l = bytearray() while v > 0: try: v, mod = divmod(v, base) l.append(charset(mod)) except Exception: raise EncodingError("can't convert to character corresponding to %d" % mod) l.extend([charset(0)] * prefix) l.reverse() return bytes(l) def to_bytes_32(v): v = from_long(v, 0, 256, lambda x: x) if len(v) > 32: raise ValueError("input to to_bytes_32 is too large") return ((b'\0' * 32) + v)[-32:] if hasattr(int, "to_bytes"): to_bytes_32 = lambda v: v.to_bytes(32, byteorder="big") def from_bytes_32(v): if len(v) != 32: raise ValueError("input to from_bytes_32 is wrong length") return to_long(256, byte_to_int, v)[0] if hasattr(int, "from_bytes"): from_bytes_32 = lambda v: int.from_bytes(v, byteorder="big") def double_sha256(data): """A standard compound hash.""" return hashlib.sha256(hashlib.sha256(data).digest()).digest() def hash160(data): """A standard compound hash.""" return ripemd160(hashlib.sha256(data).digest()).digest() def b2a_base58(s): """Convert binary to base58 using BASE58_ALPHABET. Like Bitcoin addresses.""" v, prefix = to_long(256, byte_to_int, s) s = from_long(v, prefix, BASE58_BASE, lambda v: BASE58_ALPHABET[v]) return s.decode("utf8") def a2b_base58(s): """Convert base58 to binary using BASE58_ALPHABET.""" v, prefix = to_long(BASE58_BASE, lambda c: BASE58_LOOKUP[c], s.encode("utf8")) return from_long(v, prefix, 256, lambda x: x) def b2a_hashed_base58(data): """ A "hashed_base58" structure is a base58 integer (which looks like a string) with four bytes of hash data at the end. Bitcoin does this in several places, including Bitcoin addresses. This function turns data (of type "bytes") into its hashed_base58 equivalent. """ return b2a_base58(data + double_sha256(data)[:4]) def a2b_hashed_base58(s): """ If the passed string is hashed_base58, return the binary data. Otherwise raises an EncodingError. """ data = a2b_base58(s) data, the_hash = data[:-4], data[-4:] if double_sha256(data)[:4] == the_hash: return data raise EncodingError("hashed base58 has bad checksum %s" % s) def is_hashed_base58_valid(base58): """Return True if and only if base58 is valid hashed_base58.""" try: a2b_hashed_base58(base58) except EncodingError: return False return True def wif_to_tuple_of_prefix_secret_exponent_compressed(wif): """ Return a tuple of (prefix, secret_exponent, is_compressed). """ decoded = a2b_hashed_base58(wif) actual_prefix, private_key = decoded[:1], decoded[1:] compressed = len(private_key) > 32 return actual_prefix, from_bytes_32(private_key[:32]), compressed def wif_to_tuple_of_secret_exponent_compressed(wif, allowable_wif_prefixes=[b'\x80']): """Convert a WIF string to the corresponding secret exponent. Private key manipulation. Returns a tuple: the secret exponent, as a bignum integer, and a boolean indicating if the WIF corresponded to a compressed key or not. Not that it matters, since we can use the secret exponent to generate both the compressed and uncompressed Bitcoin address.""" actual_prefix, secret_exponent, is_compressed = wif_to_tuple_of_prefix_secret_exponent_compressed(wif) if actual_prefix not in allowable_wif_prefixes: raise EncodingError("unexpected first byte of WIF %s" % wif) return secret_exponent, is_compressed def wif_to_secret_exponent(wif, allowable_wif_prefixes=[b'\x80']): """Convert a WIF string to the corresponding secret exponent.""" return wif_to_tuple_of_secret_exponent_compressed(wif, allowable_wif_prefixes=allowable_wif_prefixes)[0] def is_valid_wif(wif, allowable_wif_prefixes=[b'\x80']): """Return a boolean indicating if the WIF is valid.""" try: wif_to_secret_exponent(wif, allowable_wif_prefixes=allowable_wif_prefixes) except EncodingError: return False return True def secret_exponent_to_wif(secret_exp, compressed=True, wif_prefix=b'\x80'): """Convert a secret exponent (correspdong to a private key) to WIF format.""" d = wif_prefix + to_bytes_32(secret_exp) if compressed: d += b'\01' return b2a_hashed_base58(d) def public_pair_to_sec(public_pair, compressed=True): """Convert a public pair (a pair of bignums corresponding to a public key) to the gross internal sec binary format used by OpenSSL.""" x_str = to_bytes_32(public_pair[0]) if compressed: return bytes_from_int((2 + (public_pair[1] & 1))) + x_str y_str = to_bytes_32(public_pair[1]) return b'\4' + x_str + y_str def sec_to_public_pair(sec): """Convert a public key in sec binary format to a public pair.""" x = from_bytes_32(sec[1:33]) sec0 = sec[:1] if sec0 == b'\4': y = from_bytes_32(sec[33:65]) from .ecdsa import generator_secp256k1, is_public_pair_valid public_pair = (x, y) # verify this is on the curve if not is_public_pair_valid(generator_secp256k1, public_pair): raise EncodingError("invalid (x, y) pair") return public_pair if sec0 in (b'\2', b'\3'): from .ecdsa import public_pair_for_x, generator_secp256k1 return public_pair_for_x(generator_secp256k1, x, is_even=(sec0 == b'\2')) raise EncodingError("bad sec encoding for public key") def is_sec_compressed(sec): """Return a boolean indicating if the sec represents a compressed public key.""" return sec[:1] in (b'\2', b'\3') def public_pair_to_hash160_sec(public_pair, compressed=True): """Convert a public_pair (corresponding to a public key) to hash160_sec format. This is a hash of the sec representation of a public key, and is used to generate the corresponding Bitcoin address.""" return hash160(public_pair_to_sec(public_pair, compressed=compressed)) def hash160_sec_to_bitcoin_address(hash160_sec, address_prefix=b'\0'): """Convert the hash160 of a sec version of a public_pair to a Bitcoin address.""" return b2a_hashed_base58(address_prefix + hash160_sec) def bitcoin_address_to_hash160_sec_with_prefix(bitcoin_address): """ Convert a Bitcoin address back to the hash160_sec format and also return the prefix. """ blob = a2b_hashed_base58(bitcoin_address) if len(blob) != 21: raise EncodingError("incorrect binary length (%d) for Bitcoin address %s" % (len(blob), bitcoin_address)) if blob[:1] not in [b'\x6f', b'\0']: raise EncodingError("incorrect first byte (%s) for Bitcoin address %s" % (blob[0], bitcoin_address)) return blob[1:], blob[:1] def bitcoin_address_to_hash160_sec(bitcoin_address, address_prefix=b'\0'): """Convert a Bitcoin address back to the hash160_sec format of the public key. Since we only know the hash of the public key, we can't get the full public key back.""" hash160, actual_prefix = bitcoin_address_to_hash160_sec_with_prefix(bitcoin_address) if (address_prefix == actual_prefix): return hash160 raise EncodingError("Bitcoin address %s for wrong network" % bitcoin_address) def public_pair_to_bitcoin_address(public_pair, compressed=True, address_prefix=b'\0'): """Convert a public_pair (corresponding to a public key) to a Bitcoin address.""" return hash160_sec_to_bitcoin_address(public_pair_to_hash160_sec( public_pair, compressed=compressed), address_prefix=address_prefix) def is_valid_bitcoin_address(bitcoin_address, allowable_prefixes=b'\0'): """Return True if and only if bitcoin_address is valid.""" try: hash160, prefix = bitcoin_address_to_hash160_sec_with_prefix(bitcoin_address) except EncodingError: return False return prefix in allowable_prefixes
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 9958, 1785, 15841, 2997, 367, 13806, 1373, 21158, 1475, 370, 4573, 12, 5893, 2005, 199, 1589, 11779, 13, 3936, 729, 66, 461, 1475, 19871, 63, 1095, 2010, 14, 421, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6171, 701, 30846, 1005, 1804, 19857, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 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, 1549, 199, 8947, 5177, 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, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 18061, 4141, 14, 199, 624, 199, 199, 646, 8337, 199, 199, 504, 1275, 442, 2394, 492, 3696, 63, 475, 63, 442, 12, 2783, 63, 504, 63, 442, 421, 199, 5825, 2010, 63, 748, 9791, 1217, 775, 275, 330, 7, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 5825, 2010, 63, 5825, 275, 822, 8, 5825, 2010, 63, 748, 9791, 1217, 775, 9, 199, 5825, 2010, 63, 29149, 275, 1211, 1332, 67, 12, 284, 9, 367, 284, 12, 286, 315, 3874, 8, 5825, 2010, 63, 748, 9791, 1217, 775, 430, 421, 199, 533, 19694, 547, 8, 1726, 304, 272, 986, 421, 199, 318, 8012, 321, 1064, 8488, 8, 576, 304, 272, 372, 8337, 14, 1222, 480, 322, 321, 1064, 8488, 401, 666, 9, 199, 199, 893, 26, 272, 8012, 321, 1064, 8488, 8, 66, 7, 1959, 5671, 342, 199, 2590, 2186, 26, 272, 327, 410, 31596, 4475, 4693, 12580, 8337, 3181, 1133, 2291, 8012, 321, 1064, 8488, 367, 2005, 410, 31596, 4499, 272, 327, 492, 652, 687, 1134, 10316, 14, 2047, 1929, 370, 1050, 272, 327, 446, 536, 26, 1134, 10316, 272, 327, 257, 1015, 26, 298, 7410, 2, 272, 327, 370, 314, 298, 10159, 2, 3420, 402, 2195, 1145, 14, 5963, 272, 687, 18855, 14, 3476, 14, 6129, 1510, 5127, 492, 820, 41, 1510, 5127, 8488, 3476, 465, 8012, 321, 1064, 8488, 421, 199, 318, 370, 63, 2809, 8, 1095, 12, 4237, 63, 70, 12, 308, 304, 272, 408, 272, 7905, 376, 1625, 370, 282, 334, 19614, 330, 1030, 453, 9, 3000, 12, 3180, 543, 282, 2403, 574, 272, 402, 4212, 5002, 18239, 10136, 2337, 787, 14, 339, 1300, 26, 267, 314, 1350, 1300, 272, 4237, 63, 70, 26, 267, 282, 805, 370, 3957, 376, 1819, 402, 308, 370, 282, 574, 3382, 378, 436, 1300, 13, 17, 14, 272, 308, 26, 267, 314, 574, 370, 3957, 272, 408, 272, 2403, 275, 378, 272, 373, 275, 378, 272, 367, 286, 315, 308, 26, 267, 373, 9000, 1300, 267, 862, 26, 288, 373, 847, 4237, 63, 70, 8, 67, 9, 267, 871, 2186, 26, 288, 746, 19694, 547, 480, 4087, 4528, 450, 83, 315, 1059, 450, 83, 2, 450, 334, 67, 12, 308, 430, 267, 340, 373, 508, 378, 26, 288, 2403, 847, 413, 272, 372, 373, 12, 2403, 421, 199, 318, 687, 63, 2809, 8, 86, 12, 2403, 12, 1300, 12, 5960, 304, 272, 408, 1918, 11484, 402, 370, 63, 2809, 14, 7905, 376, 3000, 370, 376, 9697, 1300, 14, 339, 373, 26, 314, 3000, 574, 370, 3957, 272, 2403, 26, 314, 1329, 402, 18239, 378, 83, 370, 2387, 272, 1300, 26, 314, 892, 1300, 272, 5960, 26, 376, 1625, 9297, 4052, 21834, 4528, 370, 675, 367, 1924, 574, 14, 272, 408, 272, 634, 275, 11640, 342, 272, 1830, 373, 690, 378, 26, 267, 862, 26, 288, 373, 12, 3413, 275, 16438, 8, 86, 12, 1300, 9, 288, 634, 14, 740, 8, 6043, 8, 1494, 430, 267, 871, 2186, 26, 288, 746, 19694, 547, 480, 2425, 1133, 3957, 370, 4528, 5226, 370, 450, 68, 2, 450, 3413, 9, 272, 634, 14, 2880, 779, 6043, 8, 16, 1874, 627, 2403, 9, 272, 634, 14, 4471, 342, 272, 372, 2783, 8, 76, 9, 421, 199, 318, 370, 63, 2394, 63, 708, 8, 86, 304, 272, 373, 275, 687, 63, 2809, 8, 86, 12, 378, 12, 7633, 12, 2400, 671, 26, 671, 9, 272, 340, 822, 8, 86, 9, 690, 4337, 26, 267, 746, 1722, 480, 1210, 370, 370, 63, 2394, 63, 708, 365, 4634, 7031, 531, 272, 372, 3666, 66, 1154, 16, 7, 627, 4337, 9, 435, 373, 15786, 708, 2938, 199, 199, 692, 2688, 8, 442, 12, 298, 475, 63, 2394, 2349, 272, 370, 63, 2394, 63, 708, 275, 2400, 373, 26, 373, 14, 475, 63, 2394, 8, 708, 12, 30310, 628, 5076, 531, 421, 199, 318, 687, 63, 2394, 63, 708, 8, 86, 304, 272, 340, 822, 8, 86, 9, 1137, 4337, 26, 267, 746, 1722, 480, 1210, 370, 687, 63, 2394, 63, 708, 365, 6835, 2582, 531, 272, 372, 370, 63, 2809, 8, 3912, 12, 3696, 63, 475, 63, 442, 12, 373, 2788, 16, 61, 199, 199, 692, 2688, 8, 442, 12, 298, 504, 63, 2394, 2349, 272, 687, 63, 2394, 63, 708, 275, 2400, 373, 26, 1109, 14, 504, 63, 2394, 8, 86, 12, 30310, 628, 5076, 531, 421, 199, 318, 4270, 63, 4835, 3912, 8, 576, 304, 272, 408, 33, 4465, 16487, 2631, 1041, 272, 372, 8337, 14, 4835, 3912, 8, 24722, 14, 4835, 3912 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 9958, 1785, 15841, 2997, 367, 13806, 1373, 21158, 1475, 370, 4573, 12, 5893, 2005, 199, 1589, 11779, 13, 3936, 729, 66, 461, 1475, 19871, 63, 1095, 2010, 14, 421, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6171, 701, 30846, 1005, 1804, 19857, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 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, 1549, 199, 8947, 5177, 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, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 18061, 4141, 14, 199, 624, 199, 199, 646, 8337, 199, 199, 504, 1275, 442, 2394, 492, 3696, 63, 475, 63, 442, 12, 2783, 63, 504, 63, 442, 421, 199, 5825, 2010, 63, 748, 9791, 1217, 775, 275, 330, 7, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 5825, 2010, 63, 5825, 275, 822, 8, 5825, 2010, 63, 748, 9791, 1217, 775, 9, 199, 5825, 2010, 63, 29149, 275, 1211, 1332, 67, 12, 284, 9, 367, 284, 12, 286, 315, 3874, 8, 5825, 2010, 63, 748, 9791, 1217, 775, 430, 421, 199, 533, 19694, 547, 8, 1726, 304, 272, 986, 421, 199, 318, 8012, 321, 1064, 8488, 8, 576, 304, 272, 372, 8337, 14, 1222, 480, 322, 321, 1064, 8488, 401, 666, 9, 199, 199, 893, 26, 272, 8012, 321, 1064, 8488, 8, 66, 7, 1959, 5671, 342, 199, 2590, 2186, 26, 272, 327, 410, 31596, 4475, 4693, 12580, 8337, 3181, 1133, 2291, 8012, 321, 1064, 8488, 367, 2005, 410, 31596, 4499, 272, 327, 492, 652, 687, 1134, 10316, 14, 2047, 1929, 370, 1050, 272, 327, 446, 536, 26, 1134, 10316, 272, 327, 257, 1015, 26, 298, 7410, 2, 272, 327, 370, 314, 298, 10159, 2, 3420, 402, 2195, 1145, 14, 5963, 272, 687, 18855, 14, 3476, 14, 6129, 1510, 5127, 492, 820, 41, 1510, 5127, 8488, 3476, 465, 8012, 321, 1064, 8488, 421, 199, 318, 370, 63, 2809, 8, 1095, 12, 4237, 63, 70, 12, 308, 304, 272, 408, 272, 7905, 376, 1625, 370, 282, 334, 19614, 330, 1030, 453, 9, 3000, 12, 3180, 543, 282, 2403, 574, 272, 402, 4212, 5002, 18239, 10136, 2337, 787, 14, 339, 1300, 26, 267, 314, 1350, 1300, 272, 4237, 63, 70, 26, 267, 282, 805, 370, 3957, 376, 1819, 402, 308, 370, 282, 574, 3382, 378, 436, 1300, 13, 17, 14, 272, 308, 26, 267, 314, 574, 370, 3957, 272, 408, 272, 2403, 275, 378, 272, 373, 275, 378, 272, 367, 286, 315, 308, 26, 267, 373, 9000, 1300, 267, 862, 26, 288, 373, 847, 4237, 63, 70, 8, 67, 9, 267, 871, 2186, 26, 288, 746, 19694, 547, 480, 4087, 4528, 450, 83, 315, 1059, 450, 83, 2, 450, 334, 67, 12, 308, 430, 267, 340, 373, 508, 378, 26, 288, 2403, 847, 413, 272, 372, 373, 12, 2403, 421, 199, 318, 687, 63, 2809, 8, 86, 12, 2403, 12, 1300, 12, 5960, 304, 272, 408, 1918, 11484, 402, 370, 63, 2809, 14, 7905, 376, 3000, 370, 376, 9697, 1300, 14, 339, 373, 26, 314, 3000, 574, 370, 3957, 272, 2403, 26, 314, 1329, 402, 18239, 378, 83, 370, 2387, 272, 1300, 26, 314, 892, 1300, 272, 5960, 26, 376, 1625, 9297, 4052, 21834, 4528, 370, 675, 367, 1924, 574, 14, 272, 408, 272, 634, 275, 11640, 342, 272, 1830, 373, 690, 378, 26, 267, 862, 26, 288, 373, 12, 3413, 275, 16438, 8, 86, 12, 1300, 9, 288, 634, 14, 740, 8, 6043, 8, 1494, 430, 267, 871, 2186, 26, 288, 746, 19694, 547, 480, 2425, 1133, 3957, 370, 4528, 5226, 370, 450, 68, 2, 450, 3413, 9, 272, 634, 14, 2880, 779, 6043, 8, 16, 1874, 627, 2403, 9, 272, 634, 14, 4471, 342, 272, 372, 2783, 8, 76, 9, 421, 199, 318, 370, 63, 2394, 63, 708, 8, 86, 304, 272, 373, 275, 687, 63, 2809, 8, 86, 12, 378, 12, 7633, 12, 2400, 671, 26, 671, 9, 272, 340, 822, 8, 86, 9, 690, 4337, 26, 267, 746, 1722, 480, 1210, 370, 370, 63, 2394, 63, 708, 365, 4634, 7031, 531, 272, 372, 3666, 66, 1154, 16, 7, 627, 4337, 9, 435, 373, 15786, 708, 2938, 199, 199, 692, 2688, 8, 442, 12, 298, 475, 63, 2394, 2349, 272, 370, 63, 2394, 63, 708, 275, 2400, 373, 26, 373, 14, 475, 63, 2394, 8, 708, 12, 30310, 628, 5076, 531, 421, 199, 318, 687, 63, 2394, 63, 708, 8, 86, 304, 272, 340, 822, 8, 86, 9, 1137, 4337, 26, 267, 746, 1722, 480, 1210, 370, 687, 63, 2394, 63, 708, 365, 6835, 2582, 531, 272, 372, 370, 63, 2809, 8, 3912, 12, 3696, 63, 475, 63, 442, 12, 373, 2788, 16, 61, 199, 199, 692, 2688, 8, 442, 12, 298, 504, 63, 2394, 2349, 272, 687, 63, 2394, 63, 708, 275, 2400, 373, 26, 1109, 14, 504, 63, 2394, 8, 86, 12, 30310, 628, 5076, 531, 421, 199, 318, 4270, 63, 4835, 3912, 8, 576, 304, 272, 408, 33, 4465, 16487, 2631, 1041, 272, 372, 8337, 14, 4835, 3912, 8, 24722, 14, 4835, 3912, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rcarrillocruz/ansible
lib/ansible/modules/files/tempfile.py
17
3614
#!/usr/bin/python #coding: utf-8 -*- # (c) 2016 Krzysztof Magosa <krzysztof@magosa.pl> # # 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: tempfile version_added: "2.3" author: - Krzysztof Magosa short_description: Creates temporary files and directories. description: - The C(tempfile) module creates temporary files and directories. C(mktemp) command takes different parameters on various systems, this module helps to avoid troubles related to that. Files/directories created by module are accessible only by creator. In case you need to make them world-accessible you need to use M(file) module. - For Windows targets, use the M(win_tempfile) module instead. options: state: description: - Whether to create file or directory. required: false choices: [ "file", "directory" ] default: file path: description: - Location where temporary file or directory should be created. If path is not specified default system temporary directory will be used. required: false default: null prefix: description: - Prefix of file/directory name created by module. required: false default: ansible. suffix: description: - Suffix of file/directory name created by module. required: false default: "" notes: - For Windows targets, use the M(win_tempfile) module instead. ''' EXAMPLES = """ - name: create temporary build directory tempfile: state: directory suffix: build - name: create temporary file tempfile: state: file suffix: temp """ RETURN = ''' path: description: Path to created file or directory returned: success type: string sample: "/tmp/ansible.bMlvdk" ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception from tempfile import mkstemp, mkdtemp from os import close def main(): module = AnsibleModule( argument_spec = dict( state = dict(default='file', choices=['file', 'directory']), path = dict(default=None), prefix = dict(default='ansible.'), suffix = dict(default='') ) ) try: if module.params['state'] == 'file': handle, path = mkstemp( prefix=module.params['prefix'], suffix=module.params['suffix'], dir=module.params['path'] ) close(handle) elif module.params['state'] == 'directory': path = mkdtemp( prefix=module.params['prefix'], suffix=module.params['suffix'], dir=module.params['path'] ) module.exit_json(changed=True, path=path) except Exception: e = get_exception() module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1523, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 1804, 30841, 588, 90, 31630, 603, 643, 29295, 665, 16779, 90, 588, 90, 31630, 32, 5615, 29295, 14, 1168, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 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, 5549, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 523, 446, 1804, 30841, 588, 90, 31630, 603, 643, 29295, 199, 3612, 63, 1802, 26, 10560, 7937, 1584, 436, 6602, 14, 199, 1802, 26, 523, 446, 710, 445, 8, 17336, 9, 859, 8491, 7937, 1584, 436, 6602, 14, 445, 8, 22136, 9, 1414, 6181, 3365, 2633, 641, 7750, 10460, 12, 642, 859, 22577, 272, 370, 5126, 29616, 83, 4048, 370, 626, 14, 16920, 15, 12629, 2737, 701, 859, 787, 17909, 1454, 701, 14875, 14, 1010, 1930, 1265, 1929, 370, 1852, 3062, 6701, 13, 24669, 272, 1265, 1929, 370, 675, 603, 8, 493, 9, 859, 14, 523, 446, 2104, 5417, 4545, 12, 675, 314, 603, 8, 2676, 63, 17336, 9, 859, 3140, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 370, 1218, 570, 503, 2082, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 493, 401, 298, 3619, 2, 1622, 272, 849, 26, 570, 523, 931, 26, 272, 1369, 26, 489, 446, 12625, 2382, 7937, 570, 503, 2082, 1077, 506, 2737, 14, 982, 931, 365, 440, 2013, 849, 2656, 7937, 2082, 911, 506, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2403, 26, 272, 1369, 26, 489, 446, 25110, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 1415, 26, 3055, 272, 849, 26, 3242, 14, 523, 4739, 26, 272, 1369, 26, 489, 446, 428, 2875, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 1415, 26, 3055, 272, 849, 26, 3087, 199, 5983, 26, 523, 446, 2104, 5417, 4545, 12, 675, 314, 603, 8, 2676, 63, 17336, 9, 859, 3140, 14, 199, 2344, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 1218, 7937, 1900, 2082, 523, 5549, 26, 272, 1174, 26, 2082, 272, 4739, 26, 1900, 199, 199, 13, 536, 26, 1218, 7937, 570, 523, 5549, 26, 272, 1174, 26, 570, 272, 4739, 26, 2388, 199, 624, 199, 199, 9677, 275, 1449, 199, 515, 26, 523, 1369, 26, 6912, 370, 2737, 570, 503, 2082, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 3286, 2791, 15, 4853, 14, 66, 45, 6371, 6341, 2, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 5549, 492, 333, 6080, 808, 12, 31781, 199, 504, 747, 492, 4002, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 1174, 258, 275, 1211, 8, 885, 534, 493, 297, 3415, 2968, 493, 297, 283, 3619, 3815, 288, 931, 420, 275, 1211, 8, 885, 29, 403, 395, 288, 2403, 259, 275, 1211, 8, 885, 534, 4853, 8038, 288, 4739, 259, 275, 1211, 8, 885, 13275, 267, 776, 272, 776, 339, 862, 26, 267, 340, 859, 14, 1162, 459, 929, 418, 508, 283, 493, 356, 288, 2429, 12, 931, 275, 333, 6080, 808, 8, 355, 2403, 29, 578, 14, 1162, 459, 1861, 995, 355, 4739, 29, 578, 14, 1162, 459, 4511, 995, 355, 2935, 29, 578, 14, 1162, 459, 515, 418, 288, 776, 288, 4002, 8, 2479, 9, 267, 916, 859, 14, 1162, 459, 929, 418, 508, 283, 3619, 356, 288, 931, 275, 31781, 8, 355, 2403, 29, 578, 14, 1162, 459, 1861, 995, 355, 4739, 29, 578, 14, 1162, 459, 4511, 995, 355, 2935, 29, 578, 14, 1162, 459, 515, 418, 288, 776, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 931, 29, 515, 9, 272, 871, 2186, 26, 267, 325, 275, 664, 63, 1971, 342, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 199, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1523, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 1804, 30841, 588, 90, 31630, 603, 643, 29295, 665, 16779, 90, 588, 90, 31630, 32, 5615, 29295, 14, 1168, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 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, 5549, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 523, 446, 1804, 30841, 588, 90, 31630, 603, 643, 29295, 199, 3612, 63, 1802, 26, 10560, 7937, 1584, 436, 6602, 14, 199, 1802, 26, 523, 446, 710, 445, 8, 17336, 9, 859, 8491, 7937, 1584, 436, 6602, 14, 445, 8, 22136, 9, 1414, 6181, 3365, 2633, 641, 7750, 10460, 12, 642, 859, 22577, 272, 370, 5126, 29616, 83, 4048, 370, 626, 14, 16920, 15, 12629, 2737, 701, 859, 787, 17909, 1454, 701, 14875, 14, 1010, 1930, 1265, 1929, 370, 1852, 3062, 6701, 13, 24669, 272, 1265, 1929, 370, 675, 603, 8, 493, 9, 859, 14, 523, 446, 2104, 5417, 4545, 12, 675, 314, 603, 8, 2676, 63, 17336, 9, 859, 3140, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 370, 1218, 570, 503, 2082, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 493, 401, 298, 3619, 2, 1622, 272, 849, 26, 570, 523, 931, 26, 272, 1369, 26, 489, 446, 12625, 2382, 7937, 570, 503, 2082, 1077, 506, 2737, 14, 982, 931, 365, 440, 2013, 849, 2656, 7937, 2082, 911, 506, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2403, 26, 272, 1369, 26, 489, 446, 25110, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 1415, 26, 3055, 272, 849, 26, 3242, 14, 523, 4739, 26, 272, 1369, 26, 489, 446, 428, 2875, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 1415, 26, 3055, 272, 849, 26, 3087, 199, 5983, 26, 523, 446, 2104, 5417, 4545, 12, 675, 314, 603, 8, 2676, 63, 17336, 9, 859, 3140, 14, 199, 2344, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 1218, 7937, 1900, 2082, 523, 5549, 26, 272, 1174, 26, 2082, 272, 4739, 26, 1900, 199, 199, 13, 536, 26, 1218, 7937, 570, 523, 5549, 26, 272, 1174, 26, 570, 272, 4739, 26, 2388, 199, 624, 199, 199, 9677, 275, 1449, 199, 515, 26, 523, 1369, 26, 6912, 370, 2737, 570, 503, 2082, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 3286, 2791, 15, 4853, 14, 66, 45, 6371, 6341, 2, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 5549, 492, 333, 6080, 808, 12, 31781, 199, 504, 747, 492, 4002, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 1174, 258, 275, 1211, 8, 885, 534, 493, 297, 3415, 2968, 493, 297, 283, 3619, 3815, 288, 931, 420, 275, 1211, 8, 885, 29, 403, 395, 288, 2403, 259, 275, 1211, 8, 885, 534, 4853, 8038, 288, 4739, 259, 275, 1211, 8, 885, 13275, 267, 776, 272, 776, 339, 862, 26, 267, 340, 859, 14, 1162, 459, 929, 418, 508, 283, 493, 356, 288, 2429, 12, 931, 275, 333, 6080, 808, 8, 355, 2403, 29, 578, 14, 1162, 459, 1861, 995, 355, 4739, 29, 578, 14, 1162, 459, 4511, 995, 355, 2935, 29, 578, 14, 1162, 459, 515, 418, 288, 776, 288, 4002, 8, 2479, 9, 267, 916, 859, 14, 1162, 459, 929, 418, 508, 283, 3619, 356, 288, 931, 275, 31781, 8, 355, 2403, 29, 578, 14, 1162, 459, 1861, 995, 355, 4739, 29, 578, 14, 1162, 459, 4511, 995, 355, 2935, 29, 578, 14, 1162, 459, 515, 418, 288, 776, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 931, 29, 515, 9, 272, 871, 2186, 26, 267, 325, 275, 664, 63, 1971, 342, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ronasimi/aosp-kernel_lge_geeb
tools/perf/python/twatch.py
7370
1334
#! /usr/bin/python # -*- python -*- # -*- coding: utf-8 -*- # twatch - Experimental use of the perf python interface # Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com> # # This application 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; version 2. # # This application 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. import perf def main(): cpus = perf.cpu_map() threads = perf.thread_map() evsel = perf.evsel(task = 1, comm = 1, mmap = 0, wakeup_events = 1, watermark = 1, sample_id_all = 1, sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID) evsel.open(cpus = cpus, threads = threads); evlist = perf.evlist(cpus, threads) evlist.add(evsel) evlist.mmap() while True: evlist.poll(timeout = -1) for cpu in cpus: event = evlist.read_on_cpu(cpu) if not event: continue print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu, event.sample_pid, event.sample_tid), print event if __name__ == '__main__': main()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 307, 6821, 446, 23997, 279, 675, 402, 314, 8582, 2366, 3217, 199, 3, 257, 1898, 334, 35, 9, 7760, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 257, 961, 4223, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 257, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 14, 199, 3, 199, 3, 257, 961, 4223, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 257, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 646, 8582, 199, 199, 318, 2446, 837, 199, 198, 8896, 275, 8582, 14, 3541, 63, 1130, 342, 199, 198, 6962, 275, 8582, 14, 2671, 63, 1130, 342, 199, 198, 6857, 5891, 275, 8582, 14, 6857, 5891, 8, 1765, 275, 413, 12, 1923, 275, 413, 12, 21991, 275, 378, 12, 1585, 257, 21560, 384, 63, 4368, 275, 413, 12, 22834, 1657, 275, 413, 12, 1585, 257, 2690, 63, 344, 63, 452, 275, 413, 12, 1585, 257, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 52, 998, 9, 199, 198, 6857, 5891, 14, 1490, 8, 8896, 275, 24174, 12, 7183, 275, 7183, 2736, 199, 198, 6857, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 199, 198, 6857, 513, 14, 525, 8, 6857, 5891, 9, 199, 198, 6857, 513, 14, 20671, 342, 199, 198, 6710, 715, 26, 507, 198, 6857, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 507, 198, 509, 5033, 315, 24174, 26, 686, 198, 1430, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 686, 198, 692, 440, 1566, 26, 1585, 198, 6958, 686, 198, 1361, 298, 3541, 26, 450, 18, 68, 12, 4422, 26, 450, 20, 68, 12, 11559, 26, 450, 20, 68, 2, 450, 334, 1430, 14, 3271, 63, 3541, 12, 11674, 198, 1430, 14, 3271, 63, 3150, 12, 11674, 198, 1430, 14, 3271, 63, 5700, 395, 686, 198, 1361, 1566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 307, 6821, 446, 23997, 279, 675, 402, 314, 8582, 2366, 3217, 199, 3, 257, 1898, 334, 35, 9, 7760, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 257, 961, 4223, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 257, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 14, 199, 3, 199, 3, 257, 961, 4223, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 257, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 646, 8582, 199, 199, 318, 2446, 837, 199, 198, 8896, 275, 8582, 14, 3541, 63, 1130, 342, 199, 198, 6962, 275, 8582, 14, 2671, 63, 1130, 342, 199, 198, 6857, 5891, 275, 8582, 14, 6857, 5891, 8, 1765, 275, 413, 12, 1923, 275, 413, 12, 21991, 275, 378, 12, 1585, 257, 21560, 384, 63, 4368, 275, 413, 12, 22834, 1657, 275, 413, 12, 1585, 257, 2690, 63, 344, 63, 452, 275, 413, 12, 1585, 257, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 52, 998, 9, 199, 198, 6857, 5891, 14, 1490, 8, 8896, 275, 24174, 12, 7183, 275, 7183, 2736, 199, 198, 6857, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 199, 198, 6857, 513, 14, 525, 8, 6857, 5891, 9, 199, 198, 6857, 513, 14, 20671, 342, 199, 198, 6710, 715, 26, 507, 198, 6857, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 507, 198, 509, 5033, 315, 24174, 26, 686, 198, 1430, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 686, 198, 692, 440, 1566, 26, 1585, 198, 6958, 686, 198, 1361, 298, 3541, 26, 450, 18, 68, 12, 4422, 26, 450, 20, 68, 12, 11559, 26, 450, 20, 68, 2, 450, 334, 1430, 14, 3271, 63, 3541, 12, 11674, 198, 1430, 14, 3271, 63, 3150, 12, 11674, 198, 1430, 14, 3271, 63, 5700, 395, 686, 198, 1361, 1566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
miguelfervi/SSBW-Restaurantes
restaurantes/lib/python2.7/site-packages/django/core/servers/basehttp.py
274
7319
""" HTTP server that implements the Python WSGI protocol (PEP 333, rev 1.21). Based on wsgiref.simple_server which is part of the standard library since 2.5. This is a simple server for use in testing or debugging Django apps. It hasn't been reviewed for security issues. DON'T USE IT FOR PRODUCTION USE! """ from __future__ import unicode_literals import socket import sys from wsgiref import simple_server from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import ISO_8859_1, UTF_8 from django.core.management.color import color_style from django.core.wsgi import get_wsgi_application from django.utils import six from django.utils.encoding import uri_to_iri from django.utils.module_loading import import_string from django.utils.six.moves import socketserver __all__ = ('WSGIServer', 'WSGIRequestHandler') def get_internal_wsgi_application(): """ Loads and returns the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setting itself, are only useful for Django's internal server (runserver); external WSGI servers should just be configured to point to the correct application object directly. If settings.WSGI_APPLICATION is not set (is ``None``), we just return whatever ``django.core.wsgi.get_wsgi_application`` returns. """ from django.conf import settings app_path = getattr(settings, 'WSGI_APPLICATION') if app_path is None: return get_wsgi_application() try: return import_string(app_path) except ImportError as e: msg = ( "WSGI application '%(app_path)s' could not be loaded; " "Error importing module: '%(exception)s'" % ({ 'app_path': app_path, 'exception': e, }) ) six.reraise(ImproperlyConfigured, ImproperlyConfigured(msg), sys.exc_info()[2]) def is_broken_pipe_error(): exc_type, exc_value = sys.exc_info()[:2] return issubclass(exc_type, socket.error) and exc_value.args[0] == 32 class WSGIServer(simple_server.WSGIServer, object): """BaseHTTPServer that implements the Python WSGI protocol""" request_queue_size = 10 def __init__(self, *args, **kwargs): if kwargs.pop('ipv6', False): self.address_family = socket.AF_INET6 super(WSGIServer, self).__init__(*args, **kwargs) def server_bind(self): """Override server_bind to store the server name.""" super(WSGIServer, self).server_bind() self.setup_environ() def handle_error(self, request, client_address): if is_broken_pipe_error(): sys.stderr.write("- Broken pipe from %s\n" % (client_address,)) else: super(WSGIServer, self).handle_error(request, client_address) # Inheriting from object required on Python 2. class ServerHandler(simple_server.ServerHandler, object): def handle_error(self): # Ignore broken pipe errors, otherwise pass on if not is_broken_pipe_error(): super(ServerHandler, self).handle_error() class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): def __init__(self, *args, **kwargs): self.style = color_style() super(WSGIRequestHandler, self).__init__(*args, **kwargs) def address_string(self): # Short-circuit parent method to not call socket.getfqdn return self.client_address[0] def log_message(self, format, *args): msg = "[%s] " % self.log_date_time_string() try: msg += "%s\n" % (format % args) except UnicodeDecodeError: # e.g. accessing the server via SSL on Python 2 msg += "\n" # Utilize terminal colors, if available if args[1][0] == '2': # Put 2XX first, since it should be the common case msg = self.style.HTTP_SUCCESS(msg) elif args[1][0] == '1': msg = self.style.HTTP_INFO(msg) elif args[1] == '304': msg = self.style.HTTP_NOT_MODIFIED(msg) elif args[1][0] == '3': msg = self.style.HTTP_REDIRECT(msg) elif args[1] == '404': msg = self.style.HTTP_NOT_FOUND(msg) elif args[1][0] == '4': # 0x16 = Handshake, 0x03 = SSL 3.0 or TLS 1.x if args[0].startswith(str('\x16\x03')): msg = ("You're accessing the development server over HTTPS, " "but it only supports HTTP.\n") msg = self.style.HTTP_BAD_REQUEST(msg) else: # Any 5XX, or any other response msg = self.style.HTTP_SERVER_ERROR(msg) sys.stderr.write(msg) def get_environ(self): # Strip all headers with underscores in the name before constructing # the WSGI environ. This prevents header-spoofing based on ambiguity # between underscores and dashes both normalized to underscores in WSGI # env vars. Nginx and Apache 2.4+ both do this as well. for k, v in self.headers.items(): if '_' in k: del self.headers[k] env = super(WSGIRequestHandler, self).get_environ() path = self.path if '?' in path: path = path.partition('?')[0] path = uri_to_iri(path).encode(UTF_8) # Under Python 3, non-ASCII values in the WSGI environ are arbitrarily # decoded with ISO-8859-1. We replicate this behavior here. # Refs comment in `get_bytes_from_wsgi()`. env['PATH_INFO'] = path.decode(ISO_8859_1) if six.PY3 else path return env def handle(self): """Copy of WSGIRequestHandler, but with different ServerHandler""" self.raw_requestline = self.rfile.readline(65537) if len(self.raw_requestline) > 65536: self.requestline = '' self.request_version = '' self.command = '' self.send_error(414) return if not self.parse_request(): # An error code has been sent, just exit return handler = ServerHandler( self.rfile, self.wfile, self.get_stderr(), self.get_environ() ) handler.request_handler = self # backpointer for logging handler.run(self.server.get_app()) def run(addr, port, wsgi_handler, ipv6=False, threading=False): server_address = (addr, port) if threading: httpd_cls = type(str('WSGIServer'), (socketserver.ThreadingMixIn, WSGIServer), {}) else: httpd_cls = WSGIServer httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6) if threading: # ThreadingMixIn.daemon_threads indicates how threads will behave on an # abrupt shutdown; like quitting the server by the user or restarting # by the auto-reloader. True means the server will not wait for thread # termination before it quits. This will make auto-reloader faster # and will prevent the need to kill the server manually if a thread # isn't terminating correctly. httpd.daemon_threads = True httpd.set_app(wsgi_handler) httpd.serve_forever()
gpl-3.0
[ 624, 199, 2856, 1654, 626, 9031, 314, 2018, 9279, 4113, 334, 25633, 23792, 12, 6822, 413, 14, 2025, 680, 199, 199, 20409, 641, 12464, 1121, 14, 4129, 63, 1000, 1314, 365, 1777, 402, 314, 4465, 3555, 3967, 499, 14, 21, 14, 199, 199, 2765, 365, 282, 3486, 1654, 367, 675, 315, 5343, 503, 10201, 5634, 8686, 14, 2779, 18699, 1133, 199, 1235, 287, 11248, 379, 367, 6391, 10876, 14, 577, 615, 7, 52, 4815, 473, 52, 2381, 3611, 4980, 5430, 4815, 1, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2838, 199, 646, 984, 199, 504, 12464, 1121, 492, 3486, 63, 1000, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 5586, 14, 6508, 492, 9055, 63, 4830, 63, 17, 12, 9094, 63, 24, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 3164, 63, 2487, 199, 504, 1639, 14, 1018, 14, 6508, 492, 664, 63, 6508, 63, 3578, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 5108, 63, 475, 63, 19081, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 2838, 1000, 199, 199, 363, 452, 363, 275, 661, 55, 28732, 297, 283, 16828, 11149, 358, 421, 199, 318, 664, 63, 4672, 63, 6508, 63, 3578, 837, 272, 408, 272, 30367, 436, 2529, 314, 9279, 4223, 465, 7526, 701, 314, 922, 315, 272, 1124, 1751, 14, 16828, 63, 24051, 4345, 8777, 314, 849, 1124, 928, 1715, 1040, 7054, 12, 272, 642, 911, 506, 314, 1124, 3578, 1040, 909, 315, 1124, 1715, 354, 15, 6508, 14, 647, 4345, 339, 961, 805, 12, 436, 314, 1124, 16828, 63, 24051, 1040, 4260, 6337, 12, 787, 1454, 2997, 272, 367, 5634, 1159, 5007, 1654, 334, 1065, 1000, 2736, 5957, 9279, 8037, 1077, 2951, 272, 506, 7526, 370, 2376, 370, 314, 3211, 4223, 909, 5370, 14, 339, 982, 2202, 14, 16828, 63, 24051, 365, 440, 663, 334, 374, 1124, 403, 1040, 395, 781, 2951, 372, 272, 15685, 1124, 1176, 14, 1018, 14, 6508, 14, 362, 63, 6508, 63, 3578, 1040, 2529, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 1145, 63, 515, 275, 2519, 8, 1751, 12, 283, 16828, 63, 24051, 358, 272, 340, 1145, 63, 515, 365, 488, 26, 267, 372, 664, 63, 6508, 63, 3578, 342, 339, 862, 26, 267, 372, 492, 63, 875, 8, 571, 63, 515, 9, 272, 871, 3545, 465, 325, 26, 267, 1499, 275, 334, 288, 298, 16828, 4223, 9487, 571, 63, 515, 9, 83, 7, 4293, 440, 506, 6511, 27, 298, 288, 298, 547, 16306, 859, 26, 9487, 1971, 9, 83, 4065, 450, 11459, 355, 283, 571, 63, 515, 356, 1145, 63, 515, 12, 355, 283, 1971, 356, 325, 12, 288, 3828, 267, 776, 267, 3816, 14, 20614, 8, 8499, 10951, 12, 11897, 8, 1328, 395, 490, 984, 14, 2804, 63, 815, 3430, 18, 566, 421, 199, 318, 365, 63, 15697, 63, 4990, 63, 705, 837, 272, 3178, 63, 466, 12, 3178, 63, 585, 275, 984, 14, 2804, 63, 815, 20523, 18, 61, 272, 372, 11602, 8, 2804, 63, 466, 12, 2838, 14, 705, 9, 436, 3178, 63, 585, 14, 589, 59, 16, 61, 508, 4337, 421, 199, 533, 644, 28732, 8, 4129, 63, 1000, 14, 55, 28732, 12, 909, 304, 272, 408, 1563, 14938, 626, 9031, 314, 2018, 9279, 4113, 624, 339, 1056, 63, 1825, 63, 890, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 1935, 360, 4774, 22, 297, 756, 304, 288, 291, 14, 1562, 63, 6606, 275, 2838, 14, 5699, 63, 11367, 22, 267, 1613, 8, 55, 28732, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 1654, 63, 3409, 8, 277, 304, 267, 408, 11954, 1654, 63, 3409, 370, 3877, 314, 1654, 536, 1041, 267, 1613, 8, 55, 28732, 12, 291, 680, 1000, 63, 3409, 342, 267, 291, 14, 2758, 63, 2314, 342, 339, 347, 2429, 63, 705, 8, 277, 12, 1056, 12, 1890, 63, 1562, 304, 267, 340, 365, 63, 15697, 63, 4990, 63, 705, 837, 288, 984, 14, 3083, 14, 952, 6096, 23804, 5200, 687, 450, 83, 60, 78, 2, 450, 334, 1258, 63, 1562, 4641, 267, 587, 26, 288, 1613, 8, 55, 28732, 12, 291, 680, 2479, 63, 705, 8, 1069, 12, 1890, 63, 1562, 9, 421, 199, 3, 27502, 316, 687, 909, 1415, 641, 2018, 499, 14, 199, 533, 7146, 2461, 8, 4129, 63, 1000, 14, 3120, 2461, 12, 909, 304, 272, 347, 2429, 63, 705, 8, 277, 304, 267, 327, 14092, 10529, 5200, 2552, 12, 4257, 986, 641, 267, 340, 440, 365, 63, 15697, 63, 4990, 63, 705, 837, 288, 1613, 8, 3120, 2461, 12, 291, 680, 2479, 63, 705, 342, 421, 199, 533, 9279, 11149, 8, 4129, 63, 1000, 14, 16828, 11149, 12, 909, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2487, 275, 3164, 63, 2487, 342, 267, 1613, 8, 16828, 11149, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 2287, 63, 875, 8, 277, 304, 267, 327, 20124, 13, 18516, 1676, 1083, 370, 440, 1240, 2838, 14, 362, 18364, 267, 372, 291, 14, 1258, 63, 1562, 59, 16, 61, 339, 347, 943, 63, 1188, 8, 277, 12, 1475, 12, 627, 589, 304, 398, 1499, 275, 26503, 83, 61, 298, 450, 291, 14, 793, 63, 602, 63, 521, 63, 875, 342, 267, 862, 26, 288, 1499, 847, 2071, 83, 60, 78, 2, 450, 334, 908, 450, 1249, 9, 267, 871, 18965, 26, 288, 327, 325, 14, 71, 14, 18549, 314, 1654, 4799, 7799, 641, 2018, 499, 288, 1499, 847, 1867, 78, 2, 398, 327, 738, 280, 13559, 11167, 9229, 12, 340, 2808, 267, 340, 1249, 59, 17, 1527, 16, 61, 508, 283, 18, 356, 288, 327, 16280, 499, 2483, 1642, 12, 3967, 652, 1077, 506, 314, 2863, 1930, 288, 1499, 275, 291, 14, 2487, 14, 2856, 63, 12779, 8, 1328, 9, 267, 916, 1249, 59, 17, 1527, 16, 61, 508, 283, 17, 356, 288 ]
[ 199, 2856, 1654, 626, 9031, 314, 2018, 9279, 4113, 334, 25633, 23792, 12, 6822, 413, 14, 2025, 680, 199, 199, 20409, 641, 12464, 1121, 14, 4129, 63, 1000, 1314, 365, 1777, 402, 314, 4465, 3555, 3967, 499, 14, 21, 14, 199, 199, 2765, 365, 282, 3486, 1654, 367, 675, 315, 5343, 503, 10201, 5634, 8686, 14, 2779, 18699, 1133, 199, 1235, 287, 11248, 379, 367, 6391, 10876, 14, 577, 615, 7, 52, 4815, 473, 52, 2381, 3611, 4980, 5430, 4815, 1, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2838, 199, 646, 984, 199, 504, 12464, 1121, 492, 3486, 63, 1000, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 5586, 14, 6508, 492, 9055, 63, 4830, 63, 17, 12, 9094, 63, 24, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 3164, 63, 2487, 199, 504, 1639, 14, 1018, 14, 6508, 492, 664, 63, 6508, 63, 3578, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 5108, 63, 475, 63, 19081, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 2838, 1000, 199, 199, 363, 452, 363, 275, 661, 55, 28732, 297, 283, 16828, 11149, 358, 421, 199, 318, 664, 63, 4672, 63, 6508, 63, 3578, 837, 272, 408, 272, 30367, 436, 2529, 314, 9279, 4223, 465, 7526, 701, 314, 922, 315, 272, 1124, 1751, 14, 16828, 63, 24051, 4345, 8777, 314, 849, 1124, 928, 1715, 1040, 7054, 12, 272, 642, 911, 506, 314, 1124, 3578, 1040, 909, 315, 1124, 1715, 354, 15, 6508, 14, 647, 4345, 339, 961, 805, 12, 436, 314, 1124, 16828, 63, 24051, 1040, 4260, 6337, 12, 787, 1454, 2997, 272, 367, 5634, 1159, 5007, 1654, 334, 1065, 1000, 2736, 5957, 9279, 8037, 1077, 2951, 272, 506, 7526, 370, 2376, 370, 314, 3211, 4223, 909, 5370, 14, 339, 982, 2202, 14, 16828, 63, 24051, 365, 440, 663, 334, 374, 1124, 403, 1040, 395, 781, 2951, 372, 272, 15685, 1124, 1176, 14, 1018, 14, 6508, 14, 362, 63, 6508, 63, 3578, 1040, 2529, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 1145, 63, 515, 275, 2519, 8, 1751, 12, 283, 16828, 63, 24051, 358, 272, 340, 1145, 63, 515, 365, 488, 26, 267, 372, 664, 63, 6508, 63, 3578, 342, 339, 862, 26, 267, 372, 492, 63, 875, 8, 571, 63, 515, 9, 272, 871, 3545, 465, 325, 26, 267, 1499, 275, 334, 288, 298, 16828, 4223, 9487, 571, 63, 515, 9, 83, 7, 4293, 440, 506, 6511, 27, 298, 288, 298, 547, 16306, 859, 26, 9487, 1971, 9, 83, 4065, 450, 11459, 355, 283, 571, 63, 515, 356, 1145, 63, 515, 12, 355, 283, 1971, 356, 325, 12, 288, 3828, 267, 776, 267, 3816, 14, 20614, 8, 8499, 10951, 12, 11897, 8, 1328, 395, 490, 984, 14, 2804, 63, 815, 3430, 18, 566, 421, 199, 318, 365, 63, 15697, 63, 4990, 63, 705, 837, 272, 3178, 63, 466, 12, 3178, 63, 585, 275, 984, 14, 2804, 63, 815, 20523, 18, 61, 272, 372, 11602, 8, 2804, 63, 466, 12, 2838, 14, 705, 9, 436, 3178, 63, 585, 14, 589, 59, 16, 61, 508, 4337, 421, 199, 533, 644, 28732, 8, 4129, 63, 1000, 14, 55, 28732, 12, 909, 304, 272, 408, 1563, 14938, 626, 9031, 314, 2018, 9279, 4113, 624, 339, 1056, 63, 1825, 63, 890, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 1935, 360, 4774, 22, 297, 756, 304, 288, 291, 14, 1562, 63, 6606, 275, 2838, 14, 5699, 63, 11367, 22, 267, 1613, 8, 55, 28732, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 1654, 63, 3409, 8, 277, 304, 267, 408, 11954, 1654, 63, 3409, 370, 3877, 314, 1654, 536, 1041, 267, 1613, 8, 55, 28732, 12, 291, 680, 1000, 63, 3409, 342, 267, 291, 14, 2758, 63, 2314, 342, 339, 347, 2429, 63, 705, 8, 277, 12, 1056, 12, 1890, 63, 1562, 304, 267, 340, 365, 63, 15697, 63, 4990, 63, 705, 837, 288, 984, 14, 3083, 14, 952, 6096, 23804, 5200, 687, 450, 83, 60, 78, 2, 450, 334, 1258, 63, 1562, 4641, 267, 587, 26, 288, 1613, 8, 55, 28732, 12, 291, 680, 2479, 63, 705, 8, 1069, 12, 1890, 63, 1562, 9, 421, 199, 3, 27502, 316, 687, 909, 1415, 641, 2018, 499, 14, 199, 533, 7146, 2461, 8, 4129, 63, 1000, 14, 3120, 2461, 12, 909, 304, 272, 347, 2429, 63, 705, 8, 277, 304, 267, 327, 14092, 10529, 5200, 2552, 12, 4257, 986, 641, 267, 340, 440, 365, 63, 15697, 63, 4990, 63, 705, 837, 288, 1613, 8, 3120, 2461, 12, 291, 680, 2479, 63, 705, 342, 421, 199, 533, 9279, 11149, 8, 4129, 63, 1000, 14, 16828, 11149, 12, 909, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2487, 275, 3164, 63, 2487, 342, 267, 1613, 8, 16828, 11149, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 2287, 63, 875, 8, 277, 304, 267, 327, 20124, 13, 18516, 1676, 1083, 370, 440, 1240, 2838, 14, 362, 18364, 267, 372, 291, 14, 1258, 63, 1562, 59, 16, 61, 339, 347, 943, 63, 1188, 8, 277, 12, 1475, 12, 627, 589, 304, 398, 1499, 275, 26503, 83, 61, 298, 450, 291, 14, 793, 63, 602, 63, 521, 63, 875, 342, 267, 862, 26, 288, 1499, 847, 2071, 83, 60, 78, 2, 450, 334, 908, 450, 1249, 9, 267, 871, 18965, 26, 288, 327, 325, 14, 71, 14, 18549, 314, 1654, 4799, 7799, 641, 2018, 499, 288, 1499, 847, 1867, 78, 2, 398, 327, 738, 280, 13559, 11167, 9229, 12, 340, 2808, 267, 340, 1249, 59, 17, 1527, 16, 61, 508, 283, 18, 356, 288, 327, 16280, 499, 2483, 1642, 12, 3967, 652, 1077, 506, 314, 2863, 1930, 288, 1499, 275, 291, 14, 2487, 14, 2856, 63, 12779, 8, 1328, 9, 267, 916, 1249, 59, 17, 1527, 16, 61, 508, 283, 17, 356, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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EST extension module # # Copyright (C) 2000 Peter Liljenberg <petli@ctrl-c.liu.se> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import X from Xlib.protocol import rq extname = 'XTEST' CurrentCursor = 1 class GetVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Pad(1), rq.Card16('minor_version') ) _reply = rq.Struct(rq.Pad(1), rq.Card8('major_version'), rq.Card16('sequence_number'), rq.Pad(4), rq.Card16('minor_version'), rq.Pad(22) ) def get_version(self, major, minor): return GetVersion(display = self.display, opcode = self.display.get_extension_major(extname), major_version = major, minor_version = minor) class CompareCursor(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), rq.Cursor('cursor', (X.NONE, CurrentCursor)), ) _reply = rq.Struct(rq.Pad(1), rq.Card8('same'), rq.Card16('sequence_number'), rq.Pad(28), ) def compare_cursor(self, cursor): r = CompareCursor(display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, cursor = cursor) return r.same class FakeInput(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Set('event_type', 1, (X.KeyPress, X.KeyRelease, X.ButtonPress, X.ButtonRelease, X.MotionNotify)), rq.Card8('detail'), rq.Pad(2), rq.Card32('time'), rq.Window('root', (X.NONE, )), rq.Pad(8), rq.Int16('x'), rq.Int16('y'), rq.Pad(8) ) def fake_input(self, event_type, detail = 0, time = X.CurrentTime, root = X.NONE, x = 0, y = 0): FakeInput(display = self.display, opcode = self.display.get_extension_major(extname), event_type = event_type, detail = detail, time = time, root = root, x = x, y = y) class GrabControl(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Bool('impervious'), rq.Pad(3) ) def grab_control(self, impervious): GrabControl(display = self.display, opcode = self.display.get_extension_major(extname), impervious = impervious) def init(disp, info): disp.extension_add_method('display', 'xtest_get_version', get_version) disp.extension_add_method('window', 'xtest_compare_cursor', compare_cursor) disp.extension_add_method('display', 'xtest_fake_input', fake_input) disp.extension_add_method('display', 'xtest_grab_control', grab_control)
lgpl-2.1
[ 3, 1323, 773, 14, 832, 14, 88, 396, 1553, 1323, 2864, 3329, 859, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 12293, 22912, 491, 382, 74, 287, 14630, 665, 8096, 317, 32, 12476, 13, 67, 14, 317, 85, 14, 261, 30, 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, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 199, 3, 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, 199, 3, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 259, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 259, 8155, 15630, 10902, 12, 199, 3, 259, 14453, 13540, 12, 199, 3, 259, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 199, 504, 1323, 773, 492, 1323, 199, 504, 1323, 773, 14, 3922, 492, 24659, 199, 199, 832, 354, 275, 283, 56, 2864, 7, 199, 199, 5639, 8993, 275, 413, 199, 199, 533, 2372, 3353, 8, 5098, 14, 14166, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 16, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 13832, 24, 360, 8452, 63, 1023, 659, 586, 24659, 14, 18584, 8, 17, 395, 586, 24659, 14, 13832, 975, 360, 11067, 63, 1023, 358, 586, 776, 339, 485, 8102, 275, 24659, 14, 4836, 8, 5098, 14, 18584, 8, 17, 395, 2432, 24659, 14, 13832, 24, 360, 8452, 63, 1023, 659, 2432, 24659, 14, 13832, 975, 360, 4041, 63, 1955, 659, 2432, 24659, 14, 18584, 8, 20, 395, 2432, 24659, 14, 13832, 975, 360, 11067, 63, 1023, 659, 2432, 24659, 14, 18584, 8, 1081, 9, 2432, 776, 199, 199, 318, 664, 63, 1023, 8, 277, 12, 12160, 12, 12612, 304, 272, 372, 2372, 3353, 8, 2918, 275, 291, 14, 2918, 12, 1993, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1993, 12160, 63, 1023, 275, 12160, 12, 1993, 12612, 63, 1023, 275, 12612, 9, 421, 199, 533, 18955, 8993, 8, 5098, 14, 14166, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 17, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 4301, 360, 3806, 659, 586, 24659, 14, 8993, 360, 3937, 297, 334, 56, 14, 9185, 12, 9338, 8993, 1826, 586, 776, 339, 485, 8102, 275, 24659, 14, 4836, 8, 5098, 14, 18584, 8, 17, 395, 2432, 24659, 14, 13832, 24, 360, 7191, 659, 2432, 24659, 14, 13832, 975, 360, 4041, 63, 1955, 659, 2432, 24659, 14, 18584, 8, 1651, 395, 2432, 776, 199, 199, 318, 6540, 63, 3937, 8, 277, 12, 3920, 304, 272, 519, 275, 18955, 8993, 8, 2918, 275, 291, 14, 2918, 12, 1993, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1993, 4353, 275, 291, 14, 344, 12, 1993, 3920, 275, 3920, 9, 272, 372, 519, 14, 7191, 199, 199, 533, 7777, 3205, 8, 5098, 14, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 18, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 1084, 360, 1430, 63, 466, 297, 413, 12, 334, 56, 14, 1197, 14414, 12, 8179, 1323, 14, 1197, 9625, 12, 8179, 1323, 14, 4259, 14414, 12, 8179, 1323, 14, 4259, 9625, 12, 8179, 1323, 14, 24875, 8645, 1826, 586, 24659, 14, 13832, 24, 360, 5506, 659, 586, 24659, 14, 18584, 8, 18, 395, 586, 24659, 14, 13832, 708, 360, 521, 659, 586, 24659, 14, 4301, 360, 1231, 297, 334, 56, 14, 9185, 12, 22583, 586, 24659, 14, 18584, 8, 24, 395, 586, 24659, 14, 3241, 975, 360, 88, 659, 586, 24659, 14, 3241, 975, 360, 89, 659, 586, 24659, 14, 18584, 8, 24, 9, 586, 776, 199, 199, 318, 4026, 63, 1210, 8, 277, 12, 1566, 63, 466, 12, 10093, 275, 378, 12, 900, 275, 1323, 14, 5639, 1366, 12, 2049, 1738, 275, 1323, 14, 9185, 12, 671, 275, 378, 12, 612, 275, 378, 304, 339, 7777, 3205, 8, 2918, 275, 291, 14, 2918, 12, 1598, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1598, 1566, 63, 466, 275, 1566, 63, 466, 12, 1598, 10093, 275, 10093, 12, 1598, 900, 275, 900, 12, 1598, 1738, 275, 1738, 12, 1598, 671, 275, 671, 12, 1598, 612, 275, 612, 9, 199, 199, 533, 29225, 3717, 8, 5098, 14, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 19, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 10349, 360, 3236, 281, 2971, 659, 586, 24659, 14, 18584, 8, 19, 9, 586, 776, 199, 199, 318, 18200, 63, 2785, 8, 277, 12, 1742, 281, 2971, 304, 272, 29225, 3717, 8, 2918, 275, 291, 14, 2918, 12, 355, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 355, 1742, 281, 2971, 275, 1742, 281, 2971, 9, 199, 199, 318, 4205, 8, 13654, 12, 2256, 304, 272, 9628, 14, 3435, 63, 525, 63, 765, 360, 2918, 297, 283, 88, 396, 63, 362, 63, 1023, 297, 664, 63, 1023, 9, 272, 9628, 14, 3435, 63, 525, 63, 765, 360, 3806, 297, 283, 88, 396, 63, 5785, 63, 3937, 297, 6540, 63, 3937, 9, 272, 9628, 14, 3435, 63, 525, 63, 765, 360, 2918, 297, 283, 88, 396, 63, 3183, 63, 1210, 297, 4026, 63, 1210, 9, 272 ]
[ 1323, 773, 14, 832, 14, 88, 396, 1553, 1323, 2864, 3329, 859, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 12293, 22912, 491, 382, 74, 287, 14630, 665, 8096, 317, 32, 12476, 13, 67, 14, 317, 85, 14, 261, 30, 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, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 199, 3, 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, 199, 3, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 259, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 259, 8155, 15630, 10902, 12, 199, 3, 259, 14453, 13540, 12, 199, 3, 259, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 199, 504, 1323, 773, 492, 1323, 199, 504, 1323, 773, 14, 3922, 492, 24659, 199, 199, 832, 354, 275, 283, 56, 2864, 7, 199, 199, 5639, 8993, 275, 413, 199, 199, 533, 2372, 3353, 8, 5098, 14, 14166, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 16, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 13832, 24, 360, 8452, 63, 1023, 659, 586, 24659, 14, 18584, 8, 17, 395, 586, 24659, 14, 13832, 975, 360, 11067, 63, 1023, 358, 586, 776, 339, 485, 8102, 275, 24659, 14, 4836, 8, 5098, 14, 18584, 8, 17, 395, 2432, 24659, 14, 13832, 24, 360, 8452, 63, 1023, 659, 2432, 24659, 14, 13832, 975, 360, 4041, 63, 1955, 659, 2432, 24659, 14, 18584, 8, 20, 395, 2432, 24659, 14, 13832, 975, 360, 11067, 63, 1023, 659, 2432, 24659, 14, 18584, 8, 1081, 9, 2432, 776, 199, 199, 318, 664, 63, 1023, 8, 277, 12, 12160, 12, 12612, 304, 272, 372, 2372, 3353, 8, 2918, 275, 291, 14, 2918, 12, 1993, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1993, 12160, 63, 1023, 275, 12160, 12, 1993, 12612, 63, 1023, 275, 12612, 9, 421, 199, 533, 18955, 8993, 8, 5098, 14, 14166, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 17, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 4301, 360, 3806, 659, 586, 24659, 14, 8993, 360, 3937, 297, 334, 56, 14, 9185, 12, 9338, 8993, 1826, 586, 776, 339, 485, 8102, 275, 24659, 14, 4836, 8, 5098, 14, 18584, 8, 17, 395, 2432, 24659, 14, 13832, 24, 360, 7191, 659, 2432, 24659, 14, 13832, 975, 360, 4041, 63, 1955, 659, 2432, 24659, 14, 18584, 8, 1651, 395, 2432, 776, 199, 199, 318, 6540, 63, 3937, 8, 277, 12, 3920, 304, 272, 519, 275, 18955, 8993, 8, 2918, 275, 291, 14, 2918, 12, 1993, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1993, 4353, 275, 291, 14, 344, 12, 1993, 3920, 275, 3920, 9, 272, 372, 519, 14, 7191, 199, 199, 533, 7777, 3205, 8, 5098, 14, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 18, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 1084, 360, 1430, 63, 466, 297, 413, 12, 334, 56, 14, 1197, 14414, 12, 8179, 1323, 14, 1197, 9625, 12, 8179, 1323, 14, 4259, 14414, 12, 8179, 1323, 14, 4259, 9625, 12, 8179, 1323, 14, 24875, 8645, 1826, 586, 24659, 14, 13832, 24, 360, 5506, 659, 586, 24659, 14, 18584, 8, 18, 395, 586, 24659, 14, 13832, 708, 360, 521, 659, 586, 24659, 14, 4301, 360, 1231, 297, 334, 56, 14, 9185, 12, 22583, 586, 24659, 14, 18584, 8, 24, 395, 586, 24659, 14, 3241, 975, 360, 88, 659, 586, 24659, 14, 3241, 975, 360, 89, 659, 586, 24659, 14, 18584, 8, 24, 9, 586, 776, 199, 199, 318, 4026, 63, 1210, 8, 277, 12, 1566, 63, 466, 12, 10093, 275, 378, 12, 900, 275, 1323, 14, 5639, 1366, 12, 2049, 1738, 275, 1323, 14, 9185, 12, 671, 275, 378, 12, 612, 275, 378, 304, 339, 7777, 3205, 8, 2918, 275, 291, 14, 2918, 12, 1598, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 1598, 1566, 63, 466, 275, 1566, 63, 466, 12, 1598, 10093, 275, 10093, 12, 1598, 900, 275, 900, 12, 1598, 1738, 275, 1738, 12, 1598, 671, 275, 671, 12, 1598, 612, 275, 612, 9, 199, 199, 533, 29225, 3717, 8, 5098, 14, 2017, 304, 272, 485, 1069, 275, 24659, 14, 4836, 8, 5098, 14, 13832, 24, 360, 14325, 659, 586, 24659, 14, 4619, 600, 8, 19, 395, 586, 24659, 14, 2017, 4625, 1062, 586, 24659, 14, 10349, 360, 3236, 281, 2971, 659, 586, 24659, 14, 18584, 8, 19, 9, 586, 776, 199, 199, 318, 18200, 63, 2785, 8, 277, 12, 1742, 281, 2971, 304, 272, 29225, 3717, 8, 2918, 275, 291, 14, 2918, 12, 355, 10508, 275, 291, 14, 2918, 14, 362, 63, 3435, 63, 8452, 8, 832, 354, 395, 355, 1742, 281, 2971, 275, 1742, 281, 2971, 9, 199, 199, 318, 4205, 8, 13654, 12, 2256, 304, 272, 9628, 14, 3435, 63, 525, 63, 765, 360, 2918, 297, 283, 88, 396, 63, 362, 63, 1023, 297, 664, 63, 1023, 9, 272, 9628, 14, 3435, 63, 525, 63, 765, 360, 3806, 297, 283, 88, 396, 63, 5785, 63, 3937, 297, 6540, 63, 3937, 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 ]
subhrm/google-code-jam-solutions
solutions/helpers/CodeJam-0.3.0/codejam/datastructures/summing_list.py
1
1482
class summing_list: layers = [[0]] size = 0 def __init__(self, iter=None): if iter != None: for i in iter: self.append(i) def _sum(self, i): t = 0 for r in self.layers: if i % 2: t += r[i - 1] i >>= 1 return t def sum_elements(self, i=None, j=None): if j == None: if i == None: i = self.size return self._sum(i) else: return self._sum(max(i, j)) - self._sum(min(i, j)) def __getitem__(self, i): if i < self.size: return self.layers[0][i] else: raise ValueError() def __setitem__(self, i, v): d = v - self.layers[0][i] for r in self.layers: r[i] += d i >>= 1 def _double_size(self): for r in self.layers: r += [0] * len(r) self.layers += [[self.layers[-1][0]]] def __iadd__(self, iter): for i in iter: self.append(i) return self def __add__(self, x): both = summing_list(self) both += x return both def append(self, x): self.size += 1 if self.size > len(self.layers[0]): self._double_size() self[self.size - 1] = x def __repr__(self): return self.layers[0][:self.size].__repr__() def __iter__(self): return iter(self.layers[0][:self.size])
mit
[ 533, 3089, 14566, 63, 513, 26, 272, 9393, 275, 3474, 16, 2677, 272, 1568, 275, 378, 339, 347, 636, 826, 721, 277, 12, 2740, 29, 403, 304, 267, 340, 2740, 1137, 488, 26, 288, 367, 284, 315, 2740, 26, 355, 291, 14, 740, 8, 73, 9, 339, 347, 485, 1838, 8, 277, 12, 284, 304, 267, 307, 275, 378, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 340, 284, 450, 499, 26, 355, 307, 847, 519, 59, 73, 446, 413, 61, 288, 284, 4331, 29, 413, 267, 372, 307, 339, 347, 3089, 63, 5527, 8, 277, 12, 284, 29, 403, 12, 1335, 29, 403, 304, 267, 340, 1335, 508, 488, 26, 288, 340, 284, 508, 488, 26, 355, 284, 275, 291, 14, 890, 288, 372, 291, 423, 1838, 8, 73, 9, 267, 587, 26, 288, 372, 291, 423, 1838, 8, 988, 8, 73, 12, 1335, 430, 446, 291, 423, 1838, 8, 827, 8, 73, 12, 1335, 430, 339, 347, 636, 6095, 721, 277, 12, 284, 304, 267, 340, 284, 665, 291, 14, 890, 26, 288, 372, 291, 14, 4359, 59, 16, 1527, 73, 61, 267, 587, 26, 288, 746, 1722, 342, 339, 347, 636, 8617, 721, 277, 12, 284, 12, 373, 304, 267, 366, 275, 373, 446, 291, 14, 4359, 59, 16, 1527, 73, 61, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 519, 59, 73, 61, 847, 366, 288, 284, 4331, 29, 413, 339, 347, 485, 3157, 63, 890, 8, 277, 304, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 519, 847, 359, 16, 61, 627, 822, 8, 82, 9, 267, 291, 14, 4359, 847, 3474, 277, 14, 4359, 1988, 17, 1527, 16, 20737, 339, 347, 636, 28788, 721, 277, 12, 2740, 304, 267, 367, 284, 315, 2740, 26, 288, 291, 14, 740, 8, 73, 9, 267, 372, 291, 339, 347, 636, 525, 721, 277, 12, 671, 304, 267, 3865, 275, 3089, 14566, 63, 513, 8, 277, 9, 267, 3865, 847, 671, 267, 372, 3865, 339, 347, 5666, 8, 277, 12, 671, 304, 267, 291, 14, 890, 847, 413, 267, 340, 291, 14, 890, 690, 822, 8, 277, 14, 4359, 59, 16, 4682, 288, 291, 423, 3157, 63, 890, 342, 267, 291, 59, 277, 14, 890, 446, 413, 61, 275, 671, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 14, 4359, 59, 16, 19663, 277, 14, 890, 17979, 2722, 4533, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 4359, 59, 16, 19663, 277, 14, 890, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3089, 14566, 63, 513, 26, 272, 9393, 275, 3474, 16, 2677, 272, 1568, 275, 378, 339, 347, 636, 826, 721, 277, 12, 2740, 29, 403, 304, 267, 340, 2740, 1137, 488, 26, 288, 367, 284, 315, 2740, 26, 355, 291, 14, 740, 8, 73, 9, 339, 347, 485, 1838, 8, 277, 12, 284, 304, 267, 307, 275, 378, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 340, 284, 450, 499, 26, 355, 307, 847, 519, 59, 73, 446, 413, 61, 288, 284, 4331, 29, 413, 267, 372, 307, 339, 347, 3089, 63, 5527, 8, 277, 12, 284, 29, 403, 12, 1335, 29, 403, 304, 267, 340, 1335, 508, 488, 26, 288, 340, 284, 508, 488, 26, 355, 284, 275, 291, 14, 890, 288, 372, 291, 423, 1838, 8, 73, 9, 267, 587, 26, 288, 372, 291, 423, 1838, 8, 988, 8, 73, 12, 1335, 430, 446, 291, 423, 1838, 8, 827, 8, 73, 12, 1335, 430, 339, 347, 636, 6095, 721, 277, 12, 284, 304, 267, 340, 284, 665, 291, 14, 890, 26, 288, 372, 291, 14, 4359, 59, 16, 1527, 73, 61, 267, 587, 26, 288, 746, 1722, 342, 339, 347, 636, 8617, 721, 277, 12, 284, 12, 373, 304, 267, 366, 275, 373, 446, 291, 14, 4359, 59, 16, 1527, 73, 61, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 519, 59, 73, 61, 847, 366, 288, 284, 4331, 29, 413, 339, 347, 485, 3157, 63, 890, 8, 277, 304, 267, 367, 519, 315, 291, 14, 4359, 26, 288, 519, 847, 359, 16, 61, 627, 822, 8, 82, 9, 267, 291, 14, 4359, 847, 3474, 277, 14, 4359, 1988, 17, 1527, 16, 20737, 339, 347, 636, 28788, 721, 277, 12, 2740, 304, 267, 367, 284, 315, 2740, 26, 288, 291, 14, 740, 8, 73, 9, 267, 372, 291, 339, 347, 636, 525, 721, 277, 12, 671, 304, 267, 3865, 275, 3089, 14566, 63, 513, 8, 277, 9, 267, 3865, 847, 671, 267, 372, 3865, 339, 347, 5666, 8, 277, 12, 671, 304, 267, 291, 14, 890, 847, 413, 267, 340, 291, 14, 890, 690, 822, 8, 277, 14, 4359, 59, 16, 4682, 288, 291, 423, 3157, 63, 890, 342, 267, 291, 59, 277, 14, 890, 446, 413, 61, 275, 671, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 14, 4359, 59, 16, 19663, 277, 14, 890, 17979, 2722, 4533, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 4359, 59, 16, 19663, 277, 14, 890, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar'] atom_width = [0.0, 4.5, 4.5, 4.5, 0.0, 0.0, 0.0, 0.0, 22.5, 19.5, 13.0, 8.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 17.5, 0.0, 0.0] atom_mass = [0.000000000, 1.007825037, 2.015650074, 3.023475111, 4.00260325, 7.0160045, 9.0121825, 11.0093053, 12.0, 14.003074008, 15.99491464, 18.99840325, 19.9924391, 22.9897697, 23.9850450, 26.9815413, 27.9769284, 30.9737634, 31.9720718, 34.968852729, 39.9623831] atom_anum = [0., 1., 1., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18.] def valid_atom(atom_sym): """Returns True if the atomic symbol is in the library.""" return atom_sym in atom_name def atom_data(atom_sym): """Returns the Gaussian width, mass, and atomic number from the atomic symbol""" if valid_atom(atom_sym): index = atom_name.index(atom_sym) return (atom_width[index], atom_mass[index] * constants.amu2au, atom_anum[index]) else: raise KeyError('Atom: '+str(atom_sym)+' not found in library')
lgpl-3.0
[ 624, 199, 33, 3555, 3035, 6222, 28186, 12, 15374, 5579, 12, 5423, 14, 199, 624, 199, 646, 17468, 350, 14, 3442, 14, 5559, 465, 5262, 421, 199, 4188, 63, 354, 221, 275, 788, 56, 297, 283, 40, 297, 283, 36, 297, 283, 52, 297, 283, 1966, 297, 283, 13009, 297, 283, 3655, 297, 283, 34, 297, 283, 35, 297, 283, 46, 297, 283, 47, 297, 283, 38, 297, 1598, 283, 4698, 297, 283, 8565, 297, 283, 45, 71, 297, 283, 2439, 297, 283, 18934, 297, 283, 48, 297, 283, 51, 297, 283, 1968, 297, 283, 1596, 418, 199, 4188, 63, 2063, 275, 359, 16, 14, 16, 12, 841, 14, 21, 12, 841, 14, 21, 12, 841, 14, 21, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 6928, 14, 21, 12, 5851, 14, 21, 12, 4944, 14, 16, 12, 1695, 14, 21, 12, 1598, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 5557, 14, 21, 12, 378, 14, 16, 12, 378, 14, 16, 61, 199, 4188, 63, 11535, 221, 275, 359, 16, 14, 25464, 12, 413, 14, 31767, 7991, 1401, 12, 499, 14, 614, 1367, 5783, 1342, 12, 650, 14, 996, 1082, 2194, 6673, 12, 841, 14, 383, 13085, 13288, 12, 1598, 1520, 14, 614, 6683, 2322, 12, 1749, 14, 614, 9252, 821, 12, 4119, 14, 8581, 1216, 2481, 12, 3144, 14, 16, 12, 4329, 14, 24281, 1342, 8662, 12, 4114, 14, 1020, 1887, 1079, 772, 12, 1598, 6155, 14, 1020, 13462, 13288, 12, 5851, 14, 1020, 1194, 16959, 12, 6928, 14, 25, 8483, 19301, 12, 6546, 14, 25, 2426, 966, 1400, 12, 7875, 14, 2905, 10478, 969, 12, 1598, 8087, 14, 2576, 1876, 10681, 12, 4233, 14, 2576, 11452, 1082, 12, 7105, 14, 2576, 10744, 1085, 12, 8177, 14, 2534, 15889, 1465, 1398, 12, 10551, 14, 2534, 12332, 2192, 61, 199, 4188, 63, 290, 453, 221, 275, 359, 16, 2020, 413, 2020, 413, 2020, 413, 2020, 499, 2020, 650, 2020, 841, 2020, 959, 2020, 1227, 2020, 1520, 2020, 1695, 2020, 1749, 2020, 1598, 1616, 2020, 4119, 2020, 3144, 2020, 4944, 2020, 4329, 2020, 4114, 2020, 3193, 2020, 5557, 2020, 6155, 19784, 421, 199, 318, 1686, 63, 4188, 8, 4188, 63, 3840, 304, 272, 408, 3407, 715, 340, 314, 15374, 5272, 365, 315, 314, 3555, 1041, 272, 372, 6222, 63, 3840, 315, 6222, 63, 354, 421, 199, 318, 6222, 63, 576, 8, 4188, 63, 3840, 304, 272, 408, 3407, 314, 17131, 3462, 12, 12250, 12, 436, 15374, 1329, 687, 314, 272, 15374, 5272, 624, 272, 340, 1686, 63, 4188, 8, 4188, 63, 3840, 304, 267, 1478, 275, 6222, 63, 354, 14, 1080, 8, 4188, 63, 3840, 9, 267, 372, 334, 4188, 63, 2063, 59, 1080, 467, 6222, 63, 11535, 59, 1080, 61, 627, 5262, 14, 455, 85, 18, 3844, 12, 355, 6222, 63, 290, 453, 59, 1080, 566, 272, 587, 26, 267, 746, 4067, 360, 12097, 26, 6681, 495, 8, 4188, 63, 3840, 20731, 440, 1911, 315, 3555, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 33, 3555, 3035, 6222, 28186, 12, 15374, 5579, 12, 5423, 14, 199, 624, 199, 646, 17468, 350, 14, 3442, 14, 5559, 465, 5262, 421, 199, 4188, 63, 354, 221, 275, 788, 56, 297, 283, 40, 297, 283, 36, 297, 283, 52, 297, 283, 1966, 297, 283, 13009, 297, 283, 3655, 297, 283, 34, 297, 283, 35, 297, 283, 46, 297, 283, 47, 297, 283, 38, 297, 1598, 283, 4698, 297, 283, 8565, 297, 283, 45, 71, 297, 283, 2439, 297, 283, 18934, 297, 283, 48, 297, 283, 51, 297, 283, 1968, 297, 283, 1596, 418, 199, 4188, 63, 2063, 275, 359, 16, 14, 16, 12, 841, 14, 21, 12, 841, 14, 21, 12, 841, 14, 21, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 6928, 14, 21, 12, 5851, 14, 21, 12, 4944, 14, 16, 12, 1695, 14, 21, 12, 1598, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 5557, 14, 21, 12, 378, 14, 16, 12, 378, 14, 16, 61, 199, 4188, 63, 11535, 221, 275, 359, 16, 14, 25464, 12, 413, 14, 31767, 7991, 1401, 12, 499, 14, 614, 1367, 5783, 1342, 12, 650, 14, 996, 1082, 2194, 6673, 12, 841, 14, 383, 13085, 13288, 12, 1598, 1520, 14, 614, 6683, 2322, 12, 1749, 14, 614, 9252, 821, 12, 4119, 14, 8581, 1216, 2481, 12, 3144, 14, 16, 12, 4329, 14, 24281, 1342, 8662, 12, 4114, 14, 1020, 1887, 1079, 772, 12, 1598, 6155, 14, 1020, 13462, 13288, 12, 5851, 14, 1020, 1194, 16959, 12, 6928, 14, 25, 8483, 19301, 12, 6546, 14, 25, 2426, 966, 1400, 12, 7875, 14, 2905, 10478, 969, 12, 1598, 8087, 14, 2576, 1876, 10681, 12, 4233, 14, 2576, 11452, 1082, 12, 7105, 14, 2576, 10744, 1085, 12, 8177, 14, 2534, 15889, 1465, 1398, 12, 10551, 14, 2534, 12332, 2192, 61, 199, 4188, 63, 290, 453, 221, 275, 359, 16, 2020, 413, 2020, 413, 2020, 413, 2020, 499, 2020, 650, 2020, 841, 2020, 959, 2020, 1227, 2020, 1520, 2020, 1695, 2020, 1749, 2020, 1598, 1616, 2020, 4119, 2020, 3144, 2020, 4944, 2020, 4329, 2020, 4114, 2020, 3193, 2020, 5557, 2020, 6155, 19784, 421, 199, 318, 1686, 63, 4188, 8, 4188, 63, 3840, 304, 272, 408, 3407, 715, 340, 314, 15374, 5272, 365, 315, 314, 3555, 1041, 272, 372, 6222, 63, 3840, 315, 6222, 63, 354, 421, 199, 318, 6222, 63, 576, 8, 4188, 63, 3840, 304, 272, 408, 3407, 314, 17131, 3462, 12, 12250, 12, 436, 15374, 1329, 687, 314, 272, 15374, 5272, 624, 272, 340, 1686, 63, 4188, 8, 4188, 63, 3840, 304, 267, 1478, 275, 6222, 63, 354, 14, 1080, 8, 4188, 63, 3840, 9, 267, 372, 334, 4188, 63, 2063, 59, 1080, 467, 6222, 63, 11535, 59, 1080, 61, 627, 5262, 14, 455, 85, 18, 3844, 12, 355, 6222, 63, 290, 453, 59, 1080, 566, 272, 587, 26, 267, 746, 4067, 360, 12097, 26, 6681, 495, 8, 4188, 63, 3840, 20731, 440, 1911, 315, 3555, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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